diff --git a/.github/counter.txt b/.github/counter.txt index 00750edc0..b8626c4cf 100644 --- a/.github/counter.txt +++ b/.github/counter.txt @@ -1 +1 @@ -3 +4 diff --git a/README.md b/README.md index 313451cfd..9434270c5 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Developed using Java Enterprise Edition, the system offers both a web applicatio ## Current Version -Current Version: 3.0.0.20240612.3 (This line will be automatically updated to reflect the latest version) +Current Version: 3.0.0.20240612.4 (This line will be automatically updated to reflect the latest version) ## History diff --git a/src/main/java/com/divudi/bean/store/StoreCalculation.java b/src/main/java/com/divudi/bean/store/StoreCalculation.java index 600bf0e40..47b7acda8 100644 --- a/src/main/java/com/divudi/bean/store/StoreCalculation.java +++ b/src/main/java/com/divudi/bean/store/StoreCalculation.java @@ -176,6 +176,21 @@ public double getTotalQty(BillItem b, BillType billType) { //System.err.println("GETTING TOTAL QTY " + value); return value; } + public double getTotalFreeQty(BillItem b, BillType billType, Bill bill) { + String sql = "Select sum(p.pharmaceuticalBillItem.freeQty) from BillItem p where" + + " type(p.bill)=:class and p.creater is not null and" + + " p.referanceBillItem=:bt and p.bill.billType=:btp"; + + HashMap hm = new HashMap(); + hm.put("bt", b); + hm.put("btp", billType); + hm.put("class", bill.getClass()); + + double value = getPharmaceuticalBillItemFacade().findDoubleByJpql(sql, hm); + + //System.err.println("GETTING TOTAL QTY " + value); + return value; + } public double getTotalFreeQty(BillItem b, BillType billType) { String sql = "Select sum(p.pharmaceuticalBillItem.freeQty) from BillItem p where" @@ -308,6 +323,18 @@ public double calQty(PharmaceuticalBillItem po) { return (Math.abs(recieveNet) - Math.abs(retuernedNet)); } + public double calFreeQty(PharmaceuticalBillItem po) { + + double billed = getTotalFreeQty(po.getBillItem(), BillType.StoreGrnBill, new BilledBill()); + double cancelled = getTotalFreeQty(po.getBillItem(), BillType.StoreGrnBill, new CancelledBill());; + double returnedB = getTotalFreeQty(po.getBillItem(), BillType.StoreGrnReturn, new BilledBill()); + double returnedC = getTotalFreeQty(po.getBillItem(), BillType.StoreGrnReturn, new CancelledBill()); + + double recieveNet = Math.abs(billed) - Math.abs(cancelled); + double retuernedNet = Math.abs(returnedB) - Math.abs(returnedC); + + return (Math.abs(recieveNet) - Math.abs(retuernedNet)); + } public double calQtyInTwoSql(PharmaceuticalBillItem po) { diff --git a/src/main/java/com/divudi/bean/store/StoreGoodsReturnController.java b/src/main/java/com/divudi/bean/store/StoreGoodsReturnController.java index 37c73380b..657d1414f 100644 --- a/src/main/java/com/divudi/bean/store/StoreGoodsReturnController.java +++ b/src/main/java/com/divudi/bean/store/StoreGoodsReturnController.java @@ -11,6 +11,7 @@ import com.divudi.data.BillClassType; import com.divudi.data.BillNumberSuffix; import com.divudi.data.BillType; +import com.divudi.data.BillTypeAtomic; import com.divudi.ejb.BillNumberGenerator; import com.divudi.entity.Bill; import com.divudi.entity.BillItem; @@ -78,6 +79,8 @@ public Bill getReturnBill() { if (returnBill == null) { returnBill = new BilledBill(); returnBill.setBillType(BillType.StoreGrnReturn); + returnBill.setBillTypeAtomic(BillTypeAtomic.STORE_GRN_RETURN); + returnBill.setReferenceBill(getBill()); } @@ -103,6 +106,11 @@ public void onEdit(BillItem tmp) { tmp.setTmpQty(0.0); JsfUtil.addErrorMessage("You cant return over than ballanced Qty "); } + + if (tmp.getPharmaceuticalBillItem().getFreeQtyInUnit() > storeCalculation.calFreeQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) { + tmp.setTmpFreeQty(0.0); + JsfUtil.addErrorMessage("You cant return over than ballanced Qty "); + } calTotal(); getPharmacyController().setPharmacyItem(tmp.getPharmaceuticalBillItem().getBillItem().getItem()); @@ -196,6 +204,14 @@ private boolean checkGrnItems() { } public void settle() { + if (getReturnBill().getToInstitution() == null) { + JsfUtil.addErrorMessage("Select Dealor"); + return; + } + if (getReturnBill().getComments() == null || getReturnBill().getComments().trim().equals("")) { + JsfUtil.addErrorMessage("Please enter a comment"); + return; + } if (checkGrnItems()) { JsfUtil.addErrorMessage("ITems for this GRN Already issued so you can't Return "); return; @@ -242,11 +258,19 @@ private void generateBillComponent() { double rCacnelled = storeCalculation.getTotalQty(grnPh.getBillItem(), BillType.StoreGrnReturn, new CancelledBill()); double netQty = Math.abs(rBilled) - Math.abs(rCacnelled); + + double rFreeBilled = storeCalculation.getTotalFreeQty(grnPh.getBillItem(), BillType.StoreGrnReturn, new BilledBill()); + double rFreeCacnelled = storeCalculation.getTotalFreeQty(grnPh.getBillItem(), BillType.StoreGrnReturn, new CancelledBill()); + double netFreeQty = Math.abs(rFreeBilled) - Math.abs(rFreeCacnelled); //System.err.println("Billed " + rBilled); //System.err.println("Cancelled " + rCacnelled); //System.err.println("Net " + netQty); + retPh.setQty((double) (grnPh.getQtyInUnit() - netQty)); retPh.setQtyInUnit((double) (grnPh.getQtyInUnit() - netQty)); + + retPh.setFreeQty((double) (grnPh.getQtyInUnit() - netFreeQty)); + retPh.setFreeQtyInUnit((double) (grnPh.getFreeQtyInUnit() - netFreeQty)); List suggessions = new ArrayList<>(); Item item = bi.getItem(); @@ -261,10 +285,12 @@ private void generateBillComponent() { // // // bi.setTmpSuggession(suggessions); + bi.setTmpQty((double) (grnPh.getQtyInUnit() - netQty)); bi.setPharmaceuticalBillItem(retPh); getBillItems().add(bi); + calTotal(); } diff --git a/src/main/java/com/divudi/bean/store/StoreGrnController.java b/src/main/java/com/divudi/bean/store/StoreGrnController.java index af90231b0..810cae233 100644 --- a/src/main/java/com/divudi/bean/store/StoreGrnController.java +++ b/src/main/java/com/divudi/bean/store/StoreGrnController.java @@ -31,6 +31,9 @@ import com.divudi.facade.PharmaceuticalBillItemFacade; import com.divudi.facade.StockFacade; import com.divudi.bean.common.util.JsfUtil; +import com.divudi.data.BillTypeAtomic; +import com.divudi.entity.Payment; +import com.divudi.facade.PaymentFacade; import com.divudi.java.CommonFunctions; import java.io.Serializable; import java.text.DateFormat; @@ -74,6 +77,8 @@ public class StoreGrnController implements Serializable { StoreBean storeBean; @EJB private AmpFacade ampFacade; + @EJB + PaymentFacade paymentFacade; private CommonFunctions commonFunctions; @Inject @@ -341,6 +346,8 @@ public void settle() { getBillItemFacade().create(i); getGrnBill().getBillExpenses().add(i); } + + Payment p = createPayment(getGrnBill(), getGrnBill().getPaymentMethod()); getGrnBill().setDeptId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getDepartment(), BillType.StoreGrnBill, BillClassType.BilledBill, BillNumberSuffix.GRN)); getGrnBill().setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), BillType.StoreGrnBill, BillClassType.BilledBill, BillNumberSuffix.GRN)); @@ -369,6 +376,29 @@ public void settle() { printPreview = true; } + + public Payment createPayment(Bill bill, PaymentMethod pm) { + Payment p = new Payment(); + p.setBill(bill); + setPaymentMethodData(p, pm); + return p; + } + + public void setPaymentMethodData(Payment p, PaymentMethod pm) { + + p.setInstitution(getSessionController().getInstitution()); + p.setDepartment(getSessionController().getDepartment()); + p.setCreatedAt(new Date()); + p.setCreater(getSessionController().getLoggedUser()); + p.setPaymentMethod(pm); + + p.setPaidValue(p.getBill().getNetTotal()); + + if (p.getId() == null) { + paymentFacade.create(p); + } + + } public void purchaseRateUpdateListner(BillItem bi) { bi.getPharmaceuticalBillItem().setRetailRate(bi.getPharmaceuticalBillItem().getPurchaseRate()); @@ -428,6 +458,7 @@ public void saveBill() { getGrnBill().setFromInstitution(getApproveBill().getToInstitution()); getGrnBill().setDepartment(getSessionController().getDepartment()); getGrnBill().setInstitution(getSessionController().getInstitution()); + getGrnBill().setBillTypeAtomic(BillTypeAtomic.STORE_GRN); // getGrnBill().setDeptId(getBillNumberBean().departmentBillNumberGenerator(getSessionController().getDepartment(), BillType.PharmacyGrnBill, BillNumberSuffix.GRN)); // getGrnBill().setInsId(getBillNumberBean().institutionBillNumberGenerator(getSessionController().getInstitution(), getGrnBill(), BillType.PharmacyGrnBill, BillNumberSuffix.GRN)); @@ -832,6 +863,7 @@ public Bill getGrnBill() { if (grnBill == null) { grnBill = new BilledBill(); grnBill.setBillType(BillType.StoreGrnBill); + grnBill.setBillTypeAtomic(BillTypeAtomic.STORE_GRN); } return grnBill; } diff --git a/src/main/java/com/divudi/bean/store/StorePurchaseOrderController.java b/src/main/java/com/divudi/bean/store/StorePurchaseOrderController.java index be9842f71..6f655231a 100644 --- a/src/main/java/com/divudi/bean/store/StorePurchaseOrderController.java +++ b/src/main/java/com/divudi/bean/store/StorePurchaseOrderController.java @@ -12,6 +12,7 @@ import com.divudi.data.dataStructure.SearchKeyword; import com.divudi.ejb.BillNumberGenerator; import com.divudi.bean.common.util.JsfUtil; +import com.divudi.data.BillTypeAtomic; import com.divudi.entity.Bill; import com.divudi.entity.BillItem; import com.divudi.entity.BilledBill; @@ -137,7 +138,7 @@ public void approve() { getRequestedBill().setReferenceBill(getAprovedBill()); getBillFacade().edit(getRequestedBill()); - clearList(); + printPreview = true; // return viewRequestedList(); // printPreview = true; @@ -183,6 +184,7 @@ public void saveBill() { getAprovedBill().setFromInstitution(getRequestedBill().getInstitution()); getAprovedBill().setReferenceBill(getRequestedBill()); getAprovedBill().setBackwardReferenceBill(getRequestedBill()); + getAprovedBill().setBillTypeAtomic(BillTypeAtomic.STORE_ORDER_APPROVAL); // getAprovedBill().setDeptId(getBillNumberBean().institutionBillNumberGeneratorWithReference(getRequestedBill().getDepartment(), getAprovedBill(), BillType.StoreOrder, BillNumberSuffix.PO)); // getAprovedBill().setInsId(getBillNumberBean().institutionBillNumberGeneratorWithReference(getRequestedBill().getInstitution(), getAprovedBill(), BillType.StoreOrder, BillNumberSuffix.PO)); @@ -240,6 +242,11 @@ public void saveBillComponent() { getBillFacade().edit(getAprovedBill()); } + + public String navigateToPurchaseOrderApproval() { + printPreview = false; + return "/store/store_purhcase_order_approving?faces-redirect=true"; + } public void generateBillComponent() { @@ -250,6 +257,7 @@ public void generateBillComponent() { PharmaceuticalBillItem ph = new PharmaceuticalBillItem(); ph.setBillItem(bi); ph.setQtyInUnit(i.getQtyInUnit()); + ph.setFreeQtyInUnit(i.getFreeQtyInUnit()); ph.setPurchaseRateInUnit(i.getPurchaseRateInUnit()); ph.setRetailRateInUnit(i.getRetailRateInUnit()); bi.setPharmaceuticalBillItem(ph); diff --git a/src/main/java/com/divudi/bean/store/StorePurchaseOrderRequestController.java b/src/main/java/com/divudi/bean/store/StorePurchaseOrderRequestController.java index b0de5c154..0741c6028 100644 --- a/src/main/java/com/divudi/bean/store/StorePurchaseOrderRequestController.java +++ b/src/main/java/com/divudi/bean/store/StorePurchaseOrderRequestController.java @@ -23,6 +23,7 @@ import com.divudi.facade.ItemsDistributorsFacade; import com.divudi.facade.PharmaceuticalBillItemFacade; import com.divudi.bean.common.util.JsfUtil; +import com.divudi.data.BillTypeAtomic; import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; @@ -175,7 +176,7 @@ public void saveBill() { getCurrentBill().setFromDepartment(getSessionController().getLoggedUser().getDepartment()); getCurrentBill().setFromInstitution(getSessionController().getLoggedUser().getDepartment().getInstitution()); - + getCurrentBill().setBillTypeAtomic(BillTypeAtomic.STORE_ORDER_PRE); if (getCurrentBill().getId() == null) { getBillFacade().create(getCurrentBill()); } else { diff --git a/src/main/java/com/divudi/data/BillTypeAtomic.java b/src/main/java/com/divudi/data/BillTypeAtomic.java index 0dcd334cf..7f98f91f3 100644 --- a/src/main/java/com/divudi/data/BillTypeAtomic.java +++ b/src/main/java/com/divudi/data/BillTypeAtomic.java @@ -22,6 +22,20 @@ public enum BillTypeAtomic { INWARD_SERVICE_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION("Opd Bill Cancellation with Batch Bill", BillCategory.CANCELLATION, ServiceType.INWARD, BillFinanceType.NO_FINANCE_TRANSACTIONS), INWARD_SERVICE_BATCH_BILL_REFUND("Opd Bill Refund", BillCategory.REFUND, ServiceType.INWARD, BillFinanceType.NO_FINANCE_TRANSACTIONS), INWARD_SERVICE_PROFESSIONAL_PAYMENT_BILL("OPD Professional Payment bill", BillCategory.BILL, ServiceType.INWARD, BillFinanceType.NO_FINANCE_TRANSACTIONS), + //Store + STORE_ORDER("Store Order", BillCategory.BILL, ServiceType.STORE, BillFinanceType.CASH_IN), + STORE_ORDER_PRE("Store Order Pre", BillCategory.BILL, ServiceType.STORE, BillFinanceType.NO_FINANCE_TRANSACTIONS), + STORE_ORDER_CANCELLED("Store Order Cancelled", BillCategory.CANCELLATION, ServiceType.STORE, BillFinanceType.CASH_OUT), + STORE_ORDER_APPROVAL("Store Order Approval", BillCategory.BILL, ServiceType.STORE, BillFinanceType.CASH_IN), + STORE_ORDER_APPROVAL_CANCELLED("Store Order Approval Cancelled", BillCategory.CANCELLATION, ServiceType.STORE, BillFinanceType.CASH_OUT), + STORE_DIRECT_PURCHASE("Store Direct Purchase", BillCategory.BILL, ServiceType.STORE, BillFinanceType.CASH_IN), + STORE_DIRECT_PURCHASE_CANCELLED("Store Direct Purchase Cancelled", BillCategory.CANCELLATION, ServiceType.STORE, BillFinanceType.CASH_OUT), + STORE_DIRECT_PURCHASE_REFUND("Store Direct Purchase Refund", BillCategory.REFUND, ServiceType.STORE, BillFinanceType.CASH_OUT), + STORE_GRN("Store GRN", BillCategory.PAYMENTS, ServiceType.STORE, BillFinanceType.CASH_OUT), + STORE_GRN_CANCELLED("Store GRN Cancelled", BillCategory.CANCELLATION, ServiceType.STORE, BillFinanceType.CASH_OUT), + STORE_GRN_REFUND("Store GRN Refund", BillCategory.REFUND, ServiceType.STORE, BillFinanceType.CASH_OUT), + STORE_GRN_RETURN("Store GRN Return", BillCategory.REFUND, ServiceType.STORE, BillFinanceType.CASH_IN), + // Pharmacy PHARMACY_RETAIL_SALE("Pharmacy Retail Sale", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.CASH_IN), PHARMACY_RETAIL_SALE_PRE("Pharmacy Retail Sale Pre", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.NO_FINANCE_TRANSACTIONS), diff --git a/src/main/java/com/divudi/data/ServiceType.java b/src/main/java/com/divudi/data/ServiceType.java index 652dda98d..13cb3d99f 100644 --- a/src/main/java/com/divudi/data/ServiceType.java +++ b/src/main/java/com/divudi/data/ServiceType.java @@ -7,6 +7,7 @@ public enum ServiceType { OPD("Outpatient Department"), PHARMACY("Pharmacy"), + STORE("Store"), CHANNELLING("Channelling"), COLLECTING_CENTRE("Colelcting Centre"), OTHER("Other"), diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 5ac937d24..0fbab0ca0 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -21,3 +21,4 @@ + diff --git a/src/main/resources/VERSION.txt b/src/main/resources/VERSION.txt index f63ef1edf..6d5722aca 100644 --- a/src/main/resources/VERSION.txt +++ b/src/main/resources/VERSION.txt @@ -1 +1 @@ -3.0.0.20240612.3 +3.0.0.20240612.4 diff --git a/src/main/webapp/lab/patient_report.xhtml b/src/main/webapp/lab/patient_report.xhtml index 932511690..8a9517acc 100644 --- a/src/main/webapp/lab/patient_report.xhtml +++ b/src/main/webapp/lab/patient_report.xhtml @@ -478,7 +478,8 @@ -
+
+
- + + - - - + class="ui-button-danger" + > + +
+
+ + + + +
+
@@ -533,11 +539,10 @@ -
@@ -590,7 +595,7 @@
-
diff --git a/src/main/webapp/lab/patient_report_print.xhtml b/src/main/webapp/lab/patient_report_print.xhtml index 17e9c2024..64a11647f 100644 --- a/src/main/webapp/lab/patient_report_print.xhtml +++ b/src/main/webapp/lab/patient_report_print.xhtml @@ -34,11 +34,15 @@ + + + + - +
@@ -92,6 +96,7 @@
diff --git a/src/main/webapp/store/store_grn.xhtml b/src/main/webapp/store/store_grn.xhtml index 6af8ac08a..65a9fc000 100644 --- a/src/main/webapp/store/store_grn.xhtml +++ b/src/main/webapp/store/store_grn.xhtml @@ -73,25 +73,6 @@ - - - - - - - - - - @@ -202,6 +183,31 @@ + + + + + + + + + + + + diff --git a/src/main/webapp/store/store_grn_list_for_return.xhtml b/src/main/webapp/store/store_grn_list_for_return.xhtml index c4515ff9f..8755b16a8 100644 --- a/src/main/webapp/store/store_grn_list_for_return.xhtml +++ b/src/main/webapp/store/store_grn_list_for_return.xhtml @@ -11,198 +11,196 @@ + - +
+
- + - + + - - + + - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - +
- + - + - + - +
- - - + + + - +
- + - + - + -
- - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + +
+
- - +
+
diff --git a/src/main/webapp/store/store_purhcase_order_approving.xhtml b/src/main/webapp/store/store_purhcase_order_approving.xhtml index 0b2dde038..25c970dd1 100644 --- a/src/main/webapp/store/store_purhcase_order_approving.xhtml +++ b/src/main/webapp/store/store_purhcase_order_approving.xhtml @@ -22,7 +22,7 @@ + style="float: right;" actionListener="#{storePurchaseOrderController.approve}"/>
- + - + @@ -157,16 +157,28 @@ - - - - - - + + + + + + + + - + +
+ +
+ -
+
diff --git a/src/main/webapp/store/store_purhcase_order_list_to_approve.xhtml b/src/main/webapp/store/store_purhcase_order_list_to_approve.xhtml index 92baee4aa..02cbc7b72 100644 --- a/src/main/webapp/store/store_purhcase_order_list_to_approve.xhtml +++ b/src/main/webapp/store/store_purhcase_order_list_to_approve.xhtml @@ -125,7 +125,7 @@ ajax="false" icon="fas fa-check-circle" class="ui-button-success mx-2" - action="store_purhcase_order_approving?faces-redirect=true" + action="#{storePurchaseOrderController.navigateToPurchaseOrderApproval()}" disabled="#{b.referenceBill.creater ne null or b.referenceBill.cancelled eq false or b.cancelled eq true or !webUserController.hasPrivilege('StorePurchaseOrderApprove')}"> diff --git a/src/main/webapp/store/store_return_good.xhtml b/src/main/webapp/store/store_return_good.xhtml index a9757e9e5..1189d1fa8 100644 --- a/src/main/webapp/store/store_return_good.xhtml +++ b/src/main/webapp/store/store_return_good.xhtml @@ -14,17 +14,16 @@ - - - - + +
+ - - + + @@ -45,14 +44,21 @@ + + + +
+ + + +
+
+ + +
+
- - - - - - -
@@ -82,6 +88,10 @@ + + + + @@ -109,11 +119,23 @@ - + - + + + + + + + + + + + + +