diff --git a/.github/last_date.txt b/.github/last_date.txt index 6c93b259fd..83e0fd5a4a 100644 --- a/.github/last_date.txt +++ b/.github/last_date.txt @@ -1 +1 @@ -20240720 +20240720 \ No newline at end of file diff --git a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java index d820e98a81..c598ac84c5 100644 --- a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java +++ b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java @@ -21,6 +21,8 @@ import com.divudi.data.FinancialReport; import com.divudi.data.PaymentMethod; import com.divudi.data.PaymentMethodValues; +import com.divudi.data.ReportTemplateRow; +import com.divudi.data.ReportTemplateRowBundle; import com.divudi.entity.WebUser; import com.divudi.java.CommonFunctions; import javax.inject.Named; @@ -31,6 +33,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.ejb.EJB; import javax.inject.Inject; import javax.persistence.TemporalType; @@ -127,6 +130,11 @@ public class FinancialTransactionController implements Serializable { private Date fromDate; private Date toDate; + private Date fromDate; + private Date toDate; + + private ReportTemplateRowBundle paymentSummaryBundle; + // // public FinancialTransactionController() { @@ -568,6 +576,83 @@ public String navigateToCreateShiftEndSummaryBill() { return "/cashier/shift_end_summery_bill?faces-redirect=true"; } + public String navigateToDayEndSummary() { + return "/analytics/day_end_summery?faces-redirect=true"; + } + + public void processDayEndSummary() { + System.out.println("processDayEndSummary"); + resetClassVariables(); + fillPaymentsForDateRange(); + createPaymentSummery(); + + } + + private void createPaymentSummery() { + System.out.println("createPaymentSummery"); + System.out.println("paymentsFromShiftSratToNow = " + paymentsFromShiftSratToNow); + + if (paymentsFromShiftSratToNow == null) { + return; + } + + paymentSummaryBundle = new ReportTemplateRowBundle(); + Map aggregatedPayments = new HashMap<>(); + Map keyMap = new HashMap<>(); + + for (Payment p : paymentsFromShiftSratToNow) { + System.out.println("p = " + p); + + if (p == null || p.getBill() == null) { + continue; // Skip this iteration if p or p.getBill() is null + } + + ReportTemplateRow row = new ReportTemplateRow(); + + if (p.getBill().getCategory() != null) { + row.setCategory(p.getBill().getCategory()); + } + + if (p.getBill().getBillTypeAtomic() != null) { + row.setBillTypeAtomic(p.getBill().getBillTypeAtomic()); + + if (p.getBill().getBillTypeAtomic().getServiceType() != null) { + row.setServiceType(p.getBill().getBillTypeAtomic().getServiceType()); + } + } + + if (p.getBill().getCreditCompany() != null) { + row.setCreditCompany(p.getBill().getCreditCompany()); + } + + if (p.getBill().getToDepartment() != null) { + row.setToDepartment(p.getBill().getToDepartment()); + } + + row.setRowValue(p.getPaidValue()); + + String keyString = row.getCustomKey(); + + if (keyString != null) { + keyMap.putIfAbsent(keyString, row); + aggregatedPayments.merge(keyString, p.getPaidValue(), Double::sum); + } + } + + List rows = aggregatedPayments.entrySet().stream().map(entry -> { + ReportTemplateRow row = keyMap.get(entry.getKey()); + + if (row != null) { + row.setRowValue(entry.getValue()); + } + + return row; + }).collect(Collectors.toList()); + + if (paymentSummaryBundle != null) { + paymentSummaryBundle.getReportTemplateRows().addAll(rows); + } + public String navigateToViewEndOfSelectedShiftStartSummaryBill(Bill startBill) { resetClassVariables(); if (startBill == null) { @@ -1494,7 +1579,7 @@ public void setFinancialReportByPayments(FinancialReport financialReportByPaymen public Date getFromDate() { if (fromDate == null) { - fromDate = CommonFunctions.getStartOfDay(); + fromDate = CommonFunctions.getStartOfDay(new Date()); } return fromDate; } @@ -1505,7 +1590,7 @@ public void setFromDate(Date fromDate) { public Date getToDate() { if (toDate == null) { - toDate = CommonFunctions.getEndOfDay(); + toDate = CommonFunctions.getEndOfDay(toDate); } return toDate; } @@ -1514,12 +1599,23 @@ public void setToDate(Date toDate) { this.toDate = toDate; } + public ReportTemplateRowBundle getPaymentSummaryBundle() { + if (paymentSummaryBundle == null) { + paymentSummaryBundle = new ReportTemplateRowBundle(); + } + return paymentSummaryBundle; + } + + public void setPaymentSummaryBundle(ReportTemplateRowBundle paymentSummaryBundle) { + this.paymentSummaryBundle = paymentSummaryBundle; + public List getShiaftStartBills() { return shiaftStartBills; } public void setShiaftStartBills(List shiaftStartBills) { this.shiaftStartBills = shiaftStartBills; + } } diff --git a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java index ce88d159ed..6c8a4153dc 100644 --- a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java +++ b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java @@ -333,6 +333,12 @@ public class BookingControllerViewScope implements Serializable, ControllerWithP private String encryptedBillSessionId; private String encryptedExpiary; + private boolean listOngoing; + private boolean listPending; + private boolean listCancelled; + private boolean listCompleted; + private boolean listAll; + public void sessionReschedule() { if (getSelectedSessionInstanceForRechedule() == null) { JsfUtil.addErrorMessage("Pleace Select Session For Rechedule"); @@ -1036,6 +1042,182 @@ public void addMonth() { filterSessionInstances(); } + public void addMonthNew() { + Calendar cal = Calendar.getInstance(); + cal.setTime(getFromDate()); + cal.add(Calendar.MONTH, 1); + toDate = cal.getTime(); + listAndFilterSessionInstances(); + } + + public void addSingleDateToToDateNew() { + Calendar cal = Calendar.getInstance(); + cal.setTime(getFromDate()); + cal.add(Calendar.DATE, 1); + toDate = cal.getTime(); + listAndFilterSessionInstances(); + } + + public void addToDayToToDateNew() { + toDate = new Date(); + listAndFilterSessionInstances(); + } + + public void filterSessionInstancesNew() { + sessionInstancesFiltered = new ArrayList<>(); + if (sessionInstanceFilter == null) { + return; + } + if (sessionInstanceFilter.trim().equals("")) { + return; + } + if (sessionInstanceFilter.length() < 4) { + return; + } + listAndFilterSessionInstances(); + } + + public void addTwoDaysNew() { + Calendar cal = Calendar.getInstance(); + cal.setTime(getFromDate()); + cal.add(Calendar.DATE, 2); + toDate = cal.getTime(); + listAndFilterSessionInstances(); + } + + public void addSevenDaysNew() { + Calendar cal = Calendar.getInstance(); + cal.setTime(getFromDate()); + cal.add(Calendar.DATE, 7); + toDate = cal.getTime(); + listAndFilterSessionInstances(); + } + + public void listAll() { + listAll = true; + listPending = false; + listCancelled = false; + listOngoing = false; + listCompleted = false; + listAndFilterSessionInstances(); + + } + + public void listPending() { + listAll = false; + listPending = true; + listCancelled = false; + listOngoing = false; + listCompleted = false; + listAndFilterSessionInstances(); + } + + public void listOngoing() { + listAll = false; + listPending = false; + listCancelled = false; + listOngoing = true; + listCompleted = false; + listAndFilterSessionInstances(); + } + + public void listCompleted() { + listAll = false; + listPending = false; + listCancelled = false; + listOngoing = false; + listCompleted = true; + listAndFilterSessionInstances(); + } + + public void addBillSessionData() { + if (configOptionApplicationController.getBooleanValueByKey("Calculate All Patient Count When Loading Channel Booking By Dates")) { + if (sessionInstances != null) { + if (sessionInstances.size() < 21) { + for (SessionInstance s : sessionInstances) { + fillBillSessions(s); + } + } + } + } + } + + public void listAndFilterSessionInstances() { + loadSessionInstances(); + addBillSessionData(); + } + + public void loadSessionInstances() { + sessionInstancesFiltered = new ArrayList<>(); + StringBuilder jpql = new StringBuilder("select i from SessionInstance i where i.retired=:ret and i.originatingSession.retired=:ret"); + + // Initializing the parameters map + Map params = new HashMap<>(); + params.put("ret", false); + + // Adding date conditions + if (fromDate != null && toDate != null) { + jpql.append(" and i.sessionDate between :fromDate and :toDate"); + params.put("fromDate", fromDate); + params.put("toDate", toDate); + } else if (fromDate != null) { + jpql.append(" and i.sessionDate >= :fromDate"); + params.put("fromDate", fromDate); + } else if (toDate != null) { + jpql.append(" and i.sessionDate <= :toDate"); + params.put("toDate", toDate); + } else { + jpql.append(" and i.sessionDate = :sd"); + params.put("sd", new Date()); + } + + // Dynamically appending conditions based on parameters + List conditions = new ArrayList<>(); + if (listOngoing) { + conditions.add("(i.started = true and i.completed = false)"); + } + if (listCompleted) { + conditions.add("i.completed = true"); + } + if (listPending) { + conditions.add("(i.started = false and i.completed = false)"); + } + if (listCancelled) { + conditions.add("i.cancelled = true"); + } + + // Adding the conditions to the JPQL query + if (!conditions.isEmpty()) { + jpql.append(" and (").append(String.join(" or ", conditions)).append(")"); + } + + // Adding string filter conditions + if (sessionInstanceFilter != null && !sessionInstanceFilter.trim().isEmpty()) { + String[] filterKeywords = sessionInstanceFilter.trim().toLowerCase().split("\\s+"); + List filterConditions = new ArrayList<>(); + for (String keyword : filterKeywords) { + filterConditions.add("(lower(i.originatingSession.name) like :keyword" + + " or lower(i.originatingSession.staff.person.name) like :keyword" + + " or lower(i.originatingSession.staff.speciality.name) like :keyword)"); + } + jpql.append(" and (").append(String.join(" or ", filterConditions)).append(")"); + params.put("keyword", "%" + sessionInstanceFilter.trim().toLowerCase() + "%"); + } + + // Adding sorting to JPQL + jpql.append(" order by i.sessionDate, i.originatingSession.name"); + + Long numberOfSessionToLoad = configOptionApplicationController.getLongValueByKey("Maximum Number of Sessions to Load during channel booking by dates page.", 30L); + + sessionInstancesFiltered = sessionInstanceFacade.findByJpql(jpql.toString(), params, TemporalType.DATE, numberOfSessionToLoad.intValue()); + + // Select the first item if the filtered list is not empty + if (!sessionInstancesFiltered.isEmpty()) { + selectedSessionInstance = sessionInstancesFiltered.get(0); + sessionInstanceSelected(); + } + } + public void filterSessionInstances() { if (sessionInstanceFilter == null || sessionInstanceFilter.trim().isEmpty()) { if (sessionInstances != null) { @@ -1425,6 +1607,41 @@ public String navigateToChannelBookingFromMenuByDate() { } + public String navigateToChannelBookingFromMenuByDateNew() { + Boolean opdBillingAfterShiftStart = sessionController.getApplicationPreference().isOpdBillingAftershiftStart(); + + viewScopeDataTransferController.setFromDate(fromDate); + viewScopeDataTransferController.setToDate(toDate); + + viewScopeDataTransferController.setNeedToFillBillSessions(false); + viewScopeDataTransferController.setNeedToFillBillSessionDetails(false); + viewScopeDataTransferController.setNeedToFillSessionInstances(true); + viewScopeDataTransferController.setNeedToFillSessionInstanceDetails(true); + viewScopeDataTransferController.setNeedToFillMembershipDetails(false); + viewScopeDataTransferController.setNeedToPrepareForNewBooking(true); + + if (opdBillingAfterShiftStart) { + financialTransactionController.findNonClosedShiftStartFundBillIsAvailable(); + if (financialTransactionController.getNonClosedShiftStartFundBill() != null) { + fromDate = new Date(); + toDate = new Date(); + listAndFilterSessionInstances(); + prepareForNewChannellingBill(); + return "/channel/channel_booking_by_date?faces-redirect=true"; + } else { + JsfUtil.addErrorMessage("Start Your Shift First !"); + return "/cashier/index?faces-redirect=true"; + } + } else { + fromDate = new Date(); + toDate = new Date(); + listAndFilterSessionInstances(); + prepareForNewChannellingBill(); + return "/channel/channel_booking_by_date?faces-redirect=true"; + } + + } + public String navigateToChannelBookingFromMembershipByDate(Patient pt, PaymentScheme ps) { if (pt == null) { @@ -7805,4 +8022,44 @@ public void setEncryptedExpiary(String encryptedExpiary) { this.encryptedExpiary = encryptedExpiary; } + public boolean isListOngoing() { + return listOngoing; + } + + public void setListOngoing(boolean listOngoing) { + this.listOngoing = listOngoing; + } + + public boolean isListPending() { + return listPending; + } + + public void setListPending(boolean listPending) { + this.listPending = listPending; + } + + public boolean isListCancelled() { + return listCancelled; + } + + public void setListCancelled(boolean listCancelled) { + this.listCancelled = listCancelled; + } + + public boolean isListCompleted() { + return listCompleted; + } + + public void setListCompleted(boolean listCompleted) { + this.listCompleted = listCompleted; + } + + public boolean isListAll() { + return listAll; + } + + public void setListAll(boolean listAll) { + this.listAll = listAll; + } + } diff --git a/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java b/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java index 934c1feb39..3673947dad 100644 --- a/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java +++ b/src/main/java/com/divudi/bean/channel/analytics/ReportTemplateController.java @@ -40,6 +40,7 @@ import javax.faces.convert.FacesConverter; import javax.inject.Inject; import javax.inject.Named; +import javax.persistence.TemporalType; /** * @@ -72,6 +73,7 @@ public class ReportTemplateController implements Serializable { private Date fromDate; private Date toDate; private Institution institution; + private Institution creditCompany; private Department department; private Institution fromInstitution; private Department fromDepartment; @@ -79,7 +81,7 @@ public class ReportTemplateController implements Serializable { private Department toDepartment; private WebUser user; private Staff staff; - + private List ReportTemplateRows; private ReportTemplateRowBundle reportTemplateRowBundle; @@ -160,6 +162,9 @@ public String processReport() { case BILLT_TYPE_AND_PAYMENT_METHOD_SUMMARY_USING_BILLS: handleBillTypeAndPaymentMethodSummaryUsingBills(); break; + case BILL_TYPE_ATOMIC_SUMMARY_USING_FEES: + handleBillFeeGroupedByBillTypeAtomic(); + break; case BILL_FEE_GROUPED_BY_TO_DEPARTMENT_AND_CATEGORY: handleBillFeeGroupedByToDepartmentAndCategory(); break; @@ -196,6 +201,24 @@ public String processReport() { case PAYMENT_TYPE_SUMMARY_USING_BILLS: handlePaymentTypeSummaryUsingBills(); break; + case ITEM_CATEGORY_SUMMARY_BY_BILL_FEE: + handleItemCategorySummaryByBillFee(); + break; + case ITEM_CATEGORY_SUMMARY_BY_BILL_ITEM: + handleItemCategorySummaryByBillItem(); + break; + case ITEM_CATEGORY_SUMMARY_BY_BILL: + handleItemCategorySummaryByBill(); + break; + case TO_DEPARTMENT_SUMMARY_BY_BILL_FEE: + handleToDepartmentSummaryByBillFee(); + break; + case TO_DEPARTMENT_SUMMARY_BY_BILL_ITEM: + handleToDepartmentSummaryByBillItem(); + break; + case TO_DEPARTMENT_SUMMARY_BY_BILL: + handleToDepartmentSummaryByBill(); + break; default: JsfUtil.addErrorMessage("Unknown Report Type"); return ""; @@ -211,67 +234,151 @@ private void handleBillTypeAndPaymentMethodSummaryUsingBills() { // Method implementation here } - private void handleBillFeeGroupedByToDepartmentAndCategory() { + private void handleBillFeeGroupedByBillTypeAtomic() { String jpql; Map parameters = new HashMap<>(); + reportTemplateRowBundle = new ReportTemplateRowBundle(); - jpql = "select new com.divudi.data.ReportTemplateRow(bf.bill.billTypeAtomic, bf.bill.category.name, bf.bill.toDepartment.name, sum(bf.fee)) " + jpql = "select new com.divudi.data.ReportTemplateRow(" + + " bill.billTypeAtomic, sum(bf.feeValue)) " + " from BillFee bf " - + " where bf.retired=:bfr " - + " and bf.billItem.retired=:bir " - + " and bf.bill.retired=:br " - + " and bf.bill.billTypeAtomic in :btas "; + + " join bf.bill bill " + + " where bf.retired<>:bfr " + + " and bf.billItem.retired<>:bir " + + " and bill.retired<>:br "; + parameters.put("bfr", true); + parameters.put("bir", true); + parameters.put("br", true); + + if (current.getBillTypeAtomics() != null) { + jpql += " and bill.billTypeAtomic in :btas "; + parameters.put("btas", current.getBillTypeAtomics()); + } - boolean testing = true; - if (!testing) { - BillFee bf = new BillFee(); - bf.getBill().getBillTypeAtomic(); // Enum - bf.getBill().getCategory().getName(); // String - bf.getBill().getToDepartment().getName(); // String - bf.getFeeValue(); // double + for (ReportTemplateFilter f : current.getReportFilters()) { + switch (f) { + case DATE: + jpql += " and bill.billDate=:bd "; + parameters.put("bd", date); + break; + case TO_DATE: + jpql += " and bill.billDate < :td "; + parameters.put("td", toDate); + break; + case FROM_DATE: + jpql += " and bill.billDate > :fd "; + parameters.put("fd", fromDate); + break; + case INSTITUTION: + jpql += " and bill.institution=:ins "; + parameters.put("ins", institution); + break; + case DEPARTMENT: + jpql += " and bill.department=:dep "; + parameters.put("dep", department); + break; + case FROM_INSTITUTION: + jpql += " and bill.fromInstitution=:fins "; + parameters.put("fins", fromInstitution); + break; + case FROM_DEPARTMENT: + jpql += " and bill.fromDepartment=:fdep "; + parameters.put("fdep", fromDepartment); + break; + case TO_INSTITUTION: + jpql += " and bill.toInstitution=:tins "; + parameters.put("tins", toInstitution); + break; + case TO_DEPARTMENT: + jpql += " and bill.toDepartment=:tdep "; + parameters.put("tdep", toDepartment); + break; + case CREDIT_COMPANY: + jpql += " and bill.creditCompany=:creditCompany "; + parameters.put("creditCompany", creditCompany); + break; + default: + throw new AssertionError(); + } } + jpql += " group by bill.billTypeAtomic"; + + System.out.println("jpql = " + jpql); + System.out.println("parameters = " + parameters); + + List rs = (List) ejbFacade.findLightsByJpql(jpql, parameters, TemporalType.DATE); + + if (rs == null || rs.isEmpty()) { + System.out.println("No results found."); + } else { + System.out.println("Results found: " + rs.size()); + } + + long idCounter = 1; + for (ReportTemplateRow row : rs) { + row.setId(idCounter++); + } + reportTemplateRowBundle.setReportTemplateRows(rs); + } + + private void handleBillFeeGroupedByToDepartmentAndCategory() { + String jpql; + Map parameters = new HashMap<>(); + reportTemplateRowBundle = new ReportTemplateRowBundle(); + + jpql = "select new com.divudi.data.ReportTemplateRow(" + + " bill.billTypeAtomic, sum(bf.feeValue)) " + + " from BillFee bf " + + " join bf.bill bill " + + " where bf.retired<>:bfr " + + " and bf.billItem.retired<>:bir " + + " and bill.retired<>:br "; + parameters.put("bfr", true); + parameters.put("bir", true); + parameters.put("br", true); + if (current.getBillTypeAtomics() != null) { - jpql += " and bf.bill.billTypeAtomic in :btas "; + jpql += " and bill.billTypeAtomic in :btas "; parameters.put("btas", current.getBillTypeAtomics()); } for (ReportTemplateFilter f : current.getReportFilters()) { switch (f) { case DATE: - jpql += " and bf.bill.billDate=:bd "; + jpql += " and bill.billDate=:bd "; parameters.put("bd", date); break; case TO_DATE: - jpql += " and bf.bill.billDate < :td "; + jpql += " and bill.billDate < :td "; parameters.put("td", toDate); break; case FROM_DATE: - jpql += " and bf.bill.billDate > :fd "; + jpql += " and bill.billDate > :fd "; parameters.put("fd", fromDate); break; case INSTITUTION: - jpql += " and bf.bill.institution=:ins "; + jpql += " and bill.institution=:ins "; parameters.put("ins", institution); break; case DEPARTMENT: - jpql += " and bf.bill.department=:dep "; + jpql += " and bill.department=:dep "; parameters.put("dep", department); break; case FROM_INSTITUTION: - jpql += " and bf.bill.fromInstitution=:fins "; + jpql += " and bill.fromInstitution=:fins "; parameters.put("fins", fromInstitution); break; case FROM_DEPARTMENT: - jpql += " and bf.bill.fromDepartment=:fdep "; + jpql += " and bill.fromDepartment=:fdep "; parameters.put("fdep", fromDepartment); break; case TO_INSTITUTION: - jpql += " and bf.bill.toInstitution=:tins "; + jpql += " and bill.toInstitution=:tins "; parameters.put("tins", toInstitution); break; case TO_DEPARTMENT: - jpql += " and bf.bill.toDepartment=:tdep "; + jpql += " and bill.toDepartment=:tdep "; parameters.put("tdep", toDepartment); break; default: @@ -279,7 +386,24 @@ private void handleBillFeeGroupedByToDepartmentAndCategory() { } } - // Add the code to execute the JPQL query using the parameters map + jpql += " group by bill.billTypeAtomic"; + + System.out.println("jpql = " + jpql); + System.out.println("parameters = " + parameters); + + List rs = (List) ejbFacade.findLightsByJpql(jpql, parameters, TemporalType.DATE); + + if (rs == null || rs.isEmpty()) { + System.out.println("No results found."); + } else { + System.out.println("Results found: " + rs.size()); + } + + long idCounter = 1; + for (ReportTemplateRow row : rs) { + row.setId(idCounter++); + } + reportTemplateRowBundle.setReportTemplateRows(rs); } private void handleBillFeeList() { @@ -295,7 +419,87 @@ private void handleBillList() { } private void handleBillTypeAtomicSummaryUsingBills() { - // Method implementation here + String jpql; + Map parameters = new HashMap<>(); + reportTemplateRowBundle = new ReportTemplateRowBundle(); + + jpql = "select new com.divudi.data.ReportTemplateRow(" + + " bill.billTypeAtomic, sum(bill.netTotal)) " + + " from Bill bill " + + " where bill.retired<>:br "; + parameters.put("br", true); + + if (current.getBillTypeAtomics() != null) { + jpql += " and bill.billTypeAtomic in :btas "; + parameters.put("btas", current.getBillTypeAtomics()); + } + + for (ReportTemplateFilter f : current.getReportFilters()) { + switch (f) { + case DATE: + jpql += " and bill.billDate=:bd "; + parameters.put("bd", date); + break; + case TO_DATE: + jpql += " and bill.billDate < :td "; + parameters.put("td", toDate); + break; + case FROM_DATE: + jpql += " and bill.billDate > :fd "; + parameters.put("fd", fromDate); + break; + case INSTITUTION: + jpql += " and bill.institution=:ins "; + parameters.put("ins", institution); + break; + case DEPARTMENT: + jpql += " and bill.department=:dep "; + parameters.put("dep", department); + break; + case FROM_INSTITUTION: + jpql += " and bill.fromInstitution=:fins "; + parameters.put("fins", fromInstitution); + break; + case FROM_DEPARTMENT: + jpql += " and bill.fromDepartment=:fdep "; + parameters.put("fdep", fromDepartment); + break; + case TO_INSTITUTION: + jpql += " and bill.toInstitution=:tins "; + parameters.put("tins", toInstitution); + break; + case TO_DEPARTMENT: + jpql += " and bill.toDepartment=:tdep "; + parameters.put("tdep", toDepartment); + break; + case CREDIT_COMPANY: + jpql += " and bill.creditCompany=:creditCompany "; + parameters.put("creditCompany", creditCompany); + break; + default: + throw new AssertionError(); + } + } + + jpql += " group by bill.billTypeAtomic"; + + System.out.println("jpql = " + jpql); + System.out.println("parameters = " + parameters); + + List rs = (List) ejbFacade.findLightsByJpql(jpql, parameters, TemporalType.DATE); + + if (rs == null || rs.isEmpty()) { + System.out.println("No results found."); + } else { + System.out.println("Results found: " + rs.size()); + } + + long idCounter = 1; + for (ReportTemplateRow row : rs) { + row.setId(idCounter++); + } + reportTemplateRowBundle.setReportTemplateRows(rs); + } private void handleBillTypeAtomicSummaryUsingPayments() { @@ -618,11 +822,128 @@ public ReportTemplateRowBundle getReportTemplateRowBundle() { public void setReportTemplateRowBundle(ReportTemplateRowBundle reportTemplateRowBundle) { this.reportTemplateRowBundle = reportTemplateRowBundle; } - + + public Institution getCreditCompany() { + return creditCompany; + } + + public void setCreditCompany(Institution creditCompany) { + this.creditCompany = creditCompany; + } + + /** * */ - @FacesConverter(forClass = ReportTemplate.class) + private void handleItemCategorySummaryByBillFee() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + private void handleItemCategorySummaryByBillItem() { + String jpql; + Map parameters = new HashMap<>(); + reportTemplateRowBundle = new ReportTemplateRowBundle(); + + jpql = "select new com.divudi.data.ReportTemplateRow(" + + " bi.item.category.name, sum(bi.netValue)) " + + " from BillItem bi" + + " join bi.bill bill " + + " where bill.retired<>:br " + + " and bi.retired<>:br "; + parameters.put("br", true); + + if (current.getBillTypeAtomics() != null) { + jpql += " and bill.billTypeAtomic in :btas "; + parameters.put("btas", current.getBillTypeAtomics()); + } + + for (ReportTemplateFilter f : current.getReportFilters()) { + switch (f) { + case DATE: + jpql += " and bill.billDate=:bd "; + parameters.put("bd", date); + break; + case TO_DATE: + jpql += " and bill.billDate < :td "; + parameters.put("td", toDate); + break; + case FROM_DATE: + jpql += " and bill.billDate > :fd "; + parameters.put("fd", fromDate); + break; + case INSTITUTION: + jpql += " and bill.institution=:ins "; + parameters.put("ins", institution); + break; + case DEPARTMENT: + jpql += " and bill.department=:dep "; + parameters.put("dep", department); + break; + case FROM_INSTITUTION: + jpql += " and bill.fromInstitution=:fins "; + parameters.put("fins", fromInstitution); + break; + case FROM_DEPARTMENT: + jpql += " and bill.fromDepartment=:fdep "; + parameters.put("fdep", fromDepartment); + break; + case TO_INSTITUTION: + jpql += " and bill.toInstitution=:tins "; + parameters.put("tins", toInstitution); + break; + case TO_DEPARTMENT: + jpql += " and bill.toDepartment=:tdep "; + parameters.put("tdep", toDepartment); + break; + case CREDIT_COMPANY: + jpql += " and bill.creditCompany=:creditCompany "; + parameters.put("creditCompany", creditCompany); + break; + default: + throw new AssertionError(); + } + } + + jpql += " and bi.item is not null " + + " and bi.item.category is not null "; + + jpql += " group by bi.item.category "; + + System.out.println("jpql = " + jpql); + System.out.println("parameters = " + parameters); + + List rs = (List) ejbFacade.findLightsByJpql(jpql, parameters, TemporalType.DATE); + + if (rs == null || rs.isEmpty()) { + System.out.println("No results found."); + } else { + System.out.println("Results found: " + rs.size()); + } + + long idCounter = 1; + for (ReportTemplateRow row : rs) { + row.setId(idCounter++); + } + reportTemplateRowBundle.setReportTemplateRows(rs); + } + + private void handleItemCategorySummaryByBill() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + private void handleToDepartmentSummaryByBillFee() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + private void handleToDepartmentSummaryByBillItem() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + private void handleToDepartmentSummaryByBill() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + public static class ReportTemplateConverter implements Converter { @Override diff --git a/src/main/java/com/divudi/bean/opd/OpdBillController.java b/src/main/java/com/divudi/bean/opd/OpdBillController.java index e89d52bc8d..4f38fc9c6e 100644 --- a/src/main/java/com/divudi/bean/opd/OpdBillController.java +++ b/src/main/java/com/divudi/bean/opd/OpdBillController.java @@ -294,6 +294,7 @@ public class OpdBillController implements Serializable, ControllerWithPatient, C private Double totalSaffFee; private boolean canChangeSpecialityAndDoctorInAddedBillItem; private String localNumber; + /** * * Navigation Methods @@ -831,7 +832,7 @@ public void changeBillDoctorByFee(BillFee bf) { getCurrentlyWorkingStaff().add(bf.getStaff()); selectedCurrentlyWorkingStaff = bf.getStaff(); } - + public void changeBillDoctorByReferral() { if (referredBy == null) { JsfUtil.addErrorMessage("No referring doctor"); @@ -1398,6 +1399,11 @@ public void setSessionDate(Date sessionDate) { } public boolean isForeigner() { + if (configOptionApplicationController.getBooleanValueByKey("Save the Patient with Patient Status")) { + if (patient != null) { + foreigner = patient.getPerson().isForeigner(); + } + } return foreigner; } @@ -2002,7 +2008,6 @@ private void saveBatchBill() { newBatchBill.setCreatedAt(new Date()); newBatchBill.setCreater(getSessionController().getLoggedUser()); newBatchBill.setFromStaff(selectedCurrentlyWorkingStaff); - getBillFacade().create(newBatchBill); @@ -2091,9 +2096,9 @@ private Bill saveBill(Department bt, Bill newBill) { newBill.setBillDate(new Date()); newBill.setBillTime(new Date()); newBill.setPatient(patient); - + if (localNumber != null) { - newBill.setLocalNumber(localNumber); + newBill.setLocalNumber(localNumber); } // newBill.setMembershipScheme(membershipSchemeController.fetchPatientMembershipScheme(patient, getSessionController().getApplicationPreference().isMembershipExpires())); diff --git a/src/main/java/com/divudi/data/ReportTemplateRow.java b/src/main/java/com/divudi/data/ReportTemplateRow.java index 666232025b..965710e6d9 100644 --- a/src/main/java/com/divudi/data/ReportTemplateRow.java +++ b/src/main/java/com/divudi/data/ReportTemplateRow.java @@ -1,5 +1,9 @@ package com.divudi.data; +import com.divudi.entity.Category; +import com.divudi.entity.Department; +import com.divudi.entity.Institution; + /** * * @author buddhika @@ -15,9 +19,11 @@ public class ReportTemplateRow { private Long rowCount; private Long id; - public String getFeeName() { - return feeName; - } + private Category category; + private ServiceType serviceType; + private BillTypeAtomic billTypeAtomic; + private Institution creditCompany; + private Department toDepartment; public void setFeeName(String feeName) { this.feeName = feeName; @@ -80,6 +86,28 @@ public ReportTemplateRow(String feeName, String categoryName, String toDepartmen this.rowValue = rowValue; this.rowCount = rowCount; } + + public ReportTemplateRow(String categoryName, Double rowValue) { + this.categoryName = categoryName; + this.rowValue = rowValue; + } + + public ReportTemplateRow(BillTypeAtomic billTypeAtomic, String categoryName, String toDepartmentName, Double rowValue) { + this.billTypeAtomic = billTypeAtomic; + this.categoryName = categoryName; + this.toDepartmentName = toDepartmentName; + this.rowValue = rowValue; + } + + public ReportTemplateRow(BillTypeAtomic billTypeAtomic, Double rowValue) { + this.billTypeAtomic = billTypeAtomic; + this.rowValue = rowValue; + } + + + public ReportTemplateRow(Double rowValue) { + this.rowValue = rowValue; + } public ReportTemplateRow() { } @@ -92,6 +120,57 @@ public void setId(Long id) { this.id = id; } - - + 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; + } + } diff --git a/src/main/java/com/divudi/data/ReportTemplateRowBundle.java b/src/main/java/com/divudi/data/ReportTemplateRowBundle.java index e69a02a0f2..5064db5b99 100644 --- a/src/main/java/com/divudi/data/ReportTemplateRowBundle.java +++ b/src/main/java/com/divudi/data/ReportTemplateRowBundle.java @@ -1,6 +1,7 @@ package com.divudi.data; import com.divudi.entity.ReportTemplate; +import java.util.ArrayList; import java.util.List; /** @@ -10,7 +11,7 @@ public class ReportTemplateRowBundle { private ReportTemplate reportTemplate; - private List reportTemplateRowBundles; + private List reportTemplateRows; public ReportTemplate getReportTemplate() { return reportTemplate; @@ -20,13 +21,18 @@ public void setReportTemplate(ReportTemplate reportTemplate) { this.reportTemplate = reportTemplate; } - public List getReportTemplateRowBundles() { - return reportTemplateRowBundles; + public List getReportTemplateRows() { + if(reportTemplateRows==null){ + reportTemplateRows = new ArrayList<>(); + } + return reportTemplateRows; } - public void setReportTemplateRowBundles(List reportTemplateRowBundles) { - this.reportTemplateRowBundles = reportTemplateRowBundles; + public void setReportTemplateRows(List reportTemplateRows) { + this.reportTemplateRows = reportTemplateRows; } + + diff --git a/src/main/java/com/divudi/data/analytics/ReportTemplateFilter.java b/src/main/java/com/divudi/data/analytics/ReportTemplateFilter.java index adb0712e74..7aa9349a97 100644 --- a/src/main/java/com/divudi/data/analytics/ReportTemplateFilter.java +++ b/src/main/java/com/divudi/data/analytics/ReportTemplateFilter.java @@ -11,12 +11,11 @@ public enum ReportTemplateFilter { INSTITUTION("Institution"), DEPARTMENT("Department"), + CREDIT_COMPANY("Credit Company"), FROM_INSTITUTION("From Institution"), FROM_DEPARTMENT("From Department"), TO_INSTITUTION("To Institution"), - TO_DEPARTMENT("To Department"), - - ; + TO_DEPARTMENT("To Department"),; private final String label; diff --git a/src/main/java/com/divudi/data/analytics/ReportTemplateType.java b/src/main/java/com/divudi/data/analytics/ReportTemplateType.java index 139a36d735..d52b6ceb15 100644 --- a/src/main/java/com/divudi/data/analytics/ReportTemplateType.java +++ b/src/main/java/com/divudi/data/analytics/ReportTemplateType.java @@ -15,10 +15,19 @@ public enum ReportTemplateType { BILLT_TYPE_AND_PAYMENT_METHOD_SUMMARY_USING_BILLS("Bill Type Summary by using Bills"), PAYMENT_TYPE_SUMMARY_USING_BILLS("Payment Method Summary by using Bills"), BILL_TYPE_ATOMIC_SUMMARY_USING_PAYMENTS("Bill Type Summary by using Payments"), + BILL_TYPE_ATOMIC_SUMMARY_USING_FEES("Bill Type Summary usinf Bill Fees"), BILLT_TYPE_AND_PAYMENT_METHOD_SUMMARY_PAYMENTS("Bill Type Summary by using Payments"), PAYMENT_METHOD_SUMMARY_USING_PAYMENTS("Bill Type Summary by using Payments"), PAYMENT_METHOD_SUMMARY_USING_BILLS("Bill Type Summary by using Payments"), - PAYMENT_TYPE_SUMMARY_PAYMENTS("Payment Method Summary by using Payments"),; + PAYMENT_TYPE_SUMMARY_PAYMENTS("Payment Method Summary by using Payments"), + ITEM_CATEGORY_SUMMARY_BY_BILL_FEE("Item Category Summary by Bill Fee"), + ITEM_CATEGORY_SUMMARY_BY_BILL_ITEM("Item Category Summary by Bill Item"), + ITEM_CATEGORY_SUMMARY_BY_BILL("Item Category Summary by Bill"), + TO_DEPARTMENT_SUMMARY_BY_BILL_FEE("To Department Summary by Bill Fee"), + TO_DEPARTMENT_SUMMARY_BY_BILL_ITEM("To Department Summary by Bill Item"), + TO_DEPARTMENT_SUMMARY_BY_BILL("To Department Summary by Bill"); + + ; private final String label; diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml index 82d8488908..1b6f661a7c 100644 --- a/src/main/resources/META-INF/persistence.xml +++ b/src/main/resources/META-INF/persistence.xml @@ -1,23 +1,22 @@ - - org.eclipse.persistence.jpa.PersistenceProvider - jdbc/sethma - false - - - - - - - - jdbc/sethmaAudit - com.divudi.entity.AuditEvent - true - - - - - - + + + org.eclipse.persistence.jpa.PersistenceProvider + jdbc/arogya + false + + + + + + + jdbc/arogyaAudit + com.divudi.entity.AuditEvent + true + + + + + diff --git a/src/main/resources/VERSION.txt b/src/main/resources/VERSION.txt index 497b169fd2..9dc66492f8 100644 --- a/src/main/resources/VERSION.txt +++ b/src/main/resources/VERSION.txt @@ -1 +1 @@ -3.0.0.20240720.2 +3.0.0.20240720.2 \ No newline at end of file diff --git a/src/main/webapp/analytics/all_financial_transaction_summary_by_user.xhtml b/src/main/webapp/analytics/all_financial_transaction_summary_by_user.xhtml index 693ed184e9..afa6f8da4d 100644 --- a/src/main/webapp/analytics/all_financial_transaction_summary_by_user.xhtml +++ b/src/main/webapp/analytics/all_financial_transaction_summary_by_user.xhtml @@ -28,7 +28,7 @@ showTime="true" pattern="#{sessionController.applicationPreference.longDateTimeFormat}" > - + diff --git a/src/main/webapp/analytics/day_end_summery.xhtml b/src/main/webapp/analytics/day_end_summery.xhtml new file mode 100644 index 0000000000..481d47a29e --- /dev/null +++ b/src/main/webapp/analytics/day_end_summery.xhtml @@ -0,0 +1,326 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CategoryInOutNet Total
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
Float Start Funds + + + + + + + +
Float Collected   Handovers + + + + + + + + + + + +
Bank Transaction + + + + + + + + + + + +
Cash In / Outs + + + + + + + + + + + +
Total + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ +
+ diff --git a/src/main/webapp/analytics/index.xhtml b/src/main/webapp/analytics/index.xhtml index dea949d5e0..a90643fd43 100644 --- a/src/main/webapp/analytics/index.xhtml +++ b/src/main/webapp/analytics/index.xhtml @@ -35,6 +35,12 @@
+ + - +
+
- - - - - + + + + + + +
@@ -71,46 +75,49 @@ styleClass="ui-button-warning mx-1" action="#{opdBillController.navigateToNewOpdBill()}" rendered="#{configOptionApplicationController.getBooleanValueByKey('Enable Navigation Button To OPD Billing From Channel Booking By Date')}"/> - + + + + + + + action="#{bookingControllerViewScope.listCompleted()}" /> + action="#{bookingControllerViewScope.listOngoing()}" /> - + + title="Pending" + icon="fa fa-hourglass-half" + styleClass="ui-button-warning mx-1" + action="#{bookingControllerViewScope.listPending()}" /> - + + action="#{bookingControllerViewScope.listCancelled()}" /> - - @@ -268,7 +275,7 @@ - + diff --git a/src/main/webapp/dataAdmin/report.xhtml b/src/main/webapp/dataAdmin/report.xhtml index e5c7d2d1a1..44f37df918 100644 --- a/src/main/webapp/dataAdmin/report.xhtml +++ b/src/main/webapp/dataAdmin/report.xhtml @@ -1,11 +1,10 @@ - + xmlns:ez="http://xmlns.jcp.org/jsf/composite/ezcomp/report_templates"> @@ -14,11 +13,10 @@ - - - - - + + + + @@ -39,13 +37,86 @@ - - + - + +

+ + +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/webapp/dataAdmin/report_template_list.xhtml b/src/main/webapp/dataAdmin/report_template_list.xhtml index 076e0c1bb4..ffdd172956 100644 --- a/src/main/webapp/dataAdmin/report_template_list.xhtml +++ b/src/main/webapp/dataAdmin/report_template_list.xhtml @@ -23,7 +23,7 @@ - + diff --git a/src/main/webapp/opd/opd_bill.xhtml b/src/main/webapp/opd/opd_bill.xhtml index 5cbc391662..6385e40a61 100644 --- a/src/main/webapp/opd/opd_bill.xhtml +++ b/src/main/webapp/opd/opd_bill.xhtml @@ -844,26 +844,26 @@
- - - - + + + + + +
diff --git a/src/main/webapp/opd/patient.xhtml b/src/main/webapp/opd/patient.xhtml index f9da56f195..4c0c1cbf21 100644 --- a/src/main/webapp/opd/patient.xhtml +++ b/src/main/webapp/opd/patient.xhtml @@ -93,7 +93,13 @@ - + + + @@ -105,7 +111,6 @@ - diff --git a/src/main/webapp/opd/patient_edit.xhtml b/src/main/webapp/opd/patient_edit.xhtml index f269e8f8d1..b99d5588db 100644 --- a/src/main/webapp/opd/patient_edit.xhtml +++ b/src/main/webapp/opd/patient_edit.xhtml @@ -197,7 +197,7 @@ required="#{sessionController.departmentPreference.needAreaForPatientRegistration}" requiredMessage="Need an Area" > - + @@ -234,13 +234,22 @@
-
+
+
+ + + +
diff --git a/src/main/webapp/resources/ezcomp/common/patient_details.xhtml b/src/main/webapp/resources/ezcomp/common/patient_details.xhtml index bc08ba04ec..5ab1f8485d 100644 --- a/src/main/webapp/resources/ezcomp/common/patient_details.xhtml +++ b/src/main/webapp/resources/ezcomp/common/patient_details.xhtml @@ -83,7 +83,8 @@ action="#{patientController.quickSearchPatientLongPhoneNumber(cc.attrs.controller)}" process="btnSearchbyPhoneNo txtQuickSearchPhoneNumber" update="ptImp selectPatient editPatient viewPatient" - styleClass="btn-sm mx-1"/> + styleClass="btn-sm mx-1"> +
@@ -275,7 +276,7 @@
-
+
-
+ + + + + + +
- + @@ -362,6 +374,16 @@ + + + + + + diff --git a/src/main/webapp/resources/ezcomp/menu.xhtml b/src/main/webapp/resources/ezcomp/menu.xhtml index 2d60f0d872..cbaac8bd00 100644 --- a/src/main/webapp/resources/ezcomp/menu.xhtml +++ b/src/main/webapp/resources/ezcomp/menu.xhtml @@ -879,7 +879,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/resources/ezcomp/report_templates/report_bill_fee_grouped_by_category_bill_type_atomic_and_to_department.xhtml b/src/main/webapp/resources/ezcomp/report_templates/report_bill_fee_grouped_by_category_bill_type_atomic_and_to_department.xhtml new file mode 100644 index 0000000000..b498ff2047 --- /dev/null +++ b/src/main/webapp/resources/ezcomp/report_templates/report_bill_fee_grouped_by_category_bill_type_atomic_and_to_department.xhtml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/resources/ezcomp/report_templates/report_item_cateroy_value.xhtml b/src/main/webapp/resources/ezcomp/report_templates/report_item_cateroy_value.xhtml new file mode 100644 index 0000000000..cc73879a82 --- /dev/null +++ b/src/main/webapp/resources/ezcomp/report_templates/report_item_cateroy_value.xhtml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/resources/paymentMethod/multiple_payment_methods.xhtml b/src/main/webapp/resources/paymentMethod/multiple_payment_methods.xhtml index 6d57fcb3c5..3e26f20275 100644 --- a/src/main/webapp/resources/paymentMethod/multiple_payment_methods.xhtml +++ b/src/main/webapp/resources/paymentMethod/multiple_payment_methods.xhtml @@ -99,6 +99,9 @@ + + + diff --git a/src/main/webapp/resources/paymentMethod/staff_welfare.xhtml b/src/main/webapp/resources/paymentMethod/staff_welfare.xhtml new file mode 100644 index 0000000000..e0ae9f4780 --- /dev/null +++ b/src/main/webapp/resources/paymentMethod/staff_welfare.xhtml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file