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 d08180aa535..fa3fdc6e292 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 @@ -152,4 +152,5 @@ + diff --git a/fineract-provider/src/main/resources/db/changelog/tenant/parts/0133_UpdateNewHardPolicyQueries.xml b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0133_UpdateNewHardPolicyQueries.xml new file mode 100644 index 00000000000..d415bbfb7e4 --- /dev/null +++ b/fineract-provider/src/main/resources/db/changelog/tenant/parts/0133_UpdateNewHardPolicyQueries.xml @@ -0,0 +1,66 @@ + + + + + + + 0 AND overdue_loans.loan_count = 0 THEN ''GREEN'' + WHEN recredit_loans.loan_count > 0 AND overdue_loans.loan_count > 0 THEN ''RED'' + WHEN recredit_loans.loan_count = 0 THEN ''GREEN'' END as color + FROM m_prequalification_group mpg + LEFT JOIN ( + SELECT p.id AS prequalification_id, + (SELECT COUNT(distinct ml.id) + FROM m_prequalification_group mp + JOIN m_prequalification_group_members mpgm ON mpgm.group_id = mp.id + JOIN m_client mc ON mc.dpi = mpgm.dpi + JOIN m_loan ml ON ml.client_id = mc.id + JOIN m_loan_repayment_schedule mlrs on mlrs.loan_id = ml.id + WHERE ml.loan_status_id = 300 AND ml.product_id = ${loanProductId} AND (ml.is_topup IS NULL OR ml.is_topup = 0) + AND mlrs.duedate < CURRENT_DATE AND mlrs.obligations_met_on_date IS NULL + AND mp.id = ${prequalificationId} + ) AS loan_count + FROM m_prequalification_group p + )overdue_loans ON overdue_loans.prequalification_id = mpg.id + LEFT JOIN ( + SELECT p.id AS prequalification_id, + (SELECT COUNT(ml.id) + FROM m_prequalification_group mp + JOIN m_prequalification_group_members mpgm ON mpgm.group_id = mp.id + JOIN m_client mc ON mc.dpi = mpgm.dpi + JOIN m_loan ml ON ml.client_id = mc.id + WHERE ml.loan_status_id < 300 AND ml.product_id = ${loanProductId} AND ml.is_topup = 1 + AND mp.id = ${prequalificationId} + ) AS loan_count + FROM m_prequalification_group p + )recredit_loans ON recredit_loans.prequalification_id = mpg.id + WHERE mpg.id = ${prequalificationId}' WHERE report_name = 'Clients In Arrears Policy Check'; + ]]> + + + +