From a212333f267d74de0555b96a9e6c7c4769411f46 Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Sat, 3 Aug 2024 20:29:46 +0530 Subject: [PATCH] Closes#6734 Signed-off-by: DamithDeshan --- .../com/divudi/bean/common/BillSearch.java | 77 +++++++++++++++---- .../bean/common/OpdPreSettleController.java | 36 +++++++-- src/main/resources/META-INF/persistence.xml | 1 - src/main/webapp/opd/bill_refund.xhtml | 2 +- src/main/webapp/resources/ezcomp/menu.xhtml | 2 +- 5 files changed, 93 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/divudi/bean/common/BillSearch.java b/src/main/java/com/divudi/bean/common/BillSearch.java index 0be95d9e11..01f0c2e606 100644 --- a/src/main/java/com/divudi/bean/common/BillSearch.java +++ b/src/main/java/com/divudi/bean/common/BillSearch.java @@ -79,6 +79,8 @@ import com.divudi.data.ServiceType; import com.divudi.entity.Doctor; import com.divudi.facade.FeeFacade; +import com.divudi.facade.PatientFacade; +import com.divudi.facade.StaffFacade; import com.divudi.java.CommonFunctions; import com.divudi.light.common.BillLight; import java.io.Serializable; @@ -157,6 +159,8 @@ public class BillSearch implements Serializable { private EmailFacade emailFacade; @EJB FeeFacade feeFacade; + @EJB + private StaffFacade staffFacade; /** * Controllers */ @@ -1267,9 +1271,9 @@ public boolean calculateRefundTotalForOpdBill() { double refundingValue = 0; for (BillFee rbf : i.getBillFees()) { - System.out.println("rbf.getFeeValue() name = " + rbf.getFee().getName()); - System.out.println("rbf.getFeeValue() = " + rbf.getFeeValue()); - System.out.println("rbf.getFeeValue() fee = " + rbf.getFee().getFee()); + //System.out.println("rbf.getFeeValue() name = " + rbf.getFee().getName()); + //System.out.println("rbf.getFeeValue() = " + rbf.getFeeValue()); + //System.out.println("rbf.getFeeValue() fee = " + rbf.getFee().getFee()); refundingValue += rbf.getFeeValue(); } i.setNetValue(refundingValue); @@ -1569,6 +1573,13 @@ public String refundOpdBill() { JsfUtil.addErrorMessage("One or more bill Item you are refunding has been already paid to Service Provider. Can not refund again."); return ""; } + + if (paymentMethod == PaymentMethod.Staff) { + if (getBill().getToStaff() == null) { + JsfUtil.addErrorMessage("Can't Select Staff Method"); + return ""; + } + } if (refundingBill.getBillItems() != null) { for (BillItem bi : refundingBill.getBillItems()) { @@ -1602,23 +1613,36 @@ public String refundOpdBill() { Payment p = getOpdPreSettleController().createPaymentForCancellationsAndRefunds(refundingBill, paymentMethod); //TODO: Create Payments for Bill Items - if (getBill().getPaymentMethod() == PaymentMethod.Credit) { - if (getBill().getToStaff() != null) { - staffBean.updateStaffCredit(getBill().getToStaff(), 0 - (getBill().getNetTotal() + getBill().getVat())); - JsfUtil.addSuccessMessage("Staff Credit Updated"); - } else if (getBill().getCreditCompany() != null) { - //TODO : Update Credit COmpany Bill - } + if (getBill().getPaymentMethod() == PaymentMethod.Staff) { + //System.out.println("PaymentMethod - Staff"); + + //System.out.println("Before Balance = " + getBill().getToStaff().getCurrentCreditValue()); + getBill().getToStaff().setCurrentCreditValue(getBill().getToStaff().getCurrentCreditValue() - Math.abs(getRefundingBill().getNetTotal())); + + //System.out.println("After Balance = " + getBill().getToStaff().getCurrentCreditValue()); + staffFacade.edit(getBill().getToStaff()); + //System.out.println("Staff Credit Updated"); + } else if (getBill().getPaymentMethod() == PaymentMethod.PatientDeposit) { - //TODO: Update Patient Deposit + //System.out.println("Before Balance = " + bill.getPatient().getRunningBalance()); + if (bill.getPatient().getRunningBalance() == null) { + //System.out.println("Null"); + bill.getPatient().setRunningBalance(Math.abs(bill.getNetTotal())); + } else { + //System.out.println("Not Null - Add BillValue"); + bill.getPatient().setRunningBalance(bill.getPatient().getRunningBalance() + Math.abs(bill.getNetTotal())); + } + patientFacade.edit(bill.getPatient()); + //System.out.println("After Balance = " + bill.getPatient().getRunningBalance()); } - //TODO - Update Bill Payment Values - //TODO - Update Bill Paid Value printPreview = true; return ""; } + @EJB + private PatientFacade patientFacade; + public boolean sampleHasBeenCollected(Bill rf) { boolean oneItemIsSampled = false; for (BillItem bi : rf.getBillItems()) { @@ -2162,6 +2186,13 @@ public void cancelOpdBill() { } } + if (paymentMethod == PaymentMethod.Staff) { + if (getBill().getToStaff() == null) { + JsfUtil.addErrorMessage("Can't Select Staff Method"); + return; + } + } + if (!getWebUserController().hasPrivilege("OpdCancel")) { JsfUtil.addErrorMessage("You have no privilege to cancel OPD bills. Please contact System Administrator."); return; @@ -2972,7 +3003,7 @@ public String navigateViewOpdBillByBillTypeAtomic() { case PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_RETURN: case PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_SESSION: return navigateToViewChannelingProfessionalPaymentBill(); - + case OPD_BATCH_BILL_TO_COLLECT_PAYMENT_AT_CASHIER: case OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER: case OPD_BATCH_BILL_CANCELLATION: @@ -2981,7 +3012,7 @@ public String navigateViewOpdBillByBillTypeAtomic() { case PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES: case PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES_RETURN: return navigateToViewOpdProfessionalPaymentBill(); - + } JsfUtil.addErrorMessage("Wrong Bill Type"); return ""; @@ -4090,6 +4121,22 @@ public void setReferredBy(Doctor referredBy) { this.referredBy = referredBy; } + public PatientFacade getPatientFacade() { + return patientFacade; + } + + public void setPatientFacade(PatientFacade patientFacade) { + this.patientFacade = patientFacade; + } + + public StaffFacade getStaffFacade() { + return staffFacade; + } + + public void setStaffFacade(StaffFacade staffFacade) { + this.staffFacade = staffFacade; + } + public class PaymentSummary { private long idCounter = 0; diff --git a/src/main/java/com/divudi/bean/common/OpdPreSettleController.java b/src/main/java/com/divudi/bean/common/OpdPreSettleController.java index cbe22fdc56..64f44820cd 100644 --- a/src/main/java/com/divudi/bean/common/OpdPreSettleController.java +++ b/src/main/java/com/divudi/bean/common/OpdPreSettleController.java @@ -54,6 +54,7 @@ import com.divudi.facade.PaymentFacade; import com.divudi.facade.PersonFacade; import com.divudi.facade.PharmaceuticalBillItemFacade; +import com.divudi.facade.StaffFacade; import com.divudi.facade.TokenFacade; import java.io.Serializable; @@ -122,6 +123,9 @@ public OpdPreSettleController() { TokenFacade tokenFacade; @EJB StaffBean staffBean; + @EJB + private StaffFacade staffFacade; + ///////////////////////// Item selectedAlternative; @@ -1703,26 +1707,36 @@ public Payment createPaymentForCancellationsforOPDBill(Bill bill, PaymentMethod p.setCreater(getSessionController().getLoggedUser()); p.setPaymentMethod(pm); - System.out.println("pm = " + pm); + //System.out.println("pm = " + pm); if (pm == PaymentMethod.PatientDeposit) { - System.out.println("Before Balance = " + bill.getPatient().getRunningBalance()); + //System.out.println("Before Balance = " + bill.getPatient().getRunningBalance()); if (bill.getPatient().getRunningBalance() == null) { - System.out.println("Null"); + //System.out.println("Null"); bill.getPatient().setRunningBalance(Math.abs(bill.getNetTotal())); } else { - System.out.println("Not Null - Add BillValue"); + //System.out.println("Not Null - Add BillValue"); bill.getPatient().setRunningBalance(bill.getPatient().getRunningBalance() + Math.abs(bill.getNetTotal())); } patientFacade.edit(bill.getPatient()); - System.out.println("After Balance = " + bill.getPatient().getRunningBalance()); + //System.out.println("After Balance = " + bill.getPatient().getRunningBalance()); + } + + if (pm == PaymentMethod.Staff) { + //System.out.println("PaymentMethod - Staff"); + //System.out.println("Before Balance = " + bill.getToStaff().getCurrentCreditValue()); + bill.getToStaff().setCurrentCreditValue( bill.getToStaff().getCurrentCreditValue() - Math.abs(bill.getNetTotal())); + //System.out.println("After Balance = " + bill.getToStaff().getCurrentCreditValue()); + staffFacade.edit(bill.getToStaff()); + //System.out.println("Staff Credit Updated"); } - System.out.println("001"); + + //System.out.println("001"); if (p.getId() == null) { getPaymentFacade().create(p); } getPaymentFacade().edit(p); - System.out.println("End Payment"); + //System.out.println("End Payment"); return p; } @@ -2017,4 +2031,12 @@ public void setForeigner(boolean foreigner) { this.foreigner = foreigner; } + public StaffFacade getStaffFacade() { + return staffFacade; + } + + public void setStaffFacade(StaffFacade staffFacade) { + this.staffFacade = staffFacade; + } + } diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 293d3d4fb1..319a2508d1 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -19,6 +19,5 @@ - diff --git a/src/main/webapp/opd/bill_refund.xhtml b/src/main/webapp/opd/bill_refund.xhtml index ffa0d94897..8887f89996 100644 --- a/src/main/webapp/opd/bill_refund.xhtml +++ b/src/main/webapp/opd/bill_refund.xhtml @@ -64,7 +64,7 @@ - + - +