diff --git a/pom.xml b/pom.xml index ad32448af4..bfc3a0055a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,10 +3,10 @@ 4.0.0 com.divudi - sethmademo + horizon 3.0.0 war - sethmademo + horizon ${project.build.directory}/endorsed diff --git a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java index 19716302f0..778e3a974f 100644 --- a/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java +++ b/src/main/java/com/divudi/bean/cashTransaction/FinancialTransactionController.java @@ -28,11 +28,13 @@ import com.divudi.data.ServiceType; import com.divudi.data.analytics.ReportTemplateType; import com.divudi.data.dataStructure.PaymentMethodData; +import com.divudi.entity.BillComponent; import com.divudi.entity.Category; import com.divudi.entity.Department; import com.divudi.entity.Institution; import com.divudi.entity.Item; import com.divudi.entity.WebUser; +import com.divudi.facade.BillComponentFacade; import com.divudi.java.CommonFunctions; import javax.inject.Named; import javax.enterprise.context.SessionScoped; @@ -65,6 +67,8 @@ public class FinancialTransactionController implements Serializable { BillFacade billFacade; @EJB PaymentFacade paymentFacade; + @EJB + BillComponentFacade billComponentFacade; // // @@ -86,6 +90,7 @@ public class FinancialTransactionController implements Serializable { // private Bill currentBill; + private List currentBillComponents; private ReportTemplateType reportTemplateType; private ReportTemplateRowBundle reportTemplateRowBundle; private ReportTemplateRowBundle opdServiceBundle; @@ -428,11 +433,10 @@ public void processShiftEndReport() { WebUser paramUser = nonClosedShiftStartFundBill.getCreater(); Institution paramCreditCompany = null; Long paramStartId = nonClosedShiftStartFundBill.getId(); - Long paramEndId=null; - if(nonClosedShiftStartFundBill.getReferenceBill()!=null){ + Long paramEndId = null; + if (nonClosedShiftStartFundBill.getReferenceBill() != null) { paramEndId = nonClosedShiftStartFundBill.getReferenceBill().getId(); } - ReportTemplateRowBundle tmpChannellingBundle = addChannellingByCategories( channelingType, @@ -2264,6 +2268,149 @@ public String settleShiftEndFundBill() { nonClosedShiftStartFundBill.setReferenceBill(currentBill); billController.save(nonClosedShiftStartFundBill); + BillComponent bcCollectedCash = new BillComponent(); + bcCollectedCash.setName("Collected Cash"); + bcCollectedCash.setComponentValue(financialReportByPayments.getCollectedCash()); + bcCollectedCash.setBill(currentBill); + billComponentFacade.create(bcCollectedCash); + + BillComponent bcRefundedCash = new BillComponent(); + bcRefundedCash.setName("Refunded Cash"); + bcRefundedCash.setComponentValue(financialReportByPayments.getRefundedCash()); + bcRefundedCash.setBill(currentBill); + billComponentFacade.create(bcRefundedCash); + + BillComponent bcNetCashTotal = new BillComponent(); + bcNetCashTotal.setName("Net Cash Total"); + bcNetCashTotal.setComponentValue(financialReportByPayments.getNetCashTotal()); + bcNetCashTotal.setBill(currentBill); + billComponentFacade.create(bcNetCashTotal); + + BillComponent bcCollectedCreditCard = new BillComponent(); + bcCollectedCreditCard.setName("Collected Credit Card"); + bcCollectedCreditCard.setComponentValue(financialReportByPayments.getCollectedCreditCard()); + bcCollectedCreditCard.setBill(currentBill); + billComponentFacade.create(bcCollectedCreditCard); + + BillComponent bcRefundedCreditCard = new BillComponent(); + bcRefundedCreditCard.setName("Refunded Credit Card"); + bcRefundedCreditCard.setComponentValue(financialReportByPayments.getRefundedCreditCard()); + bcRefundedCreditCard.setBill(currentBill); + billComponentFacade.create(bcRefundedCreditCard); + + BillComponent bcNetCreditCardTotal = new BillComponent(); + bcNetCreditCardTotal.setName("Net Credit Card Total"); + bcNetCreditCardTotal.setComponentValue(financialReportByPayments.getNetCreditCardTotal()); + bcNetCreditCardTotal.setBill(currentBill); + billComponentFacade.create(bcNetCreditCardTotal); + + BillComponent bcCollectedVoucher = new BillComponent(); + bcCollectedVoucher.setName("Collected Voucher"); + bcCollectedVoucher.setComponentValue(financialReportByPayments.getCollectedVoucher()); + bcCollectedVoucher.setBill(currentBill); + billComponentFacade.create(bcCollectedVoucher); + + BillComponent bcRefundedVoucher = new BillComponent(); + bcRefundedVoucher.setName("Refunded Voucher"); + bcRefundedVoucher.setComponentValue(financialReportByPayments.getRefundedVoucher()); + bcRefundedVoucher.setBill(currentBill); + billComponentFacade.create(bcRefundedVoucher); + + BillComponent bcNetVoucherTotal = new BillComponent(); + bcNetVoucherTotal.setName("Net Voucher Total"); + bcNetVoucherTotal.setComponentValue(financialReportByPayments.getNetVoucherTotal()); + bcNetVoucherTotal.setBill(currentBill); + billComponentFacade.create(bcNetVoucherTotal); + + BillComponent bcCollectedOtherNonCredit = new BillComponent(); + bcCollectedOtherNonCredit.setName("Collected Other Non-Credit"); + bcCollectedOtherNonCredit.setComponentValue(financialReportByPayments.getCollectedOtherNonCredit()); + bcCollectedOtherNonCredit.setBill(currentBill); + billComponentFacade.create(bcCollectedOtherNonCredit); + + BillComponent bcRefundedOtherNonCredit = new BillComponent(); + bcRefundedOtherNonCredit.setName("Refunded Other Non-Credit"); + bcRefundedOtherNonCredit.setComponentValue(financialReportByPayments.getRefundedOtherNonCredit()); + bcRefundedOtherNonCredit.setBill(currentBill); + billComponentFacade.create(bcRefundedOtherNonCredit); + + BillComponent bcNetOtherNonCreditTotal = new BillComponent(); + bcNetOtherNonCreditTotal.setName("Net Other Non-Credit Total"); + bcNetOtherNonCreditTotal.setComponentValue(financialReportByPayments.getNetOtherNonCreditTotal()); + bcNetOtherNonCreditTotal.setBill(currentBill); + billComponentFacade.create(bcNetOtherNonCreditTotal); + + BillComponent bcShiftStartFunds = new BillComponent(); + bcShiftStartFunds.setName("Shift Start Funds"); + bcShiftStartFunds.setComponentValue(financialReportByPayments.getShiftStartFunds()); + bcShiftStartFunds.setBill(currentBill); + billComponentFacade.create(bcShiftStartFunds); + + BillComponent bcFloatReceived = new BillComponent(); + bcFloatReceived.setName("Float Received"); + bcFloatReceived.setComponentValue(financialReportByPayments.getFloatReceived()); + bcFloatReceived.setBill(currentBill); + billComponentFacade.create(bcFloatReceived); + + BillComponent bcFloatHandover = new BillComponent(); + bcFloatHandover.setName("Float Handover"); + bcFloatHandover.setComponentValue(financialReportByPayments.getFloatHandover()); + bcFloatHandover.setBill(currentBill); + billComponentFacade.create(bcFloatHandover); + + BillComponent bcBankWithdrawals = new BillComponent(); + bcBankWithdrawals.setName("Bank Withdrawals"); + bcBankWithdrawals.setComponentValue(financialReportByPayments.getBankWithdrawals()); + bcBankWithdrawals.setBill(currentBill); + billComponentFacade.create(bcBankWithdrawals); + + BillComponent bcBankDeposits = new BillComponent(); + bcBankDeposits.setName("Bank Deposits"); + bcBankDeposits.setComponentValue(financialReportByPayments.getBankDeposits()); + bcBankDeposits.setBill(currentBill); + billComponentFacade.create(bcBankDeposits); + + BillComponent bcCashCollectedTransferIn = new BillComponent(); + bcCashCollectedTransferIn.setName("Cash Collected Transfer In"); + bcCashCollectedTransferIn.setComponentValue(financialReportByPayments.getCashCollectedTransferIn()); + bcCashCollectedTransferIn.setBill(currentBill); + billComponentFacade.create(bcCashCollectedTransferIn); + + BillComponent bcCashGivenOutTransferOut = new BillComponent(); + bcCashGivenOutTransferOut.setName("Cash Given Out Transfer Out"); + bcCashGivenOutTransferOut.setComponentValue(financialReportByPayments.getCashGivenOutTransferOut()); + bcCashGivenOutTransferOut.setBill(currentBill); + billComponentFacade.create(bcCashGivenOutTransferOut); + + BillComponent bcTotal = new BillComponent(); + bcTotal.setName("Total"); + bcTotal.setComponentValue(financialReportByPayments.getTotal()); + bcTotal.setBill(currentBill); + billComponentFacade.create(bcTotal); + + BillComponent bcShortExcess = new BillComponent(); + bcShortExcess.setName("Short/Excess"); + bcShortExcess.setComponentValue(currentBill.getNetTotal() - financialReportByPayments.getTotal()); + bcShortExcess.setBill(currentBill); + billComponentFacade.create(bcShortExcess); + + currentBill.getBillComponents().add(bcCollectedCash); + currentBill.getBillComponents().add(bcRefundedCash); + currentBill.getBillComponents().add(bcNetCashTotal); + currentBill.getBillComponents().add(bcCollectedCreditCard); + currentBill.getBillComponents().add(bcRefundedCreditCard); + currentBill.getBillComponents().add(bcNetCreditCardTotal); + currentBill.getBillComponents().add(bcCollectedVoucher); + currentBill.getBillComponents().add(bcRefundedVoucher); + currentBill.getBillComponents().add(bcNetVoucherTotal); + currentBill.getBillComponents().add(bcCollectedOtherNonCredit); + currentBill.getBillComponents().add(bcRefundedOtherNonCredit); + currentBill.getBillComponents().add(bcNetOtherNonCreditTotal); + currentBill.getBillComponents().add(bcShiftStartFunds); + currentBill.getBillComponents().add(bcFloatReceived); + currentBill.getBillComponents().add(bcFloatHandover); + currentBill.getBillComponents().add(bcBankWithdrawals); + return "/cashier/shift_end_summery_bill_print?faces-redirect=true"; } @@ -3052,4 +3199,12 @@ public void setShiftEndBundles(List shiftEndBundles) { this.shiftEndBundles = shiftEndBundles; } + public List getCurrentBillComponents() { + return currentBillComponents; + } + + public void setCurrentBillComponents(List currentBillComponents) { + this.currentBillComponents = currentBillComponents; + } + } diff --git a/src/main/java/com/divudi/bean/common/PatientController.java b/src/main/java/com/divudi/bean/common/PatientController.java index 6f61db56c4..cf92b738bd 100644 --- a/src/main/java/com/divudi/bean/common/PatientController.java +++ b/src/main/java/com/divudi/bean/common/PatientController.java @@ -1716,6 +1716,7 @@ public void quickSearchPatientLongPhoneNumber(ControllerWithPatient controller) controller.setPatient(patientSearched); controller.setPatientDetailsEditable(false); opdBillController.setPaymentMethod(null); + if (controller.getPatient().getHasAnAccount() != null) { if (patientSearched.getHasAnAccount() && configOptionApplicationController.getBooleanValueByKey("Automatically set the PatientDeposit payment Method if a Deposit is Available", false)) { opdBillController.setPaymentMethod(PaymentMethod.PatientDeposit); diff --git a/src/main/java/com/divudi/bean/hr/StaffController.java b/src/main/java/com/divudi/bean/hr/StaffController.java index d094b194cd..93891bbcf4 100644 --- a/src/main/java/com/divudi/bean/hr/StaffController.java +++ b/src/main/java/com/divudi/bean/hr/StaffController.java @@ -1644,9 +1644,6 @@ public void setCurrentPerson(Person currentPerson) { /** * Converters */ - /** - * - */ @FacesConverter(forClass = Staff.class) public static class StaffControllerConverter implements Converter { @@ -1689,7 +1686,7 @@ public String getAsString(FacesContext facesContext, UIComponent component, Obje return getStringKey(o.getId()); } else { throw new IllegalArgumentException("object " + object + " is of type " - + object.getClass().getName() + "; expected type: " + StaffController.class.getName()); + + object.getClass().getName() + "; expected type: " + Staff.class.getName()); } } } diff --git a/src/main/java/com/divudi/bean/opd/OpdBillController.java b/src/main/java/com/divudi/bean/opd/OpdBillController.java index 674748dea0..e7316e8972 100644 --- a/src/main/java/com/divudi/bean/opd/OpdBillController.java +++ b/src/main/java/com/divudi/bean/opd/OpdBillController.java @@ -377,7 +377,7 @@ public void reloadCurrentlyWorkingStaff() { for (WorkingTime wt : wts) { if (wt.getStaffShift() != null && wt.getStaffShift().getStaff() != null) { currentlyWorkingStaff.add(wt.getStaffShift().getStaff()); - selectedCurrentlyWorkingStaff = wt.getStaffShift().getStaff(); +// selectedCurrentlyWorkingStaff = wt.getStaffShift().getStaff(); } } diff --git a/src/main/java/com/divudi/bean/report/CommonReport.java b/src/main/java/com/divudi/bean/report/CommonReport.java index 3fb0a95fb4..e4c14aca9b 100644 --- a/src/main/java/com/divudi/bean/report/CommonReport.java +++ b/src/main/java/com/divudi/bean/report/CommonReport.java @@ -36,8 +36,15 @@ import com.divudi.facade.InstitutionFacade; import com.divudi.facade.PriceMatrixFacade; import com.divudi.bean.common.util.JsfUtil; +import com.divudi.data.BillFinanceType; +import com.divudi.data.BillTypeAtomic; +import com.divudi.data.ReportTemplateRow; +import com.divudi.data.ReportTemplateRowBundle; +import com.divudi.data.ServiceType; +import com.divudi.entity.Staff; import com.divudi.java.CommonFunctions; import java.io.Serializable; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -96,6 +103,7 @@ public class CommonReport implements Serializable { * */ List billFees; + private ReportTemplateRowBundle bundle; List referralBills; List referralDoctorBills; List referralBillItems; @@ -937,7 +945,6 @@ public String displayOutsideBillFees() { totalFee = displayOutsideCalBillFees(); billTotal = displayOutsideBillFeeBillTotals(); - return "/lab/report_by_outside_institution"; } @@ -3279,8 +3286,6 @@ public void createTableByBillType() { getRefundedBills().setSlip(calValue(new RefundBill(), billType, PaymentMethod.Slip)); createSum(); - - } public void createTableByBillTypeWebUser() { @@ -3347,7 +3352,6 @@ public void fetchPharmacySummeryAll() { //pharmacyUnitIssueCancelBillTotals = getPharmacyBillTotal(BillType.PharmacyIssue, new CancelledBill()); //pharmacyUnitIssueReturnbillTotals = getPharmacyBillTotal(BillType.PharmacyIssue, new RefundBill()); - } List getPharmacyBills(PaymentMethod paymentMethod, BillType billType, Bill bill) { @@ -3527,8 +3531,6 @@ public void createLabCashierSummeryReport() { ////////// createSumAfterCash(); - - } String header = ""; @@ -3886,7 +3888,6 @@ public void createCashierTableByUser() { ////////// createSumAfterCash(); - Date endTime = new Date(); duration = endTime.getTime() - startTime.getTime(); auditEvent.setEventDuration(duration); @@ -4167,7 +4168,6 @@ public void createCashierTableByUserOnlyCashier() { ////////// createSumAfterCash(); - Date endTime = new Date(); duration = endTime.getTime() - startTime.getTime(); auditEvent.setEventDuration(duration); @@ -4200,7 +4200,6 @@ public void createCashierTableByUserUsingReciptNo() { } createCashierTableByUser(); - } public void createCashierTableByUserOnlyChannel() { @@ -4621,8 +4620,6 @@ public void createCashierTableByUserOnlyChannel() { ////////// createSumAfterCash(); - - } public Date fetchDate(String s) { @@ -4921,7 +4918,6 @@ public void createGrnDetailTable() { auditEvent.setEventStatus("Completed"); auditEventApplicationController.logAuditEvent(auditEvent); - } public void createGrnReturnDetailTable() { @@ -4979,7 +4975,6 @@ public void createGrnReturnDetailTable() { auditEvent.setEventStatus("Completed"); auditEventApplicationController.logAuditEvent(auditEvent); - } public void createGrnAndPurchaseBillsTable() { @@ -5082,7 +5077,6 @@ public void createGrnDetailTableStore() { getGrnReturnCancel().setCash(calValueNetTotal(new CancelledBill(), BillType.StoreGrnReturn, PaymentMethod.Cash, getDepartment())); getGrnReturnCancel().setCredit(calValueNetTotal(new CancelledBill(), BillType.StoreGrnReturn, PaymentMethod.Credit, getDepartment())); - } public void createGrnExpensTableStore() { @@ -5124,7 +5118,6 @@ public void createGrnExpensTableStore() { // getGrnReturnCancel().setBillItems(getBillItems(new CancelledBill(), BillType.StoreGrnReturn, getDepartment())); //// getGrnReturnCancel().setCash(calValueNetTotal(new CancelledBill(), BillType.StoreGrnReturn, PaymentMethod.Cash, getDepartment())); //// getGrnReturnCancel().setCredit(calValueNetTotal(new CancelledBill(), BillType.StoreGrnReturn, PaymentMethod.Credit, getDepartment())); - } // public void createGrnDetailTableStore() { @@ -5273,7 +5266,6 @@ public void createGrnPaymentTable() { getGrnPaymentCancellReturn().setCash(calValue(new CancelledBill(), BillType.GrnPaymentReturn, PaymentMethod.Cash, getDepartment())); getGrnPaymentCancellReturn().setCredit(calValue(new CancelledBill(), BillType.GrnPaymentReturn, PaymentMethod.Credit, getDepartment())); - } public void createPurchaseDetailTable() { @@ -5323,7 +5315,6 @@ public void createPurchaseDetailTable() { getPurchaseReturnCancel().setSaleCash(calValueSaleValue(new CancelledBill(), BillType.PurchaseReturn, PaymentMethod.Cash, getDepartment())); getPurchaseReturnCancel().setSaleCredit(calValueSaleValue(new CancelledBill(), BillType.PurchaseReturn, PaymentMethod.Credit, getDepartment())); - } public void createPurchaseDetailTableStore() { @@ -5360,7 +5351,6 @@ public void createPurchaseDetailTableStore() { getPurchaseReturnCancel().setCash(calValue(new CancelledBill(), BillType.PurchaseReturn, PaymentMethod.Cash, getDepartment())); getPurchaseReturnCancel().setCredit(calValue(new CancelledBill(), BillType.PurchaseReturn, PaymentMethod.Credit, getDepartment())); - } // public void createPurchaseDetailTableStore() { @@ -5474,7 +5464,6 @@ public void createGrnDetailTableByDealor() { auditEvent.setEventStatus("Completed"); auditEventApplicationController.logAuditEvent(auditEvent); - } public void createGrnDetailTableByDealorStore() { @@ -5511,7 +5500,6 @@ public void createGrnDetailTableByDealorStore() { getGrnReturnCancel().setCash(calValue(new CancelledBill(), BillType.StoreGrnReturn, PaymentMethod.Cash, getDepartment(), getInstitution())); getGrnReturnCancel().setCredit(calValue(new CancelledBill(), BillType.StoreGrnReturn, PaymentMethod.Credit, getDepartment(), getInstitution())); - } // public void createGrnDetailTableByDealorStore() { @@ -5610,38 +5598,10 @@ private void recreateList() { } public void fillInstitutionReferralBills() { - Date startTime = new Date(); - - //Done By Pasan -// String jpql; -// Map m = new HashMap(); -// if (institution != null) { -// jpql = "select b from Bill b " -// + "where b.retired=false " -// + "and b.referredByInstitution=:refIns " -// + "and b.createdAt between :fd and :td " -// + " order by b.id"; -// m.put("refIns", institution); -// m.put("fd", fromDate); -// m.put("td", toDate); -// referralBills = getBillFacade().findByJpql(jpql, m); -// }else{ -// jpql = "select b from Bill b " -// + " where b.retired=false " -// + " and b.referredByInstitution is not null " -// + "and b.createdAt between :fd and :td " -// + " order by b.id"; -// m.put("fd", fromDate); -// m.put("td", toDate); -// referralBills = getBillFacade().findByJpql(jpql, m, TemporalType.TIMESTAMP); -// } - //Done By Safrin String jpql; Map m = new HashMap(); - jpql = "select b from Bill b " + "where b.retired=false "; - if (referenceInstitution != null) { jpql += "and b.referredByInstitution=:refIns "; m.put("refIns", referenceInstitution); @@ -5655,9 +5615,176 @@ public void fillInstitutionReferralBills() { m.put("td", toDate); referralBills = getBillFacade().findByJpql(jpql, m, TemporalType.TIMESTAMP); - + } + + public void fillOpdReferralBillSummary() { + // Map to hold query parameters + Map m = new HashMap<>(); + m.put("fd", fromDate); + m.put("td", toDate); + m.put("bts", BillTypeAtomic.findByServiceType(ServiceType.OPD)); + + // First Query: For referredBy condition + String jpql1 = "select new com.divudi.data.ReportTemplateRow(" + + "rf, count(b), sum(b.netTotal))" + + " from Bill b " + + " left join b.referredBy rf " + + " where b.retired=false " + + " and rf is not null " + + " and b.createdAt between :fd and :td " + + " and b.billTypeAtomic in :bts " + + " group by rf"; + + // Second Query: For referredByInstitution condition + String jpql2 = "select new com.divudi.data.ReportTemplateRow(" + + "ri, count(b), sum(b.netTotal))" + + " from Bill b " + + " left join b.referredByInstitution ri " + + " where b.retired=false " + + " and ri is not null " + + " and b.createdAt between :fd and :td " + + " and b.billTypeAtomic in :bts " + + " group by ri"; + + // Execute both queries separately + List rtrsByReferredBy = (List) billFacade.findLightsByJpql(jpql1, m); + List rtrsByReferredByInstitution = (List) billFacade.findLightsByJpql(jpql2, m); + + // Combine results into a single bundle + bundle = new ReportTemplateRowBundle(); + List combinedResults = new ArrayList<>(); + + // Add results from the first query (Staff-based) + combinedResults.addAll(rtrsByReferredBy); + + // Add results from the second query (Institution-based) + combinedResults.addAll(rtrsByReferredByInstitution); + + // Set the combined results in the bundle + bundle.setReportTemplateRows(combinedResults); + + // Format the report name with fromDate and toDate + String dateFormat = sessionController.getApplicationPreference().getLongDateFormat(); + SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); + String formattedFromDate = sdf.format(fromDate); + String formattedToDate = sdf.format(toDate); + + String reportName = "OPD Referral Summary by Bill - From " + formattedFromDate + " to " + formattedToDate; + bundle.setName(reportName); } + public void fillChannellingReferralBillSummary() { + // Map to hold query parameters + Map m = new HashMap<>(); + m.put("fd", fromDate); + m.put("td", toDate); + m.put("bts", BillTypeAtomic.findByServiceType(ServiceType.CHANNELLING)); + + // First Query: For referredBy condition + String jpql1 = "select new com.divudi.data.ReportTemplateRow(" + + "rf, count(b), sum(b.netTotal))" + + " from Bill b " + + " left join b.referredBy rf " + + " where b.retired=false " + + " and rf is not null " + + " and b.createdAt between :fd and :td " + + " and b.billTypeAtomic in :bts " + + " group by rf"; + + // Second Query: For referredByInstitution condition + String jpql2 = "select new com.divudi.data.ReportTemplateRow(" + + "ri, count(b), sum(b.netTotal))" + + " from Bill b " + + " left join b.referredByInstitution ri " + + " where b.retired=false " + + " and ri is not null " + + " and b.createdAt between :fd and :td " + + " and b.billTypeAtomic in :bts " + + " group by ri"; + + // Execute both queries separately + List rtrsByReferredBy = (List) billFacade.findLightsByJpql(jpql1, m); + List rtrsByReferredByInstitution = (List) billFacade.findLightsByJpql(jpql2, m); + + // Combine results into a single bundle + bundle = new ReportTemplateRowBundle(); + List combinedResults = new ArrayList<>(); + + // Add results from the first query (Staff-based) + combinedResults.addAll(rtrsByReferredBy); + + // Add results from the second query (Institution-based) + combinedResults.addAll(rtrsByReferredByInstitution); + + // Set the combined results in the bundle + bundle.setReportTemplateRows(combinedResults); + + // Format the report name with fromDate and toDate + String dateFormat = sessionController.getApplicationPreference().getLongDateFormat(); + SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); + String formattedFromDate = sdf.format(fromDate); + String formattedToDate = sdf.format(toDate); + + String reportName = "Channelling Referral Summary by Bill - From " + formattedFromDate + " to " + formattedToDate; + bundle.setName(reportName); + } + + public void fillInpatientReferralBillSummary() { + // Map to hold query parameters + Map m = new HashMap<>(); + m.put("fd", fromDate); + m.put("td", toDate); + m.put("bts", BillTypeAtomic.findByServiceType(ServiceType.INWARD)); + + // First Query: For referredBy condition + String jpql1 = "select new com.divudi.data.ReportTemplateRow(" + + "rf, count(b), sum(b.netTotal))" + + " from Bill b " + + " left join b.referredBy rf " + + " where b.retired=false " + + " and rf is not null " + + " and b.createdAt between :fd and :td " + + " and b.billTypeAtomic in :bts " + + " group by rf"; + + // Second Query: For referredByInstitution condition + String jpql2 = "select new com.divudi.data.ReportTemplateRow(" + + "ri, count(b), sum(b.netTotal))" + + " from Bill b " + + " left join b.referredByInstitution ri " + + " where b.retired=false " + + " and ri is not null " + + " and b.createdAt between :fd and :td " + + " and b.billTypeAtomic in :bts " + + " group by ri"; + + // Execute both queries separately + List rtrsByReferredBy = (List) billFacade.findLightsByJpql(jpql1, m); + List rtrsByReferredByInstitution = (List) billFacade.findLightsByJpql(jpql2, m); + + // Combine results into a single bundle + bundle = new ReportTemplateRowBundle(); + List combinedResults = new ArrayList<>(); + + // Add results from the first query (Staff-based) + combinedResults.addAll(rtrsByReferredBy); + + // Add results from the second query (Institution-based) + combinedResults.addAll(rtrsByReferredByInstitution); + + // Set the combined results in the bundle + bundle.setReportTemplateRows(combinedResults); + + // Format the report name with fromDate and toDate + String dateFormat = sessionController.getApplicationPreference().getLongDateFormat(); + SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); + String formattedFromDate = sdf.format(fromDate); + String formattedToDate = sdf.format(toDate); + + String reportName = "OPD Referral Summary by Bill - From " + formattedFromDate + " to " + formattedToDate; + bundle.setName(reportName); + } + public void fillDoctorReferralBills() { Date startTime = new Date(); String jpql; @@ -5702,8 +5829,6 @@ public void fillInstitutionReferralBillItems() { m.put("td", toDate); referralBillItems = getBillItemFac().findByJpql(jpql, m, TemporalType.TIMESTAMP); - - } public void createUserOPDSeviceCount() { @@ -5838,8 +5963,6 @@ public void createUserOPDSeviceCount() { } } - - } public List fetchItems(Class[] billClasses, @@ -6820,7 +6943,6 @@ public void createCollectingCenterBillTable() { totalVat += b.getVat(); } - } public void calculateTotalOfPuchaseOrderSummaryBills() { @@ -6874,8 +6996,6 @@ public void createCollectingCenterSummeryTable() { totalVat += totVat; } - - } public List getBillList(BillType[] bts, Institution ins) { @@ -7050,6 +7170,14 @@ public void setReferralDoctorBills(List referralDoctorBills) { this.referralDoctorBills = referralDoctorBills; } + public ReportTemplateRowBundle getBundle() { + return bundle; + } + + public void setBundle(ReportTemplateRowBundle bundle) { + this.bundle = bundle; + } + public class CollectingCenteRow { Institution i; diff --git a/src/main/java/com/divudi/data/ReportTemplateRow.java b/src/main/java/com/divudi/data/ReportTemplateRow.java index 65e21439d8..5854176be8 100644 --- a/src/main/java/com/divudi/data/ReportTemplateRow.java +++ b/src/main/java/com/divudi/data/ReportTemplateRow.java @@ -11,7 +11,6 @@ import java.util.Date; import java.util.List; - /** * * @author buddhika @@ -65,6 +64,8 @@ public class ReportTemplateRow { private Long endId; private SessionInstance sessionInstance; private Staff staff; + private Institution referringInstitution; + private Staff referringStaff; private List btas; @@ -72,6 +73,25 @@ public ReportTemplateRow(SessionInstance sessionInstance) { this.sessionInstance = sessionInstance; } + public ReportTemplateRow(Staff referringStaff, Institution referringInstitution, Long long1, Double rowValue) { + this.rowValue = rowValue; + this.long1 = long1; + this.referringInstitution = referringInstitution; + this.referringStaff = referringStaff; + } + + public ReportTemplateRow(Staff referringStaff, Long long1, Double rowValue) { + this.rowValue = rowValue; + this.long1 = long1; + this.referringStaff = referringStaff; + } + + public ReportTemplateRow(Institution referringInstitution, Long long1, Double rowValue) { + this.rowValue = rowValue; + this.long1 = long1; + this.referringInstitution = referringInstitution; + } + public ReportTemplateRow(Category c) { this.category = c; } @@ -148,7 +168,6 @@ public ReportTemplateRow(BillSession billSession) { public void setBillSession(BillSession billSession) { this.billSession = billSession; } - public ReportTemplateRow(String feeName, String categoryName, String toDepartmentName, String itemName, String paymentName, Double rowValue, Long rowCount) { this.feeName = feeName; @@ -529,7 +548,21 @@ public ReportTemplateRow(Staff staff, Long long1, Long long2, Long long3, Long l this.long6 = long6; 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; + } } diff --git a/src/main/java/com/divudi/data/ReportTemplateRowBundle.java b/src/main/java/com/divudi/data/ReportTemplateRowBundle.java index 53db90d2fb..e9e95701ee 100644 --- a/src/main/java/com/divudi/data/ReportTemplateRowBundle.java +++ b/src/main/java/com/divudi/data/ReportTemplateRowBundle.java @@ -51,6 +51,8 @@ public List getReportTemplateRows() { } return reportTemplateRows; } + + public void setReportTemplateRows(List reportTemplateRows) { this.reportTemplateRows = reportTemplateRows; diff --git a/src/main/java/com/divudi/entity/BillComponent.java b/src/main/java/com/divudi/entity/BillComponent.java index 713620ed8b..50e0f1a2ec 100644 --- a/src/main/java/com/divudi/entity/BillComponent.java +++ b/src/main/java/com/divudi/entity/BillComponent.java @@ -20,45 +20,45 @@ @Entity public class BillComponent implements Serializable { - static final long serialVersionUID = 1L; + static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) //Main Properties - Long id; + Long id; @ManyToOne - Packege packege; + Packege packege; @ManyToOne - Item item; - String name; + Item item; + String name; //Created Properties @ManyToOne - WebUser creater; + WebUser creater; @Temporal(javax.persistence.TemporalType.TIMESTAMP) - Date createdAt; + Date createdAt; //Retairing properties - boolean retired; + boolean retired; @ManyToOne - WebUser retirer; + WebUser retirer; @Temporal(javax.persistence.TemporalType.TIMESTAMP) - Date retiredAt; - String retireComments; - String deptId; - String insId; - String catId; - String sessionId; + Date retiredAt; + String retireComments; + String deptId; + String insId; + String catId; + String sessionId; @ManyToOne - Bill bill; + Bill bill; @ManyToOne - BillItem billItem; + BillItem billItem; @ManyToOne - Institution institution; + Institution institution; @ManyToOne - Department department; + Department department; @ManyToOne - Staff staff; + Staff staff; @ManyToOne - Speciality speciality; - + Speciality speciality; + private Double componentValue; @@ -79,7 +79,7 @@ public int hashCode() { @Override public boolean equals(Object object) { - + if (!(object instanceof BillComponent)) { return false; } @@ -246,4 +246,12 @@ public Speciality getSpeciality() { public void setSpeciality(Speciality speciality) { this.speciality = speciality; } + + public Double getComponentValue() { + return componentValue; + } + + public void setComponentValue(Double componentValue) { + this.componentValue = componentValue; + } } diff --git a/src/main/java/com/divudi/entity/Staff.java b/src/main/java/com/divudi/entity/Staff.java index 149deef94e..a33e62183f 100644 --- a/src/main/java/com/divudi/entity/Staff.java +++ b/src/main/java/com/divudi/entity/Staff.java @@ -312,7 +312,10 @@ public boolean equals(Object object) { @Override public String toString() { - return "com.divudi.entity.Staff[ id=" + id + " ]"; + String specialityName = (getSpeciality() != null && getSpeciality().getName() != null) ? getSpeciality().getName() : "No Speciality"; + String nameWithTitle = (getPerson() != null && getPerson().getNameWithTitle() != null) ? getPerson().getNameWithTitle() : "No Name"; + + return nameWithTitle + " (" + specialityName + ")"; } public Person getPerson() { diff --git a/src/main/webapp/WEB-INF/glassfish-web.xml b/src/main/webapp/WEB-INF/glassfish-web.xml index d92795745e..ec0bde68df 100644 --- a/src/main/webapp/WEB-INF/glassfish-web.xml +++ b/src/main/webapp/WEB-INF/glassfish-web.xml @@ -1,7 +1,7 @@ - /sethmademo + /horizondev diff --git a/src/main/webapp/admin/staff/staff.xhtml b/src/main/webapp/admin/staff/staff.xhtml index 4725dff1e9..9e8ef8e9e2 100644 --- a/src/main/webapp/admin/staff/staff.xhtml +++ b/src/main/webapp/admin/staff/staff.xhtml @@ -71,7 +71,7 @@ - + diff --git a/src/main/webapp/cashier/initial_fund_bill.xhtml b/src/main/webapp/cashier/initial_fund_bill.xhtml index e1a1b72e37..3d69a56de8 100644 --- a/src/main/webapp/cashier/initial_fund_bill.xhtml +++ b/src/main/webapp/cashier/initial_fund_bill.xhtml @@ -80,7 +80,7 @@ Total Value - + @@ -88,7 +88,7 @@ - + @@ -207,7 +207,6 @@
- #{bp.currencyDenominationsJson} diff --git a/src/main/webapp/opd/opd_bill.xhtml b/src/main/webapp/opd/opd_bill.xhtml index 4a651dd2ee..28088f2868 100644 --- a/src/main/webapp/opd/opd_bill.xhtml +++ b/src/main/webapp/opd/opd_bill.xhtml @@ -1307,10 +1307,12 @@ - + - + diff --git a/src/main/webapp/reportInstitution/report_referral_summary_channelling_bill.xhtml b/src/main/webapp/reportInstitution/report_referral_summary_channelling_bill.xhtml new file mode 100644 index 0000000000..c2626f54b2 --- /dev/null +++ b/src/main/webapp/reportInstitution/report_referral_summary_channelling_bill.xhtml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/reportInstitution/report_referral_summary_inpatient_bill.xhtml b/src/main/webapp/reportInstitution/report_referral_summary_inpatient_bill.xhtml new file mode 100644 index 0000000000..b2c77be676 --- /dev/null +++ b/src/main/webapp/reportInstitution/report_referral_summary_inpatient_bill.xhtml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/reportInstitution/report_referral_summary_opd_bill.xhtml b/src/main/webapp/reportInstitution/report_referral_summary_opd_bill.xhtml new file mode 100644 index 0000000000..30553aecad --- /dev/null +++ b/src/main/webapp/reportInstitution/report_referral_summary_opd_bill.xhtml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/reportInstitution/report_referrals_index.xhtml b/src/main/webapp/reportInstitution/report_referrals_index.xhtml index ab12b34c2b..af3294ca5b 100644 --- a/src/main/webapp/reportInstitution/report_referrals_index.xhtml +++ b/src/main/webapp/reportInstitution/report_referrals_index.xhtml @@ -18,9 +18,28 @@
- - - + + + + + + +
diff --git a/src/main/webapp/resources/ezcomp/menu.xhtml b/src/main/webapp/resources/ezcomp/menu.xhtml index 9060b2115b..fc38427852 100644 --- a/src/main/webapp/resources/ezcomp/menu.xhtml +++ b/src/main/webapp/resources/ezcomp/menu.xhtml @@ -266,7 +266,6 @@ - diff --git a/src/main/webapp/resources/ezcomp/prints/five_five_paper_with_headings_for_Shift_end_fund_bill.xhtml b/src/main/webapp/resources/ezcomp/prints/five_five_paper_with_headings_for_Shift_end_fund_bill.xhtml index dc38ca7728..3fd831bc34 100644 --- a/src/main/webapp/resources/ezcomp/prints/five_five_paper_with_headings_for_Shift_end_fund_bill.xhtml +++ b/src/main/webapp/resources/ezcomp/prints/five_five_paper_with_headings_for_Shift_end_fund_bill.xhtml @@ -78,7 +78,7 @@ - + @@ -113,203 +113,35 @@ - -
-
- -
-
-
- -
- - - - - - - - - - - - - - - - - - - + +
-
-
- - - - -
- - - - - - -
- - - - -
+ - - + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - +
- - - - - - - NameValue
- - - - -
- - - - - - -
- - - - - - - - - - - - - - -
+ + + + + +
+ -
- -
-
-
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - -
- - - - - -
- - - - - -
- - - - - -
- - - - - -
- -
- +