diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml index 81aa2fa1e..8ae46ba69 100644 --- a/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml +++ b/fineract-provider/src/main/resources/db/changelog/tenant/changelog-tenant.xml @@ -231,4 +231,6 @@ + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0213_transaction_summary_adding_originators.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0213_transaction_summary_adding_originators.xml new file mode 100644 index 000000000..30db1335a --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0213_transaction_summary_adding_originators.xml @@ -0,0 +1,2649 @@ + + + + + + = '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum not in (10, 26, 32, 34, 36, 39) + AND (t.office_id = ${officeId})), + slt_charge_adj AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum = 26 + AND (t.office_id = ${officeId})), + rlt_except_charge_adj_and_accrual AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + CASE + WHEN d.payment_type_id IS NULL AND t.classification_cv_id IS NOT NULL + THEN (SELECT code_value FROM m_code_value WHERE id = t.classification_cv_id) + ELSE NULL END AS classification_name, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND + e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum not in (10, 26, 32, 34, 36, 39) + AND (t.office_id = ${officeId})), + rlt_charge_adj AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum = 26 + AND (t.office_id = ${officeId})), + slt_cap_income_amortization AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + CASE + WHEN d.payment_type_id IS NULL AND bt.classification_cv_id IS NOT NULL + THEN (SELECT code_value FROM m_code_value WHERE id = bt.classification_cv_id) + ELSE NULL END AS classification_name, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + JOIN m_loan_amortization_allocation_mapping map + ON map.amortization_loan_transaction_id = t.id + JOIN m_loan_transaction bt ON bt.id = map.base_loan_transaction_id + LEFT JOIN m_external_asset_owner_transfer e ON e.loan_id = t.loan_id AND + e.settlement_date < + '${endDate}' AND + e.effective_date_to >= + '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.is_reversed = false + AND t.transaction_type_enum IN (36, 39) + AND (t.office_id = ${officeId})), + rlt_cap_income_amortization AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + CASE + WHEN d.payment_type_id IS NULL AND bt.classification_cv_id IS NOT NULL + THEN (SELECT code_value FROM m_code_value WHERE id = bt.classification_cv_id) + ELSE NULL END AS classification_name, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + JOIN m_loan_amortization_allocation_mapping map + ON map.amortization_loan_transaction_id = t.id + JOIN m_loan_transaction bt ON bt.id = map.base_loan_transaction_id + LEFT JOIN m_external_asset_owner_transfer e ON e.loan_id = t.loan_id AND + e.settlement_date < + '${endDate}' AND + e.effective_date_to >= + '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.is_reversed = true + AND t.transaction_type_enum IN (36, 39) + AND (t.office_id = ${officeId})), + active_external_asset_owner_transfers AS (SELECT '${endDate}' AS transactiondate, + t.id, + p.name, + t.owner_id, + dt.principal_outstanding_derived, + dt.interest_outstanding_derived, + dt.fee_charges_outstanding_derived, + dt.penalty_charges_outstanding_derived, + dt.total_overpaid_derived, + l.charged_off_on_date, + t.settlement_date, + l.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_external_asset_owner_transfer t + JOIN m_loan l ON l.id = t.loan_id + JOIN m_client c ON c.id = l.client_id + JOIN m_product_loan p ON p.id = l.product_id + JOIN m_external_asset_owner_transfer_details dt + ON dt.asset_owner_transfer_id = t.id + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') + AND c.office_id = ${officeId} + AND t.settlement_date = '${endDate}'), + buyback_external_asset_owner_transfers AS (SELECT '${endDate}' AS transactiondate, + t.id, + p.name, + dt.principal_outstanding_derived, + dt.interest_outstanding_derived, + dt.fee_charges_outstanding_derived, + dt.penalty_charges_outstanding_derived, + dt.total_overpaid_derived, + l.charged_off_on_date, + t.settlement_date, + l.charge_off_reason_cv_id, + t.owner_id, + lo.originator_external_ids + FROM m_external_asset_owner_transfer t + JOIN m_loan l ON l.id = t.loan_id + JOIN m_client c ON c.id = l.client_id + JOIN m_product_loan p ON p.id = l.product_id + JOIN m_external_asset_owner_transfer_details dt + ON dt.asset_owner_transfer_id = t.id + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.status in ('BUYBACK', 'BUYBACK_INTERMEDIATE') + AND c.office_id = ${officeId} + AND t.settlement_date = '${endDate}') +SELECT '${endDate}' AS TransactionDate, + a.product AS Product, + CASE + WHEN a.transaction_type = 9999 THEN 'Asset Transfer' + WHEN a.transaction_type = 99999 THEN 'Asset Buyback' + ELSE (SELECT enum_message_property + FROM r_enum_value + WHERE enum_name = 'transaction_type_enum' + AND enum_id = a.transaction_type) END AS TransactionType_Name, + COALESCE((SELECT value FROM m_payment_type WHERE id = a.payment_type_id), + a.classification_name) AS PaymentType_Name, + a.chargetype AS chargetype, + a.reversal_indicator AS Reversed, + a.Allocation_Type AS Allocation_Type, + (SELECT code_value FROM m_code_value WHERE id = a.charge_off_reason_id) AS Chargeoff_ReasonCode, + CASE + WHEN a.transaction_type = 9999 THEN sum(a.amount) * + 1 + WHEN a.transaction_type = 99999 THEN sum(a.amount) * - 1 + WHEN a.transaction_type IN (2, 23, 21, 22, 24, 4, 5, 8, 6, 27, 9, 26, 28, 31, 33, 34, 37, 39) AND + a.reversal_indicator = false THEN sum(a.amount) * -1 + WHEN a.transaction_type IN (2, 23, 21, 22, 24, 4, 5, 8, 6, 27, 9, 26, 28, 31, 33, 34, 37, 39) AND + a.reversal_indicator = true THEN sum(a.amount) * + 1 + WHEN a.transaction_type IN (1, 10, 25, 20, 35, 36) AND a.reversal_indicator = false THEN sum(a.amount) * + 1 + WHEN a.transaction_type IN (1, 10, 25, 20, 35, 36) AND a.reversal_indicator = true + THEN sum(a.amount) * -1 END AS Transaction_Amount, + (SELECT external_id + FROM m_external_asset_owner + WHERE id = a.asset_owner_id) AS Asset_owner_id, + (SELECT external_id + FROM m_external_asset_owner + WHERE id = a.from_asset_owner_id) AS From_asset_owner_id, + a.originator_external_ids +FROM (SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE + WHEN t.transaction_type_enum in (1) THEN (CASE + WHEN t.amount is null THEN 0 + WHEN t.overpayment_portion_derived is null THEN t.amount + WHEN t.overpayment_portion_derived is not null + THEN t.amount - t.overpayment_portion_derived + ELSE t.amount END) + ELSE (CASE + WHEN t.principal_portion_derived is null THEN 0 + ELSE t.principal_portion_derived end) END amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE WHEN t.principal_portion_derived is null THEN 0 ELSE t.principal_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE WHEN t.principal_portion_derived is null THEN 0 ELSE t.principal_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + mc.name AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN pd.amount is null THEN 0 ELSE pd.amount END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + JOIN m_loan_charge_paid_by pd ON pd.loan_transaction_id = t.id + JOIN m_loan_charge c ON c.id = pd.loan_charge_id + JOIN m_charge mc ON mc.id = c.charge_id AND mc.is_penalty = false + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = false + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + mc.name AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE WHEN pd.amount is null THEN 0 ELSE pd.amount END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + JOIN m_loan_charge_paid_by pd ON pd.loan_transaction_id = t.id + JOIN m_loan_charge c ON c.id = pd.loan_charge_id + JOIN m_charge mc ON mc.id = c.charge_id AND mc.is_penalty = true + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = false + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum in (10, 34) + AND t.is_reversed = false + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE WHEN t.principal_portion_derived is null THEN 0 ELSE t.principal_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE + WHEN t.transaction_type_enum in (1) THEN (CASE + WHEN t.amount is null THEN 0 + WHEN t.overpayment_portion_derived is null THEN t.amount + WHEN t.overpayment_portion_derived is not null + THEN t.amount - t.overpayment_portion_derived + ELSE t.amount END) + ELSE (CASE + WHEN t.principal_portion_derived is null THEN 0 + ELSE t.principal_portion_derived end) END amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + mc.name AS chargetype, + true AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN pd.amount is null THEN 0 ELSE pd.amount END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + JOIN m_loan_charge_paid_by pd ON pd.loan_transaction_id = t.id + JOIN m_loan_charge c ON c.id = pd.loan_charge_id + JOIN m_charge mc ON mc.id = c.charge_id AND mc.is_penalty = false + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = true + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + mc.name AS chargetype, + true AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE WHEN pd.amount is null THEN 0 ELSE pd.amount END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + JOIN m_loan_charge_paid_by pd ON pd.loan_transaction_id = t.id + JOIN m_loan_charge c ON c.id = pd.loan_charge_id + JOIN m_charge mc ON mc.id = c.charge_id AND mc.is_penalty = true + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = true + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = true + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE WHEN t.principal_portion_derived is null THEN 0 ELSE t.principal_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_type, + t.principal_outstanding_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.principal_outstanding_derived > 0 + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_type, + t.interest_outstanding_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.interest_outstanding_derived > 0 + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_type, + t.fee_charges_outstanding_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.fee_charges_outstanding_derived > 0 + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_type, + t.penalty_charges_outstanding_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.penalty_charges_outstanding_derived > 0 + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_type, + t.total_overpaid_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null::bigint AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.total_overpaid_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_type, + t.principal_outstanding_derived AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.principal_outstanding_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_type, + t.interest_outstanding_derived AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.interest_outstanding_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_type, + t.fee_charges_outstanding_derived AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.fee_charges_outstanding_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_type, + t.penalty_charges_outstanding_derived AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.penalty_charges_outstanding_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_type, + t.total_overpaid_derived * -1 AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.total_overpaid_derived > 0) a +GROUP BY a.transactiondate, a.product, a.transaction_type, a.payment_type_id, a.classification_name, a.chargetype, + a.reversal_indicator, a.Allocation_Type, a.asset_owner_id, a.charge_off_reason_id, a.from_asset_owner_id, + a.originator_external_ids +ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + + ]]> + + report_name='Transaction Summary Report with Asset Owner' + + + + + = '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum not in (10, 26, 32, 34, 36, 39) + AND (t.office_id = ${officeId})), + slt_charge_adj AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum = 26 + AND (t.office_id = ${officeId})), + rlt_except_charge_adj_and_accrual AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + CASE + WHEN d.payment_type_id IS NULL AND t.classification_cv_id IS NOT NULL + THEN (SELECT code_value FROM m_code_value WHERE id = t.classification_cv_id) + ELSE NULL END AS classification_name, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND + e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum not in (10, 26, 32, 34, 36, 39) + AND (t.office_id = ${officeId})), + rlt_charge_adj AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum = 26 + AND (t.office_id = ${officeId})), + slt_cap_income_amortization AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + CASE + WHEN d.payment_type_id IS NULL AND bt.classification_cv_id IS NOT NULL + THEN (SELECT code_value FROM m_code_value WHERE id = bt.classification_cv_id) + ELSE NULL END AS classification_name, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + JOIN m_loan_amortization_allocation_mapping map + ON map.amortization_loan_transaction_id = t.id + JOIN m_loan_transaction bt ON bt.id = map.base_loan_transaction_id + LEFT JOIN m_external_asset_owner_transfer e ON e.loan_id = t.loan_id AND + e.settlement_date < + '${endDate}' AND + e.effective_date_to >= + '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.is_reversed = false + AND t.transaction_type_enum IN (36, 39) + AND (t.office_id = ${officeId})), + rlt_cap_income_amortization AS (SELECT '${endDate}' AS transactiondate, + t.id, + l.name, + t.transaction_type_enum, + d.payment_type_id, + CASE + WHEN d.payment_type_id IS NULL AND bt.classification_cv_id IS NOT NULL + THEN (SELECT code_value FROM m_code_value WHERE id = bt.classification_cv_id) + ELSE NULL END AS classification_name, + t.overpayment_portion_derived, + t.principal_portion_derived, + t.interest_portion_derived, + t.fee_charges_portion_derived, + t.penalty_charges_portion_derived, + t.amount, + e.status, + e.settlement_date, + e.owner_id, + m.charged_off_on_date, + t.transaction_date, + m.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_payment_detail d ON d.id = t.payment_detail_id + JOIN m_loan_amortization_allocation_mapping map + ON map.amortization_loan_transaction_id = t.id + JOIN m_loan_transaction bt ON bt.id = map.base_loan_transaction_id + LEFT JOIN m_external_asset_owner_transfer e ON e.loan_id = t.loan_id AND + e.settlement_date < + '${endDate}' AND + e.effective_date_to >= + '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.is_reversed = true + AND t.transaction_type_enum IN (36, 39) + AND (t.office_id = ${officeId})), + active_external_asset_owner_transfers AS (SELECT '${endDate}' AS transactiondate, + t.id, + p.name, + t.owner_id, + t.previous_owner_id, + dt.principal_outstanding_derived, + dt.interest_outstanding_derived, + dt.fee_charges_outstanding_derived, + dt.penalty_charges_outstanding_derived, + dt.total_overpaid_derived, + l.charged_off_on_date, + t.settlement_date, + l.charge_off_reason_cv_id, + lo.originator_external_ids + FROM m_external_asset_owner_transfer t + JOIN m_loan l ON l.id = t.loan_id + JOIN m_client c ON c.id = l.client_id + JOIN m_product_loan p ON p.id = l.product_id + JOIN m_external_asset_owner_transfer_details dt + ON dt.asset_owner_transfer_id = t.id + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') + AND c.office_id = ${officeId} + AND t.settlement_date = '${endDate}'), + buyback_external_asset_owner_transfers AS (SELECT '${endDate}' AS transactiondate, + t.id, + p.name, + dt.principal_outstanding_derived, + dt.interest_outstanding_derived, + dt.fee_charges_outstanding_derived, + dt.penalty_charges_outstanding_derived, + dt.total_overpaid_derived, + l.charged_off_on_date, + t.settlement_date, + l.charge_off_reason_cv_id, + t.owner_id, + lo.originator_external_ids + FROM m_external_asset_owner_transfer t + JOIN m_loan l ON l.id = t.loan_id + JOIN m_client c ON c.id = l.client_id + JOIN m_product_loan p ON p.id = l.product_id + JOIN m_external_asset_owner_transfer_details dt + ON dt.asset_owner_transfer_id = t.id + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.status in ('BUYBACK', 'BUYBACK_INTERMEDIATE') + AND c.office_id = ${officeId} + AND t.settlement_date = '${endDate}') +SELECT '${endDate}' AS TransactionDate, + a.product AS Product, + CASE + WHEN a.transaction_type = 9999 THEN 'Asset Transfer' + WHEN a.transaction_type = 99999 THEN 'Asset Buyback' + ELSE (SELECT enum_message_property + FROM r_enum_value + WHERE enum_name = 'transaction_type_enum' + AND enum_id = a.transaction_type) END AS TransactionType_Name, + COALESCE((SELECT value FROM m_payment_type WHERE id = a.payment_type_id), + a.classification_name) AS PaymentType_Name, + a.chargetype AS chargetype, + a.reversal_indicator AS Reversed, + a.Allocation_Type AS Allocation_Type, + (SELECT code_value FROM m_code_value WHERE id = a.charge_off_reason_id) AS Chargeoff_ReasonCode, + CASE + WHEN a.transaction_type = 9999 THEN sum(a.amount) * + 1 + WHEN a.transaction_type = 99999 THEN sum(a.amount) * - 1 + WHEN a.transaction_type IN (2, 23, 21, 22, 24, 4, 5, 8, 6, 27, 9, 26, 28, 31, 33, 34, 37, 39) AND + a.reversal_indicator = false THEN sum(a.amount) * -1 + WHEN a.transaction_type IN (2, 23, 21, 22, 24, 4, 5, 8, 6, 27, 9, 26, 28, 31, 33, 34, 37, 39) AND + a.reversal_indicator = true THEN sum(a.amount) * + 1 + WHEN a.transaction_type IN (1, 10, 25, 20, 35, 36) AND a.reversal_indicator = false THEN sum(a.amount) * + 1 + WHEN a.transaction_type IN (1, 10, 25, 20, 35, 36) AND a.reversal_indicator = true + THEN sum(a.amount) * -1 END AS Transaction_Amount, + (SELECT external_id + FROM m_external_asset_owner + WHERE id = a.asset_owner_id) AS Asset_owner_id, + (SELECT external_id + FROM m_external_asset_owner + WHERE id = a.from_asset_owner_id) AS From_asset_owner_id, + a.originator_external_ids AS Originator_External_Ids +FROM (SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE + WHEN t.transaction_type_enum in (1) THEN (CASE + WHEN t.amount is null THEN 0 + WHEN t.overpayment_portion_derived is null THEN t.amount + WHEN t.overpayment_portion_derived is not null + THEN t.amount - t.overpayment_portion_derived + ELSE t.amount END) + ELSE (CASE + WHEN t.principal_portion_derived is null THEN 0 + ELSE t.principal_portion_derived end) END amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM slt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE WHEN t.principal_portion_derived is null THEN 0 ELSE t.principal_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM slt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE WHEN t.principal_portion_derived is null THEN 0 ELSE t.principal_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.transaction_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + t.originator_external_ids AS from_asset_owner_id + FROM rlt_cap_income_amortization AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + mc.name AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN pd.amount is null THEN 0 ELSE pd.amount END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null, + lo.originator_external_ids AS from_asset_owner_id + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + JOIN m_loan_charge_paid_by pd ON pd.loan_transaction_id = t.id + JOIN m_loan_charge c ON c.id = pd.loan_charge_id + JOIN m_charge mc ON mc.id = c.charge_id AND mc.is_penalty = false + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = false + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + mc.name AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE WHEN pd.amount is null THEN 0 ELSE pd.amount END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + lo.originator_external_ids AS from_asset_owner_id + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + JOIN m_loan_charge_paid_by pd ON pd.loan_transaction_id = t.id + JOIN m_loan_charge c ON c.id = pd.loan_charge_id + JOIN m_charge mc ON mc.id = c.charge_id AND mc.is_penalty = true + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = false + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + lo.originator_external_ids AS from_asset_owner_id + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.submitted_on_date = '${endDate}' + AND t.transaction_type_enum in (10, 34) + AND t.is_reversed = false + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE WHEN t.principal_portion_derived is null THEN 0 ELSE t.principal_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM slt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE + WHEN t.transaction_type_enum in (1) THEN (CASE + WHEN t.amount is null THEN 0 + WHEN t.overpayment_portion_derived is null THEN t.amount + WHEN t.overpayment_portion_derived is not null + THEN t.amount - t.overpayment_portion_derived + ELSE t.amount END) + ELSE (CASE + WHEN t.principal_portion_derived is null THEN 0 + ELSE t.principal_portion_derived end) END amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + t.classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_except_charge_adj_and_accrual AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + mc.name AS chargetype, + true AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN pd.amount is null THEN 0 ELSE pd.amount END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + JOIN m_loan_charge_paid_by pd ON pd.loan_transaction_id = t.id + JOIN m_loan_charge c ON c.id = pd.loan_charge_id + JOIN m_charge mc ON mc.id = c.charge_id AND mc.is_penalty = false + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = true + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + mc.name AS chargetype, + true AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE WHEN pd.amount is null THEN 0 ELSE pd.amount END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + JOIN m_loan_charge_paid_by pd ON pd.loan_transaction_id = t.id + JOIN m_loan_charge c ON c.id = pd.loan_charge_id + JOIN m_charge mc ON mc.id = c.charge_id AND mc.is_penalty = true + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = true + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + l.name AS product, + t.transaction_type_enum AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN e.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND e.settlement_date < '${endDate}' + THEN e.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (m.charged_off_on_date <= t.transaction_date) + THEN m.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + lo.originator_external_ids + FROM m_loan_transaction t + JOIN m_loan m ON m.id = t.loan_id + JOIN m_product_loan l ON l.id = m.product_id + LEFT JOIN m_external_asset_owner_transfer e + ON e.loan_id = t.loan_id AND e.settlement_date < '${endDate}' AND + e.effective_date_to >= '${endDate}' + LEFT JOIN loan_originators lo ON lo.loan_id = t.loan_id + WHERE t.reversed_on_date = '${endDate}' + AND t.transaction_type_enum = 10 + AND t.is_reversed = true + AND (t.office_id = ${officeId}) + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Fees' AS Allocation_Type, + CASE WHEN t.fee_charges_portion_derived is null THEN 0 ELSE t.fee_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Penalty' AS Allocation_Type, + CASE + WHEN t.penalty_charges_portion_derived is null THEN 0 + ELSE t.penalty_charges_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Interest' AS Allocation_Type, + CASE WHEN t.interest_portion_derived is null THEN 0 ELSE t.interest_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Principal' AS Allocation_Type, + CASE WHEN t.principal_portion_derived is null THEN 0 ELSE t.principal_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + t.transaction_type_enum AS transaction_type, + t.payment_type_id, + null AS classification_name, + '' AS chargetype, + true AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_Type, + CASE WHEN t.overpayment_portion_derived is null THEN 0 ELSE t.overpayment_portion_derived END AS amount, + CASE + WHEN t.status in ('ACTIVE', 'ACTIVE_INTERMEDIATE') AND t.settlement_date < '${endDate}' + THEN t.owner_id END AS asset_owner_id, + CASE + WHEN t.transaction_type_enum = 27 OR (t.charged_off_on_date <= t.transaction_date) + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + null AS from_asset_owner_id, + t.originator_external_ids + FROM rlt_charge_adj AS t + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_type, + t.principal_outstanding_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.previous_owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.principal_outstanding_derived > 0 + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_type, + t.interest_outstanding_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.previous_owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.interest_outstanding_derived > 0 + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_type, + t.fee_charges_outstanding_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.previous_owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.fee_charges_outstanding_derived > 0 + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_type, + t.penalty_charges_outstanding_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.previous_owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.penalty_charges_outstanding_derived > 0 + UNION ALL + SELECT t.transactiondate, + t.id, + t.name AS product, + 9999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_type, + t.total_overpaid_derived AS amount, + t.owner_id AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.previous_owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM active_external_asset_owner_transfers AS t + WHERE t.total_overpaid_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Principal' AS Allocation_type, + t.principal_outstanding_derived AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.principal_outstanding_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Interest' AS Allocation_type, + t.interest_outstanding_derived AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.interest_outstanding_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Fees' AS Allocation_type, + t.fee_charges_outstanding_derived AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.fee_charges_outstanding_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Penalty' AS Allocation_type, + t.penalty_charges_outstanding_derived AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.penalty_charges_outstanding_derived > 0 + UNION ALL + SELECT '${endDate}' AS transactiondate, + t.id, + t.name AS product, + 99999 AS transaction_type, + null AS payment_type_id, + null AS classification_name, + '' AS chargetype, + false AS reversal_indicator, + 'Unallocated Credit (UNC)' AS Allocation_type, + t.total_overpaid_derived * -1 AS amount, + null AS asset_owner_id, + CASE + WHEN t.charged_off_on_date <= t.settlement_date + THEN t.charge_off_reason_cv_id END AS charge_off_reason_id, + t.owner_id AS from_asset_owner_id, + t.originator_external_ids + FROM buyback_external_asset_owner_transfers AS t + WHERE t.total_overpaid_derived > 0) a +GROUP BY a.transactiondate, a.product, a.transaction_type, a.payment_type_id, a.classification_name, a.chargetype, + a.reversal_indicator, a.Allocation_Type, a.asset_owner_id, a.charge_off_reason_id, a.from_asset_owner_id, + a.originator_external_ids +ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + + ]]> + + report_name='Transaction Summary Report with Asset Owner' + + + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0214_trial_balance_summary_adding_originators.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0214_trial_balance_summary_adding_originators.xml new file mode 100644 index 000000000..10507229f --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0214_trial_balance_summary_adding_originators.xml @@ -0,0 +1,439 @@ + + + + + + (SELECT latest FROM aggregated_date) + ) + AND acc_gl_journal_entry.submitted_on_date < '${endDate}' + AND (acc_gl_journal_entry.office_id = ${officeId}) + GROUP BY productname, glcode, glname, assetowner, originators), + merged_historical_data AS (SELECT COALESCE(s.productname, p.productname) AS productname, + COALESCE(s.glcode, p.glcode) AS glcode, + COALESCE(s.glname, p.glname) AS glname, + COALESCE(s.assetowner, p.assetowner, 0) AS assetowner, + COALESCE(s.debitamount, 0) + COALESCE(p.debitamount, 0) AS debitamount, + COALESCE(s.creditamount, 0) + COALESCE(p.creditamount, 0) AS creditamount, + p.originators AS originators + FROM summary_snapshot_baseline_data s + LEFT JOIN post_snapshot_delta_data p + ON s.glcode = p.glcode + AND s.productname = p.productname + AND s.assetowner = p.assetowner + + UNION ALL + + SELECT p.productname AS productname, + p.glcode AS glcode, + p.glname AS glname, + COALESCE(p.assetowner, 0) AS assetowner, + COALESCE(p.debitamount, 0) AS debitamount, + COALESCE(p.creditamount, 0) AS creditamount, + p.originators AS originators + FROM post_snapshot_delta_data p + LEFT JOIN summary_snapshot_baseline_data s + ON s.glcode = p.glcode + AND s.productname = p.productname + AND s.assetowner = p.assetowner + WHERE s.glcode IS NULL), + current_cob_data AS (SELECT lp.name AS productname, + account_id, + acc_gl_account.gl_code AS glcode, + acc_gl_account.name AS glname, + CASE WHEN aw.owner_id IS NULL THEN 0 ELSE aw.owner_id END AS assetowner, + SUM(CASE WHEN acc_gl_journal_entry.type_enum = 2 THEN amount ELSE 0 END) AS debitamount, + SUM(CASE WHEN acc_gl_journal_entry.type_enum = 1 THEN amount ELSE 0 END) AS creditamount, + lo.originator_external_ids AS originators + FROM acc_gl_journal_entry + JOIN acc_gl_account ON acc_gl_account.id = acc_gl_journal_entry.account_id + JOIN m_loan m ON m.id = acc_gl_journal_entry.entity_id + JOIN m_product_loan lp ON lp.id = m.product_id + LEFT JOIN m_external_asset_owner_journal_entry_mapping aw + ON aw.journal_entry_id = acc_gl_journal_entry.id + LEFT JOIN loan_originators lo ON lo.loan_id = m.id + WHERE acc_gl_journal_entry.entity_type_enum = 1 + AND acc_gl_journal_entry.manual_entry = FALSE + AND acc_gl_journal_entry.submitted_on_date = '${endDate}' + AND (acc_gl_journal_entry.office_id = ${officeId}) + GROUP BY productname, account_id, glcode, glname, assetowner, originators) + +SELECT * +FROM (SELECT * + FROM retained_earning + WHERE glacct = (SELECT gl_code FROM acc_gl_account WHERE name = 'Retained Earnings Prior Year') + + UNION + + SELECT txnreport.postingdate, + txnreport.product, + txnreport.glacct, + txnreport.description, + txnreport.assetowner, + (COALESCE(txnreport.beginningbalance, 0) + COALESCE(summary.beginningbalance, 0)) AS beginningbalance, + txnreport.debitmovement AS debitmovement, + txnreport.creditmovement AS creditmovement, + (COALESCE(txnreport.endingbalance, 0) + COALESCE(summary.beginningbalance, 0)) AS endingbalance, + txnreport.originators AS originators + FROM (SELECT * + FROM (SELECT DISTINCT '${endDate}' AS postingdate, + loan.pname AS product, + loan.gl_code AS glacct, + loan.glname AS description, + COALESCE((SELECT external_id FROM m_external_asset_owner WHERE id = loan.assetowner), + 'self') AS assetowner, + loan.openingbalance AS beginningbalance, + (loan.debitamount * 1) AS debitmovement, + (loan.creditamount * -1) AS creditmovement, + (loan.openingbalance + loan.debitamount - loan.creditamount) AS endingbalance, + loan.originators AS originators + FROM (SELECT DISTINCT g.pname AS pname, + g.gl_code AS gl_code, + g.glname AS glname, + COALESCE(mh.assetowner, c.assetowner, 0) AS assetowner, + COALESCE(mh.debitamount, 0) - COALESCE(mh.creditamount, 0) AS openingbalance, + COALESCE(c.debitamount, 0) AS debitamount, + COALESCE(c.creditamount, 0) AS creditamount, + COALESCE(mh.originators, c.originators) AS originators + FROM (SELECT DISTINCT ag.gl_code, ag.id, pl.NAME AS pname, ag.NAME AS glname + FROM acc_gl_account ag + JOIN acc_product_mapping am ON am.gl_account_id = ag.id AND am.product_type = 1 + JOIN m_product_loan pl ON pl.id = am.product_id) g + LEFT JOIN merged_historical_data mh + ON g.gl_code = mh.glcode + AND mh.productname = g.pname + LEFT JOIN current_cob_data c + ON g.gl_code = c.glcode + AND c.productname = g.pname + AND mh.assetowner = c.assetowner + + UNION ALL + + SELECT DISTINCT c.productname AS pname, + c.glcode AS gl_code, + c.glname AS glname, + COALESCE(c.assetowner, 0) AS assetowner, + 0 AS openingbalance, + COALESCE(c.debitamount, 0) AS debitamount, + COALESCE(c.creditamount, 0) AS creditamount, + COALESCE(matched.originators, c.originators) AS originators + FROM current_cob_data c + LEFT JOIN (SELECT g3.gl_code, g3.pname, mh.assetowner, mh.originators + FROM (SELECT DISTINCT ag.gl_code, pl.NAME AS pname + FROM acc_gl_account ag + JOIN acc_product_mapping am + ON am.gl_account_id = ag.id AND am.product_type = 1 + JOIN m_product_loan pl ON pl.id = am.product_id) g3 + LEFT JOIN merged_historical_data mh + ON g3.gl_code = mh.glcode + AND mh.productname = g3.pname) matched + ON matched.gl_code = c.glcode + AND matched.pname = c.productname + AND matched.assetowner = c.assetowner + WHERE matched.gl_code IS NULL) loan) a) AS txnreport + LEFT JOIN retained_earning summary + ON txnreport.glacct = summary.glacct + AND txnreport.assetowner = summary.assetowner + AND summary.product = txnreport.product) report +WHERE report.endingbalance != 0 + OR report.debitmovement != 0 + OR report.creditmovement != 0 +ORDER BY glacct + + ]]> + + report_name='Trial Balance Summary Report with Asset Owner' + + + + + (SELECT latest FROM aggregated_date) + ) + AND acc_gl_journal_entry.submitted_on_date < '${endDate}' + AND (acc_gl_journal_entry.office_id = ${officeId}) + GROUP BY productname, glcode, glname, assetowner, originators), + merged_historical_data AS (SELECT COALESCE(s.productname, p.productname) AS productname, + COALESCE(s.glcode, p.glcode) AS glcode, + COALESCE(s.glname, p.glname) AS glname, + COALESCE(s.assetowner, p.assetowner, 0) AS assetowner, + COALESCE(s.debitamount, 0) + COALESCE(p.debitamount, 0) AS debitamount, + COALESCE(s.creditamount, 0) + COALESCE(p.creditamount, 0) AS creditamount, + p.originators AS originators + FROM summary_snapshot_baseline_data s + LEFT JOIN post_snapshot_delta_data p + ON s.glcode = p.glcode + AND s.productname = p.productname + AND s.assetowner = p.assetowner + + UNION ALL + + SELECT p.productname AS productname, + p.glcode AS glcode, + p.glname AS glname, + COALESCE(p.assetowner, 0) AS assetowner, + COALESCE(p.debitamount, 0) AS debitamount, + COALESCE(p.creditamount, 0) AS creditamount, + p.originators AS originators + FROM post_snapshot_delta_data p + LEFT JOIN summary_snapshot_baseline_data s + ON s.glcode = p.glcode + AND s.productname = p.productname + AND s.assetowner = p.assetowner + WHERE s.glcode IS NULL), + current_cob_data AS (SELECT lp.name AS productname, + account_id, + acc_gl_account.gl_code AS glcode, + acc_gl_account.name AS glname, + CASE WHEN aw.owner_id IS NULL THEN 0 ELSE aw.owner_id END AS assetowner, + SUM(CASE WHEN acc_gl_journal_entry.type_enum = 2 THEN amount ELSE 0 END) AS debitamount, + SUM(CASE WHEN acc_gl_journal_entry.type_enum = 1 THEN amount ELSE 0 END) AS creditamount, + lo.originator_external_ids AS originators + FROM acc_gl_journal_entry + JOIN acc_gl_account ON acc_gl_account.id = acc_gl_journal_entry.account_id + JOIN m_loan m ON m.id = acc_gl_journal_entry.entity_id + JOIN m_product_loan lp ON lp.id = m.product_id + LEFT JOIN m_external_asset_owner_journal_entry_mapping aw + ON aw.journal_entry_id = acc_gl_journal_entry.id + LEFT JOIN loan_originators lo ON lo.loan_id = m.id + WHERE acc_gl_journal_entry.entity_type_enum = 1 + AND acc_gl_journal_entry.manual_entry = FALSE + AND acc_gl_journal_entry.submitted_on_date = '${endDate}' + AND (acc_gl_journal_entry.office_id = ${officeId}) + GROUP BY productname, account_id, glcode, glname, assetowner, originators) + +SELECT * +FROM (SELECT * + FROM retained_earning + WHERE glacct = (SELECT gl_code FROM acc_gl_account WHERE name = 'Retained Earnings Prior Year') + + UNION + + SELECT txnreport.postingdate, + txnreport.product, + txnreport.glacct, + txnreport.description, + txnreport.assetowner, + (COALESCE(txnreport.beginningbalance, 0) + COALESCE(summary.beginningbalance, 0)) AS beginningbalance, + txnreport.debitmovement AS debitmovement, + txnreport.creditmovement AS creditmovement, + (COALESCE(txnreport.endingbalance, 0) + COALESCE(summary.beginningbalance, 0)) AS endingbalance, + txnreport.originators AS originators + FROM (SELECT * + FROM (SELECT DISTINCT '${endDate}' AS postingdate, + loan.pname AS product, + loan.gl_code AS glacct, + loan.glname AS description, + COALESCE((SELECT external_id FROM m_external_asset_owner WHERE id = loan.assetowner), + 'self') AS assetowner, + loan.openingbalance AS beginningbalance, + (loan.debitamount * 1) AS debitmovement, + (loan.creditamount * -1) AS creditmovement, + (loan.openingbalance + loan.debitamount - loan.creditamount) AS endingbalance, + loan.originators AS originators + FROM (SELECT DISTINCT g.pname AS pname, + g.gl_code AS gl_code, + g.glname AS glname, + COALESCE(mh.assetowner, c.assetowner, 0) AS assetowner, + COALESCE(mh.debitamount, 0) - COALESCE(mh.creditamount, 0) AS openingbalance, + COALESCE(c.debitamount, 0) AS debitamount, + COALESCE(c.creditamount, 0) AS creditamount, + COALESCE(mh.originators, c.originators) AS originators + FROM (SELECT DISTINCT ag.gl_code, ag.id, pl.NAME AS pname, ag.NAME AS glname + FROM acc_gl_account ag + JOIN acc_product_mapping am ON am.gl_account_id = ag.id AND am.product_type = 1 + JOIN m_product_loan pl ON pl.id = am.product_id) g + LEFT JOIN merged_historical_data mh + ON g.gl_code = mh.glcode + AND mh.productname = g.pname + LEFT JOIN current_cob_data c + ON g.gl_code = c.glcode + AND c.productname = g.pname + AND mh.assetowner = c.assetowner + + UNION ALL + + SELECT DISTINCT c.productname AS pname, + c.glcode AS gl_code, + c.glname AS glname, + COALESCE(c.assetowner, 0) AS assetowner, + 0 AS openingbalance, + COALESCE(c.debitamount, 0) AS debitamount, + COALESCE(c.creditamount, 0) AS creditamount, + COALESCE(matched.originators, c.originators) AS originators + FROM current_cob_data c + LEFT JOIN (SELECT g3.gl_code, g3.pname, mh.assetowner, mh.originators + FROM (SELECT DISTINCT ag.gl_code, pl.NAME AS pname + FROM acc_gl_account ag + JOIN acc_product_mapping am + ON am.gl_account_id = ag.id AND am.product_type = 1 + JOIN m_product_loan pl ON pl.id = am.product_id) g3 + LEFT JOIN merged_historical_data mh + ON g3.gl_code = mh.glcode + AND mh.productname = g3.pname) matched + ON matched.gl_code = c.glcode + AND matched.pname = c.productname + AND matched.assetowner = c.assetowner + WHERE matched.gl_code IS NULL) loan) a) AS txnreport + LEFT JOIN retained_earning summary + ON txnreport.glacct = summary.glacct + AND txnreport.assetowner = summary.assetowner + AND summary.product = txnreport.product) report +WHERE report.endingbalance != 0 + OR report.debitmovement != 0 + OR report.creditmovement != 0 +ORDER BY glacct + + ]]> + + report_name='Trial Balance Summary Report with Asset Owner' + + + diff --git a/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignTrialBalanceSummaryReportTest.java b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignTrialBalanceSummaryReportTest.java index a33dfcd0b..64c4fd93d 100644 --- a/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignTrialBalanceSummaryReportTest.java +++ b/integration-tests/src/test/java/org/apache/fineract/integrationtests/client/feign/tests/FeignTrialBalanceSummaryReportTest.java @@ -146,7 +146,7 @@ public class FeignTrialBalanceSummaryReportTest extends FeignIntegrationTest { assertFalse(response.getColumnHeaders().isEmpty()); List expectedColumns = List.of("postingdate", "product", "glacct", "description", "assetowner", "beginningbalance", - "debitmovement", "creditmovement", "endingbalance"); + "debitmovement", "creditmovement", "endingbalance", "originators"); List actualColumns = response.getColumnHeaders().stream().map(ResultsetColumnHeaderData::getColumnName).toList(); Assertions.assertEquals(expectedColumns, actualColumns); }