BNPL | Rule Based overdue charges

  1. Add Charge through UI or API

    curl --location --request POST 'http://localhost:8080/fineract-provider/api/v1/charges' \ --header 'Accept: application/json, text/plain, */*' \ --header 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \ --header 'Authorization: bearer 6265058e-dd52-4434-a042-bd2c5aafdf5f' \ --header 'Connection: keep-alive' \ --header 'Content-Type: application/json;charset=UTF-8' \ --header 'Fineract-Platform-TenantId: default' \ --header 'Origin: http://localhost:9000' \ --header 'Referer: http://localhost:9000/' \ --header 'Sec-Fetch-Dest: empty' \ --header 'Sec-Fetch-Mode: cors' \ --header 'Sec-Fetch-Site: same-site' \ --header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \ --header 'sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"' \ --header 'sec-ch-ua-mobile: ?0' \ --header 'sec-ch-ua-platform: "macOS"' \ --data-raw '{ "active": true, "chargeAppliesTo": 5, "name": "Overdue Penal Charge", "businessIdentificationCode": "PC", "currencyCode": "INR", "chargeTimeType": 9, "overdueChargeDetail": { "overdueClassification": "Standard", "calculateChargeOnCurrentOverdue": false, "gracePeriod": "0", "penaltyFreePeriod": "0", "graceType": 2 }, "isCapitalized": false, "chargeCalculationType": 10, "chargePaymentMode": 0, "amount": "100", "feeFrequency": 6, "penalty": "true", "taxGroupId": 1, "isGlimCharge": false, "emiRoundingGoalSeek": false, "locale": "en", "monthDayFormat": "dd MMM", "isUpdateThroughDiscount": false }'

     

  2. Verify m_charge configuration :-

    1. charge_applies_to_enum :- CREDIT(5) .

    2. charge_time_enum :- OVERDUE_INSTALLMENT(9).

    3. charge_calculation_enum :- RULE_BASED(10).

    4. fee_frequency :- EACH_OVERDUE(6).

  3. Insert into f_scorecard.

    INSERT INTO `f_scorecard` (`name`, `display_name`, `value_type`, `entity`, `rule`, `rule_version`, `createdby_id`, `created_date`, `lastmodifiedby_id`, `lastmodified_date`, `version`) VALUES ('creditlineOverdueAmountFetcher', 'creditlineOverdueAmountFetcher', 'NUMBER', 'CREDIT', 'overdueFeeCalculator', 1, (SELECT id from m_appuser where username = 'system') , now(), (SELECT id from m_appuser where username = 'system'), now(), 1);
  4. insert into f_system_sql.

    INSERT INTO `f_system_sql` (`uname`, `description`, `sql`) VALUES ('creditlineOverdueAmountFetcher', 'creditlineOverdueAmountFetcher', 'SELECT\n a.principal + a.interest + a.fee + a.penalty AS overdueAmount\nFROM (\n SELECT\n SUM(ifnull(fcs.principal_charged, 0) - ifnull(fcs.principal_accounted, 0)) AS principal,\n SUM(ifnull(fcs.interest_charged, 0) - ifnull(fcs.interest_accounted, 0)) AS interest,\n SUM(ifnull(fcs.fee_charged, 0) - ifnull(fcs.fee_accounted, 0)) AS fee,\n SUM(ifnull(fcs.penalty_charged, 0) - ifnull(fcs.penalty_accounted, 0)) AS penalty\n FROM\n f_account_schedule fcs\n WHERE\n fcs.account_number =?\n AND fcs.obligations_met = 0\n AND (SELECT fcs.id from f_account_schedule fcs where fcs.account_number =? AND fcs.due_on>? ) is not null\n AND fcs.due_on <?) a');
  5. insert into f_risk_rule.

  6. Update charge with scorecard name :- In m_charge table Configure the Score card name.

     

  7. Run Arrears Job Before Running Penalties Job

    1. Curl for Arrears Job:

    2. Cur for Penalties Job: