Skip to content

Commit

Permalink
Merge pull request #6566 from hmislk/Issue#6425
Browse files Browse the repository at this point in the history
Issue#6425 Closes #6425
  • Loading branch information
DeshaniPubudu authored Jul 26, 2024
2 parents c98312d + 5a96f61 commit aa9fe29
Show file tree
Hide file tree
Showing 12 changed files with 1,077 additions and 75 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,24 @@ public ReportTemplateRowBundle generateReport(
paramEndId);
break;
case ITEM_SUMMARY_BY_BILL:
bundle =handleItemSummaryByBill(btas,
bundle = handleItemSummaryByBill(btas,
paramDate,
paramFromDate,
paramToDate,
paramInstitution,
paramDepartment,
paramFromInstitution,
paramFromDepartment,
paramToInstitution,
paramToDepartment,
paramUser,
paramCreditCompany,
paramStartId,
paramEndId);
break;
case ITEM_DEPARTMENT_SUMMARY_BY_BILL_ITEM:
bundle = handleItemDepartmentummaryByBill(
btas,
paramDate,
paramFromDate,
paramToDate,
Expand Down Expand Up @@ -513,7 +530,7 @@ public ReportTemplateRowBundle generateReport(
paramStartId,
paramEndId);
break;

case TO_DEPARTMENT_SUMMARY_BY_BILL:
bundle = handleToDepartmentSummaryByBill(
btas,
Expand Down Expand Up @@ -642,9 +659,17 @@ private ReportTemplateRowBundle handleBillFeeGroupedByBillTypeAtomic(
parameters.put("tdep", paramToDepartment);
}

if (paramCreditCompany != null) {
jpql += " and bill.creditCompany=:cc ";
parameters.put("cc", paramCreditCompany);
if (paramCreditCompany == null) {

} else {
if (paramCreditCompany.getId() == null) {
jpql += " and bill.creditCompany is not null ";
} else if (paramCreditCompany.getId() == 1l) {
jpql += " and bill.creditCompany is null ";
} else {
jpql += " and bill.creditCompany=:cc ";
parameters.put("cc", paramCreditCompany);
}
}

jpql += " group by bill.billTypeAtomic";
Expand Down Expand Up @@ -759,11 +784,19 @@ private ReportTemplateRowBundle handleBillFeeGroupedByToDepartmentAndCategory(
parameters.put("tdep", paramToDepartment);
}

if (paramCreditCompany != null) {
jpql += " and bill.creditCompany=:cc ";
parameters.put("cc", paramCreditCompany);
}
if (paramCreditCompany == null) {

} else {
if (paramCreditCompany.getId() == null) {
jpql += " and bill.creditCompany is not null ";
} else if (paramCreditCompany.getId() == 1l) {
jpql += " and bill.creditCompany is null ";
} else {
jpql += " and bill.creditCompany=:cc ";
parameters.put("cc", paramCreditCompany);
}
}

jpql += " group by bill.billTypeAtomic";

System.out.println("jpql = " + jpql);
Expand Down Expand Up @@ -871,9 +904,17 @@ private ReportTemplateRowBundle handleBillTypeAtomicSummaryUsingBills(
parameters.put("tdep", paramToDepartment);
}

if (paramCreditCompany != null) {
jpql += " and bill.creditCompany=:cc ";
parameters.put("cc", paramCreditCompany);
if (paramCreditCompany == null) {

} else {
if (paramCreditCompany.getId() == null) {
jpql += " and bill.creditCompany is not null ";
} else if (paramCreditCompany.getId() == 1l) {
jpql += " and bill.creditCompany is null ";
} else {
jpql += " and bill.creditCompany=:cc ";
parameters.put("cc", paramCreditCompany);
}
}

jpql += " group by bill.billTypeAtomic";
Expand Down Expand Up @@ -985,9 +1026,17 @@ private ReportTemplateRowBundle handleBillTypeAtomicTotalUsingBills(
parameters.put("tdep", paramToDepartment);
}

if (paramCreditCompany != null) {
jpql += " and bill.creditCompany=:cc ";
parameters.put("cc", paramCreditCompany);
if (paramCreditCompany == null) {

} else {
if (paramCreditCompany.getId() == null) {
jpql += " and bill.creditCompany is not null ";
} else if (paramCreditCompany.getId() == 1l) {
jpql += " and bill.creditCompany is null ";
} else {
jpql += " and bill.creditCompany=:cc ";
parameters.put("cc", paramCreditCompany);
}
}

if (paramUser != null) {
Expand Down Expand Up @@ -1477,14 +1526,147 @@ private ReportTemplateRowBundle handleItemCategorySummaryByBill(
long idCounter = 1;
Double total = 0.0;
for (ReportTemplateRow row : rs) {

row.setId(idCounter++);
total = row.getRowValue();
}
bundle.setReportTemplateRows(rs);
return bundle;
}

private ReportTemplateRowBundle handleItemDepartmentummaryByBill(
List<BillTypeAtomic> btas,
Date paramDate,
Date paramFromDate,
Date paramToDate,
Institution paramInstitution,
Department paramDepartment,
Institution paramFromInstitution,
Department paramFromDepartment,
Institution paramToInstitution,
Department paramToDepartment,
WebUser paramUser,
Institution paramCreditCompany,
Long paramStartId,
Long paramEndId) {

System.out.println("handleItemDepartmentummaryByBill");

String jpql;
Map<String, Object> parameters = new HashMap<>();
ReportTemplateRowBundle bundle = new ReportTemplateRowBundle();

jpql = "select new com.divudi.data.ReportTemplateRow("
+ " bi.item.department, count(bi), sum(bi.netValue)) "
+ " from BillItem bi"
+ " join bi.bill bill "
+ " where bill.retired<>:br "
+ " and bi.retired<>:br ";
parameters.put("br", true);

if (btas != null) {
jpql += " and bill.billTypeAtomic in :btas ";
parameters.put("btas", btas);
}

if (paramDate != null) {
jpql += " and bill.billDate=:bd ";
parameters.put("bd", paramDate);
}

if (paramToDate != null) {
jpql += " and bill.billDate < :td ";
parameters.put("td", paramToDate);
}

if (paramFromDate != null) {
jpql += " and bill.billDate > :fd ";
parameters.put("fd", paramFromDate);
}

if (paramStartId != null) {
jpql += " and bill.id > :sid ";
parameters.put("sid", paramStartId);
}

if (paramEndId != null) {
jpql += " and bill.id < :eid ";
parameters.put("eid", paramEndId);
}

if (paramInstitution != null) {
jpql += " and bill.institution=:ins ";
parameters.put("ins", paramInstitution);
}

if (paramDepartment != null) {
jpql += " and bill.department=:dep ";
parameters.put("dep", paramDepartment);
}

if (paramFromInstitution != null) {
jpql += " and bill.fromInstitution=:fins ";
parameters.put("fins", paramFromInstitution);
}

if (paramFromDepartment != null) {
jpql += " and bill.fromDepartment=:fdep ";
parameters.put("fdep", paramFromDepartment);
}

if (paramToInstitution != null) {
jpql += " and bill.toInstitution=:tins ";
parameters.put("tins", paramToInstitution);
}

if (paramToDepartment != null) {
jpql += " and bill.toDepartment=:tdep ";
parameters.put("tdep", paramToDepartment);
}

if (paramUser != null) {
jpql += " and bill.creater=:wu ";
parameters.put("wu", paramUser);
}

if (paramCreditCompany != null) {
jpql += " and bill.creditCompany=:creditCompany ";
parameters.put("creditCompany", paramCreditCompany);
}

// jpql += " and bi.item is not null "
// + " and bi.item.department is not null ";

jpql += " group by bi.item.department ";

System.out.println("jpql = " + jpql);
System.out.println("parameters = " + parameters);

List<ReportTemplateRow> rs = (List<ReportTemplateRow>) ejbFacade.findLightsByJpql(jpql, parameters, TemporalType.DATE);

System.out.println("rs = " + rs);

if (rs == null || rs.isEmpty()) {
System.out.println("No results found.");
} else {
System.out.println("Results found: " + rs.size());
}

long idCounter = 1;
Double total = 0.0;
for (ReportTemplateRow row : rs) {
System.out.println("row = " + row.getItemDepartment());
System.out.println("row = " + row.getRowCount());
row.setId(idCounter++);
total = row.getRowValue();
}
bundle.setReportTemplateRows(rs);
bundle.setTotal(total);
return bundle;
}



private ReportTemplateRowBundle handleItemSummaryByBill(
List<BillTypeAtomic> btas,
Date paramDate,
Expand Down Expand Up @@ -1608,8 +1790,6 @@ private ReportTemplateRowBundle handleItemSummaryByBill(
return bundle;
}



private ReportTemplateRowBundle handleToDepartmentSummaryByBillFee(
List<BillTypeAtomic> btas,
Date paramDate,
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/com/divudi/data/BillTypeAtomic.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,31 +109,31 @@ public enum BillTypeAtomic {
CHANNEL_REFUND_WITH_PAYMENT_FOR_CREDIT_SETTLED_BOOKINGS("Channel Refund with Payment for Bills where Credit Payment was Settled", BillCategory.REFUND, ServiceType.CHANNELLING, BillFinanceType.CASH_OUT, CountedServiceType.CHANNELLING),
CHANNEL_CANCELLATION_WITHOUT_PAYMENT("Channel Cancellation without Payment", BillCategory.CANCELLATION, ServiceType.CHANNELLING, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.CHANNELLING),
CHANNEL_REFUND("Channel Refund", BillCategory.REFUND, ServiceType.CHANNELLING, BillFinanceType.CASH_OUT, CountedServiceType.CHANNELLING),
// OPD
// OPD_IN
OPD_BATCH_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Opd Batch Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.NONE),
OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER("Opd Batch Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.NONE),
OPD_BATCH_BILL_WITH_PAYMENT("Opd Batch Bill with Payment Collection", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.NONE),
OPD_BATCH_BILL_CANCELLATION("Opd Batch Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.NONE),
OPD_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Opd Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.NONE),
OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER("OPD Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD),
OPD_BILL_WITH_PAYMENT("OPD Bill Payment with Payment", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD),
OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER("OPD Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN),
OPD_BILL_WITH_PAYMENT("OPD Bill Payment with Payment", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN),
OPD_BILL_CANCELLATION("Opd Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_OUT),
OPD_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION("Opd Bill Cancellation with Batch Bill", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_OUT),
OPD_BILL_REFUND("Opd Bill Refund", BillCategory.REFUND, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_OUT),
OPD_PROFESSIONAL_PAYMENT_BILL("OPD Professional Payment bill", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_PROFESSIONAL_PAYMENT),
@Deprecated
OPD_BILL_WITH_PAYMENT_UNDER_BATCH_BILL("OPD Bill with payment under batch bill", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD),
OPD_BILL_WITH_PAYMENT_UNDER_BATCH_BILL("OPD Bill with payment under batch bill", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN),
// PACKAGES
PACKAGE_OPD_BATCH_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Package Opd Batch Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD),
PACKAGE_OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER("Package Opd Batch Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.OPD),
PACKAGE_OPD_BATCH_BILL_WITH_PAYMENT("Package Opd Batch Bill with Payment Collection", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.OPD),
PACKAGE_OPD_BATCH_BILL_CANCELLATION("Package Opd Batch Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD),
PACKAGE_OPD_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Package Opd Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD),
PACKAGE_OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER("Package OPD Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD),
PACKAGE_OPD_BILL_WITH_PAYMENT("Package OPD Bill Payment with Payment", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD),
PACKAGE_OPD_BILL_CANCELLATION("Package Opd Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD),
PACKAGE_OPD_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION("Package Opd Bill Cancellation with Batch Bill", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD),
PACKAGE_OPD_BILL_REFUND("Package Opd Bill Refund", BillCategory.REFUND, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD),
PACKAGE_OPD_BATCH_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Package Opd Batch Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN),
PACKAGE_OPD_BATCH_BILL_PAYMENT_COLLECTION_AT_CASHIER("Package Opd Batch Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.OPD_IN),
PACKAGE_OPD_BATCH_BILL_WITH_PAYMENT("Package Opd Batch Bill with Payment Collection", BillCategory.BILL, ServiceType.OPD, BillFinanceType.CASH_IN, CountedServiceType.OPD_IN),
PACKAGE_OPD_BATCH_BILL_CANCELLATION("Package Opd Batch Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN),
PACKAGE_OPD_BILL_TO_COLLECT_PAYMENT_AT_CASHIER("Package Opd Bill to Collect Payment at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN),
PACKAGE_OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER("Package OPD Bill Payment Collection at Cashier", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN),
PACKAGE_OPD_BILL_WITH_PAYMENT("Package OPD Bill Payment with Payment", BillCategory.BILL, ServiceType.OPD, BillFinanceType.NO_FINANCE_TRANSACTIONS, CountedServiceType.OPD_IN),
PACKAGE_OPD_BILL_CANCELLATION("Package Opd Bill Cancellation", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_IN),
PACKAGE_OPD_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION("Package Opd Bill Cancellation with Batch Bill", BillCategory.CANCELLATION, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_IN),
PACKAGE_OPD_BILL_REFUND("Package Opd Bill Refund", BillCategory.REFUND, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_IN),
// COLLECTING CENTRE
CC_BATCH_BILL("Collecting Centre Batch Bill", BillCategory.BILL, ServiceType.COLLECTING_CENTRE, BillFinanceType.CASH_IN, CountedServiceType.COLLECTING_CENTRE),
CC_BATCH_BILL_CANCELLATION("Collecting Centre Batch Bill Cancellation", BillCategory.CANCELLATION, ServiceType.COLLECTING_CENTRE, BillFinanceType.CASH_OUT, CountedServiceType.COLLECTING_CENTRE),
Expand All @@ -158,7 +158,7 @@ public enum BillTypeAtomic {
PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE("Channelling Payment for Staff", BillCategory.PAYMENTS, ServiceType.CHANNELLING, BillFinanceType.CASH_OUT, CountedServiceType.CHANNELLING),
PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_SESSION("Channelling session Payment for Staff", BillCategory.PAYMENTS, ServiceType.CHANNELLING, BillFinanceType.CASH_OUT, CountedServiceType.CHANNELLING),
PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_CHANNELING_SERVICE_FOR_AGENCIES("Channelling Payment for Staff for agencies", BillCategory.PAYMENTS, ServiceType.OTHER, BillFinanceType.CASH_IN, CountedServiceType.OTHER),
PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES("OPD Professional Payment bill", BillCategory.PAYMENTS, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD),
PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES("OPD Professional Payment bill", BillCategory.PAYMENTS, ServiceType.OPD, BillFinanceType.CASH_OUT, CountedServiceType.OPD_IN),
PETTY_CASH_ISSUE("Petty Cash Issue", BillCategory.PAYMENTS, ServiceType.OTHER, BillFinanceType.CASH_OUT, CountedServiceType.OTHER),
PETTY_CASH_RETURN("Petty Cash Return", BillCategory.BILL, ServiceType.OTHER, BillFinanceType.CASH_IN, CountedServiceType.OTHER),
IOU_CASH_ISSUE("Iou Cash Issue", BillCategory.BILL, ServiceType.OTHER, BillFinanceType.CASH_OUT, CountedServiceType.OTHER),
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/divudi/data/CountedServiceType.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
public enum CountedServiceType {

OPD("Outpatient Department"),
OPD_IN("Outpatient Department - Collection"),
OPD_OUT("Outpatient Department - Cancellation or Refunds"),
OPD_PROFESSIONAL_PAYMENT("Outpatient Department - Professional Payment"),
NONE("NONE"),
Expand Down
Loading

0 comments on commit aa9fe29

Please sign in to comment.