From c349139e60db6c7a6f07d97483b249fc9031a419 Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Sun, 4 Aug 2024 14:14:43 +0530 Subject: [PATCH 1/2] Signed-off-by: DamithDeshan --- src/main/resources/META-INF/persistence.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index b7178ab1ca..19c35b09ad 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -1,7 +1,7 @@ - jdbc/ruhunu + jdbc/arogya false @@ -10,7 +10,7 @@ - jdbc/ruhunuAudit + jdbc/arogyaAudit false From 87bc9c8f22ff3356502c22721ba0dd1996a26fea Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Sun, 4 Aug 2024 14:14:56 +0530 Subject: [PATCH 2/2] closes#6733 Signed-off-by: DamithDeshan --- .../channel/BookingControllerViewScope.java | 141 ++++++++++++------ .../channel/manage_booking_by_date.xhtml | 63 +++++--- 2 files changed, 136 insertions(+), 68 deletions(-) diff --git a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java index e0ccc595cf..682e956441 100644 --- a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java +++ b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java @@ -430,7 +430,7 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) return; } - Bill printingBill = createBillForChannelReshedule(selectedBillSession); + Bill printingBill = createBillForChannelReshedule(selectedBillSession); BillItem savingBillItem = createSessionItemForReshedule(printingBill); if (printingBill.getBillType() == BillType.ChannelResheduleWithPayment) { createPayment(printingBill, paymentMethod); @@ -446,13 +446,13 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) newBillSession.setSessionDate(getSelectedSessionInstanceForRechedule().getSessionDate()); newBillSession.setSessionTime(getSelectedSessionInstanceForRechedule().getSessionTime()); newBillSession.setStaff(getSelectedSessionInstanceForRechedule().getStaff()); - + printingBill.setSingleBillSession(newBillSession); printingBill.setSingleBillItem(savingBillItem); printingBill.getSingleBillItem().setItem(savingBillItem.getItem()); - + newBillSession.setBill(printingBill); - + PriceMatrix priceMatrix; List savingBillFees = new ArrayList<>(); @@ -460,12 +460,11 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) System.out.println("priceMatrix = " + priceMatrix); List savingBillFeesFromSession = createBillFeeForSessions(printingBill, savingBillItem, true, priceMatrix); - if (savingBillFeesFromSession != null) { savingBillFees.addAll(savingBillFeesFromSession); } - + savingBillItem.setHospitalFee(billBeanController.calFeeValue(FeeType.OwnInstitution, savingBillItem)); savingBillItem.setStaffFee(billBeanController.calFeeValue(FeeType.Staff, savingBillItem)); savingBillItem.setBillSession(newBillSession); @@ -475,9 +474,9 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si) printingBill.setSingleBillItem(savingBillItem); printingBill.setSingleBillSession(newBillSession); printingBill.setBillFees(savingBillFees); - + calculateBillTotalsFromBillFees(printingBill, savingBillFees); - + List lastSessionReservedNumbers = CommonFunctions.convertStringToIntegerList(getSelectedSessionInstance().getOriginatingSession().getReserveNumbers()); List reservedNumbers = CommonFunctions.convertStringToIntegerList(getSelectedSessionInstanceForRechedule().getOriginatingSession().getReserveNumbers()); @@ -637,7 +636,6 @@ private BillItem createSessionItemForReshedule(Bill bill) { return bi; } - public void fillSessionInstanceByDoctor() { sessionInstanceByDoctor = new ArrayList<>(); Date currentDate = new Date(); @@ -961,11 +959,11 @@ public void completeSession() { } public void saveSessionInstanceDetails() { - if (sessionInstanceStartedEdited) { + if (sessionInstanceStartedEdited) { return; } sessionInstanceStartedEdited = true; - + if (selectedSessionInstance == null) { JsfUtil.addErrorMessage("No Session Instance is Selected"); sessionInstanceStartedEdited = false; @@ -979,7 +977,7 @@ public void saveSessionInstanceDetails() { selectedSessionInstance.setEditedAt(new Date()); selectedSessionInstance.setEditer(sessionController.getLoggedUser()); sessionInstanceFacade.edit(selectedSessionInstance); - + if (!selectedSessionInstance.getStartingTime().equals(selectedSessionInstance.getOriginatingSession().getStartingTime()) || !selectedSessionInstance.getEndingTime().equals(selectedSessionInstance.getOriginatingSession().getEndingTime())) { sendSmsChannelSessionTImeChangeNotification(); } @@ -1247,7 +1245,7 @@ public void loadSessionInstances() { params.put("keyword", "%" + sessionInstanceFilter.trim().toLowerCase() + "%"); } - // Adding sorting to JPQL with custom order + // Adding sorting to JPQL with custom order jpql.append(" order by case when i.completed = true then 1 else 0 end, i.completed asc, i.started desc, i.sessionDate asc, i.startingTime asc"); Long numberOfSessionToLoad = configOptionApplicationController.getLongValueByKey("Maximum Number of Sessions to Load during channel booking by dates page.", 30L); @@ -1369,7 +1367,7 @@ public void markSessionInstanceAsStarted() { return; } - if(!selectedSessionInstance.isArrived()){ + if (!selectedSessionInstance.isArrived()) { markAsArrived(); } selectedSessionInstance.setStarted(true); @@ -1990,7 +1988,7 @@ public String navigateToNurseView() { return ""; } } - + public String navigateToNurseViewWithItems() { if (preSet()) { getChannelReportController().fillNurseView(); @@ -2045,6 +2043,10 @@ public String navigateToAllPatientView() { } public void channelBookingCancel() { +// System.out.println("BillType = " + selectedBillSession.getBill().getBillType()); +// System.out.println("Payment Method = " + cancelPaymentMethod); + +// System.out.println("getPaymentMethod = " + getCancelPaymentMethod()); if (selectedBillSession.getBill().getBillType() == BillType.ChannelAgent) { cancelAgentPaidBill(); return; @@ -2131,10 +2133,13 @@ public void cancelCashFlowBill() { } public void cancelBookingBill() { +// System.out.println("Error check Start"); if (errorCheckCancelling()) { return; } +// System.out.println("Error check End"); + CancelledBill cb = createCancelBill1(getBillSession().getBill()); BillItem cItem = cancelBillItems(getBillSession().getBillItem(), cb); BillSession cbs = cancelBillSession(getBillSession(), cb, cItem); @@ -2143,6 +2148,17 @@ public void cancelBookingBill() { getBillFacade().edit(getBillSession().getBill()); getBillSession().setReferenceBillSession(cbs); billSessionFacade.edit(selectedBillSession); + + if (cancelPaymentMethod == PaymentMethod.Staff) { +// System.out.println("Staff"); +// System.out.println("Before Balance = " + getBillSession().getBill().getToStaff().getCurrentCreditValue()); + getBillSession().getBill().getToStaff().setCurrentCreditValue(Math.abs(getBillSession().getBill().getToStaff().getCurrentCreditValue()) - Math.abs(getBillSession().getBill().getNetTotal())); + staffFacade.edit(getBillSession().getBill().getToStaff()); +// System.out.println("Before Balance = " + getBillSession().getBill().getToStaff().getCurrentCreditValue()); + System.out.println("Staff Credit Balance Updated"); + } + + System.out.println("****"); sendSmsOnChannelCancellationBookings(); comment = null; printPreviewC = true; @@ -2185,6 +2201,13 @@ private boolean errorCheckCancelling() { return true; } + if (getCancelPaymentMethod() == PaymentMethod.Staff) { + if (getBillSession().getBill().getToStaff() == null) { + JsfUtil.addErrorMessage("Can't Cancel Bill under Staff Method"); + return true; + } + } + if (getBillSession().getBill().isCancelled()) { JsfUtil.addErrorMessage("Already Cancelled"); return true; @@ -2925,23 +2948,23 @@ public boolean patientErrorPresent(Patient p) { JsfUtil.addErrorMessage("Please enter a name"); return true; } - - if(p.getPerson().getDob() == null){ + + if (p.getPerson().getDob() == null) { JsfUtil.addErrorMessage("Please enter patient age"); return true; } - + if (p.getPerson().getPhone() == null || p.getPerson().getPhone().trim().equals("")) { JsfUtil.addErrorMessage("Please enter a phone number"); return true; } - + if (p.getPerson().getMobile() == null || p.getPerson().getMobile().trim().equals("")) { JsfUtil.addErrorMessage("Please enter a mobile number"); return true; } - - if (p.getPerson().getArea()== null) { + + if (p.getPerson().getArea() == null) { JsfUtil.addErrorMessage("Please enter a area"); return true; } @@ -3130,14 +3153,14 @@ public void addChannelBooking(boolean reservedBooking) { int maxNo = selectedSessionInstance.getMaxNo(); long bookedPatientCount = selectedSessionInstance.getBookedPatientCount(); long totalPatientCount; - + List reservedNumbers = CommonFunctions.convertStringToIntegerList(selectedSessionInstance.getReserveNumbers()); - if(reservedBooking){ - bookedPatientCount = bookedPatientCount; - }else{ + if (reservedBooking) { + bookedPatientCount = bookedPatientCount; + } else { bookedPatientCount = bookedPatientCount + reservedNumbers.size(); - } - + } + if (selectedSessionInstance.getCancelPatientCount() != null) { long canceledPatientCount = selectedSessionInstance.getCancelPatientCount(); totalPatientCount = bookedPatientCount - canceledPatientCount; @@ -3179,22 +3202,21 @@ public void addChannelBooking(boolean reservedBooking) { createPayment(printingBill, paymentMethod); } sendSmsAfterBooking(); - - if(selectedSessionInstance.isStarted()){ + + if (selectedSessionInstance.isStarted()) { sendChannellingStatusUpdateNotificationSms(printingBill.getSingleBillSession()); } settleSucessFully = true; printPreview = true; JsfUtil.addSuccessMessage("Channel Booking Added."); } - - public long totalReservedNumberCount(SessionInstance s){ + + public long totalReservedNumberCount(SessionInstance s) { List reservedNumbers = CommonFunctions.convertStringToIntegerList(s.getReserveNumbers()); long reservedNumberCount = reservedNumbers.size(); return reservedNumberCount; } - public BillSession addChannelBookingForOnlinePayment() { errorText = ""; if (billSessionErrorPresent()) { @@ -5097,9 +5119,9 @@ private Bill saveBilledBill(boolean forReservedNumbers) { if (!(savingBill.getPaymentMethod() == PaymentMethod.OnCall)) { savingBill.setPaidAmount(feeNetTotalForSelectedBill); } else { - if(feeNetTotalForSelectedBill != null){ + if (feeNetTotalForSelectedBill != null) { savingBill.setNetTotal(feeNetTotalForSelectedBill); - } + } } } @@ -5821,7 +5843,7 @@ private Bill createBill() { getBillFacade().create(bill); - if (bill.getBillType() == BillType.ChannelCash || bill.getBillType() == BillType.ChannelAgent) { + if (bill.getBillType() == BillType.ChannelCash || bill.getBillType() == BillType.ChannelAgent || bill.getBillType() == BillType.ChannelStaff) { bill.setPaidBill(bill); getBillFacade().edit(bill); } @@ -6605,7 +6627,7 @@ public void settleCredit() { getBillSession().getBill().setPaidAmount(b.getPaidAmount()); getBillSession().getBill().setBalance(0.0); getBillSession().getBill().setPaidBill(b); - + getBillFacade().edit(getBillSession().getBill()); b.setSingleBillItem(bi); @@ -6906,6 +6928,14 @@ public void refundCreditPaidBill() { JsfUtil.addErrorMessage("Already Refunded"); return; } + + if (getRefundPaymentMethod() == PaymentMethod.Staff) { + if (getBillSession().getPaidBillSession().getBill().getToStaff() == null) { + JsfUtil.addErrorMessage("Cant't Refund to Use Staff Method"); + return; + } + } + if (getCommentR() == null || getCommentR().trim().equals("")) { JsfUtil.addErrorMessage("Please enter a comment"); return; @@ -7064,6 +7094,16 @@ public void refund1(Bill bill, BillItem billItem, List billFees, BillSe } } + if (refundPaymentMethod == PaymentMethod.Staff) { + //System.out.println("Credit Limit Update "); + //System.out.println("Before = " + bill.getToStaff().getCurrentCreditValue()); + //System.out.println("Refund Paid bill Total = " + rb.getNetTotal()); + bill.getToStaff().setCurrentCreditValue(Math.abs(bill.getPaidBill().getToStaff().getCurrentCreditValue() - Math.abs(rb.getNetTotal()))); + staffFacade.edit(bill.getToStaff()); + //System.out.println("After = " + bill.getToStaff().getCurrentCreditValue()); + //System.out.println("staff Credit Limit Updated"); + } + bill.setRefunded(true); bill.setRefundedBill(rb); getBillFacade().edit(bill); @@ -7309,7 +7349,7 @@ private Bill createCashRefundBill(Bill bill) { getBillFacade().create(rb); - if (bill.getPaymentMethod() == PaymentMethod.Agent || bill.getPaymentMethod() == PaymentMethod.Card ) { + if (bill.getPaymentMethod() == PaymentMethod.Agent || bill.getPaymentMethod() == PaymentMethod.Card) { //rb.setPaymentMethod(refundPaymentMethod); //tempsolution rb.setPaymentMethod(PaymentMethod.Cash); @@ -7416,6 +7456,9 @@ private Bill createCashRefundBill1(Bill bill) { // if (refundPaymentMethod == PaymentMethod.Agent) { // updateBallance(rb.getCreditCompany(), refundableTotal, HistoryType.ChannelBooking, rb, billSession.getBillItem(), billSession, billSession.getBill().getReferralNumber()); // } + } + if (bill.getPaymentMethod() == PaymentMethod.Staff) { + rb.setPaymentMethod(refundPaymentMethod); } else { rb.setPaymentMethod(bill.getPaymentMethod()); } @@ -7489,11 +7532,11 @@ public void calculateSelectedBillSessionTotal() { feeNetTotalForSelectedBill = feeTotalForSelectedBill - feeDiscountForSelectedBill; System.out.println("feeNetTotalForSelectedBill 4 = " + feeNetTotalForSelectedBill); } - + public void calculateSelectedBillSessionTotalForSettling() { System.out.println("calculateSelectedBillSessionTotalForSettling"); Category cat = getBillSession().getSessionInstance().getOriginatingSession().getCategory(); - PaymentSchemeDiscount paymentSchemeDiscount = priceMatrixController.fetchChannellingMemberShipDiscount(settlePaymentMethod, paymentScheme, cat); + PaymentSchemeDiscount paymentSchemeDiscount = priceMatrixController.fetchChannellingMemberShipDiscount(settlePaymentMethod, paymentScheme, cat); feeTotalForSelectedBill = 0.0; feeDiscountForSelectedBill = 0.0; feeNetTotalForSelectedBill = 0.0; @@ -7502,15 +7545,15 @@ public void calculateSelectedBillSessionTotalForSettling() { System.out.println("paymentScheme = " + paymentScheme); List billFees = getBillSession().getBill().getBillFees(); System.out.println("billFees = " + billFees); - if(billFees==null){ - billFees= billBeanController.getBillFee(getBillSession().getBill()); + if (billFees == null) { + billFees = billBeanController.getBillFee(getBillSession().getBill()); } System.out.println("billFees = " + billFees); if (paymentSchemeDiscount != null) { for (BillFee bf : billFees) { - - ItemFee itmf=(ItemFee) bf.getFee() ; - + + ItemFee itmf = (ItemFee) bf.getFee(); + System.out.println("itmf = " + itmf); if (foriegn) { feeTotalForSelectedBill += itmf.getFfee(); @@ -7745,6 +7788,11 @@ public void setNeedToFillBillSessions(Boolean needToFillBillSessions) { } public PaymentMethod getCancelPaymentMethod() { + if (selectedBillSession != null) { + if (selectedBillSession.getBillItem().getBill() != null) { + cancelPaymentMethod = selectedBillSession.getBillItem().getBill().getPaymentMethod(); + } + } return cancelPaymentMethod; } @@ -7797,6 +7845,11 @@ public void setRefundableTotal(double refundableTotal) { } public PaymentMethod getRefundPaymentMethod() { + if (selectedBillSession != null) { + if (selectedBillSession.getBillItem().getBill() != null) { + refundPaymentMethod = selectedBillSession.getBillItem().getBill().getPaymentMethod(); + } + } return refundPaymentMethod; } diff --git a/src/main/webapp/channel/manage_booking_by_date.xhtml b/src/main/webapp/channel/manage_booking_by_date.xhtml index 16b9e3b55b..dc81684869 100644 --- a/src/main/webapp/channel/manage_booking_by_date.xhtml +++ b/src/main/webapp/channel/manage_booking_by_date.xhtml @@ -25,10 +25,10 @@ | - () -
- + () -
+ - +
- + @@ -161,7 +161,7 @@ - + @@ -297,7 +297,7 @@ - + @@ -348,8 +348,8 @@
- - + + @@ -626,7 +626,7 @@ - + @@ -1230,7 +1230,7 @@ - + @@ -1248,22 +1248,30 @@ - - - - - - - - + #{bookingControllerViewScope.selectedBillSession.billItem.bill.paymentMethod} - +
+
+ + + + + +
+ + +
+ +
@@ -1310,7 +1318,7 @@ - + @@ -1336,6 +1344,8 @@ itemValue="#{option}"/> + + + + + + -