From 14d4a41ef17f74b9367a2901aeb44513be9ac593 Mon Sep 17 00:00:00 2001 From: buddhika75 Date: Wed, 24 Jul 2024 16:52:08 +0530 Subject: [PATCH 1/4] Signed-off-by: buddhika75 --- .../FinancialTransactionController.java | 251 ++++++++++++++++++ .../analytics/ReportTemplateController.java | 210 +++++++++++++-- .../com/divudi/data/ReportTemplateRow.java | 17 ++ .../data/analytics/ReportTemplateType.java | 1 + src/main/webapp/analytics/index.xhtml | 2 +- src/main/webapp/cashier/day_end_report.xhtml | 219 +++++++++++++++ ...ift_end_report_bill_of_selected_user.xhtml | 116 +++++++- 7 files changed, 786 insertions(+), 30 deletions(-) create mode 100644 src/main/webapp/cashier/day_end_report.xhtml diff --git a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java index 51b327f53d..302a1f3fd2 100644 --- a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java +++ b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java @@ -29,6 +29,7 @@ import com.divudi.data.analytics.ReportTemplateType; import com.divudi.data.dataStructure.PaymentMethodData; import com.divudi.entity.Category; +import com.divudi.entity.Institution; import com.divudi.entity.Item; import com.divudi.entity.WebUser; import com.divudi.java.CommonFunctions; @@ -99,6 +100,11 @@ public class FinancialTransactionController implements Serializable { private ReportTemplateRowBundle pharmacyBilld; private ReportTemplateRowBundle pharmacyReturned; + private ReportTemplateRowBundle channellingOnsite; + private ReportTemplateRowBundle channellingAgent; + private ReportTemplateRowBundle channellingOnline; + private ReportTemplateRowBundle opdByDepartment; + private Payment currentPayment; private PaymentMethodData paymentMethodData; private Payment removingPayment; @@ -205,6 +211,44 @@ private LocalDateTime convertToLocalDateTime(Date date) { } public void processShiftEndReport() { + List channellingOnlineBooking = new ArrayList<>(); + channellingOnlineBooking.add(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT_ONLINE); + channellingOnline = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + channellingOnlineBooking, + null, + null, + null, + null, + null, + null, + null, + null, + null, + nonClosedShiftStartFundBill.getCreater(), + null, + nonClosedShiftStartFundBill.getId(), + nonClosedShiftStartFundBill.getReferenceBill().getId()); + + Institution agent = new Institution(); + channellingAgent = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_IN), + null, + null, + null, + null, + null, + null, + null, + null, + null, + nonClosedShiftStartFundBill.getCreater(), + agent, + nonClosedShiftStartFundBill.getId(), + nonClosedShiftStartFundBill.getReferenceBill().getId()); + + agent.setId(1l); channellingBilled = reportTemplateController.generateReport( ReportTemplateType.BILL_NET_TOTAL, BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_IN), @@ -218,6 +262,23 @@ public void processShiftEndReport() { null, null, nonClosedShiftStartFundBill.getCreater(), + agent, + nonClosedShiftStartFundBill.getId(), + nonClosedShiftStartFundBill.getReferenceBill().getId()); + + opdByDepartment = reportTemplateController.generateReport( + ReportTemplateType.ITEM_DEPARTMENT_SUMMARY_BY_BILL_ITEM, + BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_IN), + null, + null, + null, + null, + null, + null, + null, + null, + null, + nonClosedShiftStartFundBill.getCreater(), null, nonClosedShiftStartFundBill.getId(), nonClosedShiftStartFundBill.getReferenceBill().getId()); @@ -303,6 +364,164 @@ public void processShiftEndReport() { nonClosedShiftStartFundBill.getReferenceBill().getId()); } + public String navigateToDayEndReport() { + return "/cashier/day_end_report?faces-redirect=true;"; + } + + public void processDayEndReport() { + List channellingOnlineBooking = new ArrayList<>(); + channellingOnlineBooking.add(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT_ONLINE); + channellingOnline = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + channellingOnlineBooking, + null, + fromDate, + toDate, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + + Institution agent = new Institution(); + channellingAgent = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_IN), + null, + fromDate, + toDate, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + + agent.setId(1l); + channellingBilled = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_IN), + null, + fromDate, + toDate, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + + opdByDepartment = reportTemplateController.generateReport( + ReportTemplateType.ITEM_DEPARTMENT_SUMMARY_BY_BILL_ITEM, + BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_IN), + null, + fromDate, + toDate, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + channellingReturns = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_OUT), + null, + fromDate, + toDate, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + opdBilled = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_IN), + null, + fromDate, + toDate, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + opdReturns = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_OUT), + null, + fromDate, + toDate, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + channellingDocPayment = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + BillTypeAtomic.findBillTypeAtomic(ServiceType.CHANNELLING, BillCategory.PAYMENTS), + null, + fromDate, + toDate, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + opdDocPayment = reportTemplateController.generateReport( + ReportTemplateType.BILL_NET_TOTAL, + BillTypeAtomic.findBillTypeAtomic(ServiceType.OPD, BillCategory.PAYMENTS), + null, + fromDate, + toDate, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null); + } + private ReportTemplateRowBundle combineBundlesByItem(ReportTemplateRowBundle inBundle, ReportTemplateRowBundle outBundle) { ReportTemplateRowBundle temOutBundle = new ReportTemplateRowBundle(); Map combinedRows = new HashMap<>(); @@ -2475,4 +2694,36 @@ public void setReportTemplateType(ReportTemplateType reportTemplateType) { this.reportTemplateType = reportTemplateType; } + public ReportTemplateRowBundle getChannellingOnsite() { + return channellingOnsite; + } + + public void setChannellingOnsite(ReportTemplateRowBundle channellingOnsite) { + this.channellingOnsite = channellingOnsite; + } + + public ReportTemplateRowBundle getChannellingAgent() { + return channellingAgent; + } + + public void setChannellingAgent(ReportTemplateRowBundle channellingAgent) { + this.channellingAgent = channellingAgent; + } + + public ReportTemplateRowBundle getChannellingOnline() { + return channellingOnline; + } + + public void setChannellingOnline(ReportTemplateRowBundle channellingOnline) { + this.channellingOnline = channellingOnline; + } + + public ReportTemplateRowBundle getOpdByDepartment() { + return opdByDepartment; + } + + public void setOpdByDepartment(ReportTemplateRowBundle opdByDepartment) { + this.opdByDepartment = opdByDepartment; + } + } diff --git a/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java b/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java index b5c36190e8..5a5fe067db 100644 --- a/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java +++ b/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java @@ -446,7 +446,24 @@ public ReportTemplateRowBundle generateReport( paramEndId); break; case ITEM_SUMMARY_BY_BILL: - bundle =handleItemSummaryByBill(btas, + bundle = handleItemSummaryByBill(btas, + paramDate, + paramFromDate, + paramToDate, + paramInstitution, + paramDepartment, + paramFromInstitution, + paramFromDepartment, + paramToInstitution, + paramToDepartment, + paramUser, + paramCreditCompany, + paramStartId, + paramEndId); + break; + case ITEM_DEPARTMENT_SUMMARY_BY_BILL_ITEM: + bundle = handleItemDepartmentummaryByBill( + btas, paramDate, paramFromDate, paramToDate, @@ -513,7 +530,7 @@ public ReportTemplateRowBundle generateReport( paramStartId, paramEndId); break; - + case TO_DEPARTMENT_SUMMARY_BY_BILL: bundle = handleToDepartmentSummaryByBill( btas, @@ -642,9 +659,17 @@ private ReportTemplateRowBundle handleBillFeeGroupedByBillTypeAtomic( parameters.put("tdep", paramToDepartment); } - if (paramCreditCompany != null) { - jpql += " and bill.creditCompany=:cc "; - parameters.put("cc", paramCreditCompany); + if (paramCreditCompany == null) { + + } else { + if (paramCreditCompany.getId() == null) { + jpql += " and bill.creditCompany is not null "; + } else if (paramCreditCompany.getId() == 1l) { + jpql += " and bill.creditCompany is null "; + } else { + jpql += " and bill.creditCompany=:cc "; + parameters.put("cc", paramCreditCompany); + } } jpql += " group by bill.billTypeAtomic"; @@ -759,11 +784,19 @@ private ReportTemplateRowBundle handleBillFeeGroupedByToDepartmentAndCategory( parameters.put("tdep", paramToDepartment); } - if (paramCreditCompany != null) { - jpql += " and bill.creditCompany=:cc "; - parameters.put("cc", paramCreditCompany); - } + if (paramCreditCompany == null) { + } else { + if (paramCreditCompany.getId() == null) { + jpql += " and bill.creditCompany is not null "; + } else if (paramCreditCompany.getId() == 1l) { + jpql += " and bill.creditCompany is null "; + } else { + jpql += " and bill.creditCompany=:cc "; + parameters.put("cc", paramCreditCompany); + } + } + jpql += " group by bill.billTypeAtomic"; System.out.println("jpql = " + jpql); @@ -871,9 +904,17 @@ private ReportTemplateRowBundle handleBillTypeAtomicSummaryUsingBills( parameters.put("tdep", paramToDepartment); } - if (paramCreditCompany != null) { - jpql += " and bill.creditCompany=:cc "; - parameters.put("cc", paramCreditCompany); + if (paramCreditCompany == null) { + + } else { + if (paramCreditCompany.getId() == null) { + jpql += " and bill.creditCompany is not null "; + } else if (paramCreditCompany.getId() == 1l) { + jpql += " and bill.creditCompany is null "; + } else { + jpql += " and bill.creditCompany=:cc "; + parameters.put("cc", paramCreditCompany); + } } jpql += " group by bill.billTypeAtomic"; @@ -985,9 +1026,17 @@ private ReportTemplateRowBundle handleBillTypeAtomicTotalUsingBills( parameters.put("tdep", paramToDepartment); } - if (paramCreditCompany != null) { - jpql += " and bill.creditCompany=:cc "; - parameters.put("cc", paramCreditCompany); + if (paramCreditCompany == null) { + + } else { + if (paramCreditCompany.getId() == null) { + jpql += " and bill.creditCompany is not null "; + } else if (paramCreditCompany.getId() == 1l) { + jpql += " and bill.creditCompany is null "; + } else { + jpql += " and bill.creditCompany=:cc "; + parameters.put("cc", paramCreditCompany); + } } if (paramUser != null) { @@ -1483,8 +1532,137 @@ private ReportTemplateRowBundle handleItemCategorySummaryByBill( bundle.setReportTemplateRows(rs); return bundle; } + + private ReportTemplateRowBundle handleItemDepartmentummaryByBill( + List btas, + Date paramDate, + Date paramFromDate, + Date paramToDate, + Institution paramInstitution, + Department paramDepartment, + Institution paramFromInstitution, + Department paramFromDepartment, + Institution paramToInstitution, + Department paramToDepartment, + WebUser paramUser, + Institution paramCreditCompany, + Long paramStartId, + Long paramEndId) { + + System.out.println("handleItemDepartmentummaryByBill"); + + String jpql; + Map parameters = new HashMap<>(); + ReportTemplateRowBundle bundle = new ReportTemplateRowBundle(); + + jpql = "select new com.divudi.data.ReportTemplateRow(" + + " bi.item.department, count(bi), sum(bi.netValue)) " + + " from BillItem bi" + + " join bi.bill bill " + + " where bill.retired<>:br " + + " and bi.retired<>:br "; + parameters.put("br", true); + + if (btas != null) { + jpql += " and bill.billTypeAtomic in :btas "; + parameters.put("btas", btas); + } + + if (paramDate != null) { + jpql += " and bill.billDate=:bd "; + parameters.put("bd", paramDate); + } + + if (paramToDate != null) { + jpql += " and bill.billDate < :td "; + parameters.put("td", paramToDate); + } + + if (paramFromDate != null) { + jpql += " and bill.billDate > :fd "; + parameters.put("fd", paramFromDate); + } + + if (paramStartId != null) { + jpql += " and bill.id > :sid "; + parameters.put("sid", paramStartId); + } + + if (paramEndId != null) { + jpql += " and bill.id < :eid "; + parameters.put("eid", paramEndId); + } + + if (paramInstitution != null) { + jpql += " and bill.institution=:ins "; + parameters.put("ins", paramInstitution); + } + + if (paramDepartment != null) { + jpql += " and bill.department=:dep "; + parameters.put("dep", paramDepartment); + } + + if (paramFromInstitution != null) { + jpql += " and bill.fromInstitution=:fins "; + parameters.put("fins", paramFromInstitution); + } + + if (paramFromDepartment != null) { + jpql += " and bill.fromDepartment=:fdep "; + parameters.put("fdep", paramFromDepartment); + } + + if (paramToInstitution != null) { + jpql += " and bill.toInstitution=:tins "; + parameters.put("tins", paramToInstitution); + } + + if (paramToDepartment != null) { + jpql += " and bill.toDepartment=:tdep "; + parameters.put("tdep", paramToDepartment); + } + + if (paramUser != null) { + jpql += " and bill.creater=:wu "; + parameters.put("wu", paramUser); + } + + if (paramCreditCompany != null) { + jpql += " and bill.creditCompany=:creditCompany "; + parameters.put("creditCompany", paramCreditCompany); + } + + jpql += " and bi.item is not null " + + " and bi.item.department is not null "; + + jpql += " group by bi.item.department "; + + System.out.println("jpql = " + jpql); + System.out.println("parameters = " + parameters); + + List rs = (List) ejbFacade.findLightsByJpql(jpql, parameters, TemporalType.DATE); + + System.out.println("rs = " + rs); + + if (rs == null || rs.isEmpty()) { + System.out.println("No results found."); + } else { + System.out.println("Results found: " + rs.size()); + } + + long idCounter = 1; + Double total = 0.0; + for (ReportTemplateRow row : rs) { + row.setId(idCounter++); + total = row.getRowValue(); + } + bundle.setReportTemplateRows(rs); + return bundle; + } + private ReportTemplateRowBundle handleItemSummaryByBill( List btas, Date paramDate, @@ -1608,8 +1786,6 @@ private ReportTemplateRowBundle handleItemSummaryByBill( return bundle; } - - private ReportTemplateRowBundle handleToDepartmentSummaryByBillFee( List btas, Date paramDate, diff --git a/src/main/java/com/divudi/data/ReportTemplateRow.java b/src/main/java/com/divudi/data/ReportTemplateRow.java index af872807d9..c05da8507a 100644 --- a/src/main/java/com/divudi/data/ReportTemplateRow.java +++ b/src/main/java/com/divudi/data/ReportTemplateRow.java @@ -30,6 +30,7 @@ public class ReportTemplateRow { private BillTypeAtomic billTypeAtomic; private Institution creditCompany; private Department toDepartment; + private Department itemDepartment; public ReportTemplateRow(Category c) { this.category = c; @@ -113,6 +114,12 @@ public ReportTemplateRow(Category category, Long rowCount, Double rowValue) { this.rowValue = rowValue; this.rowCount = rowCount; } + + public ReportTemplateRow(Department itemDept, Long rowCount, Double rowValue) { + this.itemDepartment = itemDept; + this.rowValue = rowValue; + this.rowCount = rowCount; + } public ReportTemplateRow(Item item, Long rowCount, Double rowValue) { this.item = item; @@ -245,4 +252,14 @@ public void setItem(Item item) { this.item = item; } + public Department getItemDepartment() { + return itemDepartment; + } + + public void setItemDepartment(Department itemDepartment) { + this.itemDepartment = itemDepartment; + } + + + } diff --git a/src/main/java/com/divudi/data/analytics/ReportTemplateType.java b/src/main/java/com/divudi/data/analytics/ReportTemplateType.java index d5126234a5..f430f28f64 100644 --- a/src/main/java/com/divudi/data/analytics/ReportTemplateType.java +++ b/src/main/java/com/divudi/data/analytics/ReportTemplateType.java @@ -23,6 +23,7 @@ public enum ReportTemplateType { PAYMENT_TYPE_SUMMARY_PAYMENTS("Payment Method Summary by using Payments"), ITEM_CATEGORY_SUMMARY_BY_BILL_FEE("Item Category Summary by Bill Fee"), ITEM_CATEGORY_SUMMARY_BY_BILL_ITEM("Item Category Summary by Bill Item"), + ITEM_DEPARTMENT_SUMMARY_BY_BILL_ITEM("Item Department Summary by Bill Item"), ITEM_CATEGORY_SUMMARY_BY_BILL("Item Category Summary by Bill"), ITEM_SUMMARY_BY_BILL("Item Summary by Bill"), TO_DEPARTMENT_SUMMARY_BY_BILL_FEE("To Department Summary by Bill Fee"), diff --git a/src/main/webapp/analytics/index.xhtml b/src/main/webapp/analytics/index.xhtml index a90643fd43..24b261dae1 100644 --- a/src/main/webapp/analytics/index.xhtml +++ b/src/main/webapp/analytics/index.xhtml @@ -28,7 +28,7 @@ ajax="false" value="Day End Summery" actionListener="#{searchController.makeNull()}" - action="#{searchController.navigateToAllFinancialTransactionSummary()}" + action="#{financialTransactionController.navigateToDayEndReport()}" class="w-100"> diff --git a/src/main/webapp/cashier/day_end_report.xhtml b/src/main/webapp/cashier/day_end_report.xhtml new file mode 100644 index 0000000000..f87fffcde6 --- /dev/null +++ b/src/main/webapp/cashier/day_end_report.xhtml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Service + + Collected + + Refunds + + Payments + + Net +
+ Channelling on site + + + + + + + + + + + + + + + + +
+ Channelling by agent + + + + + + + + + + + + + + + + +
+ Channelling by Online + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+
+ + #{financialTransactionController.opdByDepartment.reportTemplateRows} + +
+ + + +
+
+
+ +
+ diff --git a/src/main/webapp/cashier/shift_end_report_bill_of_selected_user.xhtml b/src/main/webapp/cashier/shift_end_report_bill_of_selected_user.xhtml index 04623bc714..2b24e5eb42 100644 --- a/src/main/webapp/cashier/shift_end_report_bill_of_selected_user.xhtml +++ b/src/main/webapp/cashier/shift_end_report_bill_of_selected_user.xhtml @@ -120,59 +120,151 @@ - Channelling + Channelling on site - + - + - + - + + + - - + Channelling by agent - + - + - + - + + + + + Channelling by Online + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #{financialTransactionController.opdByDepartment.reportTemplateRows} From 21e887094af88c4124afe6ae2cfb998a6fe1c5e6 Mon Sep 17 00:00:00 2001 From: buddhika75 Date: Wed, 24 Jul 2024 23:17:25 +0530 Subject: [PATCH 2/4] Signed-off-by: buddhika75 --- .../FinancialTransactionController.java | 329 ++++++++++-------- .../com/divudi/data/ReportTemplateRow.java | 32 +- .../divudi/data/ReportTemplateRowBundle.java | 18 + ...ift_end_report_bill_of_selected_user.xhtml | 56 +++ 4 files changed, 280 insertions(+), 155 deletions(-) diff --git a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java index 302a1f3fd2..f7c9665638 100644 --- a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java +++ b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java @@ -29,6 +29,7 @@ import com.divudi.data.analytics.ReportTemplateType; import com.divudi.data.dataStructure.PaymentMethodData; import com.divudi.entity.Category; +import com.divudi.entity.Department; import com.divudi.entity.Institution; import com.divudi.entity.Item; import com.divudi.entity.WebUser; @@ -105,6 +106,8 @@ public class FinancialTransactionController implements Serializable { private ReportTemplateRowBundle channellingOnline; private ReportTemplateRowBundle opdByDepartment; + private List shiftEndBundles; + private Payment currentPayment; private PaymentMethodData paymentMethodData; private Payment removingPayment; @@ -210,158 +213,112 @@ private LocalDateTime convertToLocalDateTime(Date date) { return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); } - public void processShiftEndReport() { - List channellingOnlineBooking = new ArrayList<>(); - channellingOnlineBooking.add(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT_ONLINE); - channellingOnline = reportTemplateController.generateReport( - ReportTemplateType.BILL_NET_TOTAL, - channellingOnlineBooking, - null, - null, - null, - null, - null, - null, - null, - null, - null, - nonClosedShiftStartFundBill.getCreater(), - null, - nonClosedShiftStartFundBill.getId(), - nonClosedShiftStartFundBill.getReferenceBill().getId()); - - Institution agent = new Institution(); - channellingAgent = reportTemplateController.generateReport( - ReportTemplateType.BILL_NET_TOTAL, - BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_IN), - null, - null, - null, - null, - null, - null, - null, - null, - null, - nonClosedShiftStartFundBill.getCreater(), - agent, - nonClosedShiftStartFundBill.getId(), - nonClosedShiftStartFundBill.getReferenceBill().getId()); - - agent.setId(1l); - channellingBilled = reportTemplateController.generateReport( - ReportTemplateType.BILL_NET_TOTAL, - BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_IN), - null, - null, - null, - null, - null, - null, - null, - null, - null, - nonClosedShiftStartFundBill.getCreater(), - agent, - nonClosedShiftStartFundBill.getId(), - nonClosedShiftStartFundBill.getReferenceBill().getId()); + public ReportTemplateRowBundle addChannellingByCategories( + ReportTemplateType type, + List btas, + Date paramDate, + Date paramFromDate, + Date paramToDate, + Institution paramInstitution, + Department paramDepartment, + Institution paramFromInstitution, + Department paramFromDepartment, + Institution paramToInstitution, + Department paramToDepartment, + WebUser paramUser, + Institution paramCreditCompany, + Long paramStartId, + Long paramEndId) { + + ReportTemplateRowBundle bundle; + List inBts = BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_IN); + List outBts = BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_OUT); + + ReportTemplateRowBundle ins = reportTemplateController.generateReport( + type, + inBts, + paramDate, + paramFromDate, + paramToDate, + paramInstitution, + paramDepartment, + paramFromInstitution, + paramFromDepartment, + paramToInstitution, + paramToDepartment, + paramUser, + paramCreditCompany, + paramStartId, + paramEndId); + + System.out.println("ins = " + ins.getReportTemplateRows().size()); + + ReportTemplateRowBundle outs = reportTemplateController.generateReport( + type, + outBts, + paramDate, + paramFromDate, + paramToDate, + paramInstitution, + paramDepartment, + paramFromInstitution, + paramFromDepartment, + paramToInstitution, + paramToDepartment, + paramUser, + paramCreditCompany, + paramStartId, + paramEndId); + + System.out.println("outes = " + outs.getReportTemplateRows().size()); + + bundle = combineBundlesByCategory(ins, outs); + + System.out.println("bundle = " + bundle.getReportTemplateRows().size()); + + return bundle; + } - opdByDepartment = reportTemplateController.generateReport( - ReportTemplateType.ITEM_DEPARTMENT_SUMMARY_BY_BILL_ITEM, - BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_IN), - null, - null, - null, - null, - null, - null, - null, - null, - null, - nonClosedShiftStartFundBill.getCreater(), - null, - nonClosedShiftStartFundBill.getId(), - nonClosedShiftStartFundBill.getReferenceBill().getId()); - channellingReturns = reportTemplateController.generateReport( - ReportTemplateType.BILL_NET_TOTAL, - BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_OUT), - null, - null, - null, - null, - null, - null, - null, - null, - null, - nonClosedShiftStartFundBill.getCreater(), - null, - nonClosedShiftStartFundBill.getId(), - nonClosedShiftStartFundBill.getReferenceBill().getId()); - opdBilled = reportTemplateController.generateReport( - ReportTemplateType.BILL_NET_TOTAL, - BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_IN), - null, - null, - null, - null, - null, - null, - null, - null, - null, - nonClosedShiftStartFundBill.getCreater(), - null, - nonClosedShiftStartFundBill.getId(), - nonClosedShiftStartFundBill.getReferenceBill().getId()); - opdReturns = reportTemplateController.generateReport( - ReportTemplateType.BILL_NET_TOTAL, - BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_OUT), - null, - null, - null, - null, - null, - null, - null, - null, - null, - nonClosedShiftStartFundBill.getCreater(), - null, - nonClosedShiftStartFundBill.getId(), - nonClosedShiftStartFundBill.getReferenceBill().getId()); - channellingDocPayment = reportTemplateController.generateReport( - ReportTemplateType.BILL_NET_TOTAL, - BillTypeAtomic.findBillTypeAtomic(ServiceType.CHANNELLING, BillCategory.PAYMENTS), - null, - null, - null, - null, - null, - null, - null, - null, - null, - nonClosedShiftStartFundBill.getCreater(), - null, - nonClosedShiftStartFundBill.getId(), - nonClosedShiftStartFundBill.getReferenceBill().getId()); - opdDocPayment = reportTemplateController.generateReport( - ReportTemplateType.BILL_NET_TOTAL, - BillTypeAtomic.findBillTypeAtomic(ServiceType.OPD, BillCategory.PAYMENTS), - null, - null, - null, - null, - null, - null, - null, - null, - null, - nonClosedShiftStartFundBill.getCreater(), - null, - nonClosedShiftStartFundBill.getId(), - nonClosedShiftStartFundBill.getReferenceBill().getId()); + public void processShiftEndReport() { + shiftEndBundles = new ArrayList<>(); + ReportTemplateType type = ReportTemplateType.ITEM_CATEGORY_SUMMARY_BY_BILL; + List btas = BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_IN); + Date paramDate = null; + Date paramFromDate = null; + Date paramToDate = null; + Institution paramInstitution = null; + Department paramDepartment = null; + Institution paramFromInstitution = null; + Department paramFromDepartment = null; + Institution paramToInstitution = null; + Department paramToDepartment = null; + WebUser paramUser = nonClosedShiftStartFundBill.getCreater(); + Institution paramCreditCompany = null; + Long paramStartId = nonClosedShiftStartFundBill.getId(); + Long paramEndId = nonClosedShiftStartFundBill.getReferenceBill().getId(); + + ReportTemplateRowBundle channelingBundle = addChannellingByCategories( + type, + btas, + paramDate, + paramFromDate, + paramToDate, + paramInstitution, + paramDepartment, + paramFromInstitution, + paramFromDepartment, + paramToInstitution, + paramToDepartment, + paramUser, + paramCreditCompany, + paramStartId, + paramEndId + ); + + channelingBundle.setName("Channelling"); + shiftEndBundles.add(channelingBundle); + + } public String navigateToDayEndReport() { @@ -646,6 +603,68 @@ private ReportTemplateRowBundle combineBundlesByCategory(ReportTemplateRowBundle return temOutBundle; } + private ReportTemplateRowBundle combineBundlesByDepartment(ReportTemplateRowBundle inBundle, ReportTemplateRowBundle outBundle) { + ReportTemplateRowBundle temOutBundle = new ReportTemplateRowBundle(); + Map combinedRows = new HashMap<>(); + + if (inBundle != null && inBundle.getReportTemplateRows() != null) { + for (ReportTemplateRow inRow : inBundle.getReportTemplateRows()) { + if (inRow != null) { + Department d = inRow.getDepartment(); + if (d != null) { + if (!combinedRows.containsKey(d)) { + combinedRows.put(d, new ReportTemplateRow(d)); + } + ReportTemplateRow combinedRow = combinedRows.get(d); + combinedRow.setRowCountIn((combinedRow.getRowCountIn() != null ? combinedRow.getRowCountIn() : 0L) + (inRow.getRowCount() != null ? inRow.getRowCount() : 0L)); + combinedRow.setRowValueIn((combinedRow.getRowValueIn() != null ? combinedRow.getRowValueIn() : 0.0) + (inRow.getRowValue() != null ? inRow.getRowValue() : 0.0)); + } + } + } + } + + if (outBundle != null && outBundle.getReportTemplateRows() != null) { + for (ReportTemplateRow outRow : outBundle.getReportTemplateRows()) { + if (outRow != null) { + Department d = outRow.getDepartment(); + if (d != null) { + if (!combinedRows.containsKey(d)) { + combinedRows.put(d, new ReportTemplateRow(d)); + } + ReportTemplateRow combinedRow = combinedRows.get(d); + combinedRow.setRowCountOut((combinedRow.getRowCountOut() != null ? combinedRow.getRowCountOut() : 0L) + (outRow.getRowCount() != null ? outRow.getRowCount() : 0L)); + combinedRow.setRowValueOut((combinedRow.getRowValueOut() != null ? combinedRow.getRowValueOut() : 0.0) + (outRow.getRowValue() != null ? outRow.getRowValue() : 0.0)); + } + } + } + } + + long totalInCount = 0; + long totalOutCount = 0; + double totalInValue = 0.0; + double totalOutValue = 0.0; + + for (ReportTemplateRow row : combinedRows.values()) { + row.setRowCount((row.getRowCountIn() != null ? row.getRowCountIn() : 0L) + (row.getRowCountOut() != null ? row.getRowCountOut() : 0L)); + row.setRowValue((row.getRowValueIn() != null ? row.getRowValueIn() : 0.0) + (row.getRowValueOut() != null ? row.getRowValueOut() : 0.0)); + temOutBundle.getReportTemplateRows().add(row); + + totalInCount += (row.getRowCountIn() != null ? row.getRowCountIn() : 0L); + totalOutCount += (row.getRowCountOut() != null ? row.getRowCountOut() : 0L); + totalInValue += (row.getRowValueIn() != null ? row.getRowValueIn() : 0.0); + totalOutValue += (row.getRowValueOut() != null ? row.getRowValueOut() : 0.0); + } + + temOutBundle.setCountIn(totalInCount); + temOutBundle.setCountOut(totalOutCount); + temOutBundle.setCount(totalInCount + totalOutCount); + temOutBundle.setTotalIn(totalInValue); + temOutBundle.setTotalOut(totalOutValue); + temOutBundle.setTotal(totalInValue + totalOutValue); + + return temOutBundle; + } + public void processShiftEndReportOpdCategory() { reportTemplateType = ReportTemplateType.ITEM_CATEGORY_SUMMARY_BY_BILL_ITEM; List bts = new ArrayList<>(); @@ -2726,4 +2745,12 @@ public void setOpdByDepartment(ReportTemplateRowBundle opdByDepartment) { this.opdByDepartment = opdByDepartment; } + public List getShiftEndBundles() { + return shiftEndBundles; + } + + public void setShiftEndBundles(List shiftEndBundles) { + this.shiftEndBundles = shiftEndBundles; + } + } diff --git a/src/main/java/com/divudi/data/ReportTemplateRow.java b/src/main/java/com/divudi/data/ReportTemplateRow.java index c05da8507a..e21e8df8ce 100644 --- a/src/main/java/com/divudi/data/ReportTemplateRow.java +++ b/src/main/java/com/divudi/data/ReportTemplateRow.java @@ -25,12 +25,16 @@ public class ReportTemplateRow { private Long id; private Category category; + private Item item; private ServiceType serviceType; private BillTypeAtomic billTypeAtomic; private Institution creditCompany; private Department toDepartment; - private Department itemDepartment; + private Department itemDepartment; + + private Department department; + private Institution institution; public ReportTemplateRow(Category c) { this.category = c; @@ -41,6 +45,10 @@ public ReportTemplateRow(Item item) { } + public ReportTemplateRow(Department d) { + this.department=d; + } + public void setFeeName(String feeName) { this.feeName = feeName; } @@ -93,6 +101,8 @@ public void setRowCount(Long rowCount) { this.rowCount = rowCount; } + + public ReportTemplateRow(String feeName, String categoryName, String toDepartmentName, String itemName, String paymentName, Double rowValue, Long rowCount) { this.feeName = feeName; this.categoryName = categoryName; @@ -114,7 +124,7 @@ public ReportTemplateRow(Category category, Long rowCount, Double rowValue) { this.rowValue = rowValue; this.rowCount = rowCount; } - + public ReportTemplateRow(Department itemDept, Long rowCount, Double rowValue) { this.itemDepartment = itemDept; this.rowValue = rowValue; @@ -259,7 +269,21 @@ public Department getItemDepartment() { public void setItemDepartment(Department itemDepartment) { this.itemDepartment = itemDepartment; } - - + + public Department getDepartment() { + return department; + } + + public void setDepartment(Department department) { + this.department = department; + } + + public Institution getInstitution() { + return institution; + } + + public void setInstitution(Institution institution) { + this.institution = institution; + } } diff --git a/src/main/java/com/divudi/data/ReportTemplateRowBundle.java b/src/main/java/com/divudi/data/ReportTemplateRowBundle.java index f48f2f9685..109fb84e78 100644 --- a/src/main/java/com/divudi/data/ReportTemplateRowBundle.java +++ b/src/main/java/com/divudi/data/ReportTemplateRowBundle.java @@ -18,6 +18,8 @@ public class ReportTemplateRowBundle { private Long countIn; private Long countOut; private Long count; + private String name; + private String description; @@ -90,6 +92,22 @@ public void setCount(Long count) { this.count = count; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + diff --git a/src/main/webapp/cashier/shift_end_report_bill_of_selected_user.xhtml b/src/main/webapp/cashier/shift_end_report_bill_of_selected_user.xhtml index 2b24e5eb42..bbdf25d67b 100644 --- a/src/main/webapp/cashier/shift_end_report_bill_of_selected_user.xhtml +++ b/src/main/webapp/cashier/shift_end_report_bill_of_selected_user.xhtml @@ -100,6 +100,62 @@ + + + + + + + + + + + + + + + + + + + + +
NameCountTotalReport Template Rows
+ + + + + + + + + + + + + + + + + + + + + + + +
Category / DepartmentValueCount
+ #{r.category.name} + #{r.department.name} + + #{r.rowValue}#{r.rowCount}
+
+ + + + + +
From 3eaaa806627696edd419156ec48d3f74752553c1 Mon Sep 17 00:00:00 2001 From: buddhika75 Date: Wed, 24 Jul 2024 23:42:58 +0530 Subject: [PATCH 3/4] Signed-off-by: buddhika75 --- .../FinancialTransactionController.java | 114 +++++++++++++++--- 1 file changed, 100 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java index f7c9665638..b223c9bc7d 100644 --- a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java +++ b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java @@ -250,7 +250,7 @@ public ReportTemplateRowBundle addChannellingByCategories( paramCreditCompany, paramStartId, paramEndId); - + System.out.println("ins = " + ins.getReportTemplateRows().size()); ReportTemplateRowBundle outs = reportTemplateController.generateReport( @@ -269,11 +269,77 @@ public ReportTemplateRowBundle addChannellingByCategories( paramCreditCompany, paramStartId, paramEndId); - + System.out.println("outes = " + outs.getReportTemplateRows().size()); bundle = combineBundlesByCategory(ins, outs); - + + System.out.println("bundle = " + bundle.getReportTemplateRows().size()); + + return bundle; + } + + public ReportTemplateRowBundle addOpdByDepartments( + ReportTemplateType type, + List btas, + Date paramDate, + Date paramFromDate, + Date paramToDate, + Institution paramInstitution, + Department paramDepartment, + Institution paramFromInstitution, + Department paramFromDepartment, + Institution paramToInstitution, + Department paramToDepartment, + WebUser paramUser, + Institution paramCreditCompany, + Long paramStartId, + Long paramEndId) { + + ReportTemplateRowBundle bundle; + List inBts = BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_IN); + List outBts = BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_OUT); + + ReportTemplateRowBundle ins = reportTemplateController.generateReport( + type, + inBts, + paramDate, + paramFromDate, + paramToDate, + paramInstitution, + paramDepartment, + paramFromInstitution, + paramFromDepartment, + paramToInstitution, + paramToDepartment, + paramUser, + paramCreditCompany, + paramStartId, + paramEndId); + + System.out.println("ins = " + ins.getReportTemplateRows().size()); + + ReportTemplateRowBundle outs = reportTemplateController.generateReport( + type, + outBts, + paramDate, + paramFromDate, + paramToDate, + paramInstitution, + paramDepartment, + paramFromInstitution, + paramFromDepartment, + paramToInstitution, + paramToDepartment, + paramUser, + paramCreditCompany, + paramStartId, + paramEndId); + + System.out.println("outes = " + outs.getReportTemplateRows().size()); + + bundle = combineBundlesByDepartment(ins, outs); + System.out.println("bundle = " + bundle.getReportTemplateRows().size()); return bundle; @@ -281,24 +347,43 @@ public ReportTemplateRowBundle addChannellingByCategories( public void processShiftEndReport() { shiftEndBundles = new ArrayList<>(); - ReportTemplateType type = ReportTemplateType.ITEM_CATEGORY_SUMMARY_BY_BILL; - List btas = BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.CHANNELLING, BillFinanceType.CASH_IN); + ReportTemplateType channelingType = ReportTemplateType.ITEM_CATEGORY_SUMMARY_BY_BILL; + ReportTemplateType opdType = ReportTemplateType.ITEM_DEPARTMENT_SUMMARY_BY_BILL_ITEM; + List btas = null; Date paramDate = null; Date paramFromDate = null; - Date paramToDate = null; + Date paramToDate = null; Institution paramInstitution = null; - Department paramDepartment = null; + Department paramDepartment = null; Institution paramFromInstitution = null; - Department paramFromDepartment = null; + Department paramFromDepartment = null; Institution paramToInstitution = null; - Department paramToDepartment = null; + Department paramToDepartment = null; WebUser paramUser = nonClosedShiftStartFundBill.getCreater(); Institution paramCreditCompany = null; - Long paramStartId = nonClosedShiftStartFundBill.getId(); - Long paramEndId = nonClosedShiftStartFundBill.getReferenceBill().getId(); + Long paramStartId = nonClosedShiftStartFundBill.getId(); + Long paramEndId = nonClosedShiftStartFundBill.getReferenceBill().getId(); ReportTemplateRowBundle channelingBundle = addChannellingByCategories( - type, + channelingType, + btas, + paramDate, + paramFromDate, + paramToDate, + paramInstitution, + paramDepartment, + paramFromInstitution, + paramFromDepartment, + paramToInstitution, + paramToDepartment, + paramUser, + paramCreditCompany, + paramStartId, + paramEndId + ); + + ReportTemplateRowBundle opdBundle = addOpdByDepartments( + opdType, btas, paramDate, paramFromDate, @@ -314,11 +399,12 @@ public void processShiftEndReport() { paramStartId, paramEndId ); - + channelingBundle.setName("Channelling"); + opdBundle.setName("OPD Bundle"); shiftEndBundles.add(channelingBundle); + shiftEndBundles.add(opdBundle); - } public String navigateToDayEndReport() { From 3bfdbe577b6eb7b8b1a93ed334d0fa19681550b9 Mon Sep 17 00:00:00 2001 From: buddhika75 Date: Thu, 25 Jul 2024 01:34:31 +0530 Subject: [PATCH 4/4] Closes #6425 Signed-off-by: buddhika75 --- .../FinancialTransactionController.java | 144 +++++++++++------- .../analytics/ReportTemplateController.java | 8 +- .../java/com/divudi/data/BillTypeAtomic.java | 30 ++-- .../com/divudi/data/CountedServiceType.java | 2 +- src/main/webapp/opd/bill_reprint.xhtml | 4 + 5 files changed, 111 insertions(+), 77 deletions(-) diff --git a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java index b223c9bc7d..7beb004efc 100644 --- a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java +++ b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java @@ -274,8 +274,6 @@ public ReportTemplateRowBundle addChannellingByCategories( bundle = combineBundlesByCategory(ins, outs); - System.out.println("bundle = " + bundle.getReportTemplateRows().size()); - return bundle; } @@ -295,10 +293,11 @@ public ReportTemplateRowBundle addOpdByDepartments( Institution paramCreditCompany, Long paramStartId, Long paramEndId) { + System.out.println("addOpdByDepartments"); ReportTemplateRowBundle bundle; - List inBts = BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_IN); - List outBts = BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_OUT); + List inBts = BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD_IN); + List outBts = BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD_OUT); ReportTemplateRowBundle ins = reportTemplateController.generateReport( type, @@ -338,9 +337,7 @@ public ReportTemplateRowBundle addOpdByDepartments( System.out.println("outes = " + outs.getReportTemplateRows().size()); - bundle = combineBundlesByDepartment(ins, outs); - - System.out.println("bundle = " + bundle.getReportTemplateRows().size()); + bundle = combineBundlesByItemDepartment(ins, outs); return bundle; } @@ -364,7 +361,7 @@ public void processShiftEndReport() { Long paramStartId = nonClosedShiftStartFundBill.getId(); Long paramEndId = nonClosedShiftStartFundBill.getReferenceBill().getId(); - ReportTemplateRowBundle channelingBundle = addChannellingByCategories( + ReportTemplateRowBundle tmpChannellingBundle = addChannellingByCategories( channelingType, btas, paramDate, @@ -382,28 +379,29 @@ public void processShiftEndReport() { paramEndId ); - ReportTemplateRowBundle opdBundle = addOpdByDepartments( - opdType, - btas, - paramDate, - paramFromDate, - paramToDate, - paramInstitution, - paramDepartment, - paramFromInstitution, - paramFromDepartment, - paramToInstitution, - paramToDepartment, - paramUser, - paramCreditCompany, - paramStartId, - paramEndId - ); - - channelingBundle.setName("Channelling"); - opdBundle.setName("OPD Bundle"); - shiftEndBundles.add(channelingBundle); - shiftEndBundles.add(opdBundle); + ReportTemplateRowBundle tmpOpdBundle + = addOpdByDepartments( + opdType, + btas, + paramDate, + paramFromDate, + paramToDate, + paramInstitution, + paramDepartment, + paramFromInstitution, + paramFromDepartment, + paramToInstitution, + paramToDepartment, + paramUser, + paramCreditCompany, + paramStartId, + paramEndId + ); + + tmpChannellingBundle.setName("Channelling"); + tmpOpdBundle.setName("OPD Bundle"); + shiftEndBundles.add(tmpChannellingBundle); + shiftEndBundles.add(tmpOpdBundle); } @@ -689,40 +687,65 @@ private ReportTemplateRowBundle combineBundlesByCategory(ReportTemplateRowBundle return temOutBundle; } - private ReportTemplateRowBundle combineBundlesByDepartment(ReportTemplateRowBundle inBundle, ReportTemplateRowBundle outBundle) { + + + private ReportTemplateRowBundle combineBundlesByItemDepartment(ReportTemplateRowBundle inBundle, ReportTemplateRowBundle outBundle) { + System.out.println("Starting combineBundlesByDepartment method"); + ReportTemplateRowBundle temOutBundle = new ReportTemplateRowBundle(); - Map combinedRows = new HashMap<>(); + temOutBundle.setReportTemplateRows(new ArrayList<>()); // Ensure the list is initialized + Map combinedRows = new HashMap<>(); + + final Object NULL_DEPARTMENT_KEY = new Object(); // Placeholder for null departments if (inBundle != null && inBundle.getReportTemplateRows() != null) { + System.out.println("Processing inBundle"); for (ReportTemplateRow inRow : inBundle.getReportTemplateRows()) { if (inRow != null) { - Department d = inRow.getDepartment(); - if (d != null) { - if (!combinedRows.containsKey(d)) { - combinedRows.put(d, new ReportTemplateRow(d)); - } - ReportTemplateRow combinedRow = combinedRows.get(d); - combinedRow.setRowCountIn((combinedRow.getRowCountIn() != null ? combinedRow.getRowCountIn() : 0L) + (inRow.getRowCount() != null ? inRow.getRowCount() : 0L)); - combinedRow.setRowValueIn((combinedRow.getRowValueIn() != null ? combinedRow.getRowValueIn() : 0.0) + (inRow.getRowValue() != null ? inRow.getRowValue() : 0.0)); + Department d = inRow.getItemDepartment(); + Object key = (d != null) ? d : NULL_DEPARTMENT_KEY; + if (d == null) { + System.out.println("Department is null in inRow"); + } else { + System.out.println("Processing inRow for Department: " + d.getName()); + } + if (!combinedRows.containsKey(key)) { + combinedRows.put(key, new ReportTemplateRow(d)); } + ReportTemplateRow combinedRow = combinedRows.get(key); + combinedRow.setRowCountIn((combinedRow.getRowCountIn() != null ? combinedRow.getRowCountIn() : 0L) + (inRow.getRowCount() != null ? inRow.getRowCount() : 0L)); + combinedRow.setRowValueIn((combinedRow.getRowValueIn() != null ? combinedRow.getRowValueIn() : 0.0) + (inRow.getRowValue() != null ? inRow.getRowValue() : 0.0)); + } else { + System.out.println("inRow is null"); } } + } else { + System.out.println("inBundle or inBundle.getReportTemplateRows() is null"); } if (outBundle != null && outBundle.getReportTemplateRows() != null) { + System.out.println("Processing outBundle"); for (ReportTemplateRow outRow : outBundle.getReportTemplateRows()) { if (outRow != null) { - Department d = outRow.getDepartment(); - if (d != null) { - if (!combinedRows.containsKey(d)) { - combinedRows.put(d, new ReportTemplateRow(d)); - } - ReportTemplateRow combinedRow = combinedRows.get(d); - combinedRow.setRowCountOut((combinedRow.getRowCountOut() != null ? combinedRow.getRowCountOut() : 0L) + (outRow.getRowCount() != null ? outRow.getRowCount() : 0L)); - combinedRow.setRowValueOut((combinedRow.getRowValueOut() != null ? combinedRow.getRowValueOut() : 0.0) + (outRow.getRowValue() != null ? outRow.getRowValue() : 0.0)); + Department d = outRow.getItemDepartment(); + Object key = (d != null) ? d : NULL_DEPARTMENT_KEY; + if (d == null) { + System.out.println("Department is null in outRow"); + } else { + System.out.println("Processing outRow for Department: " + d.getName()); } + if (!combinedRows.containsKey(key)) { + combinedRows.put(key, new ReportTemplateRow(d)); + } + ReportTemplateRow combinedRow = combinedRows.get(key); + combinedRow.setRowCountOut((combinedRow.getRowCountOut() != null ? combinedRow.getRowCountOut() : 0L) + (outRow.getRowCount() != null ? outRow.getRowCount() : 0L)); + combinedRow.setRowValueOut((combinedRow.getRowValueOut() != null ? combinedRow.getRowValueOut() : 0.0) + (outRow.getRowValue() != null ? outRow.getRowValue() : 0.0)); + } else { + System.out.println("outRow is null"); } } + } else { + System.out.println("outBundle or outBundle.getReportTemplateRows() is null"); } long totalInCount = 0; @@ -731,6 +754,8 @@ private ReportTemplateRowBundle combineBundlesByDepartment(ReportTemplateRowBund double totalOutValue = 0.0; for (ReportTemplateRow row : combinedRows.values()) { + String deptName = (row.getItemDepartment() != null) ? row.getItemDepartment().getName() : "NULL_DEPARTMENT"; + System.out.println("Combining row for Department: " + deptName); row.setRowCount((row.getRowCountIn() != null ? row.getRowCountIn() : 0L) + (row.getRowCountOut() != null ? row.getRowCountOut() : 0L)); row.setRowValue((row.getRowValueIn() != null ? row.getRowValueIn() : 0.0) + (row.getRowValueOut() != null ? row.getRowValueOut() : 0.0)); temOutBundle.getReportTemplateRows().add(row); @@ -748,17 +773,25 @@ private ReportTemplateRowBundle combineBundlesByDepartment(ReportTemplateRowBund temOutBundle.setTotalOut(totalOutValue); temOutBundle.setTotal(totalInValue + totalOutValue); + System.out.println("Total In Count: " + totalInCount); + System.out.println("Total Out Count: " + totalOutCount); + System.out.println("Total In Value: " + totalInValue); + System.out.println("Total Out Value: " + totalOutValue); + + System.out.println("Finished combineBundlesByDepartment method"); return temOutBundle; } + + public void processShiftEndReportOpdCategory() { reportTemplateType = ReportTemplateType.ITEM_CATEGORY_SUMMARY_BY_BILL_ITEM; List bts = new ArrayList<>(); bts.addAll(BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_IN)); - bts.addAll(BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD)); + bts.addAll(BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD_IN)); opdBilled = reportTemplateController.generateReport( ReportTemplateType.ITEM_CATEGORY_SUMMARY_BY_BILL_ITEM, - BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD), + BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD_IN), null, null, null, @@ -795,10 +828,10 @@ public void processShiftEndReportOpdItem() { reportTemplateType = ReportTemplateType.ITEM_SUMMARY_BY_BILL; List bts = new ArrayList<>(); bts.addAll(BillTypeAtomic.findByServiceTypeAndFinanceType(ServiceType.OPD, BillFinanceType.CASH_IN)); - bts.addAll(BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD)); + bts.addAll(BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD_IN)); opdBilled = reportTemplateController.generateReport( ReportTemplateType.ITEM_SUMMARY_BY_BILL, - BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD), + BillTypeAtomic.findByCountedServiceType(CountedServiceType.OPD_IN), null, null, null, @@ -1564,7 +1597,6 @@ public String navigateToDayEndSummary() { } public void processDayEndSummary() { - System.out.println("processDayEndSummary"); resetClassVariables(); fillPaymentsForDateRange(); createPaymentSummery(); @@ -1573,7 +1605,6 @@ public void processDayEndSummary() { private void createPaymentSummery() { System.out.println("createPaymentSummery"); - System.out.println("paymentsFromShiftSratToNow = " + paymentsFromShiftSratToNow); if (paymentsFromShiftSratToNow == null) { return; @@ -1583,7 +1614,6 @@ private void createPaymentSummery() { Map keyMap = new HashMap<>(); for (Payment p : paymentsFromShiftSratToNow) { - System.out.println("p = " + p); if (p == null || p.getBill() == null) { continue; // Skip this iteration if p or p.getBill() is null @@ -1733,7 +1763,6 @@ public void fillPaymentsForDateRange() { m.put("td", getToDate()); m.put("ret", true); System.out.println("m = " + m); - System.out.println("jpql = " + jpql); } public void fillPaymentsFromShiftStartToNow(Bill startBill, WebUser user) { @@ -2241,7 +2270,6 @@ public void updateCashDenominations(AjaxBehaviorEvent event) { System.out.println("updateCashDenominations called"); if (currentPayment == null) { - System.out.println("currentPayment is null"); return; } @@ -2249,7 +2277,6 @@ public void updateCashDenominations(AjaxBehaviorEvent event) { List denominations = currentPayment.getCurrencyDenominations(); for (Denomination denomination : denominations) { int value = denomination.getCount(); - System.out.println("Processing denomination: " + denomination.getValue() + " with count: " + value); total += denomination.getValue() * value; } currentPayment.setPaidValue(total); @@ -2264,7 +2291,6 @@ public void updateCashDenominations(AjaxBehaviorEvent event) { jsonArray.put(jsonObject); } currentPayment.setCurrencyDenominationsJson(jsonArray.toString()); - System.out.println("Updated currencyDenominationsJson: " + currentPayment.getCurrencyDenominationsJson()); } public void setCurrentPayment(Payment currentPayment) { diff --git a/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java b/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java index 5a5fe067db..2ad80b614e 100644 --- a/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java +++ b/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java @@ -1526,6 +1526,7 @@ private ReportTemplateRowBundle handleItemCategorySummaryByBill( long idCounter = 1; Double total = 0.0; for (ReportTemplateRow row : rs) { + row.setId(idCounter++); total = row.getRowValue(); } @@ -1633,8 +1634,8 @@ private ReportTemplateRowBundle handleItemDepartmentummaryByBill( parameters.put("creditCompany", paramCreditCompany); } - jpql += " and bi.item is not null " - + " and bi.item.department is not null "; +// jpql += " and bi.item is not null " +// + " and bi.item.department is not null "; jpql += " group by bi.item.department "; @@ -1654,10 +1655,13 @@ private ReportTemplateRowBundle handleItemDepartmentummaryByBill( long idCounter = 1; Double total = 0.0; for (ReportTemplateRow row : rs) { + System.out.println("row = " + row.getItemDepartment()); + System.out.println("row = " + row.getRowCount()); row.setId(idCounter++); total = row.getRowValue(); } bundle.setReportTemplateRows(rs); + bundle.setTotal(total); return bundle; } diff --git a/src/main/java/com/divudi/data/BillTypeAtomic.java b/src/main/java/com/divudi/data/BillTypeAtomic.java index 831d4ae081..4b6e48a62a 100644 --- a/src/main/java/com/divudi/data/BillTypeAtomic.java +++ b/src/main/java/com/divudi/data/BillTypeAtomic.java @@ -109,31 +109,31 @@ public enum BillTypeAtomic { CHANNEL_REFUND_WITH_PAYMENT_FOR_CREDIT_SETTLED_BOOKINGS("Channel Refund with Payment for Bills where Credit Payment was Settled", BillCategory.REFUND, ServiceType.CHANNELLING, BillFinanceType.CASH_OUT, CountedServiceType.CHANNELLING), CHANNEL_CANCELLATION_WITHOUT_PAYMENT("Channel Cancellation without Payment", BillCategory.CANCELLATION, ServiceType.CHANNELLING, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.CHANNELLING), CHANNEL_REFUND("Channel Refund", BillCategory.REFUND, ServiceType.CHANNELLING, BillFinanceType.CASH_OUT, CountedServiceType.CHANNELLING), - // OPD + // OPD_IN OPD_BATCH_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Opd Batch Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.NONE), OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER("Opd Batch Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.NONE), OPD_BATCH_BILL_WITH_PAYMENT("Opd Batch Bill with Payment Collection", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.NONE), OPD_BATCH_BILL_CANCELLATION("Opd Batch Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.NONE), OPD_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Opd Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.NONE), - OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER("OPD Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD), - OPD_BILL_WITH_PAYMENT("OPD Bill Payment with Payment", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD), + OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER("OPD Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN), + OPD_BILL_WITH_PAYMENT("OPD Bill Payment with Payment", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN), OPD_BILL_CANCELLATION("Opd Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_OUT), OPD_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION("Opd Bill Cancellation with Batch Bill", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_OUT), OPD_BILL_REFUND("Opd Bill Refund", BillCategory.REFUND, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_OUT), OPD_PROFESSIONAL_PAYMENT_BILL("OPD Professional Payment bill", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_PROFESSIONAL_PAYMENT), @Deprecated - OPD_BILL_WITH_PAYMENT_UNDER_BATCH_BILL("OPD Bill with payment under batch bill", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD), + OPD_BILL_WITH_PAYMENT_UNDER_BATCH_BILL("OPD Bill with payment under batch bill", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN), // PACKAGES - PACKAGE_OPD_BATCH_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Package Opd Batch Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD), - PACKAGE_OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER("Package Opd Batch Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.OPD), - PACKAGE_OPD_BATCH_BILL_WITH_PAYMENT("Package Opd Batch Bill with Payment Collection", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.OPD), - PACKAGE_OPD_BATCH_BILL_CANCELLATION("Package Opd Batch Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD), - PACKAGE_OPD_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Package Opd Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD), - PACKAGE_OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER("Package OPD Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD), - PACKAGE_OPD_BILL_WITH_PAYMENT("Package OPD Bill Payment with Payment", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD), - PACKAGE_OPD_BILL_CANCELLATION("Package Opd Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD), - PACKAGE_OPD_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION("Package Opd Bill Cancellation with Batch Bill", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD), - PACKAGE_OPD_BILL_REFUND("Package Opd Bill Refund", BillCategory.REFUND, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD), + PACKAGE_OPD_BATCH_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Package Opd Batch Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN), + PACKAGE_OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER("Package Opd Batch Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.OPD_IN), + PACKAGE_OPD_BATCH_BILL_WITH_PAYMENT("Package Opd Batch Bill with Payment Collection", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.OPD_IN), + PACKAGE_OPD_BATCH_BILL_CANCELLATION("Package Opd Batch Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN), + PACKAGE_OPD_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Package Opd Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN), + PACKAGE_OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER("Package OPD Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN), + PACKAGE_OPD_BILL_WITH_PAYMENT("Package OPD Bill Payment with Payment", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN), + PACKAGE_OPD_BILL_CANCELLATION("Package Opd Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_IN), + PACKAGE_OPD_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION("Package Opd Bill Cancellation with Batch Bill", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_IN), + PACKAGE_OPD_BILL_REFUND("Package Opd Bill Refund", BillCategory.REFUND, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_IN), // COLLECTING CENTRE CC_BATCH_BILL("Collecting Centre Batch Bill", BillCategory.BILL, ServiceType.COLLECTING_CENTRE, BillFinanceType.CASH_IN, CountedServiceType.COLLECTING_CENTRE), CC_BATCH_BILL_CANCELLATION("Collecting Centre Batch Bill Cancellation", BillCategory.CANCELLATION, ServiceType.COLLECTING_CENTRE, BillFinanceType.CASH_OUT, CountedServiceType.COLLECTING_CENTRE), @@ -158,7 +158,7 @@ public enum BillTypeAtomic { PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE("Channelling Payment for Staff", BillCategory.PAYMENTS, ServiceType.CHANNELLING, BillFinanceType.CASH_OUT, CountedServiceType.CHANNELLING), PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_SESSION("Channelling session Payment for Staff", BillCategory.PAYMENTS, ServiceType.CHANNELLING, BillFinanceType.CASH_OUT, CountedServiceType.CHANNELLING), PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_FOR_AGENCIES("Channelling Payment for Staff for agencies", BillCategory.PAYMENTS, ServiceType.OTHER, BillFinanceType.CASH_IN, CountedServiceType.OTHER), - PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES("OPD Professional Payment bill", BillCategory.PAYMENTS, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD), + PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES("OPD Professional Payment bill", BillCategory.PAYMENTS, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_IN), PETTY_CASH_ISSUE("Petty Cash Issue", BillCategory.PAYMENTS, ServiceType.OTHER, BillFinanceType.CASH_OUT, CountedServiceType.OTHER), PETTY_CASH_RETURN("Petty Cash Return", BillCategory.BILL, ServiceType.OTHER, BillFinanceType.CASH_IN, CountedServiceType.OTHER), IOU_CASH_ISSUE("Iou Cash Issue", BillCategory.BILL, ServiceType.OTHER, BillFinanceType.CASH_OUT, CountedServiceType.OTHER), diff --git a/src/main/java/com/divudi/data/CountedServiceType.java b/src/main/java/com/divudi/data/CountedServiceType.java index 8594ce6689..cbcebd617c 100644 --- a/src/main/java/com/divudi/data/CountedServiceType.java +++ b/src/main/java/com/divudi/data/CountedServiceType.java @@ -5,7 +5,7 @@ */ public enum CountedServiceType { - OPD("Outpatient Department"), + OPD_IN("Outpatient Department - Collection"), OPD_OUT("Outpatient Department - Cancellation or Refunds"), OPD_PROFESSIONAL_PAYMENT("Outpatient Department - Professional Payment"), NONE("NONE"), diff --git a/src/main/webapp/opd/bill_reprint.xhtml b/src/main/webapp/opd/bill_reprint.xhtml index 46ee728e0b..06d0218b03 100644 --- a/src/main/webapp/opd/bill_reprint.xhtml +++ b/src/main/webapp/opd/bill_reprint.xhtml @@ -276,6 +276,10 @@ Item + + Department + + Gross Fee Value