From c50d0ec8d11c88c267f5b314555bd5a4807a1d7b Mon Sep 17 00:00:00 2001 From: Senula88 Date: Tue, 16 Apr 2024 00:08:49 +0530 Subject: [PATCH 1/2] Closes #4596 Signed-off-by: Senula88 --- .../bean/pharmacy/GoodsReturnController.java | 50 +++++++++---------- .../java/com/divudi/data/BillTypeAtomic.java | 1 + .../com/divudi/ejb/PharmacyCalculation.java | 8 +-- .../pharmacy/pharmacy_return_good.xhtml | 18 +++---- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/divudi/bean/pharmacy/GoodsReturnController.java b/src/main/java/com/divudi/bean/pharmacy/GoodsReturnController.java index 973a54bad9..190bea880e 100644 --- a/src/main/java/com/divudi/bean/pharmacy/GoodsReturnController.java +++ b/src/main/java/com/divudi/bean/pharmacy/GoodsReturnController.java @@ -9,6 +9,7 @@ import com.divudi.data.BillClassType; import com.divudi.data.BillNumberSuffix; import com.divudi.data.BillType; +import com.divudi.data.BillTypeAtomic; import com.divudi.data.PaymentMethod; import com.divudi.ejb.BillNumberGenerator; import com.divudi.ejb.PharmacyBean; @@ -83,8 +84,6 @@ public class GoodsReturnController implements Serializable { private Bill returnBill; private boolean printPreview; private List billItems; - - private String comment; /////// public Bill getBill() { @@ -102,7 +101,8 @@ public Bill getReturnBill() { if (returnBill == null) { returnBill = new BilledBill(); returnBill.setBillType(BillType.PharmacyGrnReturn); - + returnBill.setBillTypeAtomic(BillTypeAtomic.PHARMACY_GRN_RETURN); + returnBill.setReferenceBill(getBill()); } return returnBill; @@ -125,8 +125,11 @@ public void setPrintPreview(boolean printPreview) { public void onEdit(BillItem tmp) { // PharmaceuticalBillItem tmp = (PharmaceuticalBillItem) event.getObject(); - if ((tmp.getPharmaceuticalBillItem().getQtyInUnit()+tmp.getTmpFreeQty())> getPharmacyRecieveBean().calQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) { + if (tmp.getPharmaceuticalBillItem().getQtyInUnit() > getPharmacyRecieveBean().calQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) { tmp.setTmpQty(0.0); + JsfUtil.addErrorMessage("You cant return over than ballanced Qty "); + } + if (tmp.getPharmaceuticalBillItem().getFreeQtyInUnit() > getPharmacyRecieveBean().calFreeQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) { tmp.setTmpFreeQty(0.0); JsfUtil.addErrorMessage("You cant return over than ballanced Qty "); } @@ -155,7 +158,6 @@ private void saveReturnBill() { // getReturnBill().setReferenceBill(getBill()); getReturnBill().setCreater(getSessionController().getLoggedUser()); getReturnBill().setCreatedAt(Calendar.getInstance().getTime()); - getReturnBill().setComments(comment); if (getReturnBill().getId() == null) { getBillFacade().create(getReturnBill()); @@ -229,7 +231,7 @@ private void saveComponent(Payment p) { i.setPharmaceuticalBillItem(tmpPh); getBillItemFacade().edit(i); - boolean returnFlag = getPharmacyBean().deductFromStock(i.getPharmaceuticalBillItem().getStock(), Math.abs(i.getPharmaceuticalBillItem().getQtyInUnit()+i.getPharmaceuticalBillItem().getFreeQtyInUnit()), i.getPharmaceuticalBillItem(), getSessionController().getDepartment()); + boolean returnFlag = getPharmacyBean().deductFromStock(i.getPharmaceuticalBillItem().getStock(), Math.abs(i.getPharmaceuticalBillItem().getQtyInUnit() + i.getPharmaceuticalBillItem().getFreeQtyInUnit()), i.getPharmaceuticalBillItem(), getSessionController().getDepartment()); if (!returnFlag) { i.setTmpQty(0); @@ -248,7 +250,7 @@ private void saveComponent(Payment p) { private boolean checkStock(PharmaceuticalBillItem pharmaceuticalBillItem) { double stockQty = getPharmacyBean().getStockQty(pharmaceuticalBillItem.getItemBatch(), getSessionController().getDepartment()); - if (pharmaceuticalBillItem.getQtyInUnit()+ pharmaceuticalBillItem.getFreeQtyInUnit() > stockQty) { + if (pharmaceuticalBillItem.getQtyInUnit() + pharmaceuticalBillItem.getFreeQtyInUnit() > stockQty) { return true; } else { return false; @@ -260,7 +262,7 @@ private boolean checkGrnItems() { if (bi.getTmpQty() == 0.0) { continue; } - + if (bi.getTmpFreeQty() == 0.0) { continue; } @@ -274,12 +276,12 @@ private boolean checkGrnItems() { } public void settle() { - + if (getReturnBill().getToInstitution() == null) { JsfUtil.addErrorMessage("Select Dealor"); return; } - if (getComment() == null || getComment().trim().equals("")) { + if (getReturnBill().getComments() == null || getReturnBill().getComments().trim().equals("")) { JsfUtil.addErrorMessage("Please enter a comment"); return; } @@ -295,7 +297,7 @@ public void settle() { calTotal(); pharmacyCalculation.calculateRetailSaleValueAndFreeValueAtPurchaseRate(getReturnBill()); - + getBillFacade().edit(getReturnBill()); printPreview = true; @@ -333,15 +335,17 @@ private void generateBillComponent() { double rCacnelled = getPharmacyRecieveBean().getTotalQty(grnPh.getBillItem(), BillType.PharmacyGrnReturn, new CancelledBill()); double netQty = Math.abs(rBilled) - Math.abs(rCacnelled); - + double rFreeBilled = getPharmacyRecieveBean().getTotalFreeQty(grnPh.getBillItem(), BillType.PharmacyGrnReturn, new BilledBill()); double rFreeCacnelled = getPharmacyRecieveBean().getTotalFreeQty(grnPh.getBillItem(), BillType.PharmacyGrnReturn, 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<>(); @@ -357,11 +361,15 @@ private void generateBillComponent() { // // // bi.setTmpSuggession(suggessions); + bi.setTmpQty((double) (grnPh.getQtyInUnit() - netQty)); + bi.setTmpFreeQty((double) (grnPh.getFreeQtyInUnit() - netFreeQty)); bi.setPharmaceuticalBillItem(retPh); - getBillItems().add(bi); + calTotal(); + getPharmacyController().setPharmacyItem(bi.getPharmaceuticalBillItem().getBillItem().getItem()); + } } @@ -372,10 +380,10 @@ public Payment createPayment(Bill bill, PaymentMethod pm) { setPaymentMethodData(p, pm); return p; } - - public String navigateToGrnReturnBill(Bill b){ + + public String navigateToGrnReturnBill(Bill b) { setReturnBill(b); - if(returnBill==null){ + if (returnBill == null) { JsfUtil.addErrorMessage("No Bill get selected"); return ""; } @@ -548,12 +556,4 @@ public void setPaymentFacade(PaymentFacade paymentFacade) { this.paymentFacade = paymentFacade; } - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - } diff --git a/src/main/java/com/divudi/data/BillTypeAtomic.java b/src/main/java/com/divudi/data/BillTypeAtomic.java index f08db0fbfb..40089871ec 100644 --- a/src/main/java/com/divudi/data/BillTypeAtomic.java +++ b/src/main/java/com/divudi/data/BillTypeAtomic.java @@ -39,6 +39,7 @@ public enum BillTypeAtomic { PHARMACY_GRN_WHOLESALE("Pharmacy Wholesale GRN", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.CASH_IN), PHARMACY_GRN_CANCELLED("Pharmacy GRN Cancelled", BillCategory.CANCELLATION, ServiceType.PHARMACY, BillFinanceType.CASH_OUT), PHARMACY_GRN_REFUND("Pharmacy GRN Refund", BillCategory.REFUND, ServiceType.PHARMACY, BillFinanceType.CASH_OUT), + PHARMACY_GRN_RETURN("Pharmacy GRN Return", BillCategory.REFUND, ServiceType.PHARMACY, BillFinanceType.CASH_OUT), PHARMACY_WHOLESALE_DIRECT_PURCHASE_BILL("Pharmacy Direct Purchase", BillCategory.BILL, ServiceType.PHARMACY, BillFinanceType.CASH_IN), PHARMACY_WHOLESALE_DIRECT_PURCHASE_BILL_CANCELLED("Pharmacy Direct Purchase - Cancelled", BillCategory.CANCELLATION, ServiceType.PHARMACY, BillFinanceType.CASH_OUT), PHARMACY_WHOLESALE_DIRECT_PURCHASE_BILL_REFUND("Pharmacy Direct Purchase - Refund", BillCategory.REFUND, ServiceType.PHARMACY, BillFinanceType.CASH_OUT), diff --git a/src/main/java/com/divudi/ejb/PharmacyCalculation.java b/src/main/java/com/divudi/ejb/PharmacyCalculation.java index 3ddb060787..1b4efcfad6 100644 --- a/src/main/java/com/divudi/ejb/PharmacyCalculation.java +++ b/src/main/java/com/divudi/ejb/PharmacyCalculation.java @@ -400,10 +400,10 @@ public double getReturnedTotalFreeQty(BillItem b, BillType billType) { public double calQty(PharmaceuticalBillItem po) { - double billed = getTotalQtyWithFreeQty(po.getBillItem(), BillType.PharmacyGrnBill, new BilledBill()); - double cancelled = getTotalQtyWithFreeQty(po.getBillItem(), BillType.PharmacyGrnBill, new CancelledBill());; - double returnedB = getReturnedTotalQtyWithFreeQty(po.getBillItem(), BillType.PharmacyGrnReturn, new BilledBill()); - double returnedC = getReturnedTotalQtyWithFreeQty(po.getBillItem(), BillType.PharmacyGrnReturn, new CancelledBill()); + double billed = getTotalQty(po.getBillItem(), BillType.PharmacyGrnBill, new BilledBill()); + double cancelled = getTotalQty(po.getBillItem(), BillType.PharmacyGrnBill, new CancelledBill());; + double returnedB = getReturnedTotalQty(po.getBillItem(), BillType.PharmacyGrnReturn, new BilledBill()); + double returnedC = getReturnedTotalQty(po.getBillItem(), BillType.PharmacyGrnReturn, new CancelledBill()); double recieveNet = Math.abs(billed) - Math.abs(cancelled); double retuernedNet = Math.abs(returnedB) - Math.abs(returnedC); diff --git a/src/main/webapp/pharmacy/pharmacy_return_good.xhtml b/src/main/webapp/pharmacy/pharmacy_return_good.xhtml index ddbf182dbe..14ab8b4372 100644 --- a/src/main/webapp/pharmacy/pharmacy_return_good.xhtml +++ b/src/main/webapp/pharmacy/pharmacy_return_good.xhtml @@ -45,7 +45,7 @@ - +
@@ -61,7 +61,6 @@
- @@ -76,20 +75,16 @@ Returning Item - - - - - + - + @@ -114,7 +109,7 @@ - + @@ -126,7 +121,7 @@ - + @@ -135,6 +130,9 @@ + + + From 25063203ce8b5d3c10769015fdd0ea4b1fd60547 Mon Sep 17 00:00:00 2001 From: Senula88 Date: Tue, 16 Apr 2024 00:14:12 +0530 Subject: [PATCH 2/2] Signed-off-by: Senula88 --- src/main/webapp/pharmacy/pharmacy_return_good.xhtml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/pharmacy/pharmacy_return_good.xhtml b/src/main/webapp/pharmacy/pharmacy_return_good.xhtml index 14ab8b4372..b30edd5d3c 100644 --- a/src/main/webapp/pharmacy/pharmacy_return_good.xhtml +++ b/src/main/webapp/pharmacy/pharmacy_return_good.xhtml @@ -101,8 +101,10 @@ - - + + + +