diff --git a/src/main/java/com/divudi/bean/common/ReportsController.java b/src/main/java/com/divudi/bean/common/ReportsController.java index 288fd1cd20..154bd7a48b 100644 --- a/src/main/java/com/divudi/bean/common/ReportsController.java +++ b/src/main/java/com/divudi/bean/common/ReportsController.java @@ -31,7 +31,6 @@ 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; @@ -316,16 +315,16 @@ public class ReportsController implements Serializable { private String dischargedStatus; private String selectedDateType = "invoice"; - + private boolean showChart; private Investigation investigation; + // Map>> Map>> weeklyDailyBillItemMap7to7; Map>> weeklyDailyBillItemMap7to1; Map>> weeklyDailyBillItemMap1to7; - private boolean showChart; public String getDischargedStatus() { return dischargedStatus; @@ -390,7 +389,8 @@ public String getSelectedDateType() { public void setSelectedDateType(String selectedDateType) { this.selectedDateType = selectedDateType; - + } + public Investigation getInvestigation() { return investigation; } @@ -1598,14 +1598,6 @@ 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(); @@ -1662,7 +1654,7 @@ private ReportTemplateRowBundle generateSampleCarrierBillItems(List 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<>(); @@ -2398,38 +2422,6 @@ 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) " @@ -3774,4 +3766,5 @@ public ReportTemplateRowBundle generateDiscountBillItems(List bt b.calculateTotalsWithCredit(); return b; } + } 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/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() { 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/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java b/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java new file mode 100644 index 0000000000..9e963c0cd3 --- /dev/null +++ b/src/main/java/com/divudi/bean/pharmacy/PharmacySummaryReportController.java @@ -0,0 +1,1170 @@ +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.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.IncomeBundle; +import com.divudi.entity.Bill; +import com.divudi.entity.Category; +import com.divudi.entity.WebUser; +import com.divudi.facade.DrawerFacade; +import com.divudi.facade.PaymentFacade; +import com.divudi.java.CommonFunctions; +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; +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; + @EJB + BillService billService; + +// +// + @Inject + private BillBeanController billBean; + @Inject + private SessionController sessionController; + @Inject + private 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 IncomeBundle bundle; + + private StreamedContent downloadingExcel; + private UploadedFile file; + + // Numeric variables + private int maxResult = 50; + +// +// + public String navigateToPharmacyIncomeReport() { + return "/pharmacy/reports/summary_reports/pharmacy_income_report?faces-redirect=true"; + } + + public String navigateToDailyStockBalanceReport() { + return "/pharmacy/reports/summary_reports/daily_stock_balance_report?faces-redirect=true"; + } +// +// + + public void resetAllFiltersExceptDateRange() { + 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(); + setFromDate(null); + setToDate(null); + } + + public void processPharmacyIncomeReport(){ + List billTypeAtomics = new ArrayList<>(); + billTypeAtomics.add(BillTypeAtomic.PHARMACY_RETAIL_SALE); + billTypeAtomics.add(BillTypeAtomic.PHARMACY_RETAIL_SALE_CANCELLED); + billTypeAtomics.add(BillTypeAtomic.PHARMACY_RETAIL_SALE_REFUND); + billTypeAtomics.add(BillTypeAtomic.PHARMACY_RETAIL_SALE_RETURN_ITEMS_AND_PAYMENTS); + billTypeAtomics.add(BillTypeAtomic.PHARMACY_RETAIL_SALE_RETURN_ITEMS_ONLY); + billTypeAtomics.add(BillTypeAtomic.PHARMACY_WHOLESALE); + billTypeAtomics.add(BillTypeAtomic.PHARMACY_WHOLESALE_CANCELLED); + billTypeAtomics.add(BillTypeAtomic.PHARMACY_WHOLESALE_PRE); + billTypeAtomics.add(BillTypeAtomic.PHARMACY_WHOLESALE_REFUND); + + List bills = billService.fetchBills(fromDate,toDate,institution,site,department,webUser, billTypeAtomics); + bundle = new IncomeBundle(bills); + bundle.generatePaymentDetailsForBills(); + } + +// +// + 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/IncomeRow.java b/src/main/java/com/divudi/data/IncomeRow.java new file mode 100644 index 0000000000..4aa02bd855 --- /dev/null +++ b/src/main/java/com/divudi/data/IncomeRow.java @@ -0,0 +1,1377 @@ +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; + +/** + * @author buddhika + */ +public class IncomeRow 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 noneValue; + + 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 IncomeRow() { + this.id = UUID.randomUUID(); + } + + public IncomeRow(Institution institution) { + this.institution = institution; + } + + public IncomeRow(Institution institution, Double itemTotal) { + this.itemTotal = itemTotal; + this.institution = institution; + } + + public IncomeRow(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 IncomeRow(Institution collectingCentre, Double totalHospitalFee, Double qty) { + this.collectingCentre = collectingCentre; + this.totalHospitalFee = totalHospitalFee; + this.qty = qty; + } + + public IncomeRow(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; + } + IncomeRow that = (IncomeRow) 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 IncomeRow(PatientInvestigation patientInvestigation) { + this.patientInvestigation = patientInvestigation; + } + + public IncomeRow(SessionInstance sessionInstance) { + this.sessionInstance = sessionInstance; + } + + public IncomeRow(Department department, Double rowValue) { + this.rowValue = rowValue; + this.department = department; + } + + 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; + 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; + this.noneValue = noneValue; + } + + 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; + 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; + this.noneValue = noneValue; + } + + 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; + 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; + this.noneValue = noneValue; + } + + 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; + this.rowCount = rowCount; + this.grossTotal = grossTotal; + this.discount = discount; + this.total = total; + } + + public IncomeRow(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 IncomeRow(BillTypeAtomic billTypeAtomic, Long rowCount) { + this.billTypeAtomic = billTypeAtomic; + this.rowCount = rowCount; + } + + 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; + 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; + this.noneValue = noneValue; + } + + public IncomeRow(Staff referringStaff, Institution referringInstitution, Long long1, Double rowValue) { + this.rowValue = rowValue; + this.long1 = long1; + this.referringInstitution = referringInstitution; + this.referringStaff = referringStaff; + } + + public IncomeRow(Staff referringStaff, Long long1, Double rowValue) { + this.rowValue = rowValue; + this.long1 = long1; + this.referringStaff = referringStaff; + } + + public IncomeRow(Institution referringInstitution, Long long1, Double rowValue) { + this.rowValue = rowValue; + this.long1 = long1; + this.referringInstitution = referringInstitution; + } + + public IncomeRow(Category c) { + this.category = c; + } + + public IncomeRow(Item item) { + this.item = item; + + } + + public IncomeRow(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 IncomeRow(BillSession billSession) { + this.billSession = billSession; + } + + public void setBillSession(BillSession billSession) { + this.billSession = billSession; + } + + 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; + this.itemName = itemName; + this.paymentName = paymentName; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public IncomeRow(String categoryName, Long rowCount, Double rowValue) { + this.categoryName = categoryName; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public IncomeRow(Category category, Long rowCount, Double rowValue) { + this.category = category; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public IncomeRow(Department itemDept, Long rowCount, Double rowValue) { + this.itemDepartment = itemDept; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public IncomeRow(Item item, Long rowCount, Double rowValue) { + this.item = item; + this.rowValue = rowValue; + this.rowCount = rowCount; + } + + public IncomeRow(String categoryName, Double rowValue) { + this.categoryName = categoryName; + this.rowValue = rowValue; + } + + public IncomeRow(BillTypeAtomic billTypeAtomic, String categoryName, String toDepartmentName, Double rowValue) { + this.billTypeAtomic = billTypeAtomic; + this.categoryName = categoryName; + this.toDepartmentName = toDepartmentName; + this.rowValue = rowValue; + } + + public IncomeRow(BillTypeAtomic billTypeAtomic, Double rowValue) { + this.billTypeAtomic = billTypeAtomic; + this.rowValue = rowValue; + } + + public IncomeRow(BillTypeAtomic billTypeAtomic, Long rowCount, Double rowValue) { + this.rowValue = rowValue; + this.rowCount = rowCount; + this.billTypeAtomic = billTypeAtomic; + } + + public IncomeRow(Double rowValue) { + this.rowValue = rowValue; + } + + public IncomeRow(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 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; + 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 IncomeRow(Bill bill) { + this.bill = bill; + } + + public Payment getPayment() { + return payment; + } + + public void setPayment(Payment payment) { + this.payment = payment; + } + + public IncomeRow(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 IncomeRow(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 IncomeRow(BillFee billFee) { + this.billFee = billFee; + } + + public Speciality getSpeciality() { + return speciality; + } + + public void setSpeciality(Speciality speciality) { + this.speciality = speciality; + } + + public IncomeRow(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; + } + + public double getNoneValue() { + return noneValue; + } + + public void setNoneValue(double noneValue) { + this.noneValue = noneValue; + } + +} 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/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/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 442320af04..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/southernlanka + jdbc/Ruhunu false @@ -13,7 +13,7 @@ - jdbc/southernlankaAudit + jdbc/ruhunuAudit false 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}" /> + + + + + + + + @@ -15,184 +16,263 @@ - - - - - - - - - - - - - - - - - - + +
+
+ + +
+
+ + + + + + + +
+
+
+ +
+
+ + + + + + + + + + +
+ +
+ +
+
+
+ + + + + + + + + + + + +
+
+ +
+
+
+
+ + + + + + +
+
+ +
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + +
+
+
+
- - - - - - - - - - - - - + - - - - - - - - - - - - - - - -
diff --git a/src/main/webapp/lab/patient_report.xhtml b/src/main/webapp/lab/patient_report.xhtml index 331377ee4b..4b927b1e20 100644 --- a/src/main/webapp/lab/patient_report.xhtml +++ b/src/main/webapp/lab/patient_report.xhtml @@ -175,12 +175,11 @@ - + @@ -190,7 +189,6 @@ - @@ -205,7 +203,6 @@ rendered="#{patientReportController.currentPatientReport.transInvestigation.reportType ne 'Microbiology' and patientReportController.currentPatientReport.containFlags eq true}" > - @@ -215,7 +212,7 @@ > - - + + + + @@ -797,10 +806,20 @@ + + + + + diff --git a/src/main/webapp/pharmacy/pharmacy_analytics.xhtml b/src/main/webapp/pharmacy/pharmacy_analytics.xhtml index 0fb4ecdbc0..d57fd67031 100644 --- a/src/main/webapp/pharmacy/pharmacy_analytics.xhtml +++ b/src/main/webapp/pharmacy/pharmacy_analytics.xhtml @@ -15,14 +15,20 @@ - +
+ value="Pharmacy Income Report" + action="#{pharmacySummaryReportController.navigateToPharmacyIncomeReport()}"/> +
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..f16848b049 --- /dev/null +++ b/src/main/webapp/pharmacy/reports/summary_reports/pharmacy_income_report.xhtml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #{myBundle1.name} - #{myBundle1.bundleType}
+
+
+ + + + + + + + + + +
+
+
+ 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
+ @@ -273,7 +270,7 @@ >
+ @@ -775,7 +772,19 @@ CSS - Contents + LOB + + Str + + Display + + Double + + Value
#{prv.lobValue} + #{prv.strValue} + #{prv.displayValue} + #{prv.doubleValue} + #{prv.value} +