From 8021c15dd53367aafcd40880921f6e2454a6a0fb Mon Sep 17 00:00:00 2001 From: imexh Date: Thu, 19 Dec 2024 18:11:17 +0530 Subject: [PATCH 01/28] Debtor Analysis-Excess Age #9616 --- .../cash_inward_excess_age.xhtml | 98 ------------------- 1 file changed, 98 deletions(-) diff --git a/src/main/webapp/reports/financialReports/cash_inward_excess_age.xhtml b/src/main/webapp/reports/financialReports/cash_inward_excess_age.xhtml index 5a951740c1..ae488e34f0 100644 --- a/src/main/webapp/reports/financialReports/cash_inward_excess_age.xhtml +++ b/src/main/webapp/reports/financialReports/cash_inward_excess_age.xhtml @@ -26,108 +26,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Date: Thu, 19 Dec 2024 18:15:18 +0530 Subject: [PATCH 02/28] Debtor Analysis-Excess Search #9615 --- .../financialReports/cash_inward_excess.xhtml | 98 ------------------- 1 file changed, 98 deletions(-) diff --git a/src/main/webapp/reports/financialReports/cash_inward_excess.xhtml b/src/main/webapp/reports/financialReports/cash_inward_excess.xhtml index cd2789516e..72f46f2d63 100644 --- a/src/main/webapp/reports/financialReports/cash_inward_excess.xhtml +++ b/src/main/webapp/reports/financialReports/cash_inward_excess.xhtml @@ -62,108 +62,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Date: Thu, 19 Dec 2024 21:24:57 +0530 Subject: [PATCH 03/28] Signed-off-by: DamithDeshan --- src/main/java/com/divudi/bean/lab/PatientReportController.java | 3 +++ src/main/resources/META-INF/persistence.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/divudi/bean/lab/PatientReportController.java b/src/main/java/com/divudi/bean/lab/PatientReportController.java index b1bf1e3511..27da5be52b 100644 --- a/src/main/java/com/divudi/bean/lab/PatientReportController.java +++ b/src/main/java/com/divudi/bean/lab/PatientReportController.java @@ -949,12 +949,15 @@ public void calculate() { System.out.println("resultStr = " + resultObj); } else if (resultObj instanceof Double) { result = (double) resultObj; + resultStr= result+""; System.out.println("result = " + result); } else { System.out.println("Else = "); result = 0.0; resultStr = ""; } + System.out.println("resultStr = " + resultStr); + System.out.println("result = " + result); } catch (Exception ex) { Logger.getLogger(PatientReportController.class diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 3859a00e7b..86c91a32de 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -2,7 +2,7 @@ org.eclipse.persistence.jpa.PersistenceProvider - jdbc/ruhunu + jdbc/Ruhunu false From bdc1f88f729de10387bb3afd3b95be8c83a984db Mon Sep 17 00:00:00 2001 From: Buddhika Ariyaratne Date: Thu, 19 Dec 2024 21:49:12 +0530 Subject: [PATCH 04/28] Signed-off-by: Buddhika Ariyaratne --- .../entity/lab/PatientReportItemValue.java | 16 ++++++------- src/main/resources/META-INF/persistence.xml | 2 +- src/main/webapp/lab/patient_report.xhtml | 24 ++++++++++++++++++- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/divudi/entity/lab/PatientReportItemValue.java b/src/main/java/com/divudi/entity/lab/PatientReportItemValue.java index 3520cf80f0..4ca28387f3 100644 --- a/src/main/java/com/divudi/entity/lab/PatientReportItemValue.java +++ b/src/main/java/com/divudi/entity/lab/PatientReportItemValue.java @@ -175,33 +175,33 @@ public String getValue() { String value = ""; String formatString = this.investigationItem.formatString; -// System.out.println("Format string: " + formatString); + System.out.println("Format string: " + formatString); -// System.out.println("this.investigationItem.ixItemValueType = " + this.investigationItem.ixItemValueType); + System.out.println("this.investigationItem.ixItemValueType = " + this.investigationItem.ixItemValueType); switch (this.investigationItem.ixItemValueType) { case Double: case Long: if (this.doubleValue != null) { -// System.out.println("Double value before formatting: " + this.doubleValue); + System.out.println("Double value before formatting: " + this.doubleValue); if (formatString != null) { DecimalFormat decimalFormat = new DecimalFormat(formatString); value = decimalFormat.format(this.doubleValue); } else { value = Double.toString(this.doubleValue); } -// System.out.println("Double value after formatting: " + value); + System.out.println("Double value after formatting: " + value); } else { -// System.out.println("Double value is null"); + System.out.println("Double value is null"); } break; case Varchar: value = this.strValue; -// System.out.println("Varchar value: " + value); + System.out.println("Varchar value: " + value); break; case Memo: value = this.lobValue; -// System.out.println("Memo value: " + value); + System.out.println("Memo value: " + value); break; default: value = this.investigationItem.ixItemValueType.toString(); @@ -209,7 +209,7 @@ public String getValue() { break; } -// System.out.println("Final value: " + value); + System.out.println("Final value: " + value); return value; } diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 86c91a32de..3859a00e7b 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -2,7 +2,7 @@ org.eclipse.persistence.jpa.PersistenceProvider - jdbc/Ruhunu + jdbc/ruhunu false diff --git a/src/main/webapp/lab/patient_report.xhtml b/src/main/webapp/lab/patient_report.xhtml index 331377ee4b..b84c12e961 100644 --- a/src/main/webapp/lab/patient_report.xhtml +++ b/src/main/webapp/lab/patient_report.xhtml @@ -775,7 +775,19 @@ CSS - Contents + LOB + + + Str + + + Display + + + Double + + + Value @@ -797,10 +809,20 @@ #{prv.lobValue} + + #{prv.strValue} + + #{prv.displayValue} + + #{prv.doubleValue} + + #{prv.value} + + From e961b16567827da7e3914c01d7e69fa5b4946b82 Mon Sep 17 00:00:00 2001 From: imexh Date: Fri, 20 Dec 2024 02:21:09 +0530 Subject: [PATCH 05/28] #9773 --- .../divudi/bean/common/ReportsController.java | 281 ++++++- .../divudi/data/ReportTemplateRowBundle.java | 26 + .../reports/financialReports/discount.xhtml | 782 ++++++++++-------- 3 files changed, 727 insertions(+), 362 deletions(-) diff --git a/src/main/java/com/divudi/bean/common/ReportsController.java b/src/main/java/com/divudi/bean/common/ReportsController.java index 9c103ea87c..93455a6d8b 100644 --- a/src/main/java/com/divudi/bean/common/ReportsController.java +++ b/src/main/java/com/divudi/bean/common/ReportsController.java @@ -247,6 +247,8 @@ public class ReportsController implements Serializable { private Date maxDate; private Doctor referingDoctor; private Month month; + private PaymentScheme paymentScheme; + private String remarks; private double cashTotal; private double cardTotal; @@ -311,6 +313,8 @@ public class ReportsController implements Serializable { private String settlementStatus; private String dischargedStatus; + private String selectedDateType = "invoice"; + public String getDischargedStatus() { return dischargedStatus; } @@ -324,11 +328,9 @@ public PaymentMethod getPaymentMethod() { return paymentMethod; } - public void setPaymentMethod(PaymentMethod paymentMethod) { this.paymentMethod = paymentMethod; } - public CommonController getCommonController() { return commonController; @@ -354,6 +356,30 @@ public void setPatientReportFacade(PatientReportFacade patientReportFacade) { this.patientReportFacade = patientReportFacade; } + public PaymentScheme getPaymentScheme() { + return paymentScheme; + } + + public void setPaymentScheme(PaymentScheme paymentScheme) { + this.paymentScheme = paymentScheme; + } + + public String getRemarks() { + return remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } + + public String getSelectedDateType() { + return selectedDateType; + } + + public void setSelectedDateType(String selectedDateType) { + this.selectedDateType = selectedDateType; + } + public Institution getCreditCompany() { return creditCompany; } @@ -2383,7 +2409,7 @@ public void generateDebtorBalanceReport(final boolean onlyDueBills) { } public ReportTemplateRowBundle generateDebtorBalanceReportBills(List bts, List billPaymentMethods, - boolean onlyDueBills) { + boolean onlyDueBills) { Map parameters = new HashMap<>(); String jpql = "SELECT new com.divudi.data.ReportTemplateRow(bill) " + "FROM Bill bill " @@ -3270,7 +3296,7 @@ private void groupBills() { bundle.setGroupedBillItemsByInstitution(billMap); } - + public Double calculateNetTotalByBills(List bills) { Double netTotal = 0.0; @@ -3291,7 +3317,7 @@ public Double calculateDiscountByBills(List bills) { return discount; } - + public Double calculateSubTotal() { double subTotal = 0.0; Map> billMap = bundle.getGroupedBillItemsByInstitution(); @@ -3305,4 +3331,249 @@ public Double calculateSubTotal() { return subTotal; } + public void generateDiscountReport() { + if (visitType == null || visitType.trim().isEmpty()) { + JsfUtil.addErrorMessage("Please select a visit type"); + return; + } + + System.out.println("generateDiscountReport = " + this); + bundle = new ReportTemplateRowBundle(); + + List opdBts = new ArrayList<>(); + bundle = new ReportTemplateRowBundle(); + + if (visitType.equalsIgnoreCase("IP")) { + opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL); + opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL); + opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL_CANCELLATION); + opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL_CANCELLATION); + opdBts.add(BillTypeAtomic.INWARD_FINAL_BILL); + } else if (visitType.equalsIgnoreCase("OP")) { + opdBts.add(BillTypeAtomic.OPD_BILL_WITH_PAYMENT); + opdBts.add(BillTypeAtomic.OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER); + opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_WITH_PAYMENT); + opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER); + opdBts.add(BillTypeAtomic.PACKAGE_OPD_BATCH_BILL_WITH_PAYMENT); + opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER); + opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_CANCELLATION); + opdBts.add(BillTypeAtomic.OPD_BILL_CANCELLATION); + opdBts.add(BillTypeAtomic.PACKAGE_OPD_BATCH_BILL_CANCELLATION); + opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_CANCELLATION); + } + + if (reportType.equalsIgnoreCase("detail")) { + bundle.setName("BillItems"); + bundle.setBundleType("billItemList"); + + bundle = generateDiscountBillItems(opdBts); + bundle.calculateTotalDiscountByBillItems(); + } else if (reportType.equalsIgnoreCase("summary")) { + bundle.setName("Bills"); + bundle.setBundleType("billList"); + + bundle = generateDiscountBills(opdBts); + bundle.calculateTotalDiscountByBills(); + } + } + + public ReportTemplateRowBundle generateDiscountBills(List bts) { + Map parameters = new HashMap<>(); + + String jpql = "SELECT new com.divudi.data.ReportTemplateRow(bill) " + + "FROM Bill bill " + + "WHERE bill.retired <> :br " + + "AND bill.paymentScheme is not null "; + + parameters.put("br", true); + + jpql += "AND bill.billTypeAtomic in :bts "; + parameters.put("bts", bts); + + if (paymentMethod != null) { + List billPaymentMethods = new ArrayList<>(); + billPaymentMethods.add(paymentMethod); + + jpql += "AND bill.paymentMethod in :bpms "; + parameters.put("bpms", billPaymentMethods); + } + + if (visitType != null && (visitType.equalsIgnoreCase("IP") && admissionType != null)) { + jpql += "AND bill.patientEncounter.admissionType = :type "; + parameters.put("type", admissionType); + } + + if (visitType != null && (visitType.equalsIgnoreCase("IP") && roomCategory != null)) { + jpql += "AND bill.patientEncounter.currentPatientRoom.roomFacilityCharge.roomCategory = :category "; + parameters.put("category", roomCategory); + } + + if (discount > 0) { + jpql += "AND bill.discount = :dis "; + parameters.put("dis", discount); + } + + if (remarks != null && !remarks.trim().isEmpty()) { + jpql += "AND bill.comments LIKE :rem "; + parameters.put("rem", remarks + "%"); + } + + if (institution != null) { + jpql += "AND bill.department.institution = :ins "; + parameters.put("ins", institution); + } + + if (department != null) { + jpql += "AND bill.department = :dep "; + parameters.put("dep", department); + } + if (site != null) { + jpql += "AND bill.department.site = :site "; + parameters.put("site", site); + } + if (webUser != null) { + jpql += "AND bill.creater = :wu "; + parameters.put("wu", webUser); + } + + if (collectingCentre != null) { + jpql += "AND bill.collectingCentre = :cc "; + parameters.put("cc", collectingCentre); + } + + if (creditCompany != null) { + jpql += "AND bill.creditCompany = :cc "; + parameters.put("cc", creditCompany); + } + + if (paymentScheme != null) { + jpql += "AND bill.paymentScheme = :ps "; + parameters.put("ps", paymentScheme); + } + + if (selectedDateType != null && !selectedDateType.trim().isEmpty() && selectedDateType.equalsIgnoreCase("admission")) { + jpql += "AND bill.patientEncounter.dateOfAdmission BETWEEN :fd AND :td "; + } else if (selectedDateType != null && !selectedDateType.trim().isEmpty() && selectedDateType.equalsIgnoreCase("discharge")) { + jpql += "AND bill.patientEncounter.dateOfDischarge BETWEEN :fd AND :td "; + } else { + jpql += "AND bill.createdAt BETWEEN :fd AND :td "; + } + + parameters.put("fd", fromDate); + parameters.put("td", toDate); + + jpql += "GROUP BY bill"; + + List rs = (List) paymentFacade.findLightsByJpql(jpql, parameters, TemporalType.TIMESTAMP); + + ReportTemplateRowBundle b = new ReportTemplateRowBundle(); + b.setReportTemplateRows(rs); + b.createRowValuesFromBill(); + b.calculateTotalsWithCredit(); + return b; + } + + public ReportTemplateRowBundle generateDiscountBillItems(List bts) { + Map parameters = new HashMap<>(); + + String jpql = "SELECT new com.divudi.data.ReportTemplateRow(billItem) " + + "FROM BillItem billItem " + + "JOIN billItem.bill bill " + + "WHERE billItem.retired <> :bfr AND bill.retired <> :br " + + "AND billItem.bill.paymentScheme is not null "; + + parameters.put("bfr", true); + parameters.put("br", true); + + jpql += "AND bill.billTypeAtomic in :bts "; + parameters.put("bts", bts); + + if (paymentMethod != null) { + List billPaymentMethods = new ArrayList<>(); + billPaymentMethods.add(paymentMethod); + + jpql += "AND bill.paymentMethod in :bpms "; + parameters.put("bpms", billPaymentMethods); + } + + if (discount > 0) { + jpql += "AND billItem.bill.discount = :dis "; + parameters.put("dis", discount); + } + + if (remarks != null && !remarks.trim().isEmpty()) { + jpql += "AND billItem.bill.comments LIKE :rem "; + parameters.put("rem", remarks + "%"); + } + + if (visitType != null && (visitType.equalsIgnoreCase("IP") && admissionType != null)) { + jpql += "AND bill.patientEncounter.admissionType = :type "; + parameters.put("type", admissionType); + } + + if (visitType != null && (visitType.equalsIgnoreCase("IP") && roomCategory != null)) { + jpql += "AND bill.patientEncounter.currentPatientRoom.roomFacilityCharge.roomCategory = :category "; + parameters.put("category", roomCategory); + } + + if (institution != null) { + jpql += "AND bill.department.institution = :ins "; + parameters.put("ins", institution); + } + + if (department != null) { + jpql += "AND bill.department = :dep "; + parameters.put("dep", department); + } + if (site != null) { + jpql += "AND bill.department.site = :site "; + parameters.put("site", site); + } + if (webUser != null) { + jpql += "AND bill.creater = :wu "; + parameters.put("wu", webUser); + } + + if (collectingCentre != null) { + jpql += "AND bill.collectingCentre = :cc "; + parameters.put("cc", collectingCentre); + } + + if (creditCompany != null) { + jpql += "AND bill.creditCompany = :cc "; + parameters.put("cc", creditCompany); + } + + if (paymentScheme != null) { + jpql += "AND bill.paymentScheme = :ps "; + parameters.put("ps", paymentScheme); + } + + if ("notSettled".equalsIgnoreCase(settlementStatus)) { + jpql += "AND (billItem.referenceBill.netTotal + billItem.referenceBill.vat + billItem.referenceBill.paidAmount) <> 0 "; + } else if ("settled".equalsIgnoreCase(settlementStatus)) { + jpql += "AND (billItem.referenceBill.netTotal + billItem.referenceBill.vat + billItem.referenceBill.paidAmount) = 0 "; + } + + if (selectedDateType != null && !selectedDateType.trim().isEmpty() && selectedDateType.equalsIgnoreCase("admission")) { + jpql += "AND bill.patientEncounter.dateOfAdmission BETWEEN :fd AND :td "; + } else if (selectedDateType != null && !selectedDateType.trim().isEmpty() && selectedDateType.equalsIgnoreCase("discharge")) { + jpql += "AND bill.patientEncounter.dateOfDischarge BETWEEN :fd AND :td "; + } else { + jpql += "AND bill.createdAt BETWEEN :fd AND :td "; + } + + parameters.put("fd", fromDate); + parameters.put("td", toDate); + + jpql += "GROUP BY billItem"; + + List rs = (List) paymentFacade.findLightsByJpql(jpql, parameters, TemporalType.TIMESTAMP); + + ReportTemplateRowBundle b = new ReportTemplateRowBundle(); + b.setReportTemplateRows(rs); + b.createRowValuesFromBillItems(); + b.calculateTotalsWithCredit(); + return b; + } } diff --git a/src/main/java/com/divudi/data/ReportTemplateRowBundle.java b/src/main/java/com/divudi/data/ReportTemplateRowBundle.java index 582e0241e1..09c59171de 100644 --- a/src/main/java/com/divudi/data/ReportTemplateRowBundle.java +++ b/src/main/java/com/divudi/data/ReportTemplateRowBundle.java @@ -1137,6 +1137,32 @@ public void calculateTotalByHospitalFee() { } } + public void calculateTotalDiscountByBillItems() { + discount = 0.0; + if (this.reportTemplateRows != null && !this.reportTemplateRows.isEmpty()) { + for (ReportTemplateRow row : this.reportTemplateRows) { + if (row.getBillItem().getBill() == null) { + continue; + } + Double amount = safeDouble(row.getBillItem().getBill().getDiscount()); + discount += amount; + } + } + } + + public void calculateTotalDiscountByBills() { + discount = 0.0; + if (this.reportTemplateRows != null && !this.reportTemplateRows.isEmpty()) { + for (ReportTemplateRow row : this.reportTemplateRows) { + if (row.getBill() == null) { + continue; + } + Double amount = safeDouble(row.getBill().getDiscount()); + discount += amount; + } + } + } + public void calculateTotalCCFee() { ccTotal = 0.0; if (this.reportTemplateRows != null && !this.reportTemplateRows.isEmpty()) { diff --git a/src/main/webapp/reports/financialReports/discount.xhtml b/src/main/webapp/reports/financialReports/discount.xhtml index d4d0257b4d..ddf8ebaf30 100644 --- a/src/main/webapp/reports/financialReports/discount.xhtml +++ b/src/main/webapp/reports/financialReports/discount.xhtml @@ -1,416 +1,484 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + - + - - - - - + + + + + - - + - - + - + itemValue="#{d}"/> + - - + - - + - + itemValue="#{d}"/> + - - + - - + - + itemValue="#{d}"/> + - - + - - + - + itemValue="#{d}"/> + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- - - - + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + - - - + + - - - + + - - -
+ +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From bfe6b1b4c2aa631fc30135f08dc94799c9cc6da5 Mon Sep 17 00:00:00 2001 From: Buddhika Ariyaratne Date: Fri, 20 Dec 2024 04:55:42 +0530 Subject: [PATCH 06/28] Pharmacy Summary Report Controller Created Signed-off-by: Buddhika Ariyaratne --- .../divudi/bean/common/SearchController.java | 248 +-- .../PharmacySummaryReportController.java | 242 +++ .../TransactionTypeAndPaymentMethodRow.java | 1368 +++++++++++++++++ .../webapp/pharmacy/pharmacy_analytics.xhtml | 10 +- .../daily_stock_balance_report.xhtml | 17 + .../pharmacy_income_report.xhtml | 17 + 6 files changed, 1785 insertions(+), 117 deletions(-) create mode 100644 src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java create mode 100644 src/main/java/com/divudi/data/TransactionTypeAndPaymentMethodRow.java create mode 100644 src/main/webapp/pharmacy/reports/summary_reports/daily_stock_balance_report.xhtml create mode 100644 src/main/webapp/pharmacy/reports/summary_reports/pharmacy_income_report.xhtml diff --git a/src/main/java/com/divudi/bean/common/SearchController.java b/src/main/java/com/divudi/bean/common/SearchController.java index 28eb8e91c1..8e1eebeb49 100644 --- a/src/main/java/com/divudi/bean/common/SearchController.java +++ b/src/main/java/com/divudi/bean/common/SearchController.java @@ -1,5 +1,8 @@ package com.divudi.bean.common; +// +// +// import com.divudi.bean.cashTransaction.CashBookEntryController; import com.divudi.bean.cashTransaction.DrawerController; import com.divudi.bean.cashTransaction.DrawerEntryController; @@ -63,6 +66,20 @@ import com.divudi.data.BillFinanceType; import com.divudi.data.BillTypeAtomic; +import static com.divudi.data.BillTypeAtomic.OPD_BATCH_BILL_WITH_PAYMENT; +import static com.divudi.data.BillTypeAtomic.OPD_BILL_CANCELLATION; +import static com.divudi.data.BillTypeAtomic.OPD_BILL_REFUND; +import static com.divudi.data.BillTypeAtomic.OPD_BILL_WITH_PAYMENT; +import static com.divudi.data.BillTypeAtomic.OPD_PROFESSIONAL_PAYMENT_BILL; +import static com.divudi.data.BillTypeAtomic.OPD_PROFESSIONAL_PAYMENT_BILL_RETURN; +import static com.divudi.data.BillTypeAtomic.PHARMACY_RETAIL_SALE; +import static com.divudi.data.BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_FOR_AGENCIES; +import static com.divudi.data.BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_FOR_AGENCIES_RETURN; +import static com.divudi.data.BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_RETURN; +import static com.divudi.data.BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_SESSION; +import static com.divudi.data.BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_INWARD_SERVICE_RETURN; +import static com.divudi.data.BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES; +import static com.divudi.data.BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES_RETURN; import com.divudi.data.PaymentCategory; import com.divudi.data.PaymentStatus; import com.divudi.data.PaymentType; @@ -122,18 +139,17 @@ import java.util.Map; import java.util.TreeMap; +// /** - * @author safrin + * @author Dr M H B Ariyaratne */ @Named @SessionScoped public class SearchController implements Serializable { private static final long serialVersionUID = 1L; - /** - * EJBs - */ + // private CommonFunctions commonFunctions; @EJB private BillFacade billFacade; @@ -163,10 +179,8 @@ public class SearchController implements Serializable { BillService billService; @EJB PatientInvestigationService patientInvestigationService; - - /** - * Inject - */ + // + // @Inject private BillBeanController billBean; @Inject @@ -215,10 +229,8 @@ public class SearchController implements Serializable { DrawerController drawerController; @Inject EnumController enumController; - - /** - * Properties - */ + // + // private String visitType; private String methodType; @@ -354,6 +366,8 @@ public class SearchController implements Serializable { private Department serviceDepartment; private Department billedDepartment; + // + // public String navigateToUserDrawerDashboard() { Drawer d = drawerController.getUsersDrawer(drawer.getDrawerUser()); drawerController.setCurrent(d); @@ -479,6 +493,8 @@ public String navigateToFinancialTransactionSummaryByDepartment() { departments = departmentController.getInstitutionDepatrments(sessionController.getInstitution()); return "/analytics/financial_transaction_summary_Department?faces-redirect=true"; } + // + // public void clearBillList() { if (bills == null) { @@ -6156,7 +6172,6 @@ public void listBillsAndItemsWithFees() { } - public void listMissingBillNumberinBills() { Map parameters = new HashMap<>(); String jpql = "SELECT bill " @@ -6175,7 +6190,7 @@ public void listMissingBillNumberinBills() { jpql += "AND bill.department.site = :site "; parameters.put("site", site); } - + jpql += "AND bill.createdAt BETWEEN :fd AND :td "; parameters.put("fd", fromDate); parameters.put("td", toDate); @@ -6183,9 +6198,9 @@ public void listMissingBillNumberinBills() { parameters.put("dep", null); bills = billFacade.findByJpql(jpql, parameters, TemporalType.TIMESTAMP); - + } - + public StreamedContent getFileForDownload() { prepareDataForExcelExport(); // Prepare data and create the Excel file return fileForDownload; // This should now contain the generated Excel file @@ -6199,9 +6214,9 @@ public void createBillsBillItemsAndBillFeesTable(Set bills, List Row headerRow = sheet.createRow(rowIdx++); // Expanding the headers to include all necessary fields String[] headers = { - "Bill ID", "Insitution Name", "Department Name", "Patient Name", "Staff Name", "Bill Type", "Total", "Discount", "Net Total", "Payment Method", - "Bill Item Name", "Bill Item Code", "Item Type", "Quantity", "Rate", "Gross Value", "Bill Item Discount", "Net Value", - "Fee Name", "Fee Type", "Fee Value", "Institution Name", "Department Name", "Staff Name" + "Bill ID", "Insitution Name", "Department Name", "Patient Name", "Staff Name", "Bill Type", "Total", "Discount", "Net Total", "Payment Method", + "Bill Item Name", "Bill Item Code", "Item Type", "Quantity", "Rate", "Gross Value", "Bill Item Discount", "Net Value", + "Fee Name", "Fee Type", "Fee Value", "Institution Name", "Department Name", "Staff Name" }; for (int i = 0; i < headers.length; i++) { headerRow.createCell(i).setCellValue(headers[i]); @@ -8533,9 +8548,9 @@ public void listOpdBilledBills() { } public void listBills(BillType billType, Class billClass, Boolean onlyCancelledBills, Boolean onlyReturnedBills, - Institution fromInstitution, Department fromDepartment, - Institution toInstitution, Department toDepartment, - Doctor referredDoctor, Institution referredInstitution) { + Institution fromInstitution, Department fromDepartment, + Institution toInstitution, Department toDepartment, + Doctor referredDoctor, Institution referredInstitution) { bills = null; String sql; Map temMap = new HashMap(); @@ -8785,21 +8800,21 @@ public void createTableByKeyword(BillType billType, Institution ins, Department } public ReportTemplateRowBundle createBundleByKeywordForBills(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep) { return billService.createBundleByKeywordForBills(billTypesAtomics, ins, dep, fromIns, fromDep, toIns, toDep, null, fromDate, toDate, searchKeyword); } public ReportTemplateRowBundle createBundleForBills(List billTypesAtomics, - Institution ins, - Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep) { + Institution ins, + Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep) { return createBundleForBills( billTypesAtomics, ins, @@ -8815,15 +8830,15 @@ public ReportTemplateRowBundle createBundleForBills(List billTyp } public ReportTemplateRowBundle createBundleForBills(List billTypesAtomics, - Institution ins, - Department dep, - Institution site, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep, - Speciality paramSpeciality, - Staff paramStaff) { + Institution ins, + Department dep, + Institution site, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep, + Speciality paramSpeciality, + Staff paramStaff) { ReportTemplateRowBundle outputBundle = new ReportTemplateRowBundle(); List outputRows; bills = null; @@ -8896,11 +8911,11 @@ public ReportTemplateRowBundle createBundleForBills(List billTyp } public void createTableByKeyword(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep) { bills = null; String sql; Map temMap = new HashMap(); @@ -8977,13 +8992,13 @@ public void createTableByKeyword(List billTypesAtomics, } public void createTableByKeywordForChannelBills(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep, - Staff consultant, - Speciality speciality + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep, + Staff consultant, + Speciality speciality ) { bills = null; String sql; @@ -9071,12 +9086,12 @@ public void createTableByKeywordForChannelBills(List billTypesAt } public void createTableByKeywords(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep, - Staff stf) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep, + Staff stf) { bills = null; String sql; Map temMap = new HashMap(); @@ -9133,21 +9148,21 @@ public void createTableByKeywords(List billTypesAtomics, } public void createTableByKeywordForBillFees(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep) { createTableByKeywordForBillFees(billTypesAtomics, ins, dep, fromIns, fromDep, toIns, toDep, null); } public ReportTemplateRowBundle createBundleByKeywordForBillFees(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep, - Category cat) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep, + Category cat) { ReportTemplateRowBundle outputBundle = new ReportTemplateRowBundle(); List outputRows; String sql; @@ -9236,12 +9251,12 @@ public ReportTemplateRowBundle createBundleByKeywordForBillFees(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep, - Category cat) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep, + Category cat) { String sql; Map temMap = new HashMap(); @@ -9323,22 +9338,22 @@ public void createTableByKeywordForBillFees(List billTypesAtomic } public void createTableByKeywordForBillFee(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep, - Staff stf) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep, + Staff stf) { createTableByKeywordBillFee(billTypesAtomics, ins, dep, fromIns, fromDep, toIns, toDep, stf); } public void createTableByKeywordBillFee(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep, - Staff stf) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep, + Staff stf) { String sql; Map temMap = new HashMap(); @@ -9395,11 +9410,11 @@ public void createTableByKeywordBillFee(List billTypesAtomics, } public void createTableByKeywordForBillsWithoutToStaff(List billTypesAtomics, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep) { bills = null; String sql; Map temMap = new HashMap(); @@ -9477,11 +9492,11 @@ public void createTableByKeywordForBillsWithoutToStaff(List bill } public void createTableByKeyword(BillType billType, - Institution ins, Department dep, - Institution fromIns, - Department fromDep, - Institution toIns, - Department toDep) { + Institution ins, Department dep, + Institution fromIns, + Department fromDep, + Institution toIns, + Department toDep) { bills = null; String sql; Map temMap = new HashMap(); @@ -11385,11 +11400,11 @@ public void channelPaymentBills() { Map m = new HashMap(); BillType[] bt = { - BillType.ChannelOnCall, - BillType.ChannelCash, - BillType.ChannelAgent, - BillType.ChannelStaff, - BillType.ChannelCredit,}; + BillType.ChannelOnCall, + BillType.ChannelCash, + BillType.ChannelAgent, + BillType.ChannelStaff, + BillType.ChannelCredit,}; List bts = Arrays.asList(bt); @@ -11454,12 +11469,12 @@ public void channelPaymentBillsNew() { Map m = new HashMap(); BillType[] bt = { - BillType.ChannelOnCall, - BillType.ChannelCash, - BillType.ChannelAgent, - BillType.ChannelStaff, - BillType.ChannelPaid, - BillType.ChannelCredit,}; + BillType.ChannelOnCall, + BillType.ChannelCash, + BillType.ChannelAgent, + BillType.ChannelStaff, + BillType.ChannelPaid, + BillType.ChannelCredit,}; List bts = Arrays.asList(bt); @@ -11710,7 +11725,7 @@ public void createPatientDepositTable() { createPatientDepositTable(BillType.PatientPaymentReceiveBill); } - + public void createPatientDepositReturnTable() { createPatientDepositTable(BillType.PatientPaymentRefundBill); } @@ -14036,7 +14051,6 @@ public void generateCashierDetailed() { // opdCreditRefundBundle.setName("OPD Credit Refunds"); // bundle.getBundles().add(opdCreditRefundBundle); // collectionForTheDay += getSafeTotal(opdCreditRefundBundle); - // Generate Pharmacy Credit Bills, Cancellation, and Refund and add to the main bundle List pharmacyCreditBills = new ArrayList<>(); pharmacyCreditBills.add(BillTypeAtomic.PHARMACY_CREDIT_COMPANY_PAYMENT_RECEIVED); @@ -16797,7 +16811,7 @@ public void listAgentChannelBookings() { jpql += " AND b.creditCompany = :creditcom "; m.put("creditcom", creditCompany); } - + if (institution != null) { jpql += " AND b.institution = :ins "; m.put("ins", institution); @@ -17370,6 +17384,8 @@ public PharmacyAdjustmentRow(Item itm, double purchaseRate, double saleRate, dou this.afterVal = afterQty * purchaseRate; } + // + // public Item getItm() { return itm; } @@ -17965,8 +17981,8 @@ public void createBillsBillItemsList(Set bills, List billItems) Row headerRow = sheet.createRow(rowIdx++); // Headers for both bills and bill items String[] headers = { - "Bill ID", "Institution Name", "Department Name", "Patient Name", "Staff Name", "User", "Bill Type", "Total", "Discount", "Net Total", "Payment Method", - "Bill Item Name", "Bill Item Code", "Item Type", "Quantity", "Rate", "Gross Value", "Bill Item Discount", "Net Value" + "Bill ID", "Institution Name", "Department Name", "Patient Name", "Staff Name", "User", "Bill Type", "Total", "Discount", "Net Total", "Payment Method", + "Bill Item Name", "Bill Item Code", "Item Type", "Quantity", "Rate", "Gross Value", "Bill Item Discount", "Net Value" }; for (int i = 0; i < headers.length; i++) { headerRow.createCell(i).setCellValue(headers[i]); @@ -18129,4 +18145,6 @@ public void prepareDataBillsAndBillItemsDownload() { } } + // + } diff --git a/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java b/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java new file mode 100644 index 0000000000..4bb7b23201 --- /dev/null +++ b/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java @@ -0,0 +1,242 @@ +package com.divudi.bean.pharmacy; + +// +import com.divudi.bean.common.*; +import com.divudi.bean.cashTransaction.CashBookEntryController; +import com.divudi.bean.cashTransaction.DrawerController; +import com.divudi.bean.cashTransaction.DrawerEntryController; +import com.divudi.bean.channel.ChannelSearchController; +import com.divudi.bean.channel.analytics.ReportTemplateController; +import com.divudi.data.BillType; +import com.divudi.data.PaymentMethod; +import com.divudi.data.dataStructure.SearchKeyword; +import com.divudi.data.hr.ReportKeyWord; + +import com.divudi.ejb.PharmacyBean; +import com.divudi.entity.Bill; +import com.divudi.entity.BillFee; +import com.divudi.entity.BillItem; +import com.divudi.entity.Department; +import com.divudi.entity.Institution; +import com.divudi.entity.Item; +import com.divudi.entity.Patient; +import com.divudi.entity.PatientEncounter; +import com.divudi.entity.Staff; +import com.divudi.facade.BillFacade; +import com.divudi.facade.BillFeeFacade; +import com.divudi.facade.BillItemFacade; +import com.divudi.facade.PatientFacade; +import com.divudi.facade.StockFacade; +import com.divudi.bean.opd.OpdBillController; +import com.divudi.data.BillClassType; + +import com.divudi.data.BillTypeAtomic; +import com.divudi.data.ReportTemplateRowBundle; +import com.divudi.entity.Category; +import com.divudi.entity.Payment; +import com.divudi.entity.WebUser; +import com.divudi.facade.DrawerFacade; +import com.divudi.facade.PaymentFacade; +import com.divudi.java.CommonFunctions; +import com.divudi.light.common.BillLight; +import com.divudi.light.common.BillSummaryRow; +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import javax.ejb.EJB; +import javax.enterprise.context.SessionScoped; +import javax.inject.Inject; +import javax.inject.Named; +import org.primefaces.model.file.UploadedFile; + +import org.primefaces.model.StreamedContent; +// + +/** + * @author Dr M H B Ariyaratne + */ +@Named +@SessionScoped +public class PharmacySummaryReportController implements Serializable { + + private static final long serialVersionUID = 1L; + +// + private CommonFunctions commonFunctions; + @EJB + private BillFacade billFacade; + @EJB + private PaymentFacade paymentFacade; + @EJB + private BillFeeFacade billFeeFacade; + @EJB + private BillItemFacade billItemFacade; + @EJB + private PharmacyBean pharmacyBean; + @EJB + private StockFacade stockFacade; + @EJB + private PatientFacade patientFacade; + @EJB + private DrawerFacade drawerFacade; + +// +// + @Inject + private BillBeanController billBean; + @Inject + private SessionController sessionController; + @Inject + TransferController transferController; + @Inject + private CommonController commonController; + @Inject + private PharmacySaleBhtController pharmacySaleBhtController; + @Inject + private WebUserController webUserController; + @Inject + private OpdPreSettleController opdPreSettleController; + @Inject + private PharmacyPreSettleController pharmacyPreSettleController; + @Inject + private TokenController tokenController; + @Inject + private DepartmentController departmentController; + @Inject + private BillSearch billSearch; + @Inject + private PharmacyBillSearch pharmacyBillSearch; + @Inject + private OpdBillController opdBillController; + @Inject + private ConfigOptionApplicationController configOptionApplicationController; + @Inject + private ChannelSearchController channelSearchController; + @Inject + private ReportTemplateController reportTemplateController; + @Inject + private CashBookEntryController cashBookEntryController; + @Inject + private ExcelController excelController; + @Inject + private PdfController pdfController; + @Inject + private DrawerEntryController drawerEntryController; + @Inject + private DrawerController drawerController; + @Inject + private EnumController enumController; +// +// + // Basic types + private String visitType; + private String methodType; + private String searchType; + private String reportType; + + // Date range + private Date fromDate; + private Date toDate; + + // Enum and category types + private Category category; + private BillType billType; + private BillTypeAtomic billTypeAtomic; + private BillClassType billClassType; + private PaymentMethod paymentMethod; + + // Collections + private List paymentMethods; + + // User-related + private WebUser webUser; + private Staff staff; + private Staff currentStaff; + + // Institutional and departmental entities + private Institution institution; + private Institution creditCompany; + private Institution dealer; + private Institution site; + private Institution toSite; + private Institution fromInstitution; + private Institution toInstitution; + + private Department department; + private Department fromDepartment; + private Department toDepartment; + + // Healthcare-specific entities + private Patient patient; + private PatientEncounter patientEncounter; + private Item item; + + // Reporting and files + private SearchKeyword searchKeyword; + private ReportKeyWord reportKeyWord; + private ReportTemplateRowBundle bundle; + + private StreamedContent downloadingExcel; + private UploadedFile file; + + // Numeric variables + private int maxResult = 50; + +// +// + public String navigateToPharmacyIncomeReport() { + return "/pharmacy/reports/pharmacy_income_report?faces-redirect=true"; + } + + public String navigateToDailyStockBalanceReport() { + return "/pharmacy/reports/daily_stock_balance_report?faces-redirect=true"; + } +// +// + + public void resetAllFiltersExceptDateRange() { + institution = null; + department = null; + webUser = null; + site = null; + paymentMethod = null; + searchKeyword = null; + category = null; + item = null; + staff = null; + currentStaff = null; + creditCompany = null; + dealer = null; + toSite = null; + fromInstitution = null; + toInstitution = null; + fromDepartment = null; + toDepartment = null; + patient = null; + patientEncounter = null; + billType = null; + billTypeAtomic = null; + billClassType = null; + paymentMethods = null; + reportKeyWord = null; + bundle = new ReportTemplateRowBundle(); + downloadingExcel = null; + file = null; + searchKeyword = new SearchKeyword(); + } + + public void resetAllFilters() { + resetAllFiltersExceptDateRange(); + fromDate = null; + toDate = null; + } + +// +// + public PharmacySummaryReportController() { + } +// +// + +// +} diff --git a/src/main/java/com/divudi/data/TransactionTypeAndPaymentMethodRow.java b/src/main/java/com/divudi/data/TransactionTypeAndPaymentMethodRow.java new file mode 100644 index 0000000000..b6d19313b1 --- /dev/null +++ b/src/main/java/com/divudi/data/TransactionTypeAndPaymentMethodRow.java @@ -0,0 +1,1368 @@ +package com.divudi.data; + +import com.divudi.entity.*; +import com.divudi.entity.cashTransaction.DenominationTransaction; +import com.divudi.entity.channel.SessionInstance; +import com.divudi.entity.lab.PatientInvestigation; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.logging.Logger; + +/** + * @author buddhika + */ +public class TransactionTypeAndPaymentMethodRow implements Serializable { + + private static final long serialVersionUID = 1L; + + private String uuid; + private Long counter; + + private Category category; + private Bill bill; + private BillItem billItem; + private BillFee billFee; + private Payment payment; + + + private BillType billType; + private BillClassType billClassType; + BillTypeAtomic billTypeAtomic; + + + private boolean selected; + + private Item item; + + private Long categoryCount; + private Double categoryTotal; + private Double categoryHospitalFee; + private Double categoryDiscountAmount; + private Double categoryCollectingCentreFee; + private Double categoryDiscount; + private Double categoryProfessionalFee; + private Double categoryNetTotal; + + private Long itemCount; + private Double itemTotal; + private Double itemHospitalFee; + private Double itemDiscountAmount; + private Double itemCollectingCentreFee; + private Double itemDiscount; + private Double itemProfessionalFee; + private Double itemNetTotal; + + private List cashHnadovers; + + private String feeName; + private String categoryName; + private String toDepartmentName; + private String itemName; + private String paymentName; + private Double rowValue; + private Double rowValueIn; + private Double rowValueOut; + private Long rowCountIn; + private Long rowCountOut; + private Long rowCount; + + private Long long1; + private Long long2; + private Long long3; + private Long long4; + private Long long5; + private Long long6; + private Long long7; + private Long long8; + private Long long9; + private Long long10; + + private ServiceType serviceType; + private Institution creditCompany; + private Department toDepartment; + private Department itemDepartment; + private BillSession billSession; + private Department department; + private Institution institution; + private Institution site; + private AgentHistory agentHistory; + + private Date date; + private Date fromDate; + private Date toDate; + private Institution fromInstitution; + private Department fromDepartment; + private Institution toInstitution; + private WebUser user; + private Long startId; + private Long endId; + private SessionInstance sessionInstance; + private Speciality speciality; + private Staff staff; + private Institution referringInstitution; + private Staff referringStaff; + + private List btas; + + private double onCallValue; + private double cashValue; + private double cardValue; + private double multiplePaymentMethodsValue; + private double staffValue; + private double creditValue; + private double staffWelfareValue; + private double voucherValue; + private double iouValue; + private double agentValue; + private double chequeValue; + private double slipValue; + private double eWalletValue; + private double patientDepositValue; + private double patientPointsValue; + private double onlineSettlementValue; + + private Double grossTotal; + private Double discount; + private Double total; + private Double tax; + + private Double hospitalTotal; + private Double staffTotal; + private Double ccTotal; + + private Route route; + private Institution collectingCentre; + private Double totalHospitalFee; + private Double qty; + + private PatientInvestigation patientInvestigation; + + private long duration; + + private String rowType; + + private UUID id; + + private List denominationTransactions; + + private PaymentHandover paymentHandover; + + // Constructor to generate a new UUID when an object is created + public TransactionTypeAndPaymentMethodRow() { + this.id = UUID.randomUUID(); + } + + public TransactionTypeAndPaymentMethodRow(Institution institution) { + this.institution = institution; + } + + + public TransactionTypeAndPaymentMethodRow(Institution institution, Double itemTotal) { + this.itemTotal = itemTotal; + this.institution = institution; + } + + public TransactionTypeAndPaymentMethodRow(Institution institution, Long itemCount, Double itemHospitalFee, Double itemCollectingCentreFee, Double itemProfessionalFee, Double itemNetTotal) { + this.itemCount = itemCount; + this.itemHospitalFee = itemHospitalFee; + this.itemCollectingCentreFee = itemCollectingCentreFee; + this.itemProfessionalFee = itemProfessionalFee; + this.itemNetTotal = itemNetTotal; + this.institution = institution; + } + + public TransactionTypeAndPaymentMethodRow(Institution collectingCentre, Double totalHospitalFee, Double qty) { + this.collectingCentre = collectingCentre; + this.totalHospitalFee = totalHospitalFee; + this.qty = qty; + } + + public TransactionTypeAndPaymentMethodRow(Route route, Double totalHospitalFee, Double qty) { + this.route = route; + this.totalHospitalFee = totalHospitalFee; + this.qty = qty; + } + + // Getter for UUID (optional, depending on use case) + public UUID getId() { + if (id == null) { + id = UUID.randomUUID(); + } + return id; + } + + // Override equals() using UUID field + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TransactionTypeAndPaymentMethodRow that = (TransactionTypeAndPaymentMethodRow) o; + return Objects.equals(getId(), that.id); + } + + // Override hashCode() using UUID field + @Override + public int hashCode() { + return Objects.hash(getId()); + } + + // Override toString() for better readability (optional) + @Override + public String toString() { + return "ReportTemplateRow{id=" + getId() + '}'; + } + + public TransactionTypeAndPaymentMethodRow(PatientInvestigation patientInvestigation) { + this.patientInvestigation = patientInvestigation; + } + + + + public TransactionTypeAndPaymentMethodRow(SessionInstance sessionInstance) { + this.sessionInstance = sessionInstance; + } + + public TransactionTypeAndPaymentMethodRow(Department department, Double rowValue) { + this.rowValue = rowValue; + this.department = department; + } + + public TransactionTypeAndPaymentMethodRow(Department department, Date date, + double cashValue, double cardValue, double multiplePaymentMethodsValue, + double staffValue, double creditValue, double staffWelfareValue, + double voucherValue, double iouValue, double agentValue, + double chequeValue, double slipValue, double eWalletValue, + double patientDepositValue, double patientPointsValue, double onlineSettlementValue) { + this.department = department; + this.date = date; + this.cashValue = cashValue; + this.cardValue = cardValue; + this.multiplePaymentMethodsValue = multiplePaymentMethodsValue; + this.staffValue = staffValue; + this.creditValue = creditValue; + this.staffWelfareValue = staffWelfareValue; + this.voucherValue = voucherValue; + this.iouValue = iouValue; + this.agentValue = agentValue; + this.chequeValue = chequeValue; + this.slipValue = slipValue; + this.eWalletValue = eWalletValue; + this.patientDepositValue = patientDepositValue; + this.patientPointsValue = patientPointsValue; + this.onlineSettlementValue = onlineSettlementValue; + } + + public TransactionTypeAndPaymentMethodRow(Department department, BillTypeAtomic billTypeAtomic, + double cashValue, double cardValue, double multiplePaymentMethodsValue, + double staffValue, double creditValue, double staffWelfareValue, + double voucherValue, double iouValue, double agentValue, + double chequeValue, double slipValue, double eWalletValue, + double patientDepositValue, double patientPointsValue, double onlineSettlementValue) { + this.department = department; + this.billTypeAtomic = billTypeAtomic; + this.cashValue = cashValue; + this.cardValue = cardValue; + this.multiplePaymentMethodsValue = multiplePaymentMethodsValue; + this.staffValue = staffValue; + this.creditValue = creditValue; + this.staffWelfareValue = staffWelfareValue; + this.voucherValue = voucherValue; + this.iouValue = iouValue; + this.agentValue = agentValue; + this.chequeValue = chequeValue; + this.slipValue = slipValue; + this.eWalletValue = eWalletValue; + this.patientDepositValue = patientDepositValue; + this.patientPointsValue = patientPointsValue; + this.onlineSettlementValue = onlineSettlementValue; + } + + public TransactionTypeAndPaymentMethodRow(Bill bill, + double cashValue, double cardValue, double multiplePaymentMethodsValue, + double staffValue, double creditValue, double staffWelfareValue, + double voucherValue, double iouValue, double agentValue, + double chequeValue, double slipValue, double eWalletValue, + double patientDepositValue, double patientPointsValue, double onlineSettlementValue) { + this.bill = bill; + this.cashValue = cashValue; + this.cardValue = cardValue; + this.multiplePaymentMethodsValue = multiplePaymentMethodsValue; + this.staffValue = staffValue; + this.creditValue = creditValue; + this.staffWelfareValue = staffWelfareValue; + this.voucherValue = voucherValue; + this.iouValue = iouValue; + this.agentValue = agentValue; + this.chequeValue = chequeValue; + this.slipValue = slipValue; + this.eWalletValue = eWalletValue; + this.patientDepositValue = patientDepositValue; + this.patientPointsValue = patientPointsValue; + this.onlineSettlementValue = onlineSettlementValue; + } + + public TransactionTypeAndPaymentMethodRow(BillType billType, BillClassType billClassType, BillTypeAtomic billTypeAtomic, Long rowCount, Double grossTotal, Double discount, Double total) { + this.billType = billType; + this.billClassType = billClassType; + this.billTypeAtomic = billTypeAtomic; + this.rowCount = rowCount; + this.grossTotal = grossTotal; + this.discount = discount; + this.total = total; + } + + public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, Long rowCount, Double grossTotal, Double discount, Double total) { + this.billTypeAtomic = billTypeAtomic; + this.rowCount = rowCount; + this.grossTotal = grossTotal; + this.discount = discount; + this.total = total; + } + + public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, Long rowCount) { + this.billTypeAtomic = billTypeAtomic; + this.rowCount = rowCount; + } + + public TransactionTypeAndPaymentMethodRow(Department department, Date date, WebUser user, + double cashValue, double cardValue, double multiplePaymentMethodsValue, + double staffValue, double creditValue, double staffWelfareValue, + double voucherValue, double iouValue, double agentValue, + double chequeValue, double slipValue, double eWalletValue, + double patientDepositValue, double patientPointsValue, double onlineSettlementValue) { + this.department = department; + this.date = date; + this.cashValue = cashValue; + this.user = user; + this.cardValue = cardValue; + this.multiplePaymentMethodsValue = multiplePaymentMethodsValue; + this.staffValue = staffValue; + this.creditValue = creditValue; + this.staffWelfareValue = staffWelfareValue; + this.voucherValue = voucherValue; + this.iouValue = iouValue; + this.agentValue = agentValue; + this.chequeValue = chequeValue; + this.slipValue = slipValue; + this.eWalletValue = eWalletValue; + this.patientDepositValue = patientDepositValue; + this.patientPointsValue = patientPointsValue; + this.onlineSettlementValue = onlineSettlementValue; + } + + public TransactionTypeAndPaymentMethodRow(Staff referringStaff, Institution referringInstitution, Long long1, Double rowValue) { + this.rowValue = rowValue; + this.long1 = long1; + this.referringInstitution = referringInstitution; + this.referringStaff = referringStaff; + } + + public TransactionTypeAndPaymentMethodRow(Staff referringStaff, Long long1, Double rowValue) { + this.rowValue = rowValue; + this.long1 = long1; + this.referringStaff = referringStaff; + } + + public TransactionTypeAndPaymentMethodRow(Institution referringInstitution, Long long1, Double rowValue) { + this.rowValue = rowValue; + this.long1 = long1; + this.referringInstitution = referringInstitution; + } + + public TransactionTypeAndPaymentMethodRow(Category c) { + this.category = c; + } + + public TransactionTypeAndPaymentMethodRow(Item item) { + this.item = item; + + } + + public TransactionTypeAndPaymentMethodRow(Department d) { + this.department = d; + } + + public void setFeeName(String feeName) { + this.feeName = feeName; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public String getToDepartmentName() { + return toDepartmentName; + } + + public void setToDepartmentName(String toDepartmentName) { + this.toDepartmentName = toDepartmentName; + } + + public String getItemName() { + return itemName; + } + + public void setItemName(String itemName) { + this.itemName = itemName; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public String getPaymentName() { + return paymentName; + } + + public void setPaymentName(String paymentName) { + this.paymentName = paymentName; + } + + public Double getRowValue() { + return rowValue; + } + + public void setRowValue(Double rowValue) { + this.rowValue = rowValue; + } + + public Long getRowCount() { + return rowCount; + } + + public void setRowCount(Long rowCount) { + this.rowCount = rowCount; + } + + public BillSession getBillSession() { + return billSession; + } + + public TransactionTypeAndPaymentMethodRow(BillSession billSession) { + this.billSession = billSession; + } + + public void setBillSession(BillSession billSession) { + this.billSession = billSession; + } + + public TransactionTypeAndPaymentMethodRow(String feeName, String categoryName, String toDepartmentName, String itemName, String paymentName, Double rowValue, Long rowCount) { + this.feeName = feeName; + this.categoryName = categoryName; + this.toDepartmentName = toDepartmentName; + this.itemName = itemName; + this.paymentName = paymentName; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public TransactionTypeAndPaymentMethodRow(String categoryName, Long rowCount, Double rowValue) { + this.categoryName = categoryName; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public TransactionTypeAndPaymentMethodRow(Category category, Long rowCount, Double rowValue) { + this.category = category; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public TransactionTypeAndPaymentMethodRow(Department itemDept, Long rowCount, Double rowValue) { + this.itemDepartment = itemDept; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public TransactionTypeAndPaymentMethodRow(Item item, Long rowCount, Double rowValue) { + this.item = item; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public TransactionTypeAndPaymentMethodRow(String categoryName, Double rowValue) { + this.categoryName = categoryName; + this.rowValue = rowValue; + } + + public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, String categoryName, String toDepartmentName, Double rowValue) { + this.billTypeAtomic = billTypeAtomic; + this.categoryName = categoryName; + this.toDepartmentName = toDepartmentName; + this.rowValue = rowValue; + } + + public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, Double rowValue) { + this.billTypeAtomic = billTypeAtomic; + this.rowValue = rowValue; + } + + public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, Long rowCount, Double rowValue) { + this.rowValue = rowValue; + this.rowCount = rowCount; + this.billTypeAtomic = billTypeAtomic; + } + + public TransactionTypeAndPaymentMethodRow(Double rowValue) { + this.rowValue = rowValue; + } + + public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic) { + this.billTypeAtomic = billTypeAtomic; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public ServiceType getServiceType() { + return serviceType; + } + + public void setServiceType(ServiceType serviceType) { + this.serviceType = serviceType; + } + + public Institution getCreditCompany() { + return creditCompany; + } + + public void setCreditCompany(Institution creditCompany) { + this.creditCompany = creditCompany; + } + + public Department getToDepartment() { + return toDepartment; + } + + public void setToDepartment(Department toDepartment) { + this.toDepartment = toDepartment; + } + + public BillTypeAtomic getBillTypeAtomic() { + return billTypeAtomic; + } + + public void setBillTypeAtomic(BillTypeAtomic billTypeAtomic) { + this.billTypeAtomic = billTypeAtomic; + } + + // Custom method to generate a unique key string, handling null values + public String getCustomKey() { + return (category != null ? category.getName() : "") + "|" + + (creditCompany != null ? creditCompany.getName() : "") + "|" + + (toDepartment != null ? toDepartment.getName() : "") + "|" + + (serviceType != null ? serviceType.getLabel() : "") + "|" + + (billTypeAtomic != null ? billTypeAtomic.getLabel() : ""); + } + + public String getFeeName() { + return feeName; + } + + public Double getRowValueIn() { + return rowValueIn; + } + + public void setRowValueIn(Double rowValueIn) { + this.rowValueIn = rowValueIn; + } + + public Double getRowValueOut() { + return rowValueOut; + } + + public void setRowValueOut(Double rowValueOut) { + this.rowValueOut = rowValueOut; + } + + public Long getRowCountIn() { + return rowCountIn; + } + + public void setRowCountIn(Long rowCountIn) { + this.rowCountIn = rowCountIn; + } + + public Long getRowCountOut() { + return rowCountOut; + } + + public void setRowCountOut(Long rowCountOut) { + this.rowCountOut = rowCountOut; + } + + public Item getItem() { + return item; + } + + public void setItem(Item item) { + this.item = item; + } + + public Department getItemDepartment() { + return itemDepartment; + } + + 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; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public Date getFromDate() { + return fromDate; + } + + public void setFromDate(Date fromDate) { + this.fromDate = fromDate; + } + + public Date getToDate() { + return toDate; + } + + public void setToDate(Date toDate) { + this.toDate = toDate; + } + + public Institution getFromInstitution() { + return fromInstitution; + } + + public void setFromInstitution(Institution fromInstitution) { + this.fromInstitution = fromInstitution; + } + + public Department getFromDepartment() { + return fromDepartment; + } + + public void setFromDepartment(Department fromDepartment) { + this.fromDepartment = fromDepartment; + } + + public Institution getToInstitution() { + return toInstitution; + } + + public void setToInstitution(Institution toInstitution) { + this.toInstitution = toInstitution; + } + + public WebUser getUser() { + return user; + } + + public void setUser(WebUser user) { + this.user = user; + } + + public Long getStartId() { + return startId; + } + + public void setStartId(Long startId) { + this.startId = startId; + } + + public Long getEndId() { + return endId; + } + + public void setEndId(Long endId) { + this.endId = endId; + } + + public List getBtas() { + return btas; + } + + public void setBtas(List btas) { + this.btas = btas; + } + + public SessionInstance getSessionInstance() { + return sessionInstance; + } + + public void setSessionInstance(SessionInstance sessionInstance) { + this.sessionInstance = sessionInstance; + } + + public Long getLong1() { + return long1; + } + + public void setLong1(Long long1) { + this.long1 = long1; + } + + public Long getLong2() { + return long2; + } + + public void setLong2(Long long2) { + this.long2 = long2; + } + + public Long getLong3() { + return long3; + } + + public void setLong3(Long long3) { + this.long3 = long3; + } + + public Long getLong4() { + return long4; + } + + public void setLong4(Long long4) { + this.long4 = long4; + } + + public Long getLong5() { + return long5; + } + + public void setLong5(Long long5) { + this.long5 = long5; + } + + public Long getLong6() { + return long6; + } + + public void setLong6(Long long6) { + this.long6 = long6; + } + + public Long getLong7() { + return long7; + } + + public void setLong7(Long long7) { + this.long7 = long7; + } + + public Long getLong8() { + return long8; + } + + public void setLong8(Long long8) { + this.long8 = long8; + } + + public Long getLong9() { + return long9; + } + + public void setLong9(Long long9) { + this.long9 = long9; + } + + public Long getLong10() { + return long10; + } + + public void setLong10(Long long10) { + this.long10 = long10; + } + + public Staff getStaff() { + return staff; + } + + public void setStaff(Staff staff) { + this.staff = staff; + } + + public TransactionTypeAndPaymentMethodRow(Staff staff, Long long1, Long long2, Long long3, Long long4, Long long5, Long long6, Long long7) { + this.staff = staff; + this.long1 = long1; + this.long2 = long2; + this.long3 = long3; + this.long4 = long4; + this.long5 = long5; + this.long6 = long6; + this.long7 = long7; + this.staff = staff; + } + + public Institution getReferringInstitution() { + return referringInstitution; + } + + public void setReferringInstitution(Institution referringInstitution) { + this.referringInstitution = referringInstitution; + } + + public Staff getReferringStaff() { + return referringStaff; + } + + public void setReferringStaff(Staff referringStaff) { + this.referringStaff = referringStaff; + } + + public String getUuid() { + if (uuid == null) { + uuid = UUID.randomUUID().toString(); + } + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public double getOnCallValue() { + return onCallValue; + } + + public void setOnCallValue(double onCallValue) { + this.onCallValue = onCallValue; + } + + public double getCashValue() { + return cashValue; + } + + public void setCashValue(double cashValue) { + this.cashValue = cashValue; + } + + public double getCardValue() { + return cardValue; + } + + public void setCardValue(double cardValue) { + this.cardValue = cardValue; + } + + public double getMultiplePaymentMethodsValue() { + return multiplePaymentMethodsValue; + } + + public void setMultiplePaymentMethodsValue(double multiplePaymentMethodsValue) { + this.multiplePaymentMethodsValue = multiplePaymentMethodsValue; + } + + public double getStaffValue() { + return staffValue; + } + + public void setStaffValue(double staffValue) { + this.staffValue = staffValue; + } + + public double getCreditValue() { + return creditValue; + } + + public void setCreditValue(double creditValue) { + this.creditValue = creditValue; + } + + public double getStaffWelfareValue() { + return staffWelfareValue; + } + + public void setStaffWelfareValue(double staffWelfareValue) { + this.staffWelfareValue = staffWelfareValue; + } + + public double getVoucherValue() { + return voucherValue; + } + + public void setVoucherValue(double voucherValue) { + this.voucherValue = voucherValue; + } + + public double getIouValue() { + return iouValue; + } + + public void setIouValue(double iouValue) { + this.iouValue = iouValue; + } + + public double getAgentValue() { + return agentValue; + } + + public void setAgentValue(double agentValue) { + this.agentValue = agentValue; + } + + public double getChequeValue() { + return chequeValue; + } + + public void setChequeValue(double chequeValue) { + this.chequeValue = chequeValue; + } + + public double getSlipValue() { + return slipValue; + } + + public void setSlipValue(double slipValue) { + this.slipValue = slipValue; + } + + public double getEwalletValue() { + return eWalletValue; + } + + public void setEwalletValue(double eWalletValue) { + this.eWalletValue = eWalletValue; + } + + public double getPatientDepositValue() { + return patientDepositValue; + } + + public void setPatientDepositValue(double patientDepositValue) { + this.patientDepositValue = patientDepositValue; + } + + public double getPatientPointsValue() { + return patientPointsValue; + } + + public void setPatientPointsValue(double patientPointsValue) { + this.patientPointsValue = patientPointsValue; + } + + public double getOnlineSettlementValue() { + return onlineSettlementValue; + } + + public void setOnlineSettlementValue(double onlineSettlementValue) { + this.onlineSettlementValue = onlineSettlementValue; + } + + public List getCashHnadovers() { + if (cashHnadovers == null) { + cashHnadovers = new ArrayList<>(); + } + return cashHnadovers; + } + + public void setCashHnadovers(List cashHnadovers) { + this.cashHnadovers = cashHnadovers; + } + + public double geteWalletValue() { + return eWalletValue; + } + + public void seteWalletValue(double eWalletValue) { + this.eWalletValue = eWalletValue; + } + + public Long getCategoryCount() { + return categoryCount; + } + + public void setCategoryCount(Long categoryCount) { + this.categoryCount = categoryCount; + } + + public Double getCategoryTotal() { + return categoryTotal; + } + + public void setCategoryTotal(Double categoryTotal) { + this.categoryTotal = categoryTotal; + } + + public Double getCategoryHospitalFee() { + return categoryHospitalFee; + } + + public void setCategoryHospitalFee(Double categoryHospitalFee) { + this.categoryHospitalFee = categoryHospitalFee; + } + + public Double getCategoryDiscountAmount() { + return categoryDiscountAmount; + } + + public void setCategoryDiscountAmount(Double categoryDiscountAmount) { + this.categoryDiscountAmount = categoryDiscountAmount; + } + + public Double getCategoryCollectingCentreFee() { + return categoryCollectingCentreFee; + } + + public void setCategoryCollectingCentreFee(Double categoryCollectingCentreFee) { + this.categoryCollectingCentreFee = categoryCollectingCentreFee; + } + + public Double getCategoryDiscount() { + return categoryDiscount; + } + + public void setCategoryDiscount(Double categoryDiscount) { + this.categoryDiscount = categoryDiscount; + } + + public Double getCategoryProfessionalFee() { + return categoryProfessionalFee; + } + + public void setCategoryProfessionalFee(Double categoryProfessionalFee) { + this.categoryProfessionalFee = categoryProfessionalFee; + } + + public Double getCategoryNetTotal() { + return categoryNetTotal; + } + + public void setCategoryNetTotal(Double categoryNetTotal) { + this.categoryNetTotal = categoryNetTotal; + } + + public Long getItemCount() { + return itemCount; + } + + public void setItemCount(Long itemCount) { + this.itemCount = itemCount; + } + + public Double getItemTotal() { + return itemTotal; + } + + public void setItemTotal(Double itemTotal) { + this.itemTotal = itemTotal; + } + + public Double getItemHospitalFee() { + return itemHospitalFee; + } + + public void setItemHospitalFee(Double itemHospitalFee) { + this.itemHospitalFee = itemHospitalFee; + } + + public Double getItemDiscountAmount() { + return itemDiscountAmount; + } + + public void setItemDiscountAmount(Double itemDiscountAmount) { + this.itemDiscountAmount = itemDiscountAmount; + } + + public Double getItemCollectingCentreFee() { + return itemCollectingCentreFee; + } + + public void setItemCollectingCentreFee(Double itemCollectingCentreFee) { + this.itemCollectingCentreFee = itemCollectingCentreFee; + } + + public Double getItemDiscount() { + return itemDiscount; + } + + public void setItemDiscount(Double itemDiscount) { + this.itemDiscount = itemDiscount; + } + + public Double getItemProfessionalFee() { + return itemProfessionalFee; + } + + public void setItemProfessionalFee(Double itemProfessionalFee) { + this.itemProfessionalFee = itemProfessionalFee; + } + + public Double getItemNetTotal() { + return itemNetTotal; + } + + public void setItemNetTotal(Double itemNetTotal) { + this.itemNetTotal = itemNetTotal; + } + + public String getRowType() { + return rowType; + } + + public void setRowType(String rowType) { + this.rowType = rowType; + } + + public Bill getBill() { + return bill; + } + + public void setBill(Bill bill) { + this.bill = bill; + } + + public TransactionTypeAndPaymentMethodRow(Bill bill) { + this.bill = bill; + } + + public Payment getPayment() { + return payment; + } + + public void setPayment(Payment payment) { + this.payment = payment; + } + + public TransactionTypeAndPaymentMethodRow(Payment payment) { + this.payment = payment; + } + + public BillItem getBillItem() { + return billItem; + } + + public Route getRoute() { + return route; + } + + public void setRoute(Route route) { + this.route = route; + } + + public Institution getCollectingCentre() { + return collectingCentre; + } + + public void setCollectingCentre(Institution collectingCentre) { + this.collectingCentre = collectingCentre; + } + + public Double getTotalHospitalFee() { + return totalHospitalFee; + } + + public void setTotalHospitalFee(Double totalHospitalFee) { + this.totalHospitalFee = totalHospitalFee; + } + + public Double getQty() { + return qty; + } + + public void setQty(Double qty) { + this.qty = qty; + } + + public void setBillItem(BillItem billItem) { + this.billItem = billItem; + } + + public TransactionTypeAndPaymentMethodRow(BillItem billItem) { + this.billItem = billItem; + } + + public Institution getSite() { + return site; + } + + public void setSite(Institution site) { + this.site = site; + } + + public Long getCounter() { + return counter; + } + + public void setCounter(Long counter) { + this.counter = counter; + } + + public BillFee getBillFee() { + return billFee; + } + + public void setBillFee(BillFee billFee) { + this.billFee = billFee; + } + + public TransactionTypeAndPaymentMethodRow(BillFee billFee) { + this.billFee = billFee; + } + + public Speciality getSpeciality() { + return speciality; + } + + public void setSpeciality(Speciality speciality) { + this.speciality = speciality; + } + + public TransactionTypeAndPaymentMethodRow(AgentHistory agentHistory) { + this.agentHistory = agentHistory; + } + + + public Double getGrossTotal() { + return grossTotal; + } + + public void setGrossTotal(Double grossTotal) { + this.grossTotal = grossTotal; + } + + public Double getDiscount() { + return discount; + } + + public void setDiscount(Double discount) { + this.discount = discount; + } + + public Double getTotal() { + return total; + } + + public void setTotal(Double total) { + this.total = total; + } + + public Double getHospitalTotal() { + return hospitalTotal; + } + + public void setHospitalTotal(Double hospitalTotal) { + this.hospitalTotal = hospitalTotal; + } + + public Double getStaffTotal() { + return staffTotal; + } + + public void setStaffTotal(Double staffTotal) { + this.staffTotal = staffTotal; + } + + public Double getCcTotal() { + return ccTotal; + } + + public void setCcTotal(Double ccTotal) { + this.ccTotal = ccTotal; + } + + public boolean isSelected() { + return selected; + } + + public void setSelected(boolean selected) { + this.selected = selected; + } + + public List getDenominationTransactions() { + return denominationTransactions; + } + + public void setDenominationTransactions(List denominationTransactions) { + this.denominationTransactions = denominationTransactions; + } + + public AgentHistory getAgentHistory() { + return agentHistory; + } + + public void setAgentHistory(AgentHistory agentHistory) { + this.agentHistory = agentHistory; + } + + public PaymentHandover getPaymentHandover() { + return paymentHandover; + } + + public void setPaymentHandover(PaymentHandover paymentHandover) { + this.paymentHandover = paymentHandover; + } + + public BillType getBillType() { + return billType; + } + + public void setBillType(BillType billType) { + this.billType = billType; + } + + public BillClassType getBillClassType() { + return billClassType; + } + + public void setBillClassType(BillClassType billClassType) { + this.billClassType = billClassType; + } + + public Double getTax() { + return tax; + } + + public void setTax(Double tax) { + this.tax = tax; + } + + public PatientInvestigation getPatientInvestigation() { + return patientInvestigation; + } + + public void setPatientInvestigation(PatientInvestigation patientInvestigation) { + this.patientInvestigation = patientInvestigation; + } + + +} diff --git a/src/main/webapp/pharmacy/pharmacy_analytics.xhtml b/src/main/webapp/pharmacy/pharmacy_analytics.xhtml index 0fb4ecdbc0..d8279f3964 100644 --- a/src/main/webapp/pharmacy/pharmacy_analytics.xhtml +++ b/src/main/webapp/pharmacy/pharmacy_analytics.xhtml @@ -15,13 +15,19 @@ - +
+
diff --git a/src/main/webapp/pharmacy/reports/summary_reports/daily_stock_balance_report.xhtml b/src/main/webapp/pharmacy/reports/summary_reports/daily_stock_balance_report.xhtml new file mode 100644 index 0000000000..4c3d51ae2b --- /dev/null +++ b/src/main/webapp/pharmacy/reports/summary_reports/daily_stock_balance_report.xhtml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/src/main/webapp/pharmacy/reports/summary_reports/pharmacy_income_report.xhtml b/src/main/webapp/pharmacy/reports/summary_reports/pharmacy_income_report.xhtml new file mode 100644 index 0000000000..4c3d51ae2b --- /dev/null +++ b/src/main/webapp/pharmacy/reports/summary_reports/pharmacy_income_report.xhtml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + From 334aea65472adb7b7fb79c000641919b847bab43 Mon Sep 17 00:00:00 2001 From: Lawan Samarasekara Date: Fri, 20 Dec 2024 08:05:35 +0530 Subject: [PATCH 07/28] Signed-off-by: Lawan Samarasekara --- src/main/resources/META-INF/persistence.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 442320af04..3859a00e7b 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -2,7 +2,7 @@ org.eclipse.persistence.jpa.PersistenceProvider - jdbc/southernlanka + jdbc/ruhunu false @@ -13,7 +13,7 @@ - jdbc/southernlankaAudit + jdbc/ruhunuAudit false From cd53d88104a8077a8b198cca8101b32e33fc53f9 Mon Sep 17 00:00:00 2001 From: Buddhika Ariyaratne Date: Fri, 20 Dec 2024 08:22:29 +0530 Subject: [PATCH 08/28] Signed-off-by: Buddhika Ariyaratne --- .../PharmacySummaryReportController.java | 996 ++++++- .../java/com/divudi/data/IncomeBundle.java | 2636 +++++++++++++++++ ...ndPaymentMethodRow.java => IncomeRow.java} | 153 +- .../java/com/divudi/service/BillService.java | 41 + .../pharmacy_income_report.xhtml | 163 +- 5 files changed, 3875 insertions(+), 114 deletions(-) create mode 100644 src/main/java/com/divudi/data/IncomeBundle.java rename src/main/java/com/divudi/data/{TransactionTypeAndPaymentMethodRow.java => IncomeRow.java} (83%) diff --git a/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java b/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java index 4bb7b23201..c5712fb169 100644 --- a/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java +++ b/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java @@ -13,9 +13,6 @@ import com.divudi.data.hr.ReportKeyWord; import com.divudi.ejb.PharmacyBean; -import com.divudi.entity.Bill; -import com.divudi.entity.BillFee; -import com.divudi.entity.BillItem; import com.divudi.entity.Department; import com.divudi.entity.Institution; import com.divudi.entity.Item; @@ -31,16 +28,16 @@ import com.divudi.data.BillClassType; import com.divudi.data.BillTypeAtomic; -import com.divudi.data.ReportTemplateRowBundle; +import com.divudi.data.IncomeBundle; +import com.divudi.entity.Bill; import com.divudi.entity.Category; -import com.divudi.entity.Payment; import com.divudi.entity.WebUser; import com.divudi.facade.DrawerFacade; import com.divudi.facade.PaymentFacade; import com.divudi.java.CommonFunctions; -import com.divudi.light.common.BillLight; -import com.divudi.light.common.BillSummaryRow; +import com.divudi.service.BillService; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.ejb.EJB; @@ -59,6 +56,8 @@ @SessionScoped public class PharmacySummaryReportController implements Serializable { + + private static final long serialVersionUID = 1L; // @@ -79,6 +78,8 @@ public class PharmacySummaryReportController implements Serializable { private PatientFacade patientFacade; @EJB private DrawerFacade drawerFacade; + @EJB + BillService billService; // // @@ -87,7 +88,7 @@ public class PharmacySummaryReportController implements Serializable { @Inject private SessionController sessionController; @Inject - TransferController transferController; + private TransferController transferController; @Inject private CommonController commonController; @Inject @@ -174,7 +175,7 @@ public class PharmacySummaryReportController implements Serializable { // Reporting and files private SearchKeyword searchKeyword; private ReportKeyWord reportKeyWord; - private ReportTemplateRowBundle bundle; + private IncomeBundle bundle; private StreamedContent downloadingExcel; private UploadedFile file; @@ -195,42 +196,49 @@ public String navigateToDailyStockBalanceReport() { // public void resetAllFiltersExceptDateRange() { - institution = null; - department = null; - webUser = null; - site = null; - paymentMethod = null; - searchKeyword = null; - category = null; - item = null; - staff = null; - currentStaff = null; - creditCompany = null; - dealer = null; - toSite = null; - fromInstitution = null; - toInstitution = null; - fromDepartment = null; - toDepartment = null; - patient = null; - patientEncounter = null; - billType = null; - billTypeAtomic = null; - billClassType = null; - paymentMethods = null; - reportKeyWord = null; - bundle = new ReportTemplateRowBundle(); - downloadingExcel = null; - file = null; - searchKeyword = new SearchKeyword(); + setInstitution(null); + setDepartment(null); + setWebUser(null); + setSite(null); + setPaymentMethod(null); + setSearchKeyword(null); + setCategory(null); + setItem(null); + setStaff(null); + setCurrentStaff(null); + setCreditCompany(null); + setDealer(null); + setToSite(null); + setFromInstitution(null); + setToInstitution(null); + setFromDepartment(null); + setToDepartment(null); + setPatient(null); + setPatientEncounter(null); + setBillType(null); + setBillTypeAtomic(null); + setBillClassType(null); + setPaymentMethods(null); + setReportKeyWord(null); + setBundle(new IncomeBundle()); + setDownloadingExcel(null); + setFile(null); + setSearchKeyword(new SearchKeyword()); } public void resetAllFilters() { resetAllFiltersExceptDateRange(); - fromDate = null; - toDate = null; + setFromDate(null); + setToDate(null); } + public void processPharmacyIncomeReport(){ + List billTypeAtomics = new ArrayList<>(); + List bills = billService.fetchBills(fromDate,toDate,institution,site,department,webUser, billTypeAtomics); + bundle = new IncomeBundle(bills); + bundle.generatePaymentDetailsForBills(); + } + // // public PharmacySummaryReportController() { @@ -238,5 +246,915 @@ public PharmacySummaryReportController() { // // + /** + * @return the commonFunctions + */ + public CommonFunctions getCommonFunctions() { + return commonFunctions; + } + + /** + * @param commonFunctions the commonFunctions to set + */ + public void setCommonFunctions(CommonFunctions commonFunctions) { + this.commonFunctions = commonFunctions; + } + + /** + * @return the billFacade + */ + public BillFacade getBillFacade() { + return billFacade; + } + + /** + * @param billFacade the billFacade to set + */ + public void setBillFacade(BillFacade billFacade) { + this.billFacade = billFacade; + } + + /** + * @return the paymentFacade + */ + public PaymentFacade getPaymentFacade() { + return paymentFacade; + } + + /** + * @param paymentFacade the paymentFacade to set + */ + public void setPaymentFacade(PaymentFacade paymentFacade) { + this.paymentFacade = paymentFacade; + } + + /** + * @return the billFeeFacade + */ + public BillFeeFacade getBillFeeFacade() { + return billFeeFacade; + } + + /** + * @param billFeeFacade the billFeeFacade to set + */ + public void setBillFeeFacade(BillFeeFacade billFeeFacade) { + this.billFeeFacade = billFeeFacade; + } + + /** + * @return the billItemFacade + */ + public BillItemFacade getBillItemFacade() { + return billItemFacade; + } + + /** + * @param billItemFacade the billItemFacade to set + */ + public void setBillItemFacade(BillItemFacade billItemFacade) { + this.billItemFacade = billItemFacade; + } + + /** + * @return the pharmacyBean + */ + public PharmacyBean getPharmacyBean() { + return pharmacyBean; + } + + /** + * @param pharmacyBean the pharmacyBean to set + */ + public void setPharmacyBean(PharmacyBean pharmacyBean) { + this.pharmacyBean = pharmacyBean; + } + + /** + * @return the stockFacade + */ + public StockFacade getStockFacade() { + return stockFacade; + } + + /** + * @param stockFacade the stockFacade to set + */ + public void setStockFacade(StockFacade stockFacade) { + this.stockFacade = stockFacade; + } + + /** + * @return the patientFacade + */ + public PatientFacade getPatientFacade() { + return patientFacade; + } + + /** + * @param patientFacade the patientFacade to set + */ + public void setPatientFacade(PatientFacade patientFacade) { + this.patientFacade = patientFacade; + } + + /** + * @return the drawerFacade + */ + public DrawerFacade getDrawerFacade() { + return drawerFacade; + } + + /** + * @param drawerFacade the drawerFacade to set + */ + public void setDrawerFacade(DrawerFacade drawerFacade) { + this.drawerFacade = drawerFacade; + } + + /** + * @return the billBean + */ + public BillBeanController getBillBean() { + return billBean; + } + + /** + * @param billBean the billBean to set + */ + public void setBillBean(BillBeanController billBean) { + this.billBean = billBean; + } + + /** + * @return the sessionController + */ + public SessionController getSessionController() { + return sessionController; + } + + /** + * @param sessionController the sessionController to set + */ + public void setSessionController(SessionController sessionController) { + this.sessionController = sessionController; + } + + /** + * @return the transferController + */ + public TransferController getTransferController() { + return transferController; + } + + /** + * @param transferController the transferController to set + */ + public void setTransferController(TransferController transferController) { + this.transferController = transferController; + } + + /** + * @return the commonController + */ + public CommonController getCommonController() { + return commonController; + } + + /** + * @param commonController the commonController to set + */ + public void setCommonController(CommonController commonController) { + this.commonController = commonController; + } + + /** + * @return the pharmacySaleBhtController + */ + public PharmacySaleBhtController getPharmacySaleBhtController() { + return pharmacySaleBhtController; + } + + /** + * @param pharmacySaleBhtController the pharmacySaleBhtController to set + */ + public void setPharmacySaleBhtController(PharmacySaleBhtController pharmacySaleBhtController) { + this.pharmacySaleBhtController = pharmacySaleBhtController; + } + + /** + * @return the webUserController + */ + public WebUserController getWebUserController() { + return webUserController; + } + + /** + * @param webUserController the webUserController to set + */ + public void setWebUserController(WebUserController webUserController) { + this.webUserController = webUserController; + } + + /** + * @return the opdPreSettleController + */ + public OpdPreSettleController getOpdPreSettleController() { + return opdPreSettleController; + } + + /** + * @param opdPreSettleController the opdPreSettleController to set + */ + public void setOpdPreSettleController(OpdPreSettleController opdPreSettleController) { + this.opdPreSettleController = opdPreSettleController; + } + + /** + * @return the pharmacyPreSettleController + */ + public PharmacyPreSettleController getPharmacyPreSettleController() { + return pharmacyPreSettleController; + } + + /** + * @param pharmacyPreSettleController the pharmacyPreSettleController to set + */ + public void setPharmacyPreSettleController(PharmacyPreSettleController pharmacyPreSettleController) { + this.pharmacyPreSettleController = pharmacyPreSettleController; + } + + /** + * @return the tokenController + */ + public TokenController getTokenController() { + return tokenController; + } + + /** + * @param tokenController the tokenController to set + */ + public void setTokenController(TokenController tokenController) { + this.tokenController = tokenController; + } + + /** + * @return the departmentController + */ + public DepartmentController getDepartmentController() { + return departmentController; + } + + /** + * @param departmentController the departmentController to set + */ + public void setDepartmentController(DepartmentController departmentController) { + this.departmentController = departmentController; + } + + /** + * @return the billSearch + */ + public BillSearch getBillSearch() { + return billSearch; + } + + /** + * @param billSearch the billSearch to set + */ + public void setBillSearch(BillSearch billSearch) { + this.billSearch = billSearch; + } + + /** + * @return the pharmacyBillSearch + */ + public PharmacyBillSearch getPharmacyBillSearch() { + return pharmacyBillSearch; + } + + /** + * @param pharmacyBillSearch the pharmacyBillSearch to set + */ + public void setPharmacyBillSearch(PharmacyBillSearch pharmacyBillSearch) { + this.pharmacyBillSearch = pharmacyBillSearch; + } + + /** + * @return the opdBillController + */ + public OpdBillController getOpdBillController() { + return opdBillController; + } + + /** + * @param opdBillController the opdBillController to set + */ + public void setOpdBillController(OpdBillController opdBillController) { + this.opdBillController = opdBillController; + } + + /** + * @return the configOptionApplicationController + */ + public ConfigOptionApplicationController getConfigOptionApplicationController() { + return configOptionApplicationController; + } + + /** + * @param configOptionApplicationController the configOptionApplicationController to set + */ + public void setConfigOptionApplicationController(ConfigOptionApplicationController configOptionApplicationController) { + this.configOptionApplicationController = configOptionApplicationController; + } + + /** + * @return the channelSearchController + */ + public ChannelSearchController getChannelSearchController() { + return channelSearchController; + } + + /** + * @param channelSearchController the channelSearchController to set + */ + public void setChannelSearchController(ChannelSearchController channelSearchController) { + this.channelSearchController = channelSearchController; + } + + /** + * @return the reportTemplateController + */ + public ReportTemplateController getReportTemplateController() { + return reportTemplateController; + } + + /** + * @param reportTemplateController the reportTemplateController to set + */ + public void setReportTemplateController(ReportTemplateController reportTemplateController) { + this.reportTemplateController = reportTemplateController; + } + + /** + * @return the cashBookEntryController + */ + public CashBookEntryController getCashBookEntryController() { + return cashBookEntryController; + } + + /** + * @param cashBookEntryController the cashBookEntryController to set + */ + public void setCashBookEntryController(CashBookEntryController cashBookEntryController) { + this.cashBookEntryController = cashBookEntryController; + } + + /** + * @return the excelController + */ + public ExcelController getExcelController() { + return excelController; + } + + /** + * @param excelController the excelController to set + */ + public void setExcelController(ExcelController excelController) { + this.excelController = excelController; + } + + /** + * @return the pdfController + */ + public PdfController getPdfController() { + return pdfController; + } + + /** + * @param pdfController the pdfController to set + */ + public void setPdfController(PdfController pdfController) { + this.pdfController = pdfController; + } + + /** + * @return the drawerEntryController + */ + public DrawerEntryController getDrawerEntryController() { + return drawerEntryController; + } + + /** + * @param drawerEntryController the drawerEntryController to set + */ + public void setDrawerEntryController(DrawerEntryController drawerEntryController) { + this.drawerEntryController = drawerEntryController; + } + + /** + * @return the drawerController + */ + public DrawerController getDrawerController() { + return drawerController; + } + + /** + * @param drawerController the drawerController to set + */ + public void setDrawerController(DrawerController drawerController) { + this.drawerController = drawerController; + } + + /** + * @return the enumController + */ + public EnumController getEnumController() { + return enumController; + } + + /** + * @param enumController the enumController to set + */ + public void setEnumController(EnumController enumController) { + this.enumController = enumController; + } + + /** + * @return the visitType + */ + public String getVisitType() { + return visitType; + } + + /** + * @param visitType the visitType to set + */ + public void setVisitType(String visitType) { + this.visitType = visitType; + } + + /** + * @return the methodType + */ + public String getMethodType() { + return methodType; + } + + /** + * @param methodType the methodType to set + */ + public void setMethodType(String methodType) { + this.methodType = methodType; + } + + /** + * @return the searchType + */ + public String getSearchType() { + return searchType; + } + + /** + * @param searchType the searchType to set + */ + public void setSearchType(String searchType) { + this.searchType = searchType; + } + + /** + * @return the reportType + */ + public String getReportType() { + return reportType; + } + + /** + * @param reportType the reportType to set + */ + public void setReportType(String reportType) { + this.reportType = reportType; + } + + /** + * @return the fromDate + */ + public Date getFromDate() { + return fromDate; + } + + /** + * @param fromDate the fromDate to set + */ + public void setFromDate(Date fromDate) { + this.fromDate = fromDate; + } + + /** + * @return the toDate + */ + public Date getToDate() { + return toDate; + } + + /** + * @param toDate the toDate to set + */ + public void setToDate(Date toDate) { + this.toDate = toDate; + } + + /** + * @return the category + */ + public Category getCategory() { + return category; + } + + /** + * @param category the category to set + */ + public void setCategory(Category category) { + this.category = category; + } + + /** + * @return the billType + */ + public BillType getBillType() { + return billType; + } + + /** + * @param billType the billType to set + */ + public void setBillType(BillType billType) { + this.billType = billType; + } + + /** + * @return the billTypeAtomic + */ + public BillTypeAtomic getBillTypeAtomic() { + return billTypeAtomic; + } + + /** + * @param billTypeAtomic the billTypeAtomic to set + */ + public void setBillTypeAtomic(BillTypeAtomic billTypeAtomic) { + this.billTypeAtomic = billTypeAtomic; + } + + /** + * @return the billClassType + */ + public BillClassType getBillClassType() { + return billClassType; + } + + /** + * @param billClassType the billClassType to set + */ + public void setBillClassType(BillClassType billClassType) { + this.billClassType = billClassType; + } + + /** + * @return the paymentMethod + */ + public PaymentMethod getPaymentMethod() { + return paymentMethod; + } + + /** + * @param paymentMethod the paymentMethod to set + */ + public void setPaymentMethod(PaymentMethod paymentMethod) { + this.paymentMethod = paymentMethod; + } + + /** + * @return the paymentMethods + */ + public List getPaymentMethods() { + return paymentMethods; + } + + /** + * @param paymentMethods the paymentMethods to set + */ + public void setPaymentMethods(List paymentMethods) { + this.paymentMethods = paymentMethods; + } + + /** + * @return the webUser + */ + public WebUser getWebUser() { + return webUser; + } + + /** + * @param webUser the webUser to set + */ + public void setWebUser(WebUser webUser) { + this.webUser = webUser; + } + + /** + * @return the staff + */ + public Staff getStaff() { + return staff; + } + + /** + * @param staff the staff to set + */ + public void setStaff(Staff staff) { + this.staff = staff; + } + + /** + * @return the currentStaff + */ + public Staff getCurrentStaff() { + return currentStaff; + } + + /** + * @param currentStaff the currentStaff to set + */ + public void setCurrentStaff(Staff currentStaff) { + this.currentStaff = currentStaff; + } + + /** + * @return the institution + */ + public Institution getInstitution() { + return institution; + } + + /** + * @param institution the institution to set + */ + public void setInstitution(Institution institution) { + this.institution = institution; + } + + /** + * @return the creditCompany + */ + public Institution getCreditCompany() { + return creditCompany; + } + + /** + * @param creditCompany the creditCompany to set + */ + public void setCreditCompany(Institution creditCompany) { + this.creditCompany = creditCompany; + } + + /** + * @return the dealer + */ + public Institution getDealer() { + return dealer; + } + + /** + * @param dealer the dealer to set + */ + public void setDealer(Institution dealer) { + this.dealer = dealer; + } + + /** + * @return the site + */ + public Institution getSite() { + return site; + } + + /** + * @param site the site to set + */ + public void setSite(Institution site) { + this.site = site; + } + + /** + * @return the toSite + */ + public Institution getToSite() { + return toSite; + } + + /** + * @param toSite the toSite to set + */ + public void setToSite(Institution toSite) { + this.toSite = toSite; + } + + /** + * @return the fromInstitution + */ + public Institution getFromInstitution() { + return fromInstitution; + } + + /** + * @param fromInstitution the fromInstitution to set + */ + public void setFromInstitution(Institution fromInstitution) { + this.fromInstitution = fromInstitution; + } + + /** + * @return the toInstitution + */ + public Institution getToInstitution() { + return toInstitution; + } + + /** + * @param toInstitution the toInstitution to set + */ + public void setToInstitution(Institution toInstitution) { + this.toInstitution = toInstitution; + } + + /** + * @return the department + */ + public Department getDepartment() { + return department; + } + + /** + * @param department the department to set + */ + public void setDepartment(Department department) { + this.department = department; + } + + /** + * @return the fromDepartment + */ + public Department getFromDepartment() { + return fromDepartment; + } + + /** + * @param fromDepartment the fromDepartment to set + */ + public void setFromDepartment(Department fromDepartment) { + this.fromDepartment = fromDepartment; + } + + /** + * @return the toDepartment + */ + public Department getToDepartment() { + return toDepartment; + } + + /** + * @param toDepartment the toDepartment to set + */ + public void setToDepartment(Department toDepartment) { + this.toDepartment = toDepartment; + } + + /** + * @return the patient + */ + public Patient getPatient() { + return patient; + } + + /** + * @param patient the patient to set + */ + public void setPatient(Patient patient) { + this.patient = patient; + } + + /** + * @return the patientEncounter + */ + public PatientEncounter getPatientEncounter() { + return patientEncounter; + } + + /** + * @param patientEncounter the patientEncounter to set + */ + public void setPatientEncounter(PatientEncounter patientEncounter) { + this.patientEncounter = patientEncounter; + } + + /** + * @return the item + */ + public Item getItem() { + return item; + } + + /** + * @param item the item to set + */ + public void setItem(Item item) { + this.item = item; + } + + /** + * @return the searchKeyword + */ + public SearchKeyword getSearchKeyword() { + return searchKeyword; + } + + /** + * @param searchKeyword the searchKeyword to set + */ + public void setSearchKeyword(SearchKeyword searchKeyword) { + this.searchKeyword = searchKeyword; + } + + /** + * @return the reportKeyWord + */ + public ReportKeyWord getReportKeyWord() { + return reportKeyWord; + } + + /** + * @param reportKeyWord the reportKeyWord to set + */ + public void setReportKeyWord(ReportKeyWord reportKeyWord) { + this.reportKeyWord = reportKeyWord; + } + + /** + * @return the bundle + */ + public IncomeBundle getBundle() { + return bundle; + } + + /** + * @param bundle the bundle to set + */ + public void setBundle(IncomeBundle bundle) { + this.bundle = bundle; + } + + /** + * @return the downloadingExcel + */ + public StreamedContent getDownloadingExcel() { + return downloadingExcel; + } + + /** + * @param downloadingExcel the downloadingExcel to set + */ + public void setDownloadingExcel(StreamedContent downloadingExcel) { + this.downloadingExcel = downloadingExcel; + } + + /** + * @return the file + */ + public UploadedFile getFile() { + return file; + } + + /** + * @param file the file to set + */ + public void setFile(UploadedFile file) { + this.file = file; + } + + /** + * @return the maxResult + */ + public int getMaxResult() { + return maxResult; + } + + /** + * @param maxResult the maxResult to set + */ + public void setMaxResult(int maxResult) { + this.maxResult = maxResult; + } + // } diff --git a/src/main/java/com/divudi/data/IncomeBundle.java b/src/main/java/com/divudi/data/IncomeBundle.java new file mode 100644 index 0000000000..2e11c41cbe --- /dev/null +++ b/src/main/java/com/divudi/data/IncomeBundle.java @@ -0,0 +1,2636 @@ +package com.divudi.data; + +import static com.divudi.data.PaymentMethod.Agent; +import static com.divudi.data.PaymentMethod.Card; +import static com.divudi.data.PaymentMethod.Cash; +import static com.divudi.data.PaymentMethod.Cheque; +import static com.divudi.data.PaymentMethod.Credit; +import static com.divudi.data.PaymentMethod.IOU; +import static com.divudi.data.PaymentMethod.MultiplePaymentMethods; +import static com.divudi.data.PaymentMethod.OnlineSettlement; +import static com.divudi.data.PaymentMethod.PatientDeposit; +import static com.divudi.data.PaymentMethod.PatientPoints; +import static com.divudi.data.PaymentMethod.Slip; +import static com.divudi.data.PaymentMethod.Staff; +import static com.divudi.data.PaymentMethod.Staff_Welfare; +import static com.divudi.data.PaymentMethod.Voucher; +import static com.divudi.data.PaymentMethod.YouOweMe; +import static com.divudi.data.PaymentMethod.ewallet; + +import com.divudi.entity.*; +import com.divudi.entity.channel.SessionInstance; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; + +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.*; + +/** + * @author buddhika + */ +public class IncomeBundle implements Serializable { + + private static final long serialVersionUID = 1L; + + // UUID field to uniquely identify each object + private UUID id; + + // private SessionController sessionController; + private List denominations; + + private List bundles; + private ReportTemplate reportTemplate; + private List rows; + private Map> groupedBillItems; + private Map> groupedBillItemsByInstitution; + + private Double grossTotal; + private Double discount; + private Double total; + private Double tax; + + private Double hospitalTotal; + private Double staffTotal; + private Double ccTotal; + + private Double totalIn; + private Double totalOut; + private Long countIn; + private Long countOut; + private Long count; + private String name; + private String bundleType; + private String description; + private SessionInstance sessionInstance; + private Long long1; + private Long long2; + private Long long3; + private Long long4; + private Long long5; + private Long long6; + private Long long7; + private Long long8; + private Long long9; + private Long long10; + + private PaymentMethod paymentMethod; + + private double onCallValue; + private double cashValue; + private double cardValue; + private double multiplePaymentMethodsValue; + private double staffValue; + private double creditValue; + private double staffWelfareValue; + private double voucherValue; + private double iouValue; + private double agentValue; + private double chequeValue; + private double slipValue; + private double eWalletValue; + private double patientDepositValue; + private double patientPointsValue; + private double onlineSettlementValue; + + private Boolean selectAllCashToHandover; + + private double onCallHandoverValue; + private double cashHandoverValue; + private double denominatorValue; + private double cardHandoverValue; + private double multiplePaymentMethodsHandoverValue; + private double staffHandoverValue; + private double creditHandoverValue; + private double staffWelfareHandoverValue; + private double voucherHandoverValue; + private double iouHandoverValue; + private double agentHandoverValue; + private double chequeHandoverValue; + private double slipHandoverValue; + private double eWalletHandoverValue; + private double patientDepositHandoverValue; + private double patientPointsHandoverValue; + private double onlineSettlementHandoverValue; + + private double settledAmountByPatientsTotal; + private double settledAmountBySponsorsTotal; + private double totalBalance; + + // Booleans to track transactions + private boolean hasOnCallTransaction; + private boolean hasCashTransaction; + private boolean hasCardTransaction; + private boolean hasMultiplePaymentMethodsTransaction; + private boolean hasStaffTransaction; + private boolean hasCreditTransaction; + private boolean hasStaffWelfareTransaction; + private boolean hasVoucherTransaction; + private boolean hasIouTransaction; + private boolean hasAgentTransaction; + private boolean hasChequeTransaction; + private boolean hasSlipTransaction; + private boolean hasEWalletTransaction; + private boolean hasPatientDepositTransaction; + private boolean hasPatientPointsTransaction; + private boolean hasOnlineSettlementTransaction; + + private WebUser user; + private WebUser fromUser; + private WebUser toUser; + private Date date; + private Department department; + private List departments; + private Bill startBill; + private Bill endBill; + + private PaymentHandover paymentHandover; + + private boolean selected; + + private boolean patientDepositsAreConsideredInHandingover = true; + + public IncomeBundle() { + this.id = UUID.randomUUID(); + this.rows = new ArrayList<>(); + } + + public IncomeBundle(List entries) { + this(); // Initialize id and rows list + if (entries != null && !entries.isEmpty()) { + Object firstElement = entries.get(0); + if (firstElement instanceof Bill) { + // Process list as Bills + for (Object obj : entries) { + if (obj instanceof Bill) { + Bill bill = (Bill) obj; + IncomeRow ir = new IncomeRow(bill); + rows.add(ir); + } + } + } else if (firstElement instanceof IncomeRow) { + // Process list as IncomeRows + for (Object obj : entries) { + if (obj instanceof IncomeRow) { + IncomeRow incomeRow = (IncomeRow) obj; + rows.add(incomeRow); + } + } + } + } + } + + public void generatePaymentDetailsForBills() { + for (IncomeRow r : getRows()) { + Bill b = r.getBill(); + if (b == null) { + continue; + } + if (b.getPaymentMethod() == null) { + r.setNoneValue(b.getNetTotal()); + } else if (b.getPaymentMethod() == MultiplePaymentMethods) { + + } else { + switch (b.getPaymentMethod()) { + case Agent: + r.setAgentValue(b.getNetTotal()); + break; + case Card: + r.setCardValue(b.getNetTotal()); + break; + case Cash: + r.setCashValue(b.getNetTotal()); + break; + case Cheque: + r.setChequeValue(b.getNetTotal()); + break; + case IOU: + r.setIouValue(b.getNetTotal()); + break; + case None: + break; + case OnCall: + r.setOnCallValue(b.getNetTotal()); + break; + case Credit: + case MultiplePaymentMethods: // Ignoring multiple modes and credit + break; + case OnlineSettlement: + r.setOnlineSettlementValue(b.getNetTotal()); + break; + case PatientDeposit: + r.setPatientDepositValue(b.getNetTotal()); + break; + case PatientPoints: + r.setPatientPointsValue(b.getNetTotal()); + break; + case Slip: + r.setSlipValue(b.getNetTotal()); + break; + case Staff: + r.setStaffValue(b.getNetTotal()); + break; + case Staff_Welfare: + r.setStaffWelfareValue(b.getNetTotal()); + break; + case Voucher: + r.setVoucherValue(b.getNetTotal()); + break; + case ewallet: + r.setEwalletValue(b.getNetTotal()); + break; + case YouOweMe: + break; + } + + } + } + } + + private double nullSafeDouble(Double value) { + return value != null ? value : 0.0; + } + + public void selectAllChildBundles() { + for (IncomeBundle b : getBundles()) { + b.setSelected(true); + } + } + + private void resetTotals() { + grossTotal = 0.0; + discount = 0.0; + total = 0.0; + hospitalTotal = 0.0; + staffTotal = 0.0; + ccTotal = 0.0; + totalIn = 0.0; + totalOut = 0.0; + countIn = 0L; + countOut = 0L; + count = 0L; + + onCallValue = 0.0; + cashValue = 0.0; + cardValue = 0.0; + multiplePaymentMethodsValue = 0.0; + staffValue = 0.0; + creditValue = 0.0; + staffWelfareValue = 0.0; + voucherValue = 0.0; + iouValue = 0.0; + agentValue = 0.0; + chequeValue = 0.0; + slipValue = 0.0; + eWalletValue = 0.0; + patientDepositValue = 0.0; + patientPointsValue = 0.0; + onlineSettlementValue = 0.0; + + onCallHandoverValue = 0.0; + cashHandoverValue = 0.0; + denominatorValue = 0.0; + cardHandoverValue = 0.0; + multiplePaymentMethodsHandoverValue = 0.0; + staffHandoverValue = 0.0; + creditHandoverValue = 0.0; + staffWelfareHandoverValue = 0.0; + voucherHandoverValue = 0.0; + iouHandoverValue = 0.0; + agentHandoverValue = 0.0; + chequeHandoverValue = 0.0; + slipHandoverValue = 0.0; + eWalletHandoverValue = 0.0; + patientDepositHandoverValue = 0.0; + patientPointsHandoverValue = 0.0; + onlineSettlementHandoverValue = 0.0; + + hasOnCallTransaction = false; + hasCashTransaction = false; + hasCardTransaction = false; + hasMultiplePaymentMethodsTransaction = false; + hasStaffTransaction = false; + hasCreditTransaction = false; + hasStaffWelfareTransaction = false; + hasVoucherTransaction = false; + hasIouTransaction = false; + hasAgentTransaction = false; + hasChequeTransaction = false; + hasSlipTransaction = false; + hasEWalletTransaction = false; + hasPatientDepositTransaction = false; + hasPatientPointsTransaction = false; + hasOnlineSettlementTransaction = false; + } + + public void collectDepartments() { + Set uniqueDepartments = new HashSet<>(); + if (bundles != null) { + for (IncomeBundle b : bundles) { + if (b.getDepartment() != null) { + uniqueDepartments.add(b.getDepartment()); + } + } + } + departments = new ArrayList<>(uniqueDepartments); + } + + public void aggregateTotalsFromAllChildBundles() { + resetTotals(); // Resets all totals before computation + + if (bundles != null) { + for (IncomeBundle childBundle : bundles) { + grossTotal += nullSafeDouble(childBundle.grossTotal); + discount += nullSafeDouble(childBundle.discount); + total += nullSafeDouble(childBundle.total); + hospitalTotal += nullSafeDouble(childBundle.hospitalTotal); + staffTotal += nullSafeDouble(childBundle.staffTotal); + ccTotal += nullSafeDouble(childBundle.ccTotal); + totalIn += nullSafeDouble(childBundle.totalIn); + totalOut += nullSafeDouble(childBundle.totalOut); + + // Increment counts + countIn += childBundle.countIn != null ? childBundle.countIn : 0; + countOut += childBundle.countOut != null ? childBundle.countOut : 0; + count += childBundle.count != null ? childBundle.count : 0; + + // Payment values + onCallValue += childBundle.onCallValue; + cashValue += childBundle.cashValue; + cardValue += childBundle.cardValue; + multiplePaymentMethodsValue += childBundle.multiplePaymentMethodsValue; + staffValue += childBundle.staffValue; + creditValue += childBundle.creditValue; + staffWelfareValue += childBundle.staffWelfareValue; + voucherValue += childBundle.voucherValue; + iouValue += childBundle.iouValue; + agentValue += childBundle.agentValue; + chequeValue += childBundle.chequeValue; + slipValue += childBundle.slipValue; + eWalletValue += childBundle.eWalletValue; + patientDepositValue += childBundle.patientDepositValue; + patientPointsValue += childBundle.patientPointsValue; + onlineSettlementValue += childBundle.onlineSettlementValue; + + onCallHandoverValue += childBundle.onCallHandoverValue; + cashHandoverValue += childBundle.cashHandoverValue; + cardHandoverValue += childBundle.cardHandoverValue; + multiplePaymentMethodsHandoverValue += childBundle.multiplePaymentMethodsHandoverValue; + staffHandoverValue += childBundle.staffHandoverValue; + creditHandoverValue += childBundle.creditHandoverValue; + staffWelfareHandoverValue += childBundle.staffWelfareHandoverValue; + voucherHandoverValue += childBundle.voucherHandoverValue; + iouHandoverValue += childBundle.iouHandoverValue; + agentHandoverValue += childBundle.agentHandoverValue; + chequeHandoverValue += childBundle.chequeHandoverValue; + slipHandoverValue += childBundle.slipHandoverValue; + eWalletHandoverValue += childBundle.eWalletHandoverValue; + patientDepositHandoverValue += childBundle.patientDepositHandoverValue; + patientPointsHandoverValue += childBundle.patientPointsHandoverValue; + onlineSettlementHandoverValue += childBundle.onlineSettlementHandoverValue; + + // Aggregate flags + hasOnCallTransaction |= childBundle.hasOnCallTransaction; + hasCashTransaction |= childBundle.hasCashTransaction; + hasCardTransaction |= childBundle.hasCardTransaction; + hasMultiplePaymentMethodsTransaction |= childBundle.hasMultiplePaymentMethodsTransaction; + hasStaffTransaction |= childBundle.hasStaffTransaction; + hasCreditTransaction |= childBundle.hasCreditTransaction; + hasStaffWelfareTransaction |= childBundle.hasStaffWelfareTransaction; + hasVoucherTransaction |= childBundle.hasVoucherTransaction; + hasIouTransaction |= childBundle.hasIouTransaction; + hasAgentTransaction |= childBundle.hasAgentTransaction; + hasChequeTransaction |= childBundle.hasChequeTransaction; + hasSlipTransaction |= childBundle.hasSlipTransaction; + hasEWalletTransaction |= childBundle.hasEWalletTransaction; + hasPatientDepositTransaction |= childBundle.hasPatientDepositTransaction; + hasPatientPointsTransaction |= childBundle.hasPatientPointsTransaction; + hasOnlineSettlementTransaction |= childBundle.hasOnlineSettlementTransaction; + } + } + } + + public IncomeBundle createBundleByAggregatingMonthlyTotalsFromBills() { + IncomeBundle newlyCreatedBundle = new IncomeBundle(); + Map monthlyTotalsMap = new HashMap<>(); + + for (IncomeRow row : this.getRows()) { + if (row.getBill() == null) { + continue; + } + + // Extract date and financial data from the bill + Date date = row.getBill().getCreatedAt(); + Double grossTotal = row.getBill().getTotal(); + Double tax = row.getBill().getTax(); + Double netTotal = row.getBill().getNetTotal(); + + // Convert Date to LocalDate to extract month and year + LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + int month = localDate.getMonthValue(); + int year = localDate.getYear(); + + // Create a unique key for each month-year combination + String key = year + "-" + month; + + // Retrieve or create the IncomeRow for the current month + IncomeRow monthRow = monthlyTotalsMap.get(key); + if (monthRow == null) { + monthRow = new IncomeRow(); + // Set the date to the first day of the month + LocalDate firstDayOfMonth = LocalDate.of(year, month, 1); + Date firstDayDate = Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()); + monthRow.setDate(firstDayDate); + monthRow.setTotal(0.0); + monthRow.setTax(0.0); + monthRow.setGrossTotal(0.0); + monthlyTotalsMap.put(key, monthRow); + } + + // Aggregate the totals + monthRow.setTotal(monthRow.getTotal() + netTotal); + monthRow.setTax(monthRow.getTax() + tax); + monthRow.setGrossTotal(monthRow.getGrossTotal() + grossTotal); + } + + // Collect the aggregated monthly totals into a list + List monthlyTotalRows = new ArrayList<>(monthlyTotalsMap.values()); + monthlyTotalRows.sort(Comparator.comparing(IncomeRow::getDate)); + newlyCreatedBundle.setRows(monthlyTotalRows); + return newlyCreatedBundle; + } + + public IncomeBundle createBundleByAggregatingConsultantTotalsFromBills() { + IncomeBundle newlyCreatedBundle = new IncomeBundle(); + Map staffTotalsMap = new HashMap<>(); + + for (IncomeRow row : this.getRows()) { + if (row.getBill() == null) { + continue; + } + + // Extract financial data from the bill + Double grossTotal = row.getBill().getTotal(); + Double tax = row.getBill().getTax(); + Double netTotal = row.getBill().getNetTotal(); + Staff staff = row.getBill().getStaff(); + + if (staff == null) { + continue; // Skip if no staff assigned + } + + Long staffId = staff.getId(); + + // Retrieve or create the IncomeRow for the current staff + IncomeRow staffRow = staffTotalsMap.get(staffId); + if (staffRow == null) { + staffRow = new IncomeRow(); + staffRow.setStaff(staff); + staffRow.setTotal(0.0); + staffRow.setTax(0.0); + staffRow.setGrossTotal(0.0); + staffTotalsMap.put(staffId, staffRow); + } + + // Aggregate the totals + staffRow.setTotal(staffRow.getTotal() + netTotal); + staffRow.setTax(staffRow.getTax() + tax); + staffRow.setGrossTotal(staffRow.getGrossTotal() + grossTotal); + } + + // Collect the aggregated staff totals into a list + List staffTotalRows = new ArrayList<>(staffTotalsMap.values()); + // Sort the list by staff name + Collections.sort(staffTotalRows, new Comparator() { + public int compare(IncomeRow r1, IncomeRow r2) { + return r1.getStaff().getPerson().getName().compareTo(r2.getStaff().getPerson().getName()); + } + }); + newlyCreatedBundle.setRows(staffTotalRows); + return newlyCreatedBundle; + } + + public void aggregateTotalsFromSelectedChildBundles() { + resetTotals(); // Resets all totals before computation + + if (bundles != null) { + for (IncomeBundle childBundle : bundles) { + if (childBundle.isSelected()) { + grossTotal += nullSafeDouble(childBundle.grossTotal); + discount += nullSafeDouble(childBundle.discount); + total += nullSafeDouble(childBundle.total); + hospitalTotal += nullSafeDouble(childBundle.hospitalTotal); + staffTotal += nullSafeDouble(childBundle.staffTotal); + ccTotal += nullSafeDouble(childBundle.ccTotal); + totalIn += nullSafeDouble(childBundle.totalIn); + totalOut += nullSafeDouble(childBundle.totalOut); + + // Increment counts + countIn += childBundle.countIn != null ? childBundle.countIn : 0; + countOut += childBundle.countOut != null ? childBundle.countOut : 0; + count += childBundle.count != null ? childBundle.count : 0; + + // Payment values + onCallValue += childBundle.onCallValue; + cashValue += childBundle.cashValue; + cardValue += childBundle.cardValue; + multiplePaymentMethodsValue += childBundle.multiplePaymentMethodsValue; + staffValue += childBundle.staffValue; + creditValue += childBundle.creditValue; + staffWelfareValue += childBundle.staffWelfareValue; + voucherValue += childBundle.voucherValue; + iouValue += childBundle.iouValue; + agentValue += childBundle.agentValue; + chequeValue += childBundle.chequeValue; + slipValue += childBundle.slipValue; + eWalletValue += childBundle.eWalletValue; + patientDepositValue += childBundle.patientDepositValue; + patientPointsValue += childBundle.patientPointsValue; + onlineSettlementValue += childBundle.onlineSettlementValue; + + // Handover values + onCallHandoverValue += childBundle.onCallHandoverValue; + cashHandoverValue += childBundle.cashHandoverValue; + cardHandoverValue += childBundle.cardHandoverValue; + multiplePaymentMethodsHandoverValue += childBundle.multiplePaymentMethodsHandoverValue; + staffHandoverValue += childBundle.staffHandoverValue; + creditHandoverValue += childBundle.creditHandoverValue; + staffWelfareHandoverValue += childBundle.staffWelfareHandoverValue; + voucherHandoverValue += childBundle.voucherHandoverValue; + iouHandoverValue += childBundle.iouHandoverValue; + agentHandoverValue += childBundle.agentHandoverValue; + chequeHandoverValue += childBundle.chequeHandoverValue; + slipHandoverValue += childBundle.slipHandoverValue; + eWalletHandoverValue += childBundle.eWalletHandoverValue; + patientDepositHandoverValue += childBundle.patientDepositHandoverValue; + patientPointsHandoverValue += childBundle.patientPointsHandoverValue; + onlineSettlementHandoverValue += childBundle.onlineSettlementHandoverValue; + } + + // Aggregate flags + hasOnCallTransaction |= childBundle.hasOnCallTransaction; + hasCashTransaction |= childBundle.hasCashTransaction; + hasCardTransaction |= childBundle.hasCardTransaction; + hasMultiplePaymentMethodsTransaction |= childBundle.hasMultiplePaymentMethodsTransaction; + hasStaffTransaction |= childBundle.hasStaffTransaction; + hasCreditTransaction |= childBundle.hasCreditTransaction; + hasStaffWelfareTransaction |= childBundle.hasStaffWelfareTransaction; + hasVoucherTransaction |= childBundle.hasVoucherTransaction; + hasIouTransaction |= childBundle.hasIouTransaction; + hasAgentTransaction |= childBundle.hasAgentTransaction; + hasChequeTransaction |= childBundle.hasChequeTransaction; + hasSlipTransaction |= childBundle.hasSlipTransaction; + hasEWalletTransaction |= childBundle.hasEWalletTransaction; + hasPatientDepositTransaction |= childBundle.hasPatientDepositTransaction; + hasPatientPointsTransaction |= childBundle.hasPatientPointsTransaction; + hasOnlineSettlementTransaction |= childBundle.hasOnlineSettlementTransaction; + } + } + } + + public Double getPaymentValue(PaymentMethod pm) { + switch (pm) { + case Agent: + return agentValue; + case Card: + return cardValue; + case Cash: +// if (denominationTransactions == null) { +// denominationTransactions = createDefaultDenominationTransaction(PaymentMethod.Cash); +// } + return cashValue; + case Cheque: + return chequeValue; + case Credit: + return creditValue; + case IOU: + return iouValue; + case MultiplePaymentMethods: + return multiplePaymentMethodsValue; + case OnlineSettlement: + return onlineSettlementValue; + case PatientDeposit: + return patientDepositValue; + case PatientPoints: + return patientPointsValue; + case Slip: + return slipValue; + case Staff: + return staffValue; + case Staff_Welfare: + return staffWelfareValue; + case Voucher: + return voucherValue; + case YouOweMe: + return iouValue; // Assuming YouOweMe is equivalent to IOU + case ewallet: + return eWalletValue; + default: + return null; + } + } + + public Double getPaymentHandoverValue(PaymentMethod pm) { + switch (pm) { + case Agent: + return agentHandoverValue; + case Card: + return cardHandoverValue; + case Cash: + return cashHandoverValue; +// return denominatorValue; + case Cheque: + return chequeHandoverValue; + case Credit: + return creditHandoverValue; + case IOU: + return iouHandoverValue; + case MultiplePaymentMethods: + return multiplePaymentMethodsHandoverValue; + case OnlineSettlement: + return onlineSettlementHandoverValue; + case PatientDeposit: + return patientDepositHandoverValue; + case PatientPoints: + return patientPointsHandoverValue; + case Slip: + return slipHandoverValue; + case Staff: + return staffHandoverValue; + case Staff_Welfare: + return staffWelfareHandoverValue; + case Voucher: + return voucherHandoverValue; + case YouOweMe: + return iouHandoverValue; // Assuming YouOweMe is equivalent to IOU + case ewallet: + return eWalletHandoverValue; + default: + return null; + } + } + + public List getPaymentRows(PaymentMethod pm) { + List prows = new ArrayList<>(); + if (rows == null) { + return prows; + } + if (rows.isEmpty()) { + return prows; + } + for (IncomeRow r : rows) { + if (r.getPayment() == null) { + continue; + } + if (r.getPayment().getPaymentMethod() == null) { + continue; + } + if (r.getPayment().getPaymentMethod() == pm) { + prows.add(r); + } + } + prows.sort(Comparator.comparing(r -> r.getPayment().getId())); + return prows; + } + + public UUID getId() { + if (id == null) { + id = UUID.randomUUID(); + } + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IncomeBundle that = (IncomeBundle) o; + return Objects.equals(getId(), that.id); + } + + // Override hashCode() using UUID field + @Override + public int hashCode() { + return Objects.hash(getId()); + } + + // Override toString() for better readability (optional) + @Override + public String toString() { + return "ReportTemplateRowBundle{id=" + getId() + '}'; + } + + public void calculateTotalsForProfessionalFees() { + System.out.println("calculateTotals = "); + this.total = 0.0; + this.totalIn = 0.0; + this.totalOut = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBillFee() == null) { + continue; + } +// if (row.getBillFee().getBill().isCancelled()) { +// continue; +// } +// if (row.getBillFee().getBillItem().isRefunded()) { +// continue; +// } +// //TODO: Remove +// if (row.getBillFee().getBill().isRefunded()) { +// continue; +// } + this.total += row.getBillFee().getFeeValue(); + this.totalIn += row.getBillFee().getSettleValue(); + this.totalOut += row.getBillFee().getPaidValue(); + } + } + } + + public void calculateTotalByValues() { + total = 0.0; + grossTotal = 0.0; + discount = 0.0; + count = 0l; + for (IncomeRow r : getRows()) { + grossTotal += r.getGrossTotal(); + discount += r.getDiscount(); + total += r.getTotal(); + count += r.getRowCount(); + } + } + + public void calculateTotalsForAllPaymentMethods() { + System.out.println("calculateTotals = "); + resetTotalsAndFlags(); + + // Check if the list of rows is not null and not empty + if (this.rows != null && !this.rows.isEmpty()) { + // Aggregate values from each row and update transaction flags + for (IncomeRow row : this.rows) { + addValueAndUpdateFlag("cash", safeDouble(row.getCashValue())); + addValueAndUpdateFlag("card", safeDouble(row.getCardValue())); + addValueAndUpdateFlag("multiplePaymentMethods", safeDouble(row.getMultiplePaymentMethodsValue())); + addValueAndUpdateFlag("staff", safeDouble(row.getStaffValue())); + addValueAndUpdateFlag("credit", safeDouble(row.getCreditValue())); + addValueAndUpdateFlag("staffWelfare", safeDouble(row.getStaffWelfareValue())); + addValueAndUpdateFlag("voucher", safeDouble(row.getVoucherValue())); + addValueAndUpdateFlag("iou", safeDouble(row.getIouValue())); + addValueAndUpdateFlag("agent", safeDouble(row.getAgentValue())); + addValueAndUpdateFlag("cheque", safeDouble(row.getChequeValue())); + addValueAndUpdateFlag("slip", safeDouble(row.getSlipValue())); + addValueAndUpdateFlag("eWallet", safeDouble(row.getEwalletValue())); + addValueAndUpdateFlag("patientDeposit", safeDouble(row.getPatientDepositValue())); + addValueAndUpdateFlag("patientPoints", safeDouble(row.getPatientPointsValue())); + addValueAndUpdateFlag("onlineSettlement", safeDouble(row.getOnlineSettlementValue())); + addValueAndUpdateFlag("grossTotal", safeDouble(row.getGrossTotal())); + addValueAndUpdateFlag("discount", safeDouble(row.getDiscount())); + addValueAndUpdateFlag("total", safeDouble(row.getTotal())); + addValueAndUpdateFlag("hospitalTotal", safeDouble(row.getHospitalTotal())); + addValueAndUpdateFlag("staffTotal", safeDouble(row.getStaffTotal())); + addValueAndUpdateFlag("ccTotal", safeDouble(row.getCcTotal())); + } + } + total + = this.cashValue + this.cardValue + this.multiplePaymentMethodsValue + this.staffValue + + this.creditValue + this.staffWelfareValue + this.voucherValue + this.iouValue + + this.agentValue + this.chequeValue + this.slipValue + this.eWalletValue + + this.patientDepositValue + this.patientPointsValue + this.onlineSettlementValue; + + } + + public void calculateTotals() { + System.out.println("calculateTotals = "); + resetTotalsAndFlags(); + + // Check if the list of rows is not null and not empty + if (this.rows != null && !this.rows.isEmpty()) { + // Aggregate values from each row and update transaction flags + for (IncomeRow row : this.rows) { + addValueAndUpdateFlag("cash", safeDouble(row.getCashValue())); + addValueAndUpdateFlag("card", safeDouble(row.getCardValue())); + addValueAndUpdateFlag("multiplePaymentMethods", safeDouble(row.getMultiplePaymentMethodsValue())); + addValueAndUpdateFlag("staff", safeDouble(row.getStaffValue())); + addValueAndUpdateFlag("credit", safeDouble(row.getCreditValue())); + addValueAndUpdateFlag("staffWelfare", safeDouble(row.getStaffWelfareValue())); + addValueAndUpdateFlag("voucher", safeDouble(row.getVoucherValue())); + addValueAndUpdateFlag("iou", safeDouble(row.getIouValue())); + addValueAndUpdateFlag("agent", safeDouble(row.getAgentValue())); + addValueAndUpdateFlag("cheque", safeDouble(row.getChequeValue())); + addValueAndUpdateFlag("slip", safeDouble(row.getSlipValue())); + addValueAndUpdateFlag("eWallet", safeDouble(row.getEwalletValue())); + addValueAndUpdateFlag("patientDeposit", safeDouble(row.getPatientDepositValue())); + addValueAndUpdateFlag("patientPoints", safeDouble(row.getPatientPointsValue())); + addValueAndUpdateFlag("onlineSettlement", safeDouble(row.getOnlineSettlementValue())); + addValueAndUpdateFlag("grossTotal", safeDouble(row.getGrossTotal())); + addValueAndUpdateFlag("discount", safeDouble(row.getDiscount())); + addValueAndUpdateFlag("total", safeDouble(row.getTotal())); + addValueAndUpdateFlag("hospitalTotal", safeDouble(row.getHospitalTotal())); + addValueAndUpdateFlag("staffTotal", safeDouble(row.getStaffTotal())); + addValueAndUpdateFlag("ccTotal", safeDouble(row.getCcTotal())); + } + } + total + = this.cashValue + this.cardValue + this.voucherValue + this.iouValue + this.patientDepositValue + + this.chequeValue + this.slipValue + this.eWalletValue; + + } + + public void calculateTotalsWithCredit() { + System.out.println("calculateTotals = "); + resetTotalsAndFlags(); + + // Check if the list of rows is not null and not empty + if (this.rows != null && !this.rows.isEmpty()) { + // Aggregate values from each row and update transaction flags + for (IncomeRow row : this.rows) { + addValueAndUpdateFlag("cash", safeDouble(row.getCashValue())); + addValueAndUpdateFlag("card", safeDouble(row.getCardValue())); + addValueAndUpdateFlag("multiplePaymentMethods", safeDouble(row.getMultiplePaymentMethodsValue())); + addValueAndUpdateFlag("staff", safeDouble(row.getStaffValue())); + addValueAndUpdateFlag("credit", safeDouble(row.getCreditValue())); + addValueAndUpdateFlag("staffWelfare", safeDouble(row.getStaffWelfareValue())); + addValueAndUpdateFlag("voucher", safeDouble(row.getVoucherValue())); + addValueAndUpdateFlag("iou", safeDouble(row.getIouValue())); + addValueAndUpdateFlag("agent", safeDouble(row.getAgentValue())); + addValueAndUpdateFlag("cheque", safeDouble(row.getChequeValue())); + addValueAndUpdateFlag("slip", safeDouble(row.getSlipValue())); + addValueAndUpdateFlag("eWallet", safeDouble(row.getEwalletValue())); + addValueAndUpdateFlag("patientDeposit", safeDouble(row.getPatientDepositValue())); + addValueAndUpdateFlag("patientPoints", safeDouble(row.getPatientPointsValue())); + addValueAndUpdateFlag("onlineSettlement", safeDouble(row.getOnlineSettlementValue())); + addValueAndUpdateFlag("grossTotal", safeDouble(row.getGrossTotal())); + addValueAndUpdateFlag("discount", safeDouble(row.getDiscount())); + addValueAndUpdateFlag("total", safeDouble(row.getTotal())); + addValueAndUpdateFlag("hospitalTotal", safeDouble(row.getHospitalTotal())); + addValueAndUpdateFlag("staffTotal", safeDouble(row.getStaffTotal())); + addValueAndUpdateFlag("ccTotal", safeDouble(row.getCcTotal())); + } + } + total + = this.cashValue + + this.cardValue + + this.voucherValue + + this.iouValue + // + this.patientDepositValue + + this.chequeValue + + this.slipValue + + this.creditValue + + this.eWalletValue; + + } + + public void calculateTotalsBySelectedChildBundles() { + calculateTotalsByChildBundles(); + } + + public void calculateTotalsByAllChildBundles() { + calculateTotalsByChildBundles(); + } + + public void calculateTotalsByChildBundles() { + resetTotalsAndFlags(); + + if (this.bundles != null && !this.bundles.isEmpty()) { + for (IncomeBundle childBundle : this.bundles) { + + if (childBundle.isSelected()) { + + System.out.println("selected childBundle = " + childBundle.getName()); + addValueAndUpdateFlag("cash", safeDouble(childBundle.getCashValue()), safeDouble(childBundle.getCashHandoverValue())); + addValueAndUpdateFlag("card", safeDouble(childBundle.getCardValue()), safeDouble(childBundle.getCardHandoverValue())); + addValueAndUpdateFlag("multiplePaymentMethods", safeDouble(childBundle.getMultiplePaymentMethodsValue()), safeDouble(childBundle.getMultiplePaymentMethodsHandoverValue())); + addValueAndUpdateFlag("staff", safeDouble(childBundle.getStaffValue()), safeDouble(childBundle.getStaffHandoverValue())); + addValueAndUpdateFlag("credit", safeDouble(childBundle.getCreditValue()), safeDouble(childBundle.getCreditHandoverValue())); + addValueAndUpdateFlag("staffWelfare", safeDouble(childBundle.getStaffWelfareValue()), safeDouble(childBundle.getStaffWelfareHandoverValue())); + addValueAndUpdateFlag("voucher", safeDouble(childBundle.getVoucherValue()), safeDouble(childBundle.getVoucherHandoverValue())); + addValueAndUpdateFlag("iou", safeDouble(childBundle.getIouValue()), safeDouble(childBundle.getIouHandoverValue())); + addValueAndUpdateFlag("agent", safeDouble(childBundle.getAgentValue()), safeDouble(childBundle.getAgentHandoverValue())); + addValueAndUpdateFlag("cheque", safeDouble(childBundle.getChequeValue()), safeDouble(childBundle.getChequeHandoverValue())); + addValueAndUpdateFlag("slip", safeDouble(childBundle.getSlipValue()), safeDouble(childBundle.getSlipHandoverValue())); + addValueAndUpdateFlag("eWallet", safeDouble(childBundle.getEwalletValue()), safeDouble(childBundle.getEwalletHandoverValue())); + addValueAndUpdateFlag("patientDeposit", safeDouble(childBundle.getPatientDepositValue()), safeDouble(childBundle.getPatientDepositHandoverValue())); + addValueAndUpdateFlag("patientPoints", safeDouble(childBundle.getPatientPointsValue()), safeDouble(childBundle.getPatientPointsHandoverValue())); + addValueAndUpdateFlag("onlineSettlement", safeDouble(childBundle.getOnlineSettlementValue()), safeDouble(childBundle.getOnlineSettlementHandoverValue())); + addValueAndUpdateFlag("grossTotal", safeDouble(childBundle.getGrossTotal())); + addValueAndUpdateFlag("discount", safeDouble(childBundle.getDiscount())); + + addValueAndUpdateFlag("hospitalTotal", safeDouble(childBundle.getHospitalTotal())); + addValueAndUpdateFlag("staffTotal", safeDouble(childBundle.getStaffTotal())); + addValueAndUpdateFlag("ccTotal", safeDouble(childBundle.getCcTotal())); + + System.out.println("childBundle.getTotal() = " + childBundle.getTotal()); + + System.out.println("total Before= " + total); + + addValueAndUpdateFlag("total", safeDouble(childBundle.getTotal())); + + System.out.println("total After= " + total); + } + } + } + } + + public void calculateTotalsBySelectedPayments() { + resetTotalsAndFlags(); + + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getPayment() == null || row.getPayment().getPaymentMethod() == null) { + continue; + } + + Double amount = safeDouble(row.getPayment().getPaidValue()); // Ensure amounts are not null + Double amountHandingOver = 0.0; + + if (row.isSelected()) { + amountHandingOver = amount; + } + + PaymentMethod method = row.getPayment().getPaymentMethod(); // Using the enum type directly + total += amount; + + switch (method) { + case Agent: + this.agentValue += amount; + this.agentHandoverValue += amountHandingOver; + this.hasAgentTransaction = true; + break; + case Card: + this.cardValue += amount; + this.cardHandoverValue += amountHandingOver; + this.hasCardTransaction = true; + break; + case Cash: +// if (denominationTransactions == null) { +// denominationTransactions = createDefaultDenominationTransaction(PaymentMethod.Cash); +// } + this.cashValue += amount; + this.cashHandoverValue += amountHandingOver; + this.hasCashTransaction = true; + break; + case Cheque: + this.chequeValue += amount; + this.chequeHandoverValue += amountHandingOver; + this.hasChequeTransaction = true; + break; + case Credit: + this.creditValue += amount; + this.creditHandoverValue += amountHandingOver; + this.hasCreditTransaction = true; + break; + case IOU: + this.iouValue += amount; + this.iouHandoverValue += amountHandingOver; + this.hasIouTransaction = true; + break; + case MultiplePaymentMethods: + this.multiplePaymentMethodsValue += amount; + this.multiplePaymentMethodsHandoverValue += amountHandingOver; + this.hasMultiplePaymentMethodsTransaction = true; + break; + case OnlineSettlement: + this.onlineSettlementValue += amount; + this.onlineSettlementHandoverValue += amountHandingOver; + this.hasOnlineSettlementTransaction = true; + break; + case PatientDeposit: + this.patientDepositValue += amount; + this.patientDepositHandoverValue += amountHandingOver; + this.hasPatientDepositTransaction = true; + break; + case PatientPoints: + this.patientPointsValue += amount; + this.patientPointsHandoverValue += amountHandingOver; + this.hasPatientPointsTransaction = true; + break; + case Slip: + this.slipValue += amount; + this.slipHandoverValue += amountHandingOver; + this.hasSlipTransaction = true; + break; + case Staff: + this.staffValue += amount; + this.staffHandoverValue += amountHandingOver; + this.hasStaffTransaction = true; + break; + case Staff_Welfare: + this.staffWelfareValue += amount; + this.staffWelfareHandoverValue += amountHandingOver; + this.hasStaffWelfareTransaction = true; + break; + case Voucher: + this.voucherValue += amount; + this.voucherHandoverValue += amountHandingOver; + this.hasVoucherTransaction = true; + break; + case YouOweMe: + this.iouValue += amount; // Assuming YouOweMe is equivalent to IOU + this.iouHandoverValue += amountHandingOver; + this.hasIouTransaction = true; + break; + case ewallet: + this.eWalletValue += amount; + this.eWalletHandoverValue += amountHandingOver; + this.hasEWalletTransaction = true; + break; + default: + break; + } + } + } + } + + public void calculateTotalByBills() { + total = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBill() == null) { + continue; + } + Double amount = safeDouble(row.getBill().getNetTotal()); + total += amount; + } + } + } + + public void calculateTotalByBills(final boolean isOutpatient) { + total = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBill() == null) { + continue; + } + Double amount = safeDouble(isOutpatient ? row.getBill().getNetTotal() : row.getBill().getPatientEncounter().getFinalBill().getNetTotal()); + total += amount; + } + } + } + + public void calculateTotalByReferenceBills(final boolean isOutpatient) { + total = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBillItem() == null) { + continue; + } + Double amount = safeDouble(isOutpatient ? row.getBillItem().getReferenceBill().getNetTotal() + : row.getBillItem().getPatientEncounter().getFinalBill().getNetTotal()); + total += amount; + } + } + } + + public void calculateTotalSettledAmountByPatients(final boolean isOutpatient) { + settledAmountByPatientsTotal = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBill() == null) { + continue; + } + Double amount = safeDouble(isOutpatient ? row.getBill().getSettledAmountByPatient() : row.getBill().getPatientEncounter().getFinalBill().getSettledAmountByPatient()); + settledAmountByPatientsTotal += amount; + } + } + } + + public void calculateTotalSettledAmountBySponsors(final boolean isOutpatient) { + settledAmountBySponsorsTotal = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBill() == null) { + continue; + } + Double amount = safeDouble(isOutpatient ? row.getBill().getSettledAmountBySponsor() : row.getBill().getPatientEncounter().getFinalBill().getSettledAmountBySponsor()); + settledAmountBySponsorsTotal += amount; + } + } + } + + public void calculateTotalBalance(final boolean isOutpatient) { + totalBalance = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBill() == null) { + continue; + } + Double amount = safeDouble(isOutpatient ? row.getBill().getBalance() : row.getBill().getPatientEncounter().getFinalBill().getBalance()); + totalBalance += amount; + } + } + } + + public void calculateTotalByHospitalFee() { + total = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBill() == null) { + continue; + } + Double amount = safeDouble(row.getBill().getTotalHospitalFee()); + total += amount; + } + } + } + + public void calculateTotalCCFee() { + ccTotal = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBill() == null) { + continue; + } + Double amount = safeDouble(row.getBill().getTotalCenterFee()); + ccTotal += amount; + } + } + } + + public void calculateTotalByBillItems() { + total = 0.0; + + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBillItem() == null) { + continue; + } + Double amount = safeDouble(row.getBillItem().getBill().getNetTotal()); + total += amount; + } + } + } + + public void calculateTotalByBillItemsNetTotal() { + total = 0.0; + + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBillItem() == null) { + continue; + } + Double amount = safeDouble(row.getBillItem().getNetValue()); + total += amount; + } + } + } + + public void calculateTotalHospitalFeeByBillItems() { + hospitalTotal = 0.0; + + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBillItem() == null) { + continue; + } + Double amount = safeDouble(row.getBillItem().getBill().getTotalHospitalFee()); + hospitalTotal += amount; + } + } + } + + public void calculateTotalStaffFeeByBillItems() { + staffTotal = 0.0; + + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBillItem() == null) { + continue; + } + Double amount = safeDouble(row.getBillItem().getBill().getTotalStaffFee()); + staffTotal += amount; + } + } + } + + public void calculateTotalByRowTotals() { + total = 0.0; // Ensure all counters are reset before starting calculations + grossTotal = 0.0; + discount = 0.0; + tax = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row != null) { + Double iteratingTotal = safeDouble(row.getGrossTotal()); + grossTotal += iteratingTotal; + + Double iteratingDiscount = safeDouble(row.getDiscount()); + discount += iteratingDiscount; + + Double iteratingTax = safeDouble(row.getTax()); + tax += iteratingTax; + + Double iteratingNetTotal = safeDouble(row.getTotal()); // assuming you meant to use getTotal here as well for the net total calculation + total += iteratingNetTotal; + } + } + } + } + + public void calculateTotalNetTotalTaxByBills() { + total = 0.0; + grossTotal = 0.0; + tax = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getBill() == null) { + continue; + } + Double billTotal = safeDouble(row.getBill().getNetTotal()); + Double billGrossTotal = safeDouble(row.getBill().getTotal()); + Double billTax = safeDouble(row.getBill().getTax()); + total += billTotal; + grossTotal += billGrossTotal; + tax += billTax; + } + } + } + + public void calculateTotalByPayments() { + total = 0.0; + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getPayment() == null) { + continue; + } + Double amount = safeDouble(row.getPayment().getPaidValue()); + total += amount; + } + } + } + + public void markAllAtHandover(PaymentMethod inputPaymentMethod) { + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getPayment() == null || row.getPayment().getPaymentMethod() == null) { + continue; + } + if (row.getPayment().getPaymentMethod() == inputPaymentMethod) { + row.getPayment().setSelectedForHandover(true); + row.setSelected(row.getPayment().isSelectedForHandover()); + } + } + } + } + + public void unmarkAllAtHandover() { + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getPayment() != null && row.getPayment().isSelectedForHandover()) { + row.getPayment().setSelectedForHandover(false); + row.setSelected(false); + } + } + } + } + + public void markSelectedAtHandover() { + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getPayment() == null || row.getPayment().getPaymentMethod() == null) { + continue; + } + row.setSelected(row.getPayment().isSelectedForHandover()); + } + } + } + + public void markSelectedAtHandoverAccept() { + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getPayment() == null || row.getPayment().getPaymentMethod() == null) { + continue; + } + row.setSelected(row.getPayment().isSelectedForCashbookEntry()); + } + } + } + + public void markSelectedAtRecordCreation() { + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getPayment() == null || row.getPayment().getPaymentMethod() == null) { + continue; + } + row.setSelected(row.getPayment().isSelectedForRecording()); + } + } + } + + public void markSelectedAtRecordConfirmation() { + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getPayment() == null || row.getPayment().getPaymentMethod() == null) { + continue; + } + row.setSelected(row.getPayment().isSelectedForRecordingConfirmation()); + } + } + } + + public void calculateTotalsOfSelectedRowsPlusAllCashForHandover(boolean patientDepositsAreConsideredInHandingover) { + System.out.println("calculateTotalsOfSelectedRowsPlusAllCashForHandover"); + resetTotalsAndFlags(); + + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + if (row.getPayment() == null || row.getPayment().getPaymentMethod() == null) { + continue; + } + + Double amount = safeDouble(row.getPayment().getPaidValue()); // Ensure amounts are not null + Double amountHandingOver = 0.0; + + PaymentMethod method = row.getPayment().getPaymentMethod(); + + if (row.isSelected()) { + amountHandingOver = amount; + } else { + if (method == Cash && getSelectAllCashToHandover()) { + amountHandingOver = amount; + } + } + + switch (method) { + case Agent: + this.agentValue += amount; + this.agentHandoverValue += amountHandingOver; + this.hasAgentTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case Card: + this.cardValue += amount; + this.cardHandoverValue += amountHandingOver; + this.hasCardTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case Cash: + this.cashValue += amount; + this.cashHandoverValue += amountHandingOver; + this.hasCashTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case Cheque: + this.chequeValue += amount; + this.chequeHandoverValue += amountHandingOver; + this.hasChequeTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case Credit: + this.creditValue += amount; + this.creditHandoverValue += amountHandingOver; + this.hasCreditTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case IOU: + this.iouValue += amount; + this.iouHandoverValue += amountHandingOver; + this.hasIouTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case MultiplePaymentMethods: + this.multiplePaymentMethodsValue += amount; + this.multiplePaymentMethodsHandoverValue += amountHandingOver; + this.hasMultiplePaymentMethodsTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case OnlineSettlement: + this.onlineSettlementValue += amount; + this.onlineSettlementHandoverValue += amountHandingOver; + this.hasOnlineSettlementTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case PatientDeposit: + if (patientDepositsAreConsideredInHandingover) { + this.patientDepositValue += amount; + this.patientDepositHandoverValue += amountHandingOver; + this.hasPatientDepositTransaction = true; + total += amount; + totalOut += amountHandingOver; + } + break; + case PatientPoints: + this.patientPointsValue += amount; + this.patientPointsHandoverValue += amountHandingOver; + this.hasPatientPointsTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case Slip: + this.slipValue += amount; + this.slipHandoverValue += amountHandingOver; + this.hasSlipTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case Staff: + this.staffValue += amount; + this.staffHandoverValue += amountHandingOver; + this.hasStaffTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case Staff_Welfare: + this.staffWelfareValue += amount; + this.staffWelfareHandoverValue += amountHandingOver; + this.hasStaffWelfareTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case Voucher: + this.voucherValue += amount; + this.voucherHandoverValue += amountHandingOver; + this.hasVoucherTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case YouOweMe: + this.iouValue += amount; // Assuming YouOweMe is equivalent to IOU + this.iouHandoverValue += amountHandingOver; + this.hasIouTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + case ewallet: + this.eWalletValue += amount; + this.eWalletHandoverValue += amountHandingOver; + this.hasEWalletTransaction = true; + total += amount; + totalOut += amountHandingOver; + break; + default: + + break; + } + } + } + } + + public void createRowValuesFromBill() { + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + System.out.println("Processing row: " + row); + System.out.println("row.getBill() = " + row.getBill()); + + if (row.getBill() == null) { + System.out.println("Skipping row, as bill is null."); + continue; + } + + // Debugging bill details + System.out.println("row.getBill().getGrantTotal() = " + row.getBill().getGrantTotal()); + System.out.println("row.getBill().getDiscount() = " + row.getBill().getDiscount()); + System.out.println("row.getBill().getNetTotal() = " + row.getBill().getNetTotal()); + System.out.println("row.getBill().getTotalStaffFee() = " + row.getBill().getTotalStaffFee()); + System.out.println("row.getBill().getTotalCenterFee() = " + row.getBill().getTotalCenterFee()); + System.out.println("row.getHospitalTotal() = " + row.getHospitalTotal()); + + // Setting values + row.setGrossTotal(row.getBill().getGrantTotal()); + row.setDiscount(row.getBill().getDiscount()); + row.setTotal(row.getBill().getNetTotal()); + row.setHospitalTotal(row.getHospitalTotal()); + row.setStaffTotal(row.getBill().getTotalStaffFee()); + row.setCcTotal(row.getBill().getTotalCenterFee()); + + // Debugging after setting + System.out.println("row.getGrossTotal() = " + row.getGrossTotal()); + System.out.println("row.getDiscount() = " + row.getDiscount()); + System.out.println("row.getTotal() = " + row.getTotal()); + System.out.println("row.getHospitalTotal() = " + row.getHospitalTotal()); + System.out.println("row.getStaffTotal() = " + row.getStaffTotal()); + System.out.println("row.getCcTotal() = " + row.getCcTotal()); + } + } else { + System.out.println("No reportTemplateRows to process."); + } + } + + public void createRowValuesFromBillItems() { + if (this.rows != null && !this.rows.isEmpty()) { + for (IncomeRow row : this.rows) { + System.out.println("Processing row: " + row); + System.out.println("row.getBill() = " + row.getBill()); + + if (row.getBillItem() == null) { + System.out.println("Skipping row, as bill is null."); + continue; + } + + // Setting values + row.setGrossTotal(row.getBillItem().getGrossValue()); + row.setDiscount(row.getBillItem().getDiscount()); + row.setTotal(row.getBillItem().getNetValue()); + row.setHospitalTotal(row.getHospitalTotal()); + row.setStaffTotal(row.getBillItem().getStaffFee()); + row.setCcTotal(row.getBillItem().getCollectingCentreFee()); + + // Debugging after setting + System.out.println("row.getGrossTotal() = " + row.getGrossTotal()); + System.out.println("row.getDiscount() = " + row.getDiscount()); + System.out.println("row.getTotal() = " + row.getTotal()); + System.out.println("row.getHospitalTotal() = " + row.getHospitalTotal()); + System.out.println("row.getStaffTotal() = " + row.getStaffTotal()); + System.out.println("row.getCcTotal() = " + row.getCcTotal()); + } + } else { + System.out.println("No reportTemplateRows to process."); + } + } + + public Map> getGroupedBillItems() { + return groupedBillItems; + } + + public void setGroupedBillItems(Map> groupedBillItems) { + this.groupedBillItems = groupedBillItems; + } + + public Map> getGroupedBillItemsByInstitution() { + return groupedBillItemsByInstitution; + } + + public void setGroupedBillItemsByInstitution(Map> groupedBillItemsByInstitution) { + this.groupedBillItemsByInstitution = groupedBillItemsByInstitution; + } + + private void resetTotalsAndFlags() { + this.cashValue = this.cardValue = this.multiplePaymentMethodsValue = this.staffValue + = this.creditValue = this.staffWelfareValue = this.voucherValue = this.iouValue + = this.agentValue = this.chequeValue = this.slipValue = this.eWalletValue + = this.patientDepositValue = this.patientPointsValue = this.onlineSettlementValue + = this.grossTotal = this.discount = this.total = this.totalIn = this.totalOut + = this.hospitalTotal = this.staffTotal = this.ccTotal = 0.0; + + // Reset handover values + this.cashHandoverValue = this.cardHandoverValue = this.multiplePaymentMethodsHandoverValue = this.staffHandoverValue + = this.creditHandoverValue = this.staffWelfareHandoverValue = this.voucherHandoverValue = this.iouHandoverValue + = this.agentHandoverValue = this.chequeHandoverValue = this.slipHandoverValue = this.eWalletHandoverValue + = this.patientDepositHandoverValue = this.patientPointsHandoverValue = this.onlineSettlementHandoverValue + = this.onCallHandoverValue = 0.0; + + this.hasCashTransaction = this.hasCardTransaction = this.hasMultiplePaymentMethodsTransaction = this.hasStaffTransaction + = this.hasCreditTransaction = this.hasStaffWelfareTransaction = this.hasVoucherTransaction = this.hasIouTransaction + = this.hasAgentTransaction = this.hasChequeTransaction = this.hasSlipTransaction = this.hasEWalletTransaction + = this.hasPatientDepositTransaction = this.hasPatientPointsTransaction = this.hasOnlineSettlementTransaction = false; + } + + private void addValueAndUpdateFlag(String calculationAttribute, double amount) { + if (amount != 0) { + switch (calculationAttribute) { + case "cash": + this.cashValue += amount; + this.hasCashTransaction = true; + break; + case "card": + this.cardValue += amount; + this.hasCardTransaction = true; + break; + case "multiplePaymentMethods": + this.multiplePaymentMethodsValue += amount; + this.hasMultiplePaymentMethodsTransaction = true; + break; + case "staff": + this.staffValue += amount; + this.hasStaffTransaction = true; + break; + case "credit": + this.creditValue += amount; + this.hasCreditTransaction = true; + break; + case "staffWelfare": + this.staffWelfareValue += amount; + this.hasStaffWelfareTransaction = true; + break; + case "voucher": + this.voucherValue += amount; + this.hasVoucherTransaction = true; + break; + case "iou": + this.iouValue += amount; + this.hasIouTransaction = true; + break; + case "agent": + this.agentValue += amount; + this.hasAgentTransaction = true; + break; + case "cheque": + this.chequeValue += amount; + this.hasChequeTransaction = true; + break; + case "slip": + this.slipValue += amount; + this.hasSlipTransaction = true; + break; + case "eWallet": + this.eWalletValue += amount; + this.hasEWalletTransaction = true; + break; + case "patientDeposit": + this.patientDepositValue += amount; + this.hasPatientDepositTransaction = true; + break; + case "patientPoints": + this.patientPointsValue += amount; + this.hasPatientPointsTransaction = true; + break; + case "onlineSettlement": + this.onlineSettlementValue += amount; + this.hasOnlineSettlementTransaction = true; + break; + case "grossTotal": + this.grossTotal += amount; + break; + case "discount": + this.discount += amount; + break; + case "total": + this.total += amount; + break; + case "totalOut": + this.totalOut += amount; + break; + case "totalIn": + this.totalIn += amount; + break; + case "hospitalTotal": + this.hospitalTotal += amount; + break; + case "staffTotal": + this.staffTotal += amount; + break; + case "ccTotal": + this.ccTotal += amount; + break; + default: + + break; + } + } + } + + private void addValueAndUpdateFlag(String calculationAttribute, double amount, double handoverValue) { + if (amount != 0) { + switch (calculationAttribute) { + case "cash": + this.cashValue += amount; + this.cashHandoverValue += handoverValue; + this.hasCashTransaction = true; + break; + case "card": + this.cardValue += amount; + this.cardHandoverValue += handoverValue; + this.hasCardTransaction = true; + break; + case "multiplePaymentMethods": + this.multiplePaymentMethodsValue += amount; + this.multiplePaymentMethodsHandoverValue += handoverValue; + this.hasMultiplePaymentMethodsTransaction = true; + break; + case "staff": + this.staffValue += amount; + this.staffHandoverValue += handoverValue; + this.hasStaffTransaction = true; + break; + case "credit": + this.creditValue += amount; + this.creditHandoverValue += handoverValue; + this.hasCreditTransaction = true; + break; + case "staffWelfare": + this.staffWelfareValue += amount; + this.staffWelfareHandoverValue += handoverValue; + this.hasStaffWelfareTransaction = true; + break; + case "voucher": + this.voucherValue += amount; + this.voucherHandoverValue += handoverValue; + this.hasVoucherTransaction = true; + break; + case "iou": + this.iouValue += amount; + this.iouHandoverValue += handoverValue; + this.hasIouTransaction = true; + break; + case "agent": + this.agentValue += amount; + this.agentHandoverValue += handoverValue; + this.hasAgentTransaction = true; + break; + case "cheque": + this.chequeValue += amount; + this.chequeHandoverValue += handoverValue; + this.hasChequeTransaction = true; + break; + case "slip": + this.slipValue += amount; + this.slipHandoverValue += handoverValue; + this.hasSlipTransaction = true; + break; + case "eWallet": + this.eWalletValue += amount; + this.eWalletHandoverValue += handoverValue; + this.hasEWalletTransaction = true; + break; + case "patientDeposit": + this.patientDepositValue += amount; + this.patientDepositHandoverValue += handoverValue; + this.hasPatientDepositTransaction = true; + break; + case "patientPoints": + this.patientPointsValue += amount; + this.patientPointsHandoverValue += handoverValue; + this.hasPatientPointsTransaction = true; + break; + case "onlineSettlement": + this.onlineSettlementValue += amount; + this.onlineSettlementHandoverValue += handoverValue; + this.hasOnlineSettlementTransaction = true; + break; + case "grossTotal": + this.grossTotal += amount; + break; + case "discount": + this.discount += amount; + break; + case "total": + this.total += amount; + break; + case "hospitalTotal": + this.hospitalTotal += amount; + break; + case "staffTotal": + this.staffTotal += amount; + break; + case "ccTotal": + this.ccTotal += amount; + break; + default: + // No action for unknown attributes + break; + } + } + } + + private double safeDouble(Double value) { + return value == null ? 0.0 : value; + } + + public double getOnCallValue() { + return onCallValue; + } + + public void setOnCallValue(double onCallValue) { + this.onCallValue = onCallValue; + } + + public double getCashValue() { + return cashValue; + } + + public void setCashValue(double cashValue) { + this.cashValue = cashValue; + } + + public double getCardValue() { + return cardValue; + } + + public void setCardValue(double cardValue) { + this.cardValue = cardValue; + } + + public double getMultiplePaymentMethodsValue() { + return multiplePaymentMethodsValue; + } + + public void setMultiplePaymentMethodsValue(double multiplePaymentMethodsValue) { + this.multiplePaymentMethodsValue = multiplePaymentMethodsValue; + } + + public double getStaffValue() { + return staffValue; + } + + public void setStaffValue(double staffValue) { + this.staffValue = staffValue; + } + + public double getCreditValue() { + return creditValue; + } + + public void setCreditValue(double creditValue) { + this.creditValue = creditValue; + } + + public double getStaffWelfareValue() { + return staffWelfareValue; + } + + public void setStaffWelfareValue(double staffWelfareValue) { + this.staffWelfareValue = staffWelfareValue; + } + + public double getVoucherValue() { + return voucherValue; + } + + public void setVoucherValue(double voucherValue) { + this.voucherValue = voucherValue; + } + + public double getIouValue() { + return iouValue; + } + + public void setIouValue(double iouValue) { + this.iouValue = iouValue; + } + + public double getAgentValue() { + return agentValue; + } + + public void setAgentValue(double agentValue) { + this.agentValue = agentValue; + } + + public double getChequeValue() { + return chequeValue; + } + + public void setChequeValue(double chequeValue) { + this.chequeValue = chequeValue; + } + + public double getSlipValue() { + return slipValue; + } + + public void setSlipValue(double slipValue) { + this.slipValue = slipValue; + } + + public double getEwalletValue() { + return eWalletValue; + } + + public void setEwalletValue(double eWalletValue) { + this.eWalletValue = eWalletValue; + } + + public double getPatientDepositValue() { + return patientDepositValue; + } + + public void setPatientDepositValue(double patientDepositValue) { + this.patientDepositValue = patientDepositValue; + } + + public double getPatientPointsValue() { + return patientPointsValue; + } + + public void setPatientPointsValue(double patientPointsValue) { + this.patientPointsValue = patientPointsValue; + } + + public double getOnlineSettlementValue() { + return onlineSettlementValue; + } + + public void setOnlineSettlementValue(double onlineSettlementValue) { + this.onlineSettlementValue = onlineSettlementValue; + } + + public ReportTemplate getReportTemplate() { + return reportTemplate; + } + + public void setReportTemplate(ReportTemplate reportTemplate) { + this.reportTemplate = reportTemplate; + } + + public List getRows() { + if (rows == null) { + rows = new ArrayList<>(); + } + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public Double getTotal() { + return total; + } + + public double getSettledAmountByPatientsTotal() { + return settledAmountByPatientsTotal; + } + + public void setSettledAmountByPatientsTotal(double settledAmountByPatientsTotal) { + this.settledAmountByPatientsTotal = settledAmountByPatientsTotal; + } + + public double getSettledAmountBySponsorsTotal() { + return settledAmountBySponsorsTotal; + } + + public void setSettledAmountBySponsorsTotal(double settledAmountBySponsorsTotal) { + this.settledAmountBySponsorsTotal = settledAmountBySponsorsTotal; + } + + public double getTotalBalance() { + return totalBalance; + } + + public void setTotalBalance(double totalBalance) { + this.totalBalance = totalBalance; + } + + public void setTotal(Double total) { + this.total = total; + } + + public Double getTotalIn() { + return totalIn; + } + + public void setTotalIn(Double totalIn) { + this.totalIn = totalIn; + } + + public Double getTotalOut() { + return totalOut; + } + + public void setTotalOut(Double totalOut) { + this.totalOut = totalOut; + } + + public Long getCountIn() { + return countIn; + } + + public void setCountIn(Long countIn) { + this.countIn = countIn; + } + + public Long getCountOut() { + return countOut; + } + + public void setCountOut(Long countOut) { + this.countOut = countOut; + } + + public Long getCount() { + return count; + } + + public void setCount(Long count) { + this.count = count; + } + + public String getName() { + if (name == null || name.isEmpty()) { + name = "BundleName" + UUID.randomUUID().toString(); + } + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public SessionInstance getSessionInstance() { + return sessionInstance; + } + + public void setSessionInstance(SessionInstance sessionInstance) { + this.sessionInstance = sessionInstance; + } + + public Long getLong1() { + return long1; + } + + public void setLong1(Long long1) { + this.long1 = long1; + } + + public Long getLong2() { + return long2; + } + + public void setLong2(Long long2) { + this.long2 = long2; + } + + public Long getLong3() { + return long3; + } + + public void setLong3(Long long3) { + this.long3 = long3; + } + + public Long getLong4() { + return long4; + } + + public void setLong4(Long long4) { + this.long4 = long4; + } + + public Long getLong5() { + return long5; + } + + public void setLong5(Long long5) { + this.long5 = long5; + } + + public Long getLong6() { + return long6; + } + + public void setLong6(Long long6) { + this.long6 = long6; + } + + public Long getLong7() { + return long7; + } + + public void setLong7(Long long7) { + this.long7 = long7; + } + + public Long getLong8() { + return long8; + } + + public void setLong8(Long long8) { + this.long8 = long8; + } + + public Long getLong9() { + return long9; + } + + public void setLong9(Long long9) { + this.long9 = long9; + } + + public Long getLong10() { + return long10; + } + + public void setLong10(Long long10) { + this.long10 = long10; + } + + public double geteWalletValue() { + return eWalletValue; + } + + public void seteWalletValue(double eWalletValue) { + this.eWalletValue = eWalletValue; + } + + public boolean isHasOnCallTransaction() { + return hasOnCallTransaction; + } + + public void setHasOnCallTransaction(boolean hasOnCallTransaction) { + this.hasOnCallTransaction = hasOnCallTransaction; + } + + public boolean isHasCashTransaction() { + return hasCashTransaction; + } + + public void setHasCashTransaction(boolean hasCashTransaction) { + this.hasCashTransaction = hasCashTransaction; + } + + public boolean isHasCardTransaction() { + return hasCardTransaction; + } + + public void setHasCardTransaction(boolean hasCardTransaction) { + this.hasCardTransaction = hasCardTransaction; + } + + public boolean isHasMultiplePaymentMethodsTransaction() { + return hasMultiplePaymentMethodsTransaction; + } + + public void setHasMultiplePaymentMethodsTransaction(boolean hasMultiplePaymentMethodsTransaction) { + this.hasMultiplePaymentMethodsTransaction = hasMultiplePaymentMethodsTransaction; + } + + public boolean isHasStaffTransaction() { + return hasStaffTransaction; + } + + public void setHasStaffTransaction(boolean hasStaffTransaction) { + this.hasStaffTransaction = hasStaffTransaction; + } + + public boolean isHasCreditTransaction() { + return hasCreditTransaction; + } + + public void setHasCreditTransaction(boolean hasCreditTransaction) { + this.hasCreditTransaction = hasCreditTransaction; + } + + public boolean isHasStaffWelfareTransaction() { + return hasStaffWelfareTransaction; + } + + public void setHasStaffWelfareTransaction(boolean hasStaffWelfareTransaction) { + this.hasStaffWelfareTransaction = hasStaffWelfareTransaction; + } + + public boolean isHasVoucherTransaction() { + return hasVoucherTransaction; + } + + public void setHasVoucherTransaction(boolean hasVoucherTransaction) { + this.hasVoucherTransaction = hasVoucherTransaction; + } + + public boolean isHasIouTransaction() { + return hasIouTransaction; + } + + public void setHasIouTransaction(boolean hasIouTransaction) { + this.hasIouTransaction = hasIouTransaction; + } + + public boolean isHasAgentTransaction() { + return hasAgentTransaction; + } + + public void setHasAgentTransaction(boolean hasAgentTransaction) { + this.hasAgentTransaction = hasAgentTransaction; + } + + public boolean isHasChequeTransaction() { + return hasChequeTransaction; + } + + public void setHasChequeTransaction(boolean hasChequeTransaction) { + this.hasChequeTransaction = hasChequeTransaction; + } + + public boolean isHasSlipTransaction() { + return hasSlipTransaction; + } + + public void setHasSlipTransaction(boolean hasSlipTransaction) { + this.hasSlipTransaction = hasSlipTransaction; + } + + public boolean isHasEWalletTransaction() { + return hasEWalletTransaction; + } + + public void setHasEWalletTransaction(boolean hasEWalletTransaction) { + this.hasEWalletTransaction = hasEWalletTransaction; + } + + public boolean isHasPatientDepositTransaction() { + return hasPatientDepositTransaction; + } + + public void setHasPatientDepositTransaction(boolean hasPatientDepositTransaction) { + this.hasPatientDepositTransaction = hasPatientDepositTransaction; + } + + public boolean isHasPatientPointsTransaction() { + return hasPatientPointsTransaction; + } + + public void setHasPatientPointsTransaction(boolean hasPatientPointsTransaction) { + this.hasPatientPointsTransaction = hasPatientPointsTransaction; + } + + public boolean isHasOnlineSettlementTransaction() { + return hasOnlineSettlementTransaction; + } + + public void setHasOnlineSettlementTransaction(boolean hasOnlineSettlementTransaction) { + this.hasOnlineSettlementTransaction = hasOnlineSettlementTransaction; + } + + public String getBundleType() { + return bundleType; + } + + public void setBundleType(String bundleType) { + this.bundleType = bundleType; + } + + public List getBundles() { + if (bundles == null) { + bundles = new ArrayList<>(); + } + return bundles; + } + + public void sortByDateInstitutionSiteDepartmentType() { + if (bundles == null || bundles.isEmpty()) { + return; + } + + Collections.sort(bundles, new Comparator() { + @Override + public int compare(IncomeBundle b1, IncomeBundle b2) { + // Compare by Date + int dateCompare = b1.getDate().compareTo(b2.getDate()); + if (dateCompare != 0) { + return dateCompare; + } + + // Compare by Institution Name + String institution1 = b1.getDepartment().getInstitution().getName(); + String institution2 = b2.getDepartment().getInstitution().getName(); + int institutionCompare = institution1.compareTo(institution2); + if (institutionCompare != 0) { + return institutionCompare; + } + + // Compare by Site Name + String site1 = b1.getDepartment().getSite().getName(); + String site2 = b2.getDepartment().getSite().getName(); + int siteCompare = site1.compareTo(site2); + if (siteCompare != 0) { + return siteCompare; + } + + // Compare by Department Name + String department1 = b1.getDepartment().getName(); + String department2 = b2.getDepartment().getName(); + int departmentCompare = department1.compareTo(department2); + if (departmentCompare != 0) { + return departmentCompare; + } + + // Compare by Type (If applicable) + // Assuming there is a 'type' field to be compared as a String or Enum + String type1 = b1.getBundleType(); // Adjust this depending on how type is defined + String type2 = b2.getBundleType(); // Adjust this depending on how type is defined + return type1.compareTo(type2); + } + }); + } + + public void setBundles(List bundles) { + this.bundles = bundles; + } + + public List getSelectedBundles() { + List selectedBundles = new ArrayList<>(); + for (IncomeBundle b : getBundles()) { + if (b.isSelected()) { + selectedBundles.add(b); + } + } + return selectedBundles; + } + + public Double getGrossTotal() { + return grossTotal; + } + + public void setGrossTotal(Double grossTotal) { + this.grossTotal = grossTotal; + } + + public Double getHospitalTotal() { + return hospitalTotal; + } + + public void setHospitalTotal(Double hospitalTotal) { + this.hospitalTotal = hospitalTotal; + } + + public Double getStaffTotal() { + return staffTotal; + } + + public void setStaffTotal(Double staffTotal) { + this.staffTotal = staffTotal; + } + + public Double getCcTotal() { + return ccTotal; + } + + public void setCcTotal(Double ccTotal) { + this.ccTotal = ccTotal; + } + + public Double getDiscount() { + return discount; + } + + public void setDiscount(Double discount) { + this.discount = discount; + } + + public WebUser getUser() { + return user; + } + + public void setUser(WebUser user) { + this.user = user; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public Department getDepartment() { + return department; + } + + public void setDepartment(Department department) { + this.department = department; + } + + public Bill getStartBill() { + return startBill; + } + + public void setStartBill(Bill startBill) { + this.startBill = startBill; + } + + public Bill getEndBill() { + return endBill; + } + + public void setEndBill(Bill endBill) { + this.endBill = endBill; + } + + public List getDepartments() { + return departments; + } + + public void setDepartments(List departments) { + this.departments = departments; + } + + public double getOnCallHandoverValue() { + return onCallHandoverValue; + } + + public void setOnCallHandoverValue(double onCallHandoverValue) { + this.onCallHandoverValue = onCallHandoverValue; + } + + public double getCashHandoverValue() { + return cashHandoverValue; + } + + public void setCashHandoverValue(double cashHandoverValue) { + this.cashHandoverValue = cashHandoverValue; + } + + public double getCardHandoverValue() { + return cardHandoverValue; + } + + public void setCardHandoverValue(double cardHandoverValue) { + this.cardHandoverValue = cardHandoverValue; + } + + public double getMultiplePaymentMethodsHandoverValue() { + return multiplePaymentMethodsHandoverValue; + } + + public void setMultiplePaymentMethodsHandoverValue(double multiplePaymentMethodsHandoverValue) { + this.multiplePaymentMethodsHandoverValue = multiplePaymentMethodsHandoverValue; + } + + public double getStaffHandoverValue() { + return staffHandoverValue; + } + + public void setStaffHandoverValue(double staffHandoverValue) { + this.staffHandoverValue = staffHandoverValue; + } + + public double getCreditHandoverValue() { + return creditHandoverValue; + } + + public void setCreditHandoverValue(double creditHandoverValue) { + this.creditHandoverValue = creditHandoverValue; + } + + public double getStaffWelfareHandoverValue() { + return staffWelfareHandoverValue; + } + + public void setStaffWelfareHandoverValue(double staffWelfareHandoverValue) { + this.staffWelfareHandoverValue = staffWelfareHandoverValue; + } + + public double getVoucherHandoverValue() { + return voucherHandoverValue; + } + + public void setVoucherHandoverValue(double voucherHandoverValue) { + this.voucherHandoverValue = voucherHandoverValue; + } + + public double getIouHandoverValue() { + return iouHandoverValue; + } + + public void setIouHandoverValue(double iouHandoverValue) { + this.iouHandoverValue = iouHandoverValue; + } + + public double getAgentHandoverValue() { + return agentHandoverValue; + } + + public void setAgentHandoverValue(double agentHandoverValue) { + this.agentHandoverValue = agentHandoverValue; + } + + public double getChequeHandoverValue() { + return chequeHandoverValue; + } + + public void setChequeHandoverValue(double chequeHandoverValue) { + this.chequeHandoverValue = chequeHandoverValue; + } + + public double getSlipHandoverValue() { + return slipHandoverValue; + } + + public void setSlipHandoverValue(double slipHandoverValue) { + this.slipHandoverValue = slipHandoverValue; + } + + public double getEwalletHandoverValue() { + return eWalletHandoverValue; + } + + public void setEwalletHandoverValue(double eWalletHandoverValue) { + this.eWalletHandoverValue = eWalletHandoverValue; + } + + public double getPatientDepositHandoverValue() { + return patientDepositHandoverValue; + } + + public void setPatientDepositHandoverValue(double patientDepositHandoverValue) { + this.patientDepositHandoverValue = patientDepositHandoverValue; + } + + public double getPatientPointsHandoverValue() { + return patientPointsHandoverValue; + } + + public void setPatientPointsHandoverValue(double patientPointsHandoverValue) { + this.patientPointsHandoverValue = patientPointsHandoverValue; + } + + public double getOnlineSettlementHandoverValue() { + return onlineSettlementHandoverValue; + } + + public void setOnlineSettlementHandoverValue(double onlineSettlementHandoverValue) { + this.onlineSettlementHandoverValue = onlineSettlementHandoverValue; + } + + public PaymentMethod getPaymentMethod() { + return paymentMethod; + } + + public void setPaymentMethod(PaymentMethod paymentMethod) { + this.paymentMethod = paymentMethod; + } + + public WebUser getFromUser() { + return fromUser; + } + + public void setFromUser(WebUser fromUser) { + this.fromUser = fromUser; + } + + public WebUser getToUser() { + return toUser; + } + + public void setToUser(WebUser toUser) { + this.toUser = toUser; + } + + public boolean isSelected() { + return selected; + } + + public void setSelected(boolean selected) { + this.selected = selected; + } + + public double getDenominatorValue() { + return denominatorValue; + } + + public void setDenominatorValue(double denominatorValue) { + this.denominatorValue = denominatorValue; + } + + public PaymentHandover getPaymentHandover() { + return paymentHandover; + } + + public void setPaymentHandover(PaymentHandover paymentHandover) { + this.paymentHandover = paymentHandover; + } + + public List getDenominations() { + return denominations; + } + + public void setDenominations(List denominations) { + this.denominations = denominations; + } + + public Double getTax() { + return tax; + } + + public void setTax(Double tax) { + this.tax = tax; + } + + public Boolean getSelectAllCashToHandover() { + if (selectAllCashToHandover == null) { + selectAllCashToHandover = true; + } + return selectAllCashToHandover; + } + + public void setSelectAllCashToHandover(Boolean selectAllCashToHandover) { + this.selectAllCashToHandover = selectAllCashToHandover; + } + + public boolean isPatientDepositsAreConsideredInHandingover() { + return patientDepositsAreConsideredInHandingover; + } + + public void setPatientDepositsAreConsideredInHandingover(boolean patientDepositsAreConsideredInHandingover) { + this.patientDepositsAreConsideredInHandingover = patientDepositsAreConsideredInHandingover; + } + +} diff --git a/src/main/java/com/divudi/data/TransactionTypeAndPaymentMethodRow.java b/src/main/java/com/divudi/data/IncomeRow.java similarity index 83% rename from src/main/java/com/divudi/data/TransactionTypeAndPaymentMethodRow.java rename to src/main/java/com/divudi/data/IncomeRow.java index b6d19313b1..4aa02bd855 100644 --- a/src/main/java/com/divudi/data/TransactionTypeAndPaymentMethodRow.java +++ b/src/main/java/com/divudi/data/IncomeRow.java @@ -11,12 +11,11 @@ import java.util.List; import java.util.Objects; import java.util.UUID; -import java.util.logging.Logger; /** * @author buddhika */ -public class TransactionTypeAndPaymentMethodRow implements Serializable { +public class IncomeRow implements Serializable { private static final long serialVersionUID = 1L; @@ -29,12 +28,10 @@ public class TransactionTypeAndPaymentMethodRow implements Serializable { private BillFee billFee; private Payment payment; - private BillType billType; private BillClassType billClassType; BillTypeAtomic billTypeAtomic; - private boolean selected; private Item item; @@ -125,6 +122,7 @@ public class TransactionTypeAndPaymentMethodRow implements Serializable { private double patientDepositValue; private double patientPointsValue; private double onlineSettlementValue; + private double noneValue; private Double grossTotal; private Double discount; @@ -139,7 +137,7 @@ public class TransactionTypeAndPaymentMethodRow implements Serializable { private Institution collectingCentre; private Double totalHospitalFee; private Double qty; - + private PatientInvestigation patientInvestigation; private long duration; @@ -153,21 +151,20 @@ public class TransactionTypeAndPaymentMethodRow implements Serializable { private PaymentHandover paymentHandover; // Constructor to generate a new UUID when an object is created - public TransactionTypeAndPaymentMethodRow() { + public IncomeRow() { this.id = UUID.randomUUID(); } - public TransactionTypeAndPaymentMethodRow(Institution institution) { + public IncomeRow(Institution institution) { this.institution = institution; } - - public TransactionTypeAndPaymentMethodRow(Institution institution, Double itemTotal) { + public IncomeRow(Institution institution, Double itemTotal) { this.itemTotal = itemTotal; this.institution = institution; } - public TransactionTypeAndPaymentMethodRow(Institution institution, Long itemCount, Double itemHospitalFee, Double itemCollectingCentreFee, Double itemProfessionalFee, Double itemNetTotal) { + public IncomeRow(Institution institution, Long itemCount, Double itemHospitalFee, Double itemCollectingCentreFee, Double itemProfessionalFee, Double itemNetTotal) { this.itemCount = itemCount; this.itemHospitalFee = itemHospitalFee; this.itemCollectingCentreFee = itemCollectingCentreFee; @@ -176,13 +173,13 @@ public TransactionTypeAndPaymentMethodRow(Institution institution, Long itemCoun this.institution = institution; } - public TransactionTypeAndPaymentMethodRow(Institution collectingCentre, Double totalHospitalFee, Double qty) { + public IncomeRow(Institution collectingCentre, Double totalHospitalFee, Double qty) { this.collectingCentre = collectingCentre; this.totalHospitalFee = totalHospitalFee; this.qty = qty; } - public TransactionTypeAndPaymentMethodRow(Route route, Double totalHospitalFee, Double qty) { + public IncomeRow(Route route, Double totalHospitalFee, Double qty) { this.route = route; this.totalHospitalFee = totalHospitalFee; this.qty = qty; @@ -205,7 +202,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - TransactionTypeAndPaymentMethodRow that = (TransactionTypeAndPaymentMethodRow) o; + IncomeRow that = (IncomeRow) o; return Objects.equals(getId(), that.id); } @@ -221,27 +218,27 @@ public String toString() { return "ReportTemplateRow{id=" + getId() + '}'; } - public TransactionTypeAndPaymentMethodRow(PatientInvestigation patientInvestigation) { + public IncomeRow(PatientInvestigation patientInvestigation) { this.patientInvestigation = patientInvestigation; } - - - public TransactionTypeAndPaymentMethodRow(SessionInstance sessionInstance) { + public IncomeRow(SessionInstance sessionInstance) { this.sessionInstance = sessionInstance; } - public TransactionTypeAndPaymentMethodRow(Department department, Double rowValue) { + public IncomeRow(Department department, Double rowValue) { this.rowValue = rowValue; this.department = department; } - public TransactionTypeAndPaymentMethodRow(Department department, Date date, - double cashValue, double cardValue, double multiplePaymentMethodsValue, - double staffValue, double creditValue, double staffWelfareValue, - double voucherValue, double iouValue, double agentValue, - double chequeValue, double slipValue, double eWalletValue, - double patientDepositValue, double patientPointsValue, double onlineSettlementValue) { + public IncomeRow(Department department, Date date, + double cashValue, double cardValue, double multiplePaymentMethodsValue, + double staffValue, double creditValue, double staffWelfareValue, + double voucherValue, double iouValue, double agentValue, + double chequeValue, double slipValue, double eWalletValue, + double patientDepositValue, double patientPointsValue, double onlineSettlementValue, + double noneValue + ) { this.department = department; this.date = date; this.cashValue = cashValue; @@ -259,14 +256,15 @@ public TransactionTypeAndPaymentMethodRow(Department department, Date date, this.patientDepositValue = patientDepositValue; this.patientPointsValue = patientPointsValue; this.onlineSettlementValue = onlineSettlementValue; + this.noneValue = noneValue; } - public TransactionTypeAndPaymentMethodRow(Department department, BillTypeAtomic billTypeAtomic, - double cashValue, double cardValue, double multiplePaymentMethodsValue, - double staffValue, double creditValue, double staffWelfareValue, - double voucherValue, double iouValue, double agentValue, - double chequeValue, double slipValue, double eWalletValue, - double patientDepositValue, double patientPointsValue, double onlineSettlementValue) { + public IncomeRow(Department department, BillTypeAtomic billTypeAtomic, + double cashValue, double cardValue, double multiplePaymentMethodsValue, + double staffValue, double creditValue, double staffWelfareValue, + double voucherValue, double iouValue, double agentValue, + double chequeValue, double slipValue, double eWalletValue, + double patientDepositValue, double patientPointsValue, double onlineSettlementValue, double noneValue) { this.department = department; this.billTypeAtomic = billTypeAtomic; this.cashValue = cashValue; @@ -284,14 +282,15 @@ public TransactionTypeAndPaymentMethodRow(Department department, BillTypeAtomic this.patientDepositValue = patientDepositValue; this.patientPointsValue = patientPointsValue; this.onlineSettlementValue = onlineSettlementValue; + this.noneValue = noneValue; } - public TransactionTypeAndPaymentMethodRow(Bill bill, - double cashValue, double cardValue, double multiplePaymentMethodsValue, - double staffValue, double creditValue, double staffWelfareValue, - double voucherValue, double iouValue, double agentValue, - double chequeValue, double slipValue, double eWalletValue, - double patientDepositValue, double patientPointsValue, double onlineSettlementValue) { + public IncomeRow(Bill bill, + double cashValue, double cardValue, double multiplePaymentMethodsValue, + double staffValue, double creditValue, double staffWelfareValue, + double voucherValue, double iouValue, double agentValue, + double chequeValue, double slipValue, double eWalletValue, + double patientDepositValue, double patientPointsValue, double onlineSettlementValue, double noneValue) { this.bill = bill; this.cashValue = cashValue; this.cardValue = cardValue; @@ -308,9 +307,10 @@ public TransactionTypeAndPaymentMethodRow(Bill bill, this.patientDepositValue = patientDepositValue; this.patientPointsValue = patientPointsValue; this.onlineSettlementValue = onlineSettlementValue; + this.noneValue = noneValue; } - public TransactionTypeAndPaymentMethodRow(BillType billType, BillClassType billClassType, BillTypeAtomic billTypeAtomic, Long rowCount, Double grossTotal, Double discount, Double total) { + public IncomeRow(BillType billType, BillClassType billClassType, BillTypeAtomic billTypeAtomic, Long rowCount, Double grossTotal, Double discount, Double total) { this.billType = billType; this.billClassType = billClassType; this.billTypeAtomic = billTypeAtomic; @@ -320,7 +320,7 @@ public TransactionTypeAndPaymentMethodRow(BillType billType, BillClassType billC this.total = total; } - public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, Long rowCount, Double grossTotal, Double discount, Double total) { + public IncomeRow(BillTypeAtomic billTypeAtomic, Long rowCount, Double grossTotal, Double discount, Double total) { this.billTypeAtomic = billTypeAtomic; this.rowCount = rowCount; this.grossTotal = grossTotal; @@ -328,17 +328,17 @@ public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, Long ro this.total = total; } - public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, Long rowCount) { + public IncomeRow(BillTypeAtomic billTypeAtomic, Long rowCount) { this.billTypeAtomic = billTypeAtomic; this.rowCount = rowCount; } - public TransactionTypeAndPaymentMethodRow(Department department, Date date, WebUser user, - double cashValue, double cardValue, double multiplePaymentMethodsValue, - double staffValue, double creditValue, double staffWelfareValue, - double voucherValue, double iouValue, double agentValue, - double chequeValue, double slipValue, double eWalletValue, - double patientDepositValue, double patientPointsValue, double onlineSettlementValue) { + public IncomeRow(Department department, Date date, WebUser user, + double cashValue, double cardValue, double multiplePaymentMethodsValue, + double staffValue, double creditValue, double staffWelfareValue, + double voucherValue, double iouValue, double agentValue, + double chequeValue, double slipValue, double eWalletValue, + double patientDepositValue, double patientPointsValue, double onlineSettlementValue, double noneValue) { this.department = department; this.date = date; this.cashValue = cashValue; @@ -357,37 +357,38 @@ public TransactionTypeAndPaymentMethodRow(Department department, Date date, WebU this.patientDepositValue = patientDepositValue; this.patientPointsValue = patientPointsValue; this.onlineSettlementValue = onlineSettlementValue; + this.noneValue = noneValue; } - public TransactionTypeAndPaymentMethodRow(Staff referringStaff, Institution referringInstitution, Long long1, Double rowValue) { + public IncomeRow(Staff referringStaff, Institution referringInstitution, Long long1, Double rowValue) { this.rowValue = rowValue; this.long1 = long1; this.referringInstitution = referringInstitution; this.referringStaff = referringStaff; } - public TransactionTypeAndPaymentMethodRow(Staff referringStaff, Long long1, Double rowValue) { + public IncomeRow(Staff referringStaff, Long long1, Double rowValue) { this.rowValue = rowValue; this.long1 = long1; this.referringStaff = referringStaff; } - public TransactionTypeAndPaymentMethodRow(Institution referringInstitution, Long long1, Double rowValue) { + public IncomeRow(Institution referringInstitution, Long long1, Double rowValue) { this.rowValue = rowValue; this.long1 = long1; this.referringInstitution = referringInstitution; } - public TransactionTypeAndPaymentMethodRow(Category c) { + public IncomeRow(Category c) { this.category = c; } - public TransactionTypeAndPaymentMethodRow(Item item) { + public IncomeRow(Item item) { this.item = item; } - public TransactionTypeAndPaymentMethodRow(Department d) { + public IncomeRow(Department d) { this.department = d; } @@ -455,7 +456,7 @@ public BillSession getBillSession() { return billSession; } - public TransactionTypeAndPaymentMethodRow(BillSession billSession) { + public IncomeRow(BillSession billSession) { this.billSession = billSession; } @@ -463,7 +464,7 @@ public void setBillSession(BillSession billSession) { this.billSession = billSession; } - public TransactionTypeAndPaymentMethodRow(String feeName, String categoryName, String toDepartmentName, String itemName, String paymentName, Double rowValue, Long rowCount) { + public IncomeRow(String feeName, String categoryName, String toDepartmentName, String itemName, String paymentName, Double rowValue, Long rowCount) { this.feeName = feeName; this.categoryName = categoryName; this.toDepartmentName = toDepartmentName; @@ -473,58 +474,58 @@ public TransactionTypeAndPaymentMethodRow(String feeName, String categoryName, S this.rowCount = rowCount; } - public TransactionTypeAndPaymentMethodRow(String categoryName, Long rowCount, Double rowValue) { + public IncomeRow(String categoryName, Long rowCount, Double rowValue) { this.categoryName = categoryName; this.rowValue = rowValue; this.rowCount = rowCount; } - public TransactionTypeAndPaymentMethodRow(Category category, Long rowCount, Double rowValue) { + public IncomeRow(Category category, Long rowCount, Double rowValue) { this.category = category; this.rowValue = rowValue; this.rowCount = rowCount; } - public TransactionTypeAndPaymentMethodRow(Department itemDept, Long rowCount, Double rowValue) { + public IncomeRow(Department itemDept, Long rowCount, Double rowValue) { this.itemDepartment = itemDept; this.rowValue = rowValue; this.rowCount = rowCount; } - public TransactionTypeAndPaymentMethodRow(Item item, Long rowCount, Double rowValue) { + public IncomeRow(Item item, Long rowCount, Double rowValue) { this.item = item; this.rowValue = rowValue; this.rowCount = rowCount; } - public TransactionTypeAndPaymentMethodRow(String categoryName, Double rowValue) { + public IncomeRow(String categoryName, Double rowValue) { this.categoryName = categoryName; this.rowValue = rowValue; } - public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, String categoryName, String toDepartmentName, Double rowValue) { + public IncomeRow(BillTypeAtomic billTypeAtomic, String categoryName, String toDepartmentName, Double rowValue) { this.billTypeAtomic = billTypeAtomic; this.categoryName = categoryName; this.toDepartmentName = toDepartmentName; this.rowValue = rowValue; } - public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, Double rowValue) { + public IncomeRow(BillTypeAtomic billTypeAtomic, Double rowValue) { this.billTypeAtomic = billTypeAtomic; this.rowValue = rowValue; } - public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic, Long rowCount, Double rowValue) { + public IncomeRow(BillTypeAtomic billTypeAtomic, Long rowCount, Double rowValue) { this.rowValue = rowValue; this.rowCount = rowCount; this.billTypeAtomic = billTypeAtomic; } - public TransactionTypeAndPaymentMethodRow(Double rowValue) { + public IncomeRow(Double rowValue) { this.rowValue = rowValue; } - public TransactionTypeAndPaymentMethodRow(BillTypeAtomic billTypeAtomic) { + public IncomeRow(BillTypeAtomic billTypeAtomic) { this.billTypeAtomic = billTypeAtomic; } @@ -821,7 +822,7 @@ public void setStaff(Staff staff) { this.staff = staff; } - public TransactionTypeAndPaymentMethodRow(Staff staff, Long long1, Long long2, Long long3, Long long4, Long long5, Long long6, Long long7) { + public IncomeRow(Staff staff, Long long1, Long long2, Long long3, Long long4, Long long5, Long long6, Long long7) { this.staff = staff; this.long1 = long1; this.long2 = long2; @@ -876,6 +877,8 @@ public void setCashValue(double cashValue) { this.cashValue = cashValue; } + + public double getCardValue() { return cardValue; } @@ -1151,7 +1154,7 @@ public void setBill(Bill bill) { this.bill = bill; } - public TransactionTypeAndPaymentMethodRow(Bill bill) { + public IncomeRow(Bill bill) { this.bill = bill; } @@ -1163,7 +1166,7 @@ public void setPayment(Payment payment) { this.payment = payment; } - public TransactionTypeAndPaymentMethodRow(Payment payment) { + public IncomeRow(Payment payment) { this.payment = payment; } @@ -1207,7 +1210,7 @@ public void setBillItem(BillItem billItem) { this.billItem = billItem; } - public TransactionTypeAndPaymentMethodRow(BillItem billItem) { + public IncomeRow(BillItem billItem) { this.billItem = billItem; } @@ -1235,7 +1238,7 @@ public void setBillFee(BillFee billFee) { this.billFee = billFee; } - public TransactionTypeAndPaymentMethodRow(BillFee billFee) { + public IncomeRow(BillFee billFee) { this.billFee = billFee; } @@ -1247,11 +1250,10 @@ public void setSpeciality(Speciality speciality) { this.speciality = speciality; } - public TransactionTypeAndPaymentMethodRow(AgentHistory agentHistory) { + public IncomeRow(AgentHistory agentHistory) { this.agentHistory = agentHistory; } - public Double getGrossTotal() { return grossTotal; } @@ -1363,6 +1365,13 @@ public PatientInvestigation getPatientInvestigation() { public void setPatientInvestigation(PatientInvestigation patientInvestigation) { this.patientInvestigation = patientInvestigation; } - - + + public double getNoneValue() { + return noneValue; + } + + public void setNoneValue(double noneValue) { + this.noneValue = noneValue; + } + } diff --git a/src/main/java/com/divudi/service/BillService.java b/src/main/java/com/divudi/service/BillService.java index 44eb76e168..4c32a531d8 100644 --- a/src/main/java/com/divudi/service/BillService.java +++ b/src/main/java/com/divudi/service/BillService.java @@ -596,4 +596,45 @@ public ReportTemplateRowBundle createBundleByKeywordForBills(List fetchBills(Date fromDate, + Date toDate, + Institution institution, + Institution site, + Department department, + WebUser webUser, + List billTypeAtomics) { + String jpql; + Map params = new HashMap(); + + jpql = "select b " + + " from Bill b " + + " where b.retired=:ret " + + " and b.billTypeAtomic in :billTypesAtomics " + + " and b.createdAt between :fromDate and :toDate "; + + params.put("ret", false); + params.put("billTypesAtomics", billTypeAtomics); + params.put("fromDate", fromDate); + params.put("toDate", toDate); + + if (institution != null) { + jpql += " and b.institution=:ins "; + params.put("ins", institution); + } + + if (webUser != null) { + jpql += " and b.creater=:user "; + params.put("user", webUser); + } + + if (department != null) { + jpql += " and b.department=:dep "; + params.put("dep", department); + } + + jpql += " order by b.createdAt desc "; + + return billFacade.findByJpql(jpql, params, TemporalType.TIMESTAMP); + } } diff --git a/src/main/webapp/pharmacy/reports/summary_reports/pharmacy_income_report.xhtml b/src/main/webapp/pharmacy/reports/summary_reports/pharmacy_income_report.xhtml index 4c3d51ae2b..f16848b049 100644 --- a/src/main/webapp/pharmacy/reports/summary_reports/pharmacy_income_report.xhtml +++ b/src/main/webapp/pharmacy/reports/summary_reports/pharmacy_income_report.xhtml @@ -2,15 +2,172 @@ + xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:p="http://primefaces.org/ui" + xmlns:f="http://xmlns.jcp.org/jsf/core"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #{myBundle1.name} - #{myBundle1.bundleType}
+
+
- - + + + + + + + + +
From 21c993faa909255afff3fd1722fdb9b8d4635eca Mon Sep 17 00:00:00 2001 From: imexh Date: Fri, 20 Dec 2024 08:54:11 +0530 Subject: [PATCH 09/28] methods --- .../divudi/bean/common/ReportsController.java | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/divudi/bean/common/ReportsController.java b/src/main/java/com/divudi/bean/common/ReportsController.java index 5eda7a5021..551c1a5588 100644 --- a/src/main/java/com/divudi/bean/common/ReportsController.java +++ b/src/main/java/com/divudi/bean/common/ReportsController.java @@ -2213,6 +2213,38 @@ public void generateRouteAnalysisReport() { } } + public Map getSampleCountChartData() { + Map data = new HashMap<>(); + + if (reportType.equalsIgnoreCase("detail")) { + for (YearMonth yearMonth : yearMonths) { + data.put(yearMonth, getCollectionCenterWiseTotalSampleCount(yearMonth) / calculateCollectionCenterWiseBillCount(yearMonth)); + } + } else { + for (YearMonth yearMonth : yearMonths) { + data.put(yearMonth, calculateRouteWiseTotalSampleCount(yearMonth) / calculateRouteWiseBillCount(yearMonth)); + } + } + + return data; + } + + public Map getServiceAmountChartData() { + Map data = new HashMap<>(); + + if (reportType.equalsIgnoreCase("detail")) { + for (YearMonth yearMonth : yearMonths) { + data.put(yearMonth, getCollectionCenterWiseTotalServiceAmount(yearMonth) / calculateCollectionCenterWiseBillCount(yearMonth)); + } + } else { + for (YearMonth yearMonth : yearMonths) { + data.put(yearMonth, calculateRouteWiseTotalServiceAmount(yearMonth) / calculateRouteWiseBillCount(yearMonth)); + } + } + + return data; + } + private void groupRouteWiseBillsMonthly() { Map> map = new HashMap<>(); List yearMonths = new ArrayList<>(); @@ -3456,13 +3488,4 @@ public Double calculateSubTotal() { return subTotal; } - - Map getSampleCountChartData() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody - } - - Map getServiceAmountChartData() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody - } - } From 198ac356abe8af897576f8c6b60c9672b398d30f Mon Sep 17 00:00:00 2001 From: Lawan Samarasekara Date: Fri, 20 Dec 2024 10:23:42 +0530 Subject: [PATCH 10/28] Added navigation Method Signed-off-by: Lawan Samarasekara --- .../divudi/bean/inward/AdmissionController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/divudi/bean/inward/AdmissionController.java b/src/main/java/com/divudi/bean/inward/AdmissionController.java index fc1bb302ee..ee50ca38e5 100644 --- a/src/main/java/com/divudi/bean/inward/AdmissionController.java +++ b/src/main/java/com/divudi/bean/inward/AdmissionController.java @@ -9,6 +9,7 @@ package com.divudi.bean.inward; import com.divudi.bean.common.ClinicalFindingValueController; +import com.divudi.bean.common.CommonController; import com.divudi.bean.common.CommonFunctionsController; import com.divudi.bean.common.ConfigOptionApplicationController; import com.divudi.bean.common.ControllerWithPatient; @@ -92,6 +93,8 @@ public class AdmissionController implements Serializable, ControllerWithPatient PharmacyRequestForBhtController pharmacyRequestForBhtController; @Inject ConfigOptionApplicationController configOptionApplicationController; + @Inject + private CommonController commonController; //////////// @EJB private AdmissionFacade ejbFacade; @@ -448,6 +451,18 @@ public String navigateToGuardianRoomChange() { roomChangeController.createGuardianRoom(); return "/inward/inward_room_change_guardian?faces-redirect=true"; } + + public String navigateToAddBabyAdmission() { + parentAdmission = current; + Admission ad = new Admission(); + if (ad.getDateOfAdmission() == null) { + ad.setDateOfAdmission(commonController.getCurrentDateTime()); + } + setCurrent(ad); + current.setParentEncounter(parentAdmission); + setPrintPreview(false); + return "/inward/inward_admission_child?faces-redirect=true"; + } // // Services & Items Submenu Methods // public String navigateToAddServices() { From 9739cd082abef280ad0f642e68f784e63d671081 Mon Sep 17 00:00:00 2001 From: Lawan Samarasekara Date: Fri, 20 Dec 2024 10:24:10 +0530 Subject: [PATCH 11/28] Added Button for Baby Admmission Signed-off-by: Lawan Samarasekara --- .../webapp/inward/admission_profile.xhtml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/webapp/inward/admission_profile.xhtml b/src/main/webapp/inward/admission_profile.xhtml index b325291b74..ad2fb2e781 100644 --- a/src/main/webapp/inward/admission_profile.xhtml +++ b/src/main/webapp/inward/admission_profile.xhtml @@ -67,6 +67,28 @@ target="#{roomChangeController.current}" /> + + + + + + + + Date: Fri, 20 Dec 2024 10:24:43 +0530 Subject: [PATCH 12/28] Added New Parent Admission Detail Composite Signed-off-by: Lawan Samarasekara --- .../common/parent_admission_details.xhtml | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 src/main/webapp/resources/ezcomp/common/parent_admission_details.xhtml diff --git a/src/main/webapp/resources/ezcomp/common/parent_admission_details.xhtml b/src/main/webapp/resources/ezcomp/common/parent_admission_details.xhtml new file mode 100644 index 0000000000..d730a0d10d --- /dev/null +++ b/src/main/webapp/resources/ezcomp/common/parent_admission_details.xhtml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + +
+ \ No newline at end of file From 7b83583e61ba5fa40a76068194144d1339709d3b Mon Sep 17 00:00:00 2001 From: Lawan Samarasekara Date: Fri, 20 Dec 2024 10:25:04 +0530 Subject: [PATCH 13/28] Fix UI On Child Admission Signed-off-by: Lawan Samarasekara --- .../inward/inward_admission_child.xhtml | 404 +++++++++++------- 1 file changed, 242 insertions(+), 162 deletions(-) diff --git a/src/main/webapp/inward/inward_admission_child.xhtml b/src/main/webapp/inward/inward_admission_child.xhtml index 039b1a2ff0..cc0d3a292d 100644 --- a/src/main/webapp/inward/inward_admission_child.xhtml +++ b/src/main/webapp/inward/inward_admission_child.xhtml @@ -8,6 +8,7 @@ xmlns:p="http://primefaces.org/ui" xmlns:bill="http://xmlns.jcp.org/jsf/composite/inward" xmlns:in="http://xmlns.jcp.org/jsf/composite/patient" + xmlns:common="http://xmlns.jcp.org/jsf/composite/ezcomp/common" xmlns:credit="http://xmlns.jcp.org/jsf/composite/inward/creditCompany"> @@ -15,184 +16,263 @@ - - - - - - - - - - - - - - - - - - + +
+
+ + +
+
+ + + + + + + +
+
+
+ +
+
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + + + + + + + + + +
+
+ +
+
+
+
+ + + + + + +
+
+ +
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + +
+
+
+
- - - - - - - - - - - - - + - - - - - - - - - - - - - - - -
From aad9679ce838a979c1b7ceff6401488b047f17f9 Mon Sep 17 00:00:00 2001 From: imexh Date: Fri, 20 Dec 2024 11:09:49 +0530 Subject: [PATCH 14/28] resolved conflict --- .../divudi/bean/common/ReportsController.java | 318 +++--------------- 1 file changed, 44 insertions(+), 274 deletions(-) diff --git a/src/main/java/com/divudi/bean/common/ReportsController.java b/src/main/java/com/divudi/bean/common/ReportsController.java index 93455a6d8b..82ac3bbf0c 100644 --- a/src/main/java/com/divudi/bean/common/ReportsController.java +++ b/src/main/java/com/divudi/bean/common/ReportsController.java @@ -30,6 +30,7 @@ import com.divudi.service.BillService; import com.divudi.service.PatientInvestigationService; import org.primefaces.model.StreamedContent; +import org.primefaces.model.charts.line.LineChartModel; import org.primefaces.model.file.UploadedFile; import javax.ejb.EJB; @@ -247,8 +248,6 @@ public class ReportsController implements Serializable { private Date maxDate; private Doctor referingDoctor; private Month month; - private PaymentScheme paymentScheme; - private String remarks; private double cashTotal; private double cardTotal; @@ -313,7 +312,7 @@ public class ReportsController implements Serializable { private String settlementStatus; private String dischargedStatus; - private String selectedDateType = "invoice"; + private boolean showChart; public String getDischargedStatus() { return dischargedStatus; @@ -328,10 +327,12 @@ public PaymentMethod getPaymentMethod() { return paymentMethod; } + public void setPaymentMethod(PaymentMethod paymentMethod) { this.paymentMethod = paymentMethod; } + public CommonController getCommonController() { return commonController; } @@ -356,30 +357,6 @@ public void setPatientReportFacade(PatientReportFacade patientReportFacade) { this.patientReportFacade = patientReportFacade; } - public PaymentScheme getPaymentScheme() { - return paymentScheme; - } - - public void setPaymentScheme(PaymentScheme paymentScheme) { - this.paymentScheme = paymentScheme; - } - - public String getRemarks() { - return remarks; - } - - public void setRemarks(String remarks) { - this.remarks = remarks; - } - - public String getSelectedDateType() { - return selectedDateType; - } - - public void setSelectedDateType(String selectedDateType) { - this.selectedDateType = selectedDateType; - } - public Institution getCreditCompany() { return creditCompany; } @@ -1554,6 +1531,14 @@ public void setGroupedRouteWiseBillsMonthly(Map> gro this.groupedRouteWiseBillsMonthly = groupedRouteWiseBillsMonthly; } + public boolean isShowChart() { + return showChart; + } + + public void setShowChart(boolean showChart) { + this.showChart = showChart; + } + public void generateSampleCarrierReport() { System.out.println("generateSampleCarrierReport = " + this); bundle = new ReportTemplateRowBundle(); @@ -2233,6 +2218,38 @@ public double calculateRouteWiseTotalServiceAmount(YearMonth yearmonth) { return total; } + public Map getSampleCountChartData() { + Map data = new HashMap<>(); + + if (reportType.equalsIgnoreCase("detail")) { + for (YearMonth yearMonth : yearMonths) { + data.put(yearMonth, getCollectionCenterWiseTotalSampleCount(yearMonth) / calculateCollectionCenterWiseBillCount(yearMonth)); + } + } else { + for (YearMonth yearMonth : yearMonths) { + data.put(yearMonth, calculateRouteWiseTotalSampleCount(yearMonth) / calculateRouteWiseBillCount(yearMonth)); + } + } + + return data; + } + + public Map getServiceAmountChartData() { + Map data = new HashMap<>(); + + if (reportType.equalsIgnoreCase("detail")) { + for (YearMonth yearMonth : yearMonths) { + data.put(yearMonth, getCollectionCenterWiseTotalServiceAmount(yearMonth) / calculateCollectionCenterWiseBillCount(yearMonth)); + } + } else { + for (YearMonth yearMonth : yearMonths) { + data.put(yearMonth, calculateRouteWiseTotalServiceAmount(yearMonth) / calculateRouteWiseBillCount(yearMonth)); + } + } + + return data; + } + public ReportTemplateRowBundle generateCollectingCenterWiseBillItems(List bts) { Map parameters = new HashMap<>(); String jpql = "SELECT new com.divudi.data.ReportTemplateRow(bill) " @@ -3317,7 +3334,6 @@ public Double calculateDiscountByBills(List bills) { return discount; } - public Double calculateSubTotal() { double subTotal = 0.0; Map> billMap = bundle.getGroupedBillItemsByInstitution(); @@ -3330,250 +3346,4 @@ public Double calculateSubTotal() { return subTotal; } - - public void generateDiscountReport() { - if (visitType == null || visitType.trim().isEmpty()) { - JsfUtil.addErrorMessage("Please select a visit type"); - return; - } - - System.out.println("generateDiscountReport = " + this); - bundle = new ReportTemplateRowBundle(); - - List opdBts = new ArrayList<>(); - bundle = new ReportTemplateRowBundle(); - - if (visitType.equalsIgnoreCase("IP")) { - opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL); - opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL); - opdBts.add(BillTypeAtomic.INWARD_SERVICE_BATCH_BILL_CANCELLATION); - opdBts.add(BillTypeAtomic.INWARD_SERVICE_BILL_CANCELLATION); - opdBts.add(BillTypeAtomic.INWARD_FINAL_BILL); - } else if (visitType.equalsIgnoreCase("OP")) { - opdBts.add(BillTypeAtomic.OPD_BILL_WITH_PAYMENT); - opdBts.add(BillTypeAtomic.OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER); - opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_WITH_PAYMENT); - opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER); - opdBts.add(BillTypeAtomic.PACKAGE_OPD_BATCH_BILL_WITH_PAYMENT); - opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER); - opdBts.add(BillTypeAtomic.OPD_BATCH_BILL_CANCELLATION); - opdBts.add(BillTypeAtomic.OPD_BILL_CANCELLATION); - opdBts.add(BillTypeAtomic.PACKAGE_OPD_BATCH_BILL_CANCELLATION); - opdBts.add(BillTypeAtomic.PACKAGE_OPD_BILL_CANCELLATION); - } - - if (reportType.equalsIgnoreCase("detail")) { - bundle.setName("BillItems"); - bundle.setBundleType("billItemList"); - - bundle = generateDiscountBillItems(opdBts); - bundle.calculateTotalDiscountByBillItems(); - } else if (reportType.equalsIgnoreCase("summary")) { - bundle.setName("Bills"); - bundle.setBundleType("billList"); - - bundle = generateDiscountBills(opdBts); - bundle.calculateTotalDiscountByBills(); - } - } - - public ReportTemplateRowBundle generateDiscountBills(List bts) { - Map parameters = new HashMap<>(); - - String jpql = "SELECT new com.divudi.data.ReportTemplateRow(bill) " - + "FROM Bill bill " - + "WHERE bill.retired <> :br " - + "AND bill.paymentScheme is not null "; - - parameters.put("br", true); - - jpql += "AND bill.billTypeAtomic in :bts "; - parameters.put("bts", bts); - - if (paymentMethod != null) { - List billPaymentMethods = new ArrayList<>(); - billPaymentMethods.add(paymentMethod); - - jpql += "AND bill.paymentMethod in :bpms "; - parameters.put("bpms", billPaymentMethods); - } - - if (visitType != null && (visitType.equalsIgnoreCase("IP") && admissionType != null)) { - jpql += "AND bill.patientEncounter.admissionType = :type "; - parameters.put("type", admissionType); - } - - if (visitType != null && (visitType.equalsIgnoreCase("IP") && roomCategory != null)) { - jpql += "AND bill.patientEncounter.currentPatientRoom.roomFacilityCharge.roomCategory = :category "; - parameters.put("category", roomCategory); - } - - if (discount > 0) { - jpql += "AND bill.discount = :dis "; - parameters.put("dis", discount); - } - - if (remarks != null && !remarks.trim().isEmpty()) { - jpql += "AND bill.comments LIKE :rem "; - parameters.put("rem", remarks + "%"); - } - - if (institution != null) { - jpql += "AND bill.department.institution = :ins "; - parameters.put("ins", institution); - } - - if (department != null) { - jpql += "AND bill.department = :dep "; - parameters.put("dep", department); - } - if (site != null) { - jpql += "AND bill.department.site = :site "; - parameters.put("site", site); - } - if (webUser != null) { - jpql += "AND bill.creater = :wu "; - parameters.put("wu", webUser); - } - - if (collectingCentre != null) { - jpql += "AND bill.collectingCentre = :cc "; - parameters.put("cc", collectingCentre); - } - - if (creditCompany != null) { - jpql += "AND bill.creditCompany = :cc "; - parameters.put("cc", creditCompany); - } - - if (paymentScheme != null) { - jpql += "AND bill.paymentScheme = :ps "; - parameters.put("ps", paymentScheme); - } - - if (selectedDateType != null && !selectedDateType.trim().isEmpty() && selectedDateType.equalsIgnoreCase("admission")) { - jpql += "AND bill.patientEncounter.dateOfAdmission BETWEEN :fd AND :td "; - } else if (selectedDateType != null && !selectedDateType.trim().isEmpty() && selectedDateType.equalsIgnoreCase("discharge")) { - jpql += "AND bill.patientEncounter.dateOfDischarge BETWEEN :fd AND :td "; - } else { - jpql += "AND bill.createdAt BETWEEN :fd AND :td "; - } - - parameters.put("fd", fromDate); - parameters.put("td", toDate); - - jpql += "GROUP BY bill"; - - List rs = (List) paymentFacade.findLightsByJpql(jpql, parameters, TemporalType.TIMESTAMP); - - ReportTemplateRowBundle b = new ReportTemplateRowBundle(); - b.setReportTemplateRows(rs); - b.createRowValuesFromBill(); - b.calculateTotalsWithCredit(); - return b; - } - - public ReportTemplateRowBundle generateDiscountBillItems(List bts) { - Map parameters = new HashMap<>(); - - String jpql = "SELECT new com.divudi.data.ReportTemplateRow(billItem) " - + "FROM BillItem billItem " - + "JOIN billItem.bill bill " - + "WHERE billItem.retired <> :bfr AND bill.retired <> :br " - + "AND billItem.bill.paymentScheme is not null "; - - parameters.put("bfr", true); - parameters.put("br", true); - - jpql += "AND bill.billTypeAtomic in :bts "; - parameters.put("bts", bts); - - if (paymentMethod != null) { - List billPaymentMethods = new ArrayList<>(); - billPaymentMethods.add(paymentMethod); - - jpql += "AND bill.paymentMethod in :bpms "; - parameters.put("bpms", billPaymentMethods); - } - - if (discount > 0) { - jpql += "AND billItem.bill.discount = :dis "; - parameters.put("dis", discount); - } - - if (remarks != null && !remarks.trim().isEmpty()) { - jpql += "AND billItem.bill.comments LIKE :rem "; - parameters.put("rem", remarks + "%"); - } - - if (visitType != null && (visitType.equalsIgnoreCase("IP") && admissionType != null)) { - jpql += "AND bill.patientEncounter.admissionType = :type "; - parameters.put("type", admissionType); - } - - if (visitType != null && (visitType.equalsIgnoreCase("IP") && roomCategory != null)) { - jpql += "AND bill.patientEncounter.currentPatientRoom.roomFacilityCharge.roomCategory = :category "; - parameters.put("category", roomCategory); - } - - if (institution != null) { - jpql += "AND bill.department.institution = :ins "; - parameters.put("ins", institution); - } - - if (department != null) { - jpql += "AND bill.department = :dep "; - parameters.put("dep", department); - } - if (site != null) { - jpql += "AND bill.department.site = :site "; - parameters.put("site", site); - } - if (webUser != null) { - jpql += "AND bill.creater = :wu "; - parameters.put("wu", webUser); - } - - if (collectingCentre != null) { - jpql += "AND bill.collectingCentre = :cc "; - parameters.put("cc", collectingCentre); - } - - if (creditCompany != null) { - jpql += "AND bill.creditCompany = :cc "; - parameters.put("cc", creditCompany); - } - - if (paymentScheme != null) { - jpql += "AND bill.paymentScheme = :ps "; - parameters.put("ps", paymentScheme); - } - - if ("notSettled".equalsIgnoreCase(settlementStatus)) { - jpql += "AND (billItem.referenceBill.netTotal + billItem.referenceBill.vat + billItem.referenceBill.paidAmount) <> 0 "; - } else if ("settled".equalsIgnoreCase(settlementStatus)) { - jpql += "AND (billItem.referenceBill.netTotal + billItem.referenceBill.vat + billItem.referenceBill.paidAmount) = 0 "; - } - - if (selectedDateType != null && !selectedDateType.trim().isEmpty() && selectedDateType.equalsIgnoreCase("admission")) { - jpql += "AND bill.patientEncounter.dateOfAdmission BETWEEN :fd AND :td "; - } else if (selectedDateType != null && !selectedDateType.trim().isEmpty() && selectedDateType.equalsIgnoreCase("discharge")) { - jpql += "AND bill.patientEncounter.dateOfDischarge BETWEEN :fd AND :td "; - } else { - jpql += "AND bill.createdAt BETWEEN :fd AND :td "; - } - - parameters.put("fd", fromDate); - parameters.put("td", toDate); - - jpql += "GROUP BY billItem"; - - List rs = (List) paymentFacade.findLightsByJpql(jpql, parameters, TemporalType.TIMESTAMP); - - ReportTemplateRowBundle b = new ReportTemplateRowBundle(); - b.setReportTemplateRows(rs); - b.createRowValuesFromBillItems(); - b.calculateTotalsWithCredit(); - return b; - } } From 1bd8dff868f0cc5a3ad757da3ab63c7242db1c83 Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Fri, 20 Dec 2024 12:29:59 +0530 Subject: [PATCH 15/28] Signed-off-by: DamithDeshan --- src/main/webapp/lab/patient_report.xhtml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/lab/patient_report.xhtml b/src/main/webapp/lab/patient_report.xhtml index b84c12e961..7aae4e6de5 100644 --- a/src/main/webapp/lab/patient_report.xhtml +++ b/src/main/webapp/lab/patient_report.xhtml @@ -180,7 +180,7 @@ - + @@ -190,7 +190,6 @@ - @@ -215,7 +214,7 @@ > - + @@ -273,7 +272,7 @@ > - + From 9725783d8205ed6d95b97e3c6874a5bdf6c43f70 Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Fri, 20 Dec 2024 12:33:13 +0530 Subject: [PATCH 16/28] closes #9769 Signed-off-by: DamithDeshan --- src/main/webapp/lab/patient_report.xhtml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/webapp/lab/patient_report.xhtml b/src/main/webapp/lab/patient_report.xhtml index a05509b473..4b927b1e20 100644 --- a/src/main/webapp/lab/patient_report.xhtml +++ b/src/main/webapp/lab/patient_report.xhtml @@ -203,7 +203,6 @@ rendered="#{patientReportController.currentPatientReport.transInvestigation.reportType ne 'Microbiology' and patientReportController.currentPatientReport.containFlags eq true}" > - From a1e947d0529be7fe1fabd5c7bd69326d7a6ae75f Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Fri, 20 Dec 2024 14:36:25 +0530 Subject: [PATCH 17/28] Signed-off-by: DamithDeshan --- src/main/webapp/lab/Upload_patient_report_print.xhtml | 1 - src/main/webapp/lab/generate_barcode_p.xhtml | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/lab/Upload_patient_report_print.xhtml b/src/main/webapp/lab/Upload_patient_report_print.xhtml index 528ab8056b..320dfffb75 100644 --- a/src/main/webapp/lab/Upload_patient_report_print.xhtml +++ b/src/main/webapp/lab/Upload_patient_report_print.xhtml @@ -9,7 +9,6 @@ - diff --git a/src/main/webapp/lab/generate_barcode_p.xhtml b/src/main/webapp/lab/generate_barcode_p.xhtml index d496599b65..839b8e0102 100644 --- a/src/main/webapp/lab/generate_barcode_p.xhtml +++ b/src/main/webapp/lab/generate_barcode_p.xhtml @@ -1143,7 +1143,8 @@
- - Date: Fri, 20 Dec 2024 18:08:43 +0530 Subject: [PATCH 18/28] Debtor Analysis-Excess Age (Credit Company) #9614 --- .../credit_company_inward_excess_age.xhtml | 98 ------------------- 1 file changed, 98 deletions(-) diff --git a/src/main/webapp/reports/financialReports/credit_company_inward_excess_age.xhtml b/src/main/webapp/reports/financialReports/credit_company_inward_excess_age.xhtml index ceabd0fa9f..f025b3388e 100644 --- a/src/main/webapp/reports/financialReports/credit_company_inward_excess_age.xhtml +++ b/src/main/webapp/reports/financialReports/credit_company_inward_excess_age.xhtml @@ -26,108 +26,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Date: Fri, 20 Dec 2024 19:14:53 +0530 Subject: [PATCH 19/28] Signed-off-by: DamithDeshan --- ..._report_print.xhtml => upload_patient_report_print_view.xhtml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/webapp/lab/{Upload_patient_report_print.xhtml => upload_patient_report_print_view.xhtml} (100%) diff --git a/src/main/webapp/lab/Upload_patient_report_print.xhtml b/src/main/webapp/lab/upload_patient_report_print_view.xhtml similarity index 100% rename from src/main/webapp/lab/Upload_patient_report_print.xhtml rename to src/main/webapp/lab/upload_patient_report_print_view.xhtml From ddcda1e36420f4219043753382ba88a5110fb6d8 Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Fri, 20 Dec 2024 19:16:21 +0530 Subject: [PATCH 20/28] closes #9786 Signed-off-by: DamithDeshan --- ..._report_print_view.xhtml => upload_patient_report_print.xhtml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/webapp/lab/{upload_patient_report_print_view.xhtml => upload_patient_report_print.xhtml} (100%) diff --git a/src/main/webapp/lab/upload_patient_report_print_view.xhtml b/src/main/webapp/lab/upload_patient_report_print.xhtml similarity index 100% rename from src/main/webapp/lab/upload_patient_report_print_view.xhtml rename to src/main/webapp/lab/upload_patient_report_print.xhtml From 0ec4cdf7a4d19e23f4069ad7dd9fa77a170f7762 Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Fri, 20 Dec 2024 20:12:23 +0530 Subject: [PATCH 21/28] Signed-off-by: DamithDeshan --- src/main/java/com/divudi/entity/Bill.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/divudi/entity/Bill.java b/src/main/java/com/divudi/entity/Bill.java index 775bd60699..9172167da5 100644 --- a/src/main/java/com/divudi/entity/Bill.java +++ b/src/main/java/com/divudi/entity/Bill.java @@ -408,6 +408,8 @@ public class Bill implements Serializable { @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) private PharmacyBill pharmacyBill; + private String externalDoctor; + public Bill() { if (status == null) { status = PatientInvestigationStatus.ORDERED; @@ -2507,4 +2509,12 @@ public PharmacyBill getPharmacyBill() { public void setPharmacyBill(PharmacyBill pharmacyBill) { this.pharmacyBill = pharmacyBill; } + + public String getExternalDoctor() { + return externalDoctor; + } + + public void setExternalDoctor(String externalDoctor) { + this.externalDoctor = externalDoctor; + } } From 54da2b6162162b2996e5a7d5447bdbaa495c5f45 Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Fri, 20 Dec 2024 20:12:37 +0530 Subject: [PATCH 22/28] Signed-off-by: DamithDeshan --- .../CollectingCentreBillController.java | 13 +++- src/main/webapp/collecting_centre/bill.xhtml | 60 +++++++++++++------ 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java b/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java index 893d100581..b4ad4bdef4 100644 --- a/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java +++ b/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java @@ -258,6 +258,8 @@ public class CollectingCentreBillController implements Serializable, ControllerW private YearMonthDay yearMonthDay; private PaymentMethodData paymentMethodData; + private String externalDoctor; + public List getAgentReferenceBooks() { return agentReferenceBooks; } @@ -269,7 +271,7 @@ public double findCCBalanceAfterBilling(Bill bill) { + " where ah.bill =:b " + " and ah.bill.retired=false "; params.put("b", bill); - + AgentHistory history = agentHistoryFacade.findFirstByJpql(jpql, params); System.out.println("history = " + history); double billingAfterCCBalance = history.getBalanceAfterTransaction(); @@ -1170,6 +1172,7 @@ private Bill createCcBill(Department bt) { ccBill.setFromInstitution(collectingCentre); ccBill.setReferredBy(referredBy); + ccBill.setExternalDoctor(externalDoctor); ccBill.setReferenceNumber(referralId); ccBill.setReferredByInstitution(referredByInstitution); ccBill.setComments(comment); @@ -2550,6 +2553,14 @@ public void listnerForPaymentMethodChange() { // ToDo: Add Logic } + public String getExternalDoctor() { + return externalDoctor; + } + + public void setExternalDoctor(String externalDoctor) { + this.externalDoctor = externalDoctor; + } + public class CollectingCenterBookSummeryRow { private String bookName; diff --git a/src/main/webapp/collecting_centre/bill.xhtml b/src/main/webapp/collecting_centre/bill.xhtml index 028d6c2fe0..c0b65957b3 100644 --- a/src/main/webapp/collecting_centre/bill.xhtml +++ b/src/main/webapp/collecting_centre/bill.xhtml @@ -464,16 +464,30 @@
+
+ +
+
+ + +
+
- + @@ -508,23 +522,33 @@
- +
- + #{refi.name} From d35b591f97c5c53b8fd28da73e1e16d1e54f10c7 Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Fri, 20 Dec 2024 20:12:43 +0530 Subject: [PATCH 23/28] Signed-off-by: DamithDeshan --- src/main/java/com/divudi/bean/common/ReportsController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/divudi/bean/common/ReportsController.java b/src/main/java/com/divudi/bean/common/ReportsController.java index 288fd1cd20..34ce87fd4b 100644 --- a/src/main/java/com/divudi/bean/common/ReportsController.java +++ b/src/main/java/com/divudi/bean/common/ReportsController.java @@ -390,6 +390,7 @@ public String getSelectedDateType() { public void setSelectedDateType(String selectedDateType) { this.selectedDateType = selectedDateType; + } public Investigation getInvestigation() { return investigation; @@ -397,7 +398,6 @@ public Investigation getInvestigation() { public void setInvestigation(Investigation investigation) { this.investigation = investigation; - } public Institution getCreditCompany() { From 5a9c25c4e6b1f9426fcaf68cd52b3d88c8d62a4b Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Fri, 20 Dec 2024 20:13:00 +0530 Subject: [PATCH 24/28] closes #6674 Signed-off-by: DamithDeshan --- .../cc_bill/fiveFiveCCBill_CC_Custom1.xhtml | 22 +++++++++++++++++ .../fiveFiveCCBill_Patient_Custom1.xhtml | 24 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_CC_Custom1.xhtml b/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_CC_Custom1.xhtml index 39a938cc88..155b09dc58 100644 --- a/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_CC_Custom1.xhtml +++ b/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_CC_Custom1.xhtml @@ -142,6 +142,28 @@ --> + + +
+ + + + + + + diff --git a/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_Patient_Custom1.xhtml b/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_Patient_Custom1.xhtml index 5587cd2750..82530434bb 100644 --- a/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_Patient_Custom1.xhtml +++ b/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_Patient_Custom1.xhtml @@ -142,6 +142,28 @@ --> + + + + + + + + + + @@ -257,7 +279,7 @@ --> - - +
+ + + : + + +
+ + + : + + +
- + From 0a781f9aba5df24093bd79621cd99e751ecb75cb Mon Sep 17 00:00:00 2001 From: DamithDeshan Date: Fri, 20 Dec 2024 20:29:57 +0530 Subject: [PATCH 25/28] closes #6674 Signed-off-by: DamithDeshan --- .../bean/collectingCentre/CollectingCentreBillController.java | 1 + .../resources/bill/cc_bill/fiveFiveCCBill_CC_Custom1.xhtml | 3 +-- .../bill/cc_bill/fiveFiveCCBill_Patient_Custom1.xhtml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java b/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java index b4ad4bdef4..af312b9122 100644 --- a/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java +++ b/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java @@ -1606,6 +1606,7 @@ public void prepareNewBill() { paymentMethod = PaymentMethod.Agent; collectingCentre = null; opdItems = null; + externalDoctor = null; } public void prepareNewBillKeepingCollectingCenter() { diff --git a/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_CC_Custom1.xhtml b/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_CC_Custom1.xhtml index 155b09dc58..a727c303f0 100644 --- a/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_CC_Custom1.xhtml +++ b/src/main/webapp/resources/bill/cc_bill/fiveFiveCCBill_CC_Custom1.xhtml @@ -142,8 +142,7 @@
--> - +
Date: Fri, 20 Dec 2024 22:32:21 +0530 Subject: [PATCH 26/28] Signed-off-by: DamithDeshan --- src/main/webapp/lab/generate_barcode_p.xhtml | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/webapp/lab/generate_barcode_p.xhtml b/src/main/webapp/lab/generate_barcode_p.xhtml index 839b8e0102..b2d21adf71 100644 --- a/src/main/webapp/lab/generate_barcode_p.xhtml +++ b/src/main/webapp/lab/generate_barcode_p.xhtml @@ -1090,7 +1090,7 @@ library="image" name="approved_icon.png" style="height: 30px; width: 30px; #{dpr.approved ? '':'opacity: 0.1;'}" /> - + + id="btnGenerateBarcodes" + value="Generate Barcodes" + ajax="false" + action="#{patientInvestigationController.generateBarcodesForSelectedPatientInvestigations()}" + title="Generate Barcodes" + icon="pi pi-barcode" + styleClass="m-1 w-100 ui-button-success" /> + id="btnCollectSamples" + value="Collect Samples" + ajax="false" + action="#{patientInvestigationController.collectSamples()}" + title="Collect Samples" + icon="pi pi-plus-circle" + styleClass="m-1 w-100 ui-button-primary" />