From b64332ddd95d420dd1c98a9c3de1267ed6d68c02 Mon Sep 17 00:00:00 2001 From: thiwanka570 Date: Sun, 4 Aug 2024 10:16:53 +0530 Subject: [PATCH] Signed-off-by: thiwanka570 --- .../bean/common/PettyCashBillSearch.java | 23 +++++++++++++++++++ .../divudi/ws/common/ApplicationConfig.java | 1 + src/main/resources/META-INF/persistence.xml | 4 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/divudi/bean/common/PettyCashBillSearch.java b/src/main/java/com/divudi/bean/common/PettyCashBillSearch.java index 3ba3e1133a..02eefa4eb7 100644 --- a/src/main/java/com/divudi/bean/common/PettyCashBillSearch.java +++ b/src/main/java/com/divudi/bean/common/PettyCashBillSearch.java @@ -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; /** @@ -88,6 +89,8 @@ public class PettyCashBillSearch implements Serializable { private WebUserController webUserController; @Inject PettyCashBillController pettyCashBillController; + @Inject + ConfigOptionApplicationController configOptionApplicationController; @EJB EjbApplication ejbApplication; private List tempbillItems; @@ -306,7 +309,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; diff --git a/src/main/java/com/divudi/ws/common/ApplicationConfig.java b/src/main/java/com/divudi/ws/common/ApplicationConfig.java index 6f7ec08dba..a6babb840f 100644 --- a/src/main/java/com/divudi/ws/common/ApplicationConfig.java +++ b/src/main/java/com/divudi/ws/common/ApplicationConfig.java @@ -44,6 +44,7 @@ private void addRestResourceClasses(Set> resources) { resources.add(com.divudi.ws.finance.Qb.class); resources.add(com.divudi.ws.finance.clinical.Fhir.class); resources.add(com.divudi.ws.inward.ApiInward.class); + resources.add(com.divudi.ws.lims.Lims.class); resources.add(com.divudi.ws.lims.LimsMiddlewareController.class); } diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index de4dab8214..1db2543fad 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -4,7 +4,7 @@ org.eclipse.persistence.jpa.PersistenceProvider - jdbc/hims + jdbc/arogya false @@ -13,7 +13,7 @@ - jdbc/himsAduit + jdbc/arogyaAudit com.divudi.entity.AuditEvent true