Skip to content

feat: add sanctioned amount tolerance on loan product#1320

Draft
Nihantra-Patel wants to merge 2 commits into
frappe:developfrom
Nihantra-Patel:feat/sanctioned-amount-tolerance
Draft

feat: add sanctioned amount tolerance on loan product#1320
Nihantra-Patel wants to merge 2 commits into
frappe:developfrom
Nihantra-Patel:feat/sanctioned-amount-tolerance

Conversation

@Nihantra-Patel

@Nihantra-Patel Nihantra-Patel commented Jul 10, 2026

Copy link
Copy Markdown
Member

Problem

When a customer's securities are pledged, the system automatically sanctions a credit limit (Sanctioned Loan Amount) for that customer, equal to the post-haircut value of their pledged securities.

When a new loan (or loan application) is created, the system checks that:

loan amount + customer's existing outstanding must not exceed the sanctioned limit.

This check was exact, with zero tolerance. If the requested loan was even 1 rupee over the sanctioned limit, it was rejected with "Sanctioned Amount limit crossed."

In practice, the limit is often calculated in more than one place, and small rounding differences cause the limit to end up a few paise/rupees below the intended figure. As a result, loans that should be perfectly valid fail at creation and block legitimate business.

Solution

Add a Sanctioned Amount Tolerance field on Loan Product. The sanctioned-amount check now rejects a loan only when:

loan amount + existing outstanding  >  sanctioned limit + tolerance

Because the comparison is strictly greater-than, a loan exactly at sanctioned limit + tolerance is allowed (i.e. loans less than or equal to the limit plus tolerance pass). This is applied in both Loan and Loan Application creation. With tolerance 0 (default), behaviour is unchanged.

Example (limit ₹10,00,000, tolerance ₹100)

Requested loan amount Before (no tolerance) After (tolerance ₹100)
₹10,00,050 ❌ Rejected ✅ Allowed
₹10,00,100 (= limit + tolerance) ❌ Rejected ✅ Allowed
₹10,00,101 ❌ Rejected ❌ Rejected
₹10,00,200 ❌ Rejected ❌ Rejected

Loans up to limit + tolerance go through; anything beyond is still blocked.

Configuration

On the Loan Product form, under the Limits section, set Sanctioned Amount Tolerance to the amount you want to allow above the sanctioned limit. Leave it at 0 to keep the strict check.

image

Loan and Loan Application creation reject any loan whose amount plus the
applicant's existing outstanding exceeds their sanctioned amount limit,
with no allowance for rounding. When the LOS and Frappe compute the limit
slightly differently, a valid loan fails by a small margin.

Add a Sanctioned Amount Tolerance (Currency, default 0) field on Loan
Product and allow the total to exceed the sanctioned limit by up to this
tolerance during the check on both Loan and Loan Application.
@codecov-commenter

codecov-commenter commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.59%. Comparing base (69310c9) to head (b71ea2b).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1320      +/-   ##
===========================================
+ Coverage    82.56%   82.59%   +0.03%     
===========================================
  Files          154      154              
  Lines        10881    10900      +19     
===========================================
+ Hits          8984     9003      +19     
  Misses        1897     1897              
Files with missing lines Coverage Δ
lending/loan_management/doctype/loan/loan.py 72.59% <100.00%> (+0.03%) ⬆️
lending/loan_management/doctype/loan/test_loan.py 99.22% <100.00%> (+0.01%) ⬆️
...ement/doctype/loan_application/loan_application.py 55.00% <100.00%> (+0.22%) ⬆️
...an_management/doctype/loan_product/loan_product.py 78.94% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Nihantra-Patel Nihantra-Patel force-pushed the feat/sanctioned-amount-tolerance branch from 3b3e478 to b71ea2b Compare July 10, 2026 06:17
@sourabhgir

Copy link
Copy Markdown

@Nihantra-Patel @deepeshgarg007 any fixed amount may have issues based on amount.. for e.g. on loan of 10 lac. 100 rs is only .001% so wont fix things. but 100 on 1000 loan becomes 10% which will breach RBI limit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants