Skip to content

Conversation

Nihantra-Patel
Copy link
Member

@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2025

Codecov Report

❌ Patch coverage is 83.51648% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.56%. Comparing base (ffdb8ec) to head (acc45e3).

Files with missing lines Patch % Lines
lending/overrides/sales_invoice.py 60.00% 6 Missing ⚠️
...an_management/doctype/loan_product/loan_product.py 77.27% 5 Missing ⚠️
...loan_balance_adjustment/loan_balance_adjustment.py 0.00% 3 Missing ⚠️
lending/overrides/journal_entry.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #907      +/-   ##
===========================================
+ Coverage    72.34%   72.56%   +0.21%     
===========================================
  Files          128      130       +2     
  Lines         8828     8886      +58     
===========================================
+ Hits          6387     6448      +61     
+ Misses        2441     2438       -3     
Files with missing lines Coverage Δ
lending/hooks.py 100.00% <100.00%> (ø)
lending/install.py 0.00% <ø> (ø)
...ing/loan_management/controllers/loan_controller.py 100.00% <100.00%> (ø)
lending/loan_management/doctype/loan/loan.py 61.97% <ø> (ø)
lending/loan_management/doctype/loan/test_loan.py 99.46% <100.00%> (+<0.01%) ⬆️
...loan_management/doctype/loan_demand/loan_demand.py 84.71% <100.00%> (-0.07%) ⬇️
...ent/doctype/loan_disbursement/loan_disbursement.py 76.53% <100.00%> (ø)
...ype/loan_interest_accrual/loan_interest_accrual.py 86.49% <100.00%> (-0.04%) ⬇️
...loan_management/doctype/loan_refund/loan_refund.py 78.08% <100.00%> (-0.30%) ⬇️
...anagement/doctype/loan_repayment/loan_repayment.py 80.65% <100.00%> (ø)
... and 6 more
🚀 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.

@rmehta
Copy link
Member

rmehta commented Sep 19, 2025

Company tab should be "Lending" not "Loan"

@deepeshgarg007 deepeshgarg007 marked this pull request as ready for review October 3, 2025 10:11
@deepeshgarg007 deepeshgarg007 self-requested a review as a code owner October 3, 2025 10:11
if not self.cost_center:
frappe.throw(_("Cost center is mandatory for loans having rate of interest greater than 0"))

def set_optional_accounts(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this validation is not needed since we are enforcing it at the Loan Product stage, and we fetch the value from the loan product

self.assertEqual(loan.loan_amount, 1000000)

def test_loan_disbursement(self):
frappe.db.set_value("Company", "_Test Company", "enable_loan_accounting", 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do this for every test

  1. Make this a decorator (check for similar settings in other files)
  2. Enable accounting in the setup since all other tests assume accounting is enabled
  3. In the specific tests, where we are testing accounting is disabled, disable the setting

flt(repayment.amount_paid - repayment.pending_principal_amount - interest_waiver_amount, 2),
)

def test_loan_accounting_enabled_or_disabled(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, only enable it for this test

def on_submit(self):
self.set_status_and_amounts()
self.make_gl_entries()
if loan_accounting_enabled(self.company):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting a different idea here.
Make a LoanController class like AccountsController and StockController, and let all doctypes inherit the LoanController (this will be inherited from the accounts controller), then this check can only be done at the LoanController level instead of checking in each doctype.

@@ -0,0 +1,9 @@
from erpnext.accounts.doctype.journal_entry.journal_entry import JournalEntry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

from lending.loan_management.utils import loan_accounting_enabled


class CustomSalesInvoice(SalesInvoice):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a new class, and why is it named CustomSalesInvoice?

@@ -0,0 +1,18 @@
import frappe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoroughly test this once, as it will have a larger impact once released

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.

4 participants