Skip to content

Commit

Permalink
Merge pull request #6759 from hmislk/Issue#6733
Browse files Browse the repository at this point in the history
Issue#6733 Closes #6733
  • Loading branch information
DeshaniPubudu authored Aug 7, 2024
2 parents 7b4caa8 + 7673559 commit d8ddf35
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 68 deletions.
141 changes: 97 additions & 44 deletions src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -446,26 +446,25 @@ 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<BillFee> savingBillFees = new ArrayList<>();

priceMatrix = priceMatrixController.fetchChannellingMemberShipDiscount(paymentMethod, paymentScheme, getSelectedSessionInstanceForRechedule().getOriginatingSession().getCategory());
System.out.println("priceMatrix = " + priceMatrix);

List<BillFee> 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);
Expand All @@ -475,9 +474,9 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si)
printingBill.setSingleBillItem(savingBillItem);
printingBill.setSingleBillSession(newBillSession);
printingBill.setBillFees(savingBillFees);

calculateBillTotalsFromBillFees(printingBill, savingBillFees);

List<Integer> lastSessionReservedNumbers = CommonFunctions.convertStringToIntegerList(getSelectedSessionInstance().getOriginatingSession().getReserveNumbers());
List<Integer> reservedNumbers = CommonFunctions.convertStringToIntegerList(getSelectedSessionInstanceForRechedule().getOriginatingSession().getReserveNumbers());

Expand Down Expand Up @@ -637,7 +636,6 @@ private BillItem createSessionItemForReshedule(Bill bill) {
return bi;
}


public void fillSessionInstanceByDoctor() {
sessionInstanceByDoctor = new ArrayList<>();
Date currentDate = new Date();
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1369,7 +1367,7 @@ public void markSessionInstanceAsStarted() {
return;
}

if(!selectedSessionInstance.isArrived()){
if (!selectedSessionInstance.isArrived()) {
markAsArrived();
}
selectedSessionInstance.setStarted(true);
Expand Down Expand Up @@ -1990,7 +1988,7 @@ public String navigateToNurseView() {
return "";
}
}

public String navigateToNurseViewWithItems() {
if (preSet()) {
getChannelReportController().fillNurseView();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -3130,14 +3153,14 @@ public void addChannelBooking(boolean reservedBooking) {
int maxNo = selectedSessionInstance.getMaxNo();
long bookedPatientCount = selectedSessionInstance.getBookedPatientCount();
long totalPatientCount;

List<Integer> 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;
Expand Down Expand Up @@ -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<Integer> reservedNumbers = CommonFunctions.convertStringToIntegerList(s.getReserveNumbers());
long reservedNumberCount = reservedNumbers.size();
return reservedNumberCount;
}


public BillSession addChannelBookingForOnlinePayment() {
errorText = "";
if (billSessionErrorPresent()) {
Expand Down Expand Up @@ -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);
}
}
}
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -7064,6 +7094,16 @@ public void refund1(Bill bill, BillItem billItem, List<BillFee> 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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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;
Expand All @@ -7502,15 +7545,15 @@ public void calculateSelectedBillSessionTotalForSettling() {
System.out.println("paymentScheme = " + paymentScheme);
List<BillFee> 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();
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit d8ddf35

Please sign in to comment.