diff --git a/.gitignore b/.gitignore index 344886cd4a..9d5f5b5afc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /build/ /dist/ /target/ +/src/main/resources/VERSION.txt /src/main/webapp/WEB-INF/glassfish-resources.xml /faces-config.NavData diff --git a/src/main/java/com/divudi/bean/pharmacy/GoodsReturnController.java b/src/main/java/com/divudi/bean/pharmacy/GoodsReturnController.java index 2de199000f..973a54bad9 100644 --- a/src/main/java/com/divudi/bean/pharmacy/GoodsReturnController.java +++ b/src/main/java/com/divudi/bean/pharmacy/GoodsReturnController.java @@ -83,6 +83,8 @@ public class GoodsReturnController implements Serializable { private Bill returnBill; private boolean printPreview; private List billItems; + + private String comment; /////// public Bill getBill() { @@ -123,12 +125,11 @@ public void setPrintPreview(boolean printPreview) { public void onEdit(BillItem tmp) { // PharmaceuticalBillItem tmp = (PharmaceuticalBillItem) event.getObject(); - - if (tmp.getPharmaceuticalBillItem().getQtyInUnit() > getPharmacyRecieveBean().calQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) { + if ((tmp.getPharmaceuticalBillItem().getQtyInUnit()+tmp.getTmpFreeQty())> getPharmacyRecieveBean().calQty(tmp.getReferanceBillItem().getReferanceBillItem().getPharmaceuticalBillItem())) { tmp.setTmpQty(0.0); + tmp.setTmpFreeQty(0.0); JsfUtil.addErrorMessage("You cant return over than ballanced Qty "); } - calTotal(); getPharmacyController().setPharmacyItem(tmp.getPharmaceuticalBillItem().getBillItem().getItem()); } @@ -154,6 +155,7 @@ 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()); @@ -227,7 +229,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(), 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); @@ -246,7 +248,7 @@ private void saveComponent(Payment p) { private boolean checkStock(PharmaceuticalBillItem pharmaceuticalBillItem) { double stockQty = getPharmacyBean().getStockQty(pharmaceuticalBillItem.getItemBatch(), getSessionController().getDepartment()); - if (pharmaceuticalBillItem.getQtyInUnit() > stockQty) { + if (pharmaceuticalBillItem.getQtyInUnit()+ pharmaceuticalBillItem.getFreeQtyInUnit() > stockQty) { return true; } else { return false; @@ -258,6 +260,10 @@ private boolean checkGrnItems() { if (bi.getTmpQty() == 0.0) { continue; } + + if (bi.getTmpFreeQty() == 0.0) { + continue; + } if (checkStock(bi.getPharmaceuticalBillItem())) { return true; @@ -268,11 +274,15 @@ private boolean checkGrnItems() { } public void settle() { - + if (getReturnBill().getToInstitution() == null) { JsfUtil.addErrorMessage("Select Dealor"); return; } + if (getComment() == null || getComment().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; @@ -317,18 +327,22 @@ private void generateBillComponent() { bi.setSearialNo(getBillItems().size()); PharmaceuticalBillItem retPh = new PharmaceuticalBillItem(); retPh.copy(grnPh); - retPh.setFreeQty(0.0); retPh.setBillItem(bi); double rBilled = getPharmacyRecieveBean().getTotalQty(grnPh.getBillItem(), BillType.PharmacyGrnReturn, new BilledBill()); 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.setQtyInUnit((double) (grnPh.getQtyInUnit() - netQty)); + + retPh.setFreeQtyInUnit((double) (grnPh.getFreeQtyInUnit() - netFreeQty)); List suggessions = new ArrayList<>(); Item item = bi.getItem(); @@ -534,4 +548,12 @@ 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/ejb/PharmacyCalculation.java b/src/main/java/com/divudi/ejb/PharmacyCalculation.java index 5c14c91db3..3ddb060787 100644 --- a/src/main/java/com/divudi/ejb/PharmacyCalculation.java +++ b/src/main/java/com/divudi/ejb/PharmacyCalculation.java @@ -163,6 +163,22 @@ public double getTotalQty(BillItem b, BillType billType, Bill bill) { return value; } + public double getTotalQtyWithFreeQty(BillItem b, BillType billType, Bill bill) { + String sql = "Select sum(p.pharmaceuticalBillItem.qty+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, Bill bill) { String sql = "Select sum(p.pharmaceuticalBillItem.freeQty) from BillItem p where" + " type(p.bill)=:class and p.creater is not null and" @@ -328,6 +344,20 @@ public double getReturnedTotalQty(BillItem b, BillType billType, Bill bill) { } + public double getReturnedTotalQtyWithFreeQty(BillItem b, BillType billType, Bill bill) { + String sql = "Select sum(p.pharmaceuticalBillItem.qty+p.pharmaceuticalBillItem.freeQty) from BillItem p where" + + " type(p.bill)=:class and p.bill.creater is not null and" + + " p.referanceBillItem.referanceBillItem=:bt and p.bill.billType=:btp"; + + HashMap hm = new HashMap(); + hm.put("bt", b); + hm.put("btp", billType); + hm.put("class", bill.getClass()); + + return getPharmaceuticalBillItemFacade().findDoubleByJpql(sql, hm); + + } + public double getReturnedTotalFreeQty(BillItem b, BillType billType, Bill bill) { String sql = "Select sum(p.pharmaceuticalBillItem.freeQty) from BillItem p where" + " type(p.bill)=:class and p.bill.creater is not null and" @@ -370,10 +400,10 @@ public double getReturnedTotalFreeQty(BillItem b, BillType billType) { public double calQty(PharmaceuticalBillItem po) { - 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 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 recieveNet = Math.abs(billed) - Math.abs(cancelled); double retuernedNet = Math.abs(returnedB) - Math.abs(returnedC); diff --git a/src/main/java/com/divudi/entity/BillItem.java b/src/main/java/com/divudi/entity/BillItem.java index 5153091c97..e0ece7d686 100644 --- a/src/main/java/com/divudi/entity/BillItem.java +++ b/src/main/java/com/divudi/entity/BillItem.java @@ -681,7 +681,6 @@ public void setTmpFreeQty(double tmpFreeQty) { } else { this.tmpFreeQty = tmpFreeQty; } - if (getPharmaceuticalBillItem() != null) { getPharmaceuticalBillItem().setFreeQty((double) this.tmpFreeQty); } diff --git a/src/main/resources/VERSION.txt b/src/main/resources/VERSION.txt index e9da746858..41efa6ab21 100644 --- a/src/main/resources/VERSION.txt +++ b/src/main/resources/VERSION.txt @@ -1 +1,2 @@ 3.0.0.20240415.4 + diff --git a/src/main/webapp/pharmacy/pharmacy_grn_list_for_return.xhtml b/src/main/webapp/pharmacy/pharmacy_grn_list_for_return.xhtml index 5737e42092..0482445d61 100644 --- a/src/main/webapp/pharmacy/pharmacy_grn_list_for_return.xhtml +++ b/src/main/webapp/pharmacy/pharmacy_grn_list_for_return.xhtml @@ -45,6 +45,7 @@
- - - - - - + @@ -145,7 +146,7 @@ - + diff --git a/src/main/webapp/pharmacy/pharmacy_return_good.xhtml b/src/main/webapp/pharmacy/pharmacy_return_good.xhtml index 143050f5e2..ddbf182dbe 100644 --- a/src/main/webapp/pharmacy/pharmacy_return_good.xhtml +++ b/src/main/webapp/pharmacy/pharmacy_return_good.xhtml @@ -16,15 +16,15 @@ - - +
+ - - + + @@ -45,15 +45,20 @@ - - - - - - - - + + + +
+ + + +
+
+ + +
+
@@ -83,6 +88,9 @@ + + + @@ -114,7 +122,19 @@ - +
+ + + + + + + + + + + +
@@ -129,11 +149,11 @@ - + - + diff --git a/src/main/webapp/resources/pharmacy/grnReturn.xhtml b/src/main/webapp/resources/pharmacy/grnReturn.xhtml index e3598b30f6..e579b401db 100644 --- a/src/main/webapp/resources/pharmacy/grnReturn.xhtml +++ b/src/main/webapp/resources/pharmacy/grnReturn.xhtml @@ -71,6 +71,10 @@ Return QTY #{bip.pharmaceuticalBillItem.qty}
+ + Return Free QTY + #{bip.pharmaceuticalBillItem.freeQty} + Rate #{bip.pharmaceuticalBillItem.purchaseRate}