diff --git a/src/main/java/com/divudi/bean/common/ReportsController.java b/src/main/java/com/divudi/bean/common/ReportsController.java index bb618e5549..e649a05f49 100644 --- a/src/main/java/com/divudi/bean/common/ReportsController.java +++ b/src/main/java/com/divudi/bean/common/ReportsController.java @@ -345,7 +345,6 @@ public void setDischargedStatus(String dischargedStatus) { this.dischargedStatus = dischargedStatus; } - public PaymentMethod getPaymentMethod() { return paymentMethod; } @@ -1652,7 +1651,6 @@ public void generateSampleCarrierReport() { private ReportTemplateRowBundle generateSampleCarrierBillItems(List bts) { Map parameters = new HashMap<>(); - String jpql = "SELECT new com.divudi.data.ReportTemplateRow(pi) " + "FROM PatientInvestigation pi " + "JOIN pi.billItem billItem " @@ -1661,7 +1659,6 @@ private ReportTemplateRowBundle generateSampleCarrierBillItems(List bts, List billPaymentMethods, - boolean onlyDueBills) { + boolean onlyDueBills) { Map parameters = new HashMap<>(); String jpql = "SELECT new com.divudi.data.ReportTemplateRow(bill) " + "FROM Bill bill " @@ -3140,7 +3137,6 @@ private ReportTemplateRowBundle generateExternalLaboratoryWorkloadBillItems(List // + "LEFT JOIN PatientInvestigation pi ON pi.billItem = billItem " // + "WHERE bill.billTypeAtomic IN :bts " // + "AND bill.createdAt BETWEEN :fd AND :td "; - String jpql = "SELECT new com.divudi.data.ReportTemplateRow(billItem) " + "FROM PatientInvestigation pi " + "JOIN pi.billItem billItem " @@ -3644,6 +3640,144 @@ public Double calculateSponsorShareNetTotal() { return subTotal; } + public Double calculateNetAmountNetTotal() { + double netAmountNetTotal = 0.0; + Map> billMap = bundle.getGroupedBillItemsByInstitution(); + + for (Map.Entry> entry : billMap.entrySet()) { + List bills = entry.getValue(); + + netAmountNetTotal += calculateNetAmountSubTotalByBills(bills); + } + + return netAmountNetTotal; + } + + public Double calculateNetAmountSubTotalByBills(List bills) { + Double netTotal = 0.0; + + for (Bill bill : bills) { + netTotal += bill.getNetTotal(); + } + + return netTotal; + } + + public Double calculateGrossAmountSubTotalByBills(List bills) { + Double billTotal = 0.0; + + for (Bill bill : bills) { + billTotal += bill.getBillTotal(); + } + + return billTotal; + } + + public Double calculatePatientShareSubTotalByBills(List bills) { + Double settledAmountByPatient = 0.0; + + for (Bill bill : bills) { + settledAmountByPatient += bill.getSettledAmountByPatient(); + } + + return settledAmountByPatient; + } + + public Double calculateSponsorShareSubTotalByBills(List bills) { + Double settledAmountBySponsor = 0.0; + + for (Bill bill : bills) { + settledAmountBySponsor += bill.getSettledAmountBySponsor(); + } + + return settledAmountBySponsor; + } + + public Double calculateDueAmountSubTotalByBills(List bills) { + Double balance = 0.0; + + for (Bill bill : bills) { + balance += bill.getBalance(); + } + + return balance; + } + + public Double calculateGrossAmountNetTotal() { + double grossAmountNetTotal = 0.0; + Map> billMap = bundle.getGroupedBillItemsByInstitution(); + + for (Map.Entry> entry : billMap.entrySet()) { + List bills = entry.getValue(); + + grossAmountNetTotal += calculateGrossAmountSubTotalByBills(bills); + } + + return grossAmountNetTotal; + } + + public Double calculateDiscountNetTotal() { + double discountNetTotal = 0.0; + Map> billMap = bundle.getGroupedBillItemsByInstitution(); + + for (Map.Entry> entry : billMap.entrySet()) { + List bills = entry.getValue(); + + discountNetTotal += calculateDiscountSubTotalByBills(bills); + } + + return discountNetTotal; + } + + public Double calculateDiscountSubTotalByBills(List bills) { + Double discount = 0.0; + + for (Bill bill : bills) { + discount += bill.getDiscount(); + } + + return discount; + } + + public Double calculatePatientShareNetTotal() { + double patientShareNetTotal = 0.0; + Map> billMap = bundle.getGroupedBillItemsByInstitution(); + + for (Map.Entry> entry : billMap.entrySet()) { + List bills = entry.getValue(); + + patientShareNetTotal += calculatePatientShareSubTotalByBills(bills); + } + + return patientShareNetTotal; + } + + public Double calculateDueAmountNetTotal() { + double dueAmountNetTotal = 0.0; + Map> billMap = bundle.getGroupedBillItemsByInstitution(); + + for (Map.Entry> entry : billMap.entrySet()) { + List bills = entry.getValue(); + + dueAmountNetTotal += calculateDueAmountSubTotalByBills(bills); + } + + return dueAmountNetTotal; + } + + public Double calculateSponsorShareNetTotal() { + double sponsorShareNetTotal = 0.0; + Map> billMap = bundle.getGroupedBillItemsByInstitution(); + + for (Map.Entry> entry : billMap.entrySet()) { + List bills = entry.getValue(); + + sponsorShareNetTotal += calculateSponsorShareSubTotalByBills(bills); + } + + return sponsorShareNetTotal; + } + public void generateDiscountReport() { if (visitType == null || visitType.trim().isEmpty()) { JsfUtil.addErrorMessage("Please select a visit type"); @@ -3984,6 +4118,7 @@ public void exportCollectionCenterBillWiseDetailReportToExcel() { try (XSSFWorkbook workbook = new XSSFWorkbook(); OutputStream out = response.getOutputStream()) { + XSSFSheet sheet = workbook.createSheet("Report"); int rowIndex = 0; diff --git a/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java b/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java index f5ef2dc277..ecd2b6edd6 100644 --- a/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java +++ b/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java @@ -232,6 +232,7 @@ public void resetAllFilters() { } public void processPharmacyIncomeReport() { + System.out.println("processPharmacyIncomeReport"); List billTypeAtomics = new ArrayList<>(); billTypeAtomics.add(BillTypeAtomic.PHARMACY_RETAIL_SALE); billTypeAtomics.add(BillTypeAtomic.PHARMACY_RETAIL_SALE_CANCELLED); @@ -242,6 +243,18 @@ public void processPharmacyIncomeReport() { billTypeAtomics.add(BillTypeAtomic.PHARMACY_WHOLESALE_CANCELLED); billTypeAtomics.add(BillTypeAtomic.PHARMACY_WHOLESALE_PRE); billTypeAtomics.add(BillTypeAtomic.PHARMACY_WHOLESALE_REFUND); + billTypeAtomics.add(BillTypeAtomic.DIRECT_ISSUE_INWARD_MEDICINE); + billTypeAtomics.add(BillTypeAtomic.DIRECT_ISSUE_INWARD_MEDICINE_CANCELLATION); + billTypeAtomics.add(BillTypeAtomic.DIRECT_ISSUE_INWARD_MEDICINE_RETURN); + billTypeAtomics.add(BillTypeAtomic.DIRECT_ISSUE_THEATRE_MEDICINE); + billTypeAtomics.add(BillTypeAtomic.DIRECT_ISSUE_THEATRE_MEDICINE_CANCELLATION); + billTypeAtomics.add(BillTypeAtomic.DIRECT_ISSUE_THEATRE_MEDICINE_RETURN); + billTypeAtomics.add(BillTypeAtomic.ISSUE_MEDICINE_ON_REQUEST_INWARD); + billTypeAtomics.add(BillTypeAtomic.ISSUE_MEDICINE_ON_REQUEST_INWARD_CANCELLATION); + billTypeAtomics.add(BillTypeAtomic.ISSUE_MEDICINE_ON_REQUEST_THEATRE); + billTypeAtomics.add(BillTypeAtomic.ISSUE_MEDICINE_ON_REQUEST_THEATRE_CANCELLATION); + billTypeAtomics.add(BillTypeAtomic.ACCEPT_RETURN_MEDICINE_INWARD); + billTypeAtomics.add(BillTypeAtomic.ACCEPT_RETURN_MEDICINE_THEATRE); List bills = billService.fetchBills(fromDate, toDate, institution, site, department, webUser, billTypeAtomics); bundle = new IncomeBundle(bills); @@ -252,7 +265,7 @@ public void processPharmacyIncomeReport() { if (r.getBill().getPaymentMethod() == null) { continue; } - if(r.getBill().getPaymentMethod().equals(PaymentMethod.MultiplePaymentMethods)){ + if (r.getBill().getPaymentMethod().equals(PaymentMethod.MultiplePaymentMethods)) { r.setPayments(billService.fetchBillPayments(r.getBill())); } } diff --git a/src/main/java/com/divudi/data/IncomeBundle.java b/src/main/java/com/divudi/data/IncomeBundle.java index e58ad197e4..97644be512 100644 --- a/src/main/java/com/divudi/data/IncomeBundle.java +++ b/src/main/java/com/divudi/data/IncomeBundle.java @@ -234,9 +234,18 @@ public void generatePaymentDetailsForBills() { r.setNetTotal(b.getNetTotal()); r.setDiscount(b.getDiscount()); r.setActualTotal(b.getNetTotal() - b.getServiceCharge()); - + if (b.getPaymentMethod() == null) { - r.setNoneValue(b.getNetTotal()); + r.setCreditValue(b.getNetTotal()); + if (r.getBill().getPatientEncounter() != null) { + r.setOpdCreditValue(0); + r.setInpatientCreditValue(b.getNetTotal()); + } else { + r.setOpdCreditValue(0); + r.setInpatientCreditValue(0); + r.setNoneValue(b.getNetTotal()); + } + } else { switch (b.getPaymentMethod()) { case Agent: @@ -261,7 +270,7 @@ public void generatePaymentDetailsForBills() { break; case Credit: r.setCreditValue(b.getNetTotal()); - if (r.getBill().getPatientEncounter() == null) { + if (r.getBill().getPatientEncounter() != null) { r.setOpdCreditValue(0); r.setInpatientCreditValue(b.getNetTotal()); } else { @@ -301,7 +310,7 @@ public void generatePaymentDetailsForBills() { } } - + } populateSummaryRow(); } @@ -336,10 +345,10 @@ private void calculateBillPaymentValuesFromPayments(IncomeRow r) { break; case Credit: r.setCreditValue(r.getCreditValue() + p.getPaidValue()); - if (r.getBill().getPatientEncounter() == null) { - r.setOpdCreditValue(r.getOpdCreditValue() + p.getPaidValue()); - } else { + if (r.getBill().getPatientEncounter() != null) { r.setInpatientCreditValue(r.getInpatientCreditValue() + p.getPaidValue()); + } else { + r.setOpdCreditValue(r.getOpdCreditValue() + p.getPaidValue()); } break; case IOU: diff --git a/src/main/java/com/divudi/service/BillService.java b/src/main/java/com/divudi/service/BillService.java index 4c32a531d8..3391c3bd26 100644 --- a/src/main/java/com/divudi/service/BillService.java +++ b/src/main/java/com/divudi/service/BillService.java @@ -634,7 +634,10 @@ public List fetchBills(Date fromDate, } jpql += " order by b.createdAt desc "; - - return billFacade.findByJpql(jpql, params, TemporalType.TIMESTAMP); + System.out.println("params = " + params); + System.out.println("jpql = " + jpql); + List fetchedBills = billFacade.findByJpql(jpql, params, TemporalType.TIMESTAMP); + System.out.println("fetchedBills = " + fetchedBills); + return fetchedBills; } } diff --git a/src/main/webapp/pharmacy/pharmacy_analytics.xhtml b/src/main/webapp/pharmacy/pharmacy_analytics.xhtml index 9fa0ed31f4..a7b95ba15a 100644 --- a/src/main/webapp/pharmacy/pharmacy_analytics.xhtml +++ b/src/main/webapp/pharmacy/pharmacy_analytics.xhtml @@ -10,7 +10,7 @@
-
+
@@ -297,7 +297,7 @@
-
+
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 a37361c4ff..fc32cb0216 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 @@ -171,10 +171,11 @@ - + @@ -232,7 +233,7 @@ - + @@ -243,7 +244,7 @@ - + @@ -254,7 +255,7 @@ - + @@ -265,7 +266,7 @@ - + diff --git a/src/main/webapp/resources/css/ohmis.css b/src/main/webapp/resources/css/ohmis.css index c8cfac2e26..f607f6cb31 100644 --- a/src/main/webapp/resources/css/ohmis.css +++ b/src/main/webapp/resources/css/ohmis.css @@ -290,6 +290,63 @@ th.align-right-header .ui-column-title { width: 58%; } +.compact-datatable { + --content-padding: 0.0rem; /* Reduced from 1rem */ + --inline-spacing: 0.0rem; /* Reduced from 0.5rem */ + --border-radius: 0px; /* Reduced from 4px */ +} +.compact-datatable .ui-datatable-data tr td { + margin: 0 !important; + padding: 2px !important; /* Minimal padding */ + line-height: 1.2; /* Reduce line spacing */ +} +.compact-datatable .ui-datatable-header, +.compact-datatable .ui-datatable-footer, +.compact-datatable .ui-column-title, +.compact-datatable .ui-datatable-footer .ui-datatable-footer-table, +.compact-datatable .ui-datatable-footer .ui-datatable-footer-tablewrapper, +.compact-datatable .ui-datatable-footer table, +.compact-datatable .ui-datatable-footer td, +.compact-datatable .ui-datatable-footer td.ui-state-default, +.compact-datatable .ui-datatable-footer td:empty, +.compact-datatable .ui-datatable-footer .ui-datatable-footer-tablewrapper table { + margin: 0 !important; + padding: 2px !important; + line-height: 1.1; +} +.compact-datatable .ui-datatable-footer td:empty { + display: none; /* Hide empty cells completely */ +} +.compact-datatable .ui-datatable-footer, +.compact-datatable tfoot.ui-widget-content, +.compact-datatable .ui-datatable-footer td, +.compact-datatable .ui-datatable-footer td.ui-state-default { + margin: 0 !important; + padding: 0.1rem !important; + line-height: 1; + font-size: 0.8rem; +} +.compact-datatable .ui-state-default { + margin: 0 !important; + padding: 0 !important; +} + +.light-grey-background { + background-color: #e2e3e5; /* Slightly darker grey than before */ + color: #343a40; /* Dark grey text, ensuring good contrast */ +} +.light-grey-background, +.light-grey-background .ui-column-footer, +.light-grey-background .ui-column-header { + background-color: #e2e3e5; /* Slightly darker grey than before */ + color: #343a40; /* Dark grey text, ensuring good contrast */ +} +.compact-datatable .light-grey-background, +.compact-datatable .ui-datatable thead th.light-grey-background, +.compact-datatable .ui-datatable tfoot td.light-grey-background { + background-color: #e2e3e5; /* Slightly darker grey */ + color: #343a40; /* Dark grey text for contrast */ +} @media print {