Skip to content

Commit

Permalink
Merge pull request #6756 from hmislk/issue#6445
Browse files Browse the repository at this point in the history
Issue#6445 Closes #6445
  • Loading branch information
DeshaniPubudu authored Aug 7, 2024
2 parents c80d5c6 + dce0a18 commit 8a19b33
Show file tree
Hide file tree
Showing 3 changed files with 618 additions and 150 deletions.
24 changes: 24 additions & 0 deletions src/main/java/com/divudi/bean/common/PettyCashBillSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import javax.inject.Named;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.joda.time.LocalTime;
import org.primefaces.model.LazyDataModel;

/**
Expand Down Expand Up @@ -88,6 +89,9 @@ public class PettyCashBillSearch implements Serializable {
private WebUserController webUserController;
@Inject
PettyCashBillController pettyCashBillController;

@Inject
ConfigOptionApplicationController configOptionApplicationController;
@EJB
EjbApplication ejbApplication;
private List<BillItem> tempbillItems;
Expand Down Expand Up @@ -306,7 +310,27 @@ public void setCashTransactionBean(CashTransactionBean cashTransactionBean) {
this.cashTransactionBean = cashTransactionBean;
}

public static Date getMidnight() {
Calendar calendar = Calendar.getInstance();
// Reset the time to midnight
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}

public void cancelBill() {
Date current= new Date();
Date midNight=getMidnight();
System.out.println("current.before(midNight) = " + current.before(midNight));
if (configOptionApplicationController.getBooleanValueByKey("Enable PettyCash bill cancellation restriction after midnight")) {
if (!current.before(midNight)) {
JsfUtil.addErrorMessage("Bill cancellation is not allowed after midnight.");
return;
}
}

if (getBill() != null && getBill().getId() != null && getBill().getId() != 0) {
if (errorCheck()) {
return;
Expand Down
Loading

0 comments on commit 8a19b33

Please sign in to comment.