Skip to content

Commit a04f3ab

Browse files
authored
Merge pull request #10011 from hmislk/9972-discount-report-bugfixes
9972 discount report bug fixes Closes #9972
2 parents c7051a0 + 986f5a6 commit a04f3ab

File tree

3 files changed

+61
-26
lines changed

3 files changed

+61
-26
lines changed

src/main/java/com/divudi/bean/common/ReportsController.java

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,7 +2650,7 @@ public void generateDebtorBalanceReport(final boolean onlyDueBills) {
26502650
}
26512651

26522652
public ReportTemplateRowBundle generateDebtorBalanceReportBills(List<BillTypeAtomic> bts, List<PaymentMethod> billPaymentMethods,
2653-
boolean onlyDueBills) {
2653+
boolean onlyDueBills) {
26542654
Map<String, Object> parameters = new HashMap<>();
26552655
String jpql = "SELECT new com.divudi.data.ReportTemplateRow(bill) "
26562656
+ "FROM Bill bill "
@@ -3704,28 +3704,32 @@ public void generateDiscountReport() {
37043704
bundle = new ReportTemplateRowBundle();
37053705

37063706
if (visitType.equalsIgnoreCase("IP")) {
3707-
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL);
3708-
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL);
3709-
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL_CANCELLATION);
3710-
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL_CANCELLATION);
3711-
opdBts.add(BillTypeAtomic.INWARD_FINAL_BILL);
3707+
if (reportType.equalsIgnoreCase("detail")) {
3708+
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL);
3709+
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL_CANCELLATION);
3710+
opdBts.add(BillTypeAtomic.INWARD_FINAL_BILL);
3711+
} else if (reportType.equalsIgnoreCase("summary")) {
3712+
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL);
3713+
opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL_CANCELLATION);
3714+
}
37123715
} else if (visitType.equalsIgnoreCase("OP")) {
3713-
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_WITH_PAYMENT);
3714-
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BATCH_BILL_WITH_PAYMENT);
3715-
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER);
3716-
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BATCH_BILL_CANCELLATION);
3717-
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_CANCELLATION);
3718-
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_REFUND);
3719-
3720-
opdBts.add(BillTypeAtomic.OPD_BILL_WITH_PAYMENT);
3721-
opdBts.add(BillTypeAtomic.OPD_BILL_CANCELLATION);
3722-
opdBts.add(BillTypeAtomic.OPD_BILL_REFUND);
3723-
3724-
opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_WITH_PAYMENT);
3725-
opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_CANCELLATION);
3726-
3727-
opdBts.add(BillTypeAtomic.OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER);
3728-
opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER);
3716+
if (reportType.equalsIgnoreCase("detail")) {
3717+
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_WITH_PAYMENT);
3718+
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER);
3719+
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_CANCELLATION);
3720+
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_REFUND);
3721+
opdBts.add(BillTypeAtomic.OPD_BILL_WITH_PAYMENT);
3722+
opdBts.add(BillTypeAtomic.OPD_BILL_CANCELLATION);
3723+
opdBts.add(BillTypeAtomic.OPD_BILL_REFUND);
3724+
opdBts.add(BillTypeAtomic.OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER);
3725+
3726+
} else if (reportType.equalsIgnoreCase("summary")) {
3727+
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BATCH_BILL_WITH_PAYMENT);
3728+
opdBts.add(BillTypeAtomic.PACKAGE_OPD_BATCH_BILL_CANCELLATION);
3729+
opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_WITH_PAYMENT);
3730+
opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_CANCELLATION);
3731+
opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER);
3732+
}
37293733
}
37303734

37313735
if (reportType.equalsIgnoreCase("detail")) {
@@ -3743,6 +3747,25 @@ public void generateDiscountReport() {
37433747
}
37443748
}
37453749

3750+
public double calculateDiscount(final BillItem billItem, final List<ReportTemplateRow> reportTemplateRows) {
3751+
if (!billItem.getItem().isDiscountAllowed()) {
3752+
return 0.0;
3753+
}
3754+
3755+
double totalDiscount = billItem.getBill().getDiscount();
3756+
int billItemCount = 0;
3757+
3758+
for (ReportTemplateRow row : reportTemplateRows) {
3759+
BillItem item = row.getBillItem();
3760+
3761+
if (item.getBill().equals(billItem.getBill()) && item.getItem().isDiscountAllowed()) {
3762+
billItemCount++;
3763+
}
3764+
}
3765+
3766+
return billItemCount > 0 ? totalDiscount / billItemCount : 0.0;
3767+
}
3768+
37463769
public ReportTemplateRowBundle generateDiscountBills(List<BillTypeAtomic> bts) {
37473770
Map<String, Object> parameters = new HashMap<>();
37483771

@@ -3936,6 +3959,12 @@ public ReportTemplateRowBundle generateDiscountBillItems(List<BillTypeAtomic> bt
39363959

39373960
List<ReportTemplateRow> rs = (List<ReportTemplateRow>) paymentFacade.findLightsByJpql(jpql, parameters, TemporalType.TIMESTAMP);
39383961

3962+
for (ReportTemplateRow row : rs) {
3963+
BillItem billItem = row.getBillItem();
3964+
3965+
billItem.setDiscount(calculateDiscount(billItem, rs));
3966+
}
3967+
39393968
ReportTemplateRowBundle b = new ReportTemplateRowBundle();
39403969
b.setReportTemplateRows(rs);
39413970
b.createRowValuesFromBillItems();
@@ -4306,8 +4335,8 @@ public void exportDetailedWeeklyOPDReportToPDF() {
43064335
}
43074336

43084337
private void addWeeklyReportSection(Document document, String sectionTitle, List<String> itemList,
4309-
List<Integer> daysOfWeek, Map<Integer, Map<String, Map<Integer, Double>>> weeklyDailyBillItemMap,
4310-
int week, com.itextpdf.text.Font headerFont, com.itextpdf.text.Font regularFont) throws DocumentException {
4338+
List<Integer> daysOfWeek, Map<Integer, Map<String, Map<Integer, Double>>> weeklyDailyBillItemMap,
4339+
int week, com.itextpdf.text.Font headerFont, com.itextpdf.text.Font regularFont) throws DocumentException {
43114340
document.add(new com.itextpdf.text.Paragraph(sectionTitle, headerFont));
43124341
document.add(com.itextpdf.text.Chunk.NEWLINE);
43134342

src/main/java/com/divudi/data/ReportTemplateRowBundle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ public void calculateTotalDiscountByBillItems() {
11441144
if (row.getBillItem().getBill() == null) {
11451145
continue;
11461146
}
1147-
Double amount = safeDouble(row.getBillItem().getBill().getDiscount());
1147+
Double amount = safeDouble(row.getBillItem().getDiscount());
11481148
discount += amount;
11491149
}
11501150
}

src/main/webapp/reports/financialReports/discount.xhtml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@
347347
<p:column headerText="Visit Type">
348348
<h:outputText value="#{row.bill.ipOpOrCc}"/>
349349
</p:column>
350+
<p:column headerText="Admission Type" rendered="#{reportsController.visitType eq 'IP'}">
351+
<h:outputText value="#{row.bill.patientEncounter.admissionType.name}"/>
352+
</p:column>
350353
<p:column headerText="Invoice No" width="13rem">
351354
<h:outputText value="#{row.bill.deptId}" rendered="#{row.bill.patientEncounter eq null}"/>
352355
<h:outputText value="#{row.bill.patientEncounter.finalBill.deptId}"
@@ -417,6 +420,9 @@
417420
<p:column headerText="Visit Type">
418421
<h:outputText value="#{row.billItem.bill.ipOpOrCc}"/>
419422
</p:column>
423+
<p:column headerText="Admission Type" rendered="#{reportsController.visitType eq 'IP'}">
424+
<h:outputText value="#{row.billItem.patientEncounter.admissionType.name}"/>
425+
</p:column>
420426
<p:column headerText="Invoice No" width="13rem">
421427
<h:outputText value="#{row.billItem.bill.deptId}"
422428
rendered="#{row.billItem.patientEncounter eq null}"/>
@@ -454,7 +460,7 @@
454460
</h:outputText>
455461
</p:column>
456462
<p:column headerText="Discount">
457-
<h:outputText value="#{row.billItem.bill.discount}">
463+
<h:outputText value="#{row.billItem.discount}">
458464
<f:convertNumber pattern="#,##0.00"/>
459465
</h:outputText>
460466
<f:facet name="footer">

0 commit comments

Comments
 (0)