Skip to content

Commit

Permalink
Merge branch 'master' into issue#4674
Browse files Browse the repository at this point in the history
  • Loading branch information
DamithDeshan authored Apr 20, 2024
2 parents 7882759 + 0373a31 commit 073efa0
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/counter.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9
2
2 changes: 1 addition & 1 deletion .github/last_date.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20240419
20240420
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Developed using Java Enterprise Edition, the system offers both a web applicatio

## Current Version

Current Version: 3.0.0.20240419.9 (This line will be automatically updated to reflect the latest version)
Current Version: 3.0.0.20240420.2 (This line will be automatically updated to reflect the latest version)


## History
Expand Down
70 changes: 52 additions & 18 deletions src/main/java/com/divudi/bean/channel/BookingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import com.divudi.data.OptionScope;
import com.divudi.data.SmsSentResponse;
import com.divudi.data.dataStructure.ComponentDetail;
import com.divudi.entity.Fee;
import com.divudi.entity.Payment;
import com.divudi.entity.lab.ItemForItem;
import com.divudi.facade.PaymentFacade;
Expand Down Expand Up @@ -705,6 +706,7 @@ public void addChannelBooking(boolean reservedBooking) {
}
patientController.save(patient);
printingBill = saveBilledBill(reservedBooking);

createPayment(printingBill, paymentMethod);
sendSmsAfterBooking();
settleSucessFully = true;
Expand Down Expand Up @@ -809,7 +811,7 @@ private String createChanellBookingNoShowSms(Bill b) {
private String createChanellBookingSms(Bill b) {
// String template = sessionController.getDepartmentPreference().getSmsTemplateForChannelBooking();
String template = configOptionController.getLongTextValueByKey("Template for SMS sent on Channel Booking", OptionScope.APPLICATION, null, null, null);
if(template==null||template.isEmpty()){
if (template == null || template.isEmpty()) {
template = "Dear {patient_name}, Your appointment with {doctor} is confirmed for {appointment_time} on {appointment_date}. Your serial no. is {serial_no}. Please arrive 10 minutes early. Thank you.";
}
return createSmsForChannelBooking(b, template);
Expand Down Expand Up @@ -1877,8 +1879,8 @@ private Bill saveBilledBill(boolean forReservedNumbers) {

List<BillFee> savingBillFees = new ArrayList<>();

List<BillFee> savingBillFeesFromSession = createBillFeeForSessions(savingBill, savingBillItem);
List<BillFee> savingBillFeesFromAdditionalItem = createBillFeeForSessions(savingBill, additionalBillItem);
List<BillFee> savingBillFeesFromSession = createBillFeeForSessions(savingBill, savingBillItem, false);
List<BillFee> savingBillFeesFromAdditionalItem = createBillFeeForSessions(savingBill, additionalBillItem, true);

if (savingBillFeesFromSession != null) {
savingBillFees.addAll(savingBillFeesFromSession);
Expand Down Expand Up @@ -1917,6 +1919,8 @@ private Bill saveBilledBill(boolean forReservedNumbers) {
savingBill.setSingleBillItem(savingBillItem);
savingBill.setSingleBillSession(savingBillSession);

calculateBillTotalsFromBillFees(savingBill, savingBillFees);

getBillFacade().edit(savingBill);
getBillSessionFacade().edit(savingBillSession);
return savingBill;
Expand Down Expand Up @@ -2051,7 +2055,9 @@ public List<ItemFee> findServiceSessionFees(ServiceSession ss) {
+ " or f.item=:ses )"
+ " order by f.id";
m.put("ses", ss);
return itemFeeFacade.findByJpql(sql, m);
List<ItemFee> tfs = itemFeeFacade.findByJpql(sql, m);
System.out.println("tfs = " + tfs);
return tfs;
}

public List<ItemFee> findItemFees(Item i) {
Expand All @@ -2065,23 +2071,32 @@ public List<ItemFee> findItemFees(Item i) {
return itemFeeFacade.findByJpql(sql, m);
}

private List<BillFee> createBillFeeForSessions(Bill bill, BillItem billItem) {
private List<BillFee> createBillFeeForSessions(Bill bill, BillItem billItem, boolean thisIsAnAdditionalFee) {
List<BillFee> billFeeList = new ArrayList<>();
double tmpTotal = 0;
double tmpDiscount = 0;
double tmpGrossTotal = 0.0;
List<ItemFee> sessionsFees = findServiceSessionFees(getSelectedSessionInstance().getOriginatingSession());

if (billItem.getItem() != null) {
List<ItemFee> sessionsFees = null;
// sessionsFees = findServiceSessionFees(getSelectedSessionInstance().getOriginatingSession());

if (thisIsAnAdditionalFee) {
sessionsFees = findItemFees(billItem.getItem());
} else {
if (billItem.getItem() instanceof ServiceSession) {
sessionsFees = findServiceSessionFees((ServiceSession) billItem.getItem());
} else if (billItem.getItem() instanceof Item) {
sessionsFees = findItemFees(billItem.getItem());
}
} else {
sessionsFees = findServiceSessionFees(getSelectedSessionInstance().getOriginatingSession());
}

// if (billItem.getItem() != null) {
// if (billItem.getItem() instanceof ServiceSession) {
// sessionsFees = findServiceSessionFees((ServiceSession) billItem.getItem());
// } else if (billItem.getItem() instanceof Item) {
// sessionsFees = findItemFees(billItem.getItem());
// }
// } else {
// sessionsFees = findServiceSessionFees(getSelectedSessionInstance().getOriginatingSession());
// }
if (sessionsFees == null) {
return billFeeList;
}
Expand Down Expand Up @@ -2172,22 +2187,41 @@ private List<BillFee> createBillFeeForSessions(Bill bill, BillItem billItem) {
billFeeFacade.create(bf);
billFeeList.add(bf);
}
bill.setDiscount(tmpDiscount);
bill.setNetTotal(tmpTotal);
bill.setTotal(tmpGrossTotal);
getBillFacade().edit(bill);


billItem.setDiscount(tmpDiscount);
billItem.setNetValue(tmpTotal);
getBillItemFacade().edit(billItem);

// if (paymentMethod != PaymentMethod.Agent) {
// changeAgentFeeToHospitalFee();
// }
return billFeeList;

}

private void calculateBillTotalsFromBillFees(Bill billToCaclculate, List<BillFee> billfeesAvailable) {
double calculatingGrossBillTotal = 0.0;
double calculatingNetBillTotal = 0.0;

for (BillFee iteratingBillFee : billfeesAvailable) {
System.out.println("iteratingBillFee = " + iteratingBillFee);
Fee currentItemFee;
if (iteratingBillFee.getFee() == null) {
System.err.println("No Fee for Bill Fee");
continue;
}
System.out.println("iteratingBillFee.getFeeGrossValue() = " + iteratingBillFee.getFeeGrossValue());
System.out.println("iteratingBillFee.getFeeValue() = " + iteratingBillFee.getFeeValue());


calculatingGrossBillTotal += iteratingBillFee.getFeeGrossValue();
calculatingNetBillTotal += iteratingBillFee.getFeeValue();

}
billToCaclculate.setDiscount(calculatingGrossBillTotal-calculatingNetBillTotal);
billToCaclculate.setNetTotal(calculatingNetBillTotal);
billToCaclculate.setTotal(calculatingGrossBillTotal);
getBillFacade().edit(billToCaclculate);
}

private Bill createBill() {
System.out.println("create bill started = " + new Date());
Bill bill = new BilledBill();
Expand Down
Loading

0 comments on commit 073efa0

Please sign in to comment.