From 16c94d292c27d06d6f94ceef4f78b73283e79785 Mon Sep 17 00:00:00 2001 From: Abhinav Raut Date: Thu, 4 Aug 2022 19:04:34 +0530 Subject: [PATCH 1/2] fix: pending principal- amount (cherry picked from commit a272d73dd9b30d014829d97c9d0a642286d7d38e) # Conflicts: # erpnext/loan_management/doctype/loan_repayment/loan_repayment.json --- .../loan_balance_adjustment.py | 2 +- .../loan_disbursement/loan_disbursement.json | 6 ++--- .../loan_disbursement/loan_disbursement.py | 3 +++ .../loan_interest_accrual.py | 3 +++ .../loan_repayment/loan_repayment.json | 8 ++++-- .../doctype/loan_repayment/loan_repayment.py | 5 +++- .../loan_security_unpledge.py | 3 +++ .../doctype/loan_write_off/loan_write_off.py | 25 ++++++++++++++----- 8 files changed, 42 insertions(+), 13 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_balance_adjustment/loan_balance_adjustment.py b/erpnext/loan_management/doctype/loan_balance_adjustment/loan_balance_adjustment.py index 0a576d69692a..514a5fcfafb8 100644 --- a/erpnext/loan_management/doctype/loan_balance_adjustment/loan_balance_adjustment.py +++ b/erpnext/loan_management/doctype/loan_balance_adjustment/loan_balance_adjustment.py @@ -99,7 +99,7 @@ def make_gl_entries(self, cancel=0, adv_adj=0): loan_account = frappe.db.get_value("Loan", self.loan, "loan_account") remarks = "{} against loan {}".format(self.adjustment_type.capitalize(), self.loan) if self.reference_number: - remarks += "with reference no. {}".format(self.reference_number) + remarks += " with reference no. {}".format(self.reference_number) loan_entry = { "account": loan_account, diff --git a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.json b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.json index 50926d772686..c7b5c033756f 100644 --- a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.json +++ b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.json @@ -163,11 +163,11 @@ }, { "fetch_from": "against_loan.disbursement_account", + "fetch_if_empty": 1, "fieldname": "disbursement_account", "fieldtype": "Link", "label": "Disbursement Account", - "options": "Account", - "read_only": 1 + "options": "Account" }, { "fieldname": "column_break_16", @@ -185,7 +185,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2022-02-17 18:23:44.157598", + "modified": "2022-08-04 17:16:04.922444", "modified_by": "Administrator", "module": "Loan Management", "name": "Loan Disbursement", diff --git a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py index 10174e531a19..8a493a5fc77a 100644 --- a/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py +++ b/erpnext/loan_management/doctype/loan_disbursement/loan_disbursement.py @@ -209,6 +209,9 @@ def get_disbursal_amount(loan, on_current_security_price=0): "loan_amount", "disbursed_amount", "total_payment", + "debit_adjustment_amount", + "credit_adjustment_amount", + "refund_amount", "total_principal_paid", "total_interest_payable", "status", diff --git a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py index 3a4c6513e455..ef53303f5a10 100644 --- a/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py +++ b/erpnext/loan_management/doctype/loan_interest_accrual/loan_interest_accrual.py @@ -147,6 +147,9 @@ def make_accrual_interest_entry_for_demand_loans( "name", "total_payment", "total_amount_paid", + "debit_adjustment_amount", + "credit_adjustment_amount", + "refund_amount", "loan_account", "interest_income_account", "loan_amount", diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json index 480e010b49a5..cd807984dab6 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json @@ -281,11 +281,11 @@ }, { "fetch_from": "against_loan.payment_account", + "fetch_if_empty": 1, "fieldname": "payment_account", "fieldtype": "Link", "label": "Repayment Account", - "options": "Account", - "read_only": 1 + "options": "Account" }, { "fieldname": "column_break_36", @@ -311,7 +311,11 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2022-02-18 19:10:07.742298", +======= + "modified": "2022-08-04 17:13:51.964203", +>>>>>>> a272d73dd9 (fix: pending principal- amount) "modified_by": "Administrator", "module": "Loan Management", "name": "Loan Repayment", diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py index 18803504eb15..2f9f4571f28c 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py @@ -150,6 +150,9 @@ def update_paid_amount(self): "status", "is_secured_loan", "total_payment", + "debit_adjustment_amount", + "credit_adjustment_amount", + "refund_amount", "loan_amount", "disbursed_amount", "total_interest_payable", @@ -399,7 +402,7 @@ def make_gl_entries(self, cancel=0, adv_adj=0): remarks = "Repayment against loan " + self.against_loan if self.reference_number: - remarks += "with reference no. {}".format(self.reference_number) + remarks += " with reference no. {}".format(self.reference_number) if self.repay_from_salary: payment_account = self.payroll_payable_account diff --git a/erpnext/loan_management/doctype/loan_security_unpledge/loan_security_unpledge.py b/erpnext/loan_management/doctype/loan_security_unpledge/loan_security_unpledge.py index 731b65e9a29f..3f773011b29b 100644 --- a/erpnext/loan_management/doctype/loan_security_unpledge/loan_security_unpledge.py +++ b/erpnext/loan_management/doctype/loan_security_unpledge/loan_security_unpledge.py @@ -58,6 +58,9 @@ def validate_unpledge_qty(self): self.loan, [ "total_payment", + "debit_adjustment_amount", + "credit_adjustment_amount", + "refund_amount", "total_principal_paid", "loan_amount", "total_interest_payable", diff --git a/erpnext/loan_management/doctype/loan_write_off/loan_write_off.py b/erpnext/loan_management/doctype/loan_write_off/loan_write_off.py index e19fd15fc84b..2eeb97c8f890 100644 --- a/erpnext/loan_management/doctype/loan_write_off/loan_write_off.py +++ b/erpnext/loan_management/doctype/loan_write_off/loan_write_off.py @@ -9,6 +9,9 @@ import erpnext from erpnext.accounts.general_ledger import make_gl_entries from erpnext.controllers.accounts_controller import AccountsController +from erpnext.loan_management.doctype.loan_repayment.loan_repayment import ( + get_pending_principal_amount, +) class LoanWriteOff(AccountsController): @@ -22,16 +25,26 @@ def set_missing_values(self): def validate_write_off_amount(self): precision = cint(frappe.db.get_default("currency_precision")) or 2 - total_payment, principal_paid, interest_payable, written_off_amount = frappe.get_value( + + loan_details = frappe.get_value( "Loan", self.loan, - ["total_payment", "total_principal_paid", "total_interest_payable", "written_off_amount"], + [ + "total_payment", + "debit_adjustment_amount", + "credit_adjustment_amount", + "refund_amount", + "total_principal_paid", + "loan_amount", + "total_interest_payable", + "written_off_amount", + "disbursed_amount", + "status", + ], + as_dict=1, ) - pending_principal_amount = flt( - flt(total_payment) - flt(interest_payable) - flt(principal_paid) - flt(written_off_amount), - precision, - ) + pending_principal_amount = flt(get_pending_principal_amount(loan_details), precision) if self.write_off_amount > pending_principal_amount: frappe.throw(_("Write off amount cannot be greater than pending principal amount")) From fb3725752ff005aff70493d94df87418ff8b3831 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 8 Aug 2022 11:53:49 +0530 Subject: [PATCH 2/2] chore: resolve conflicts --- .../doctype/loan_repayment/loan_repayment.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json index cd807984dab6..71f93e26bdbc 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json @@ -311,11 +311,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2022-02-18 19:10:07.742298", -======= "modified": "2022-08-04 17:13:51.964203", ->>>>>>> a272d73dd9 (fix: pending principal- amount) "modified_by": "Administrator", "module": "Loan Management", "name": "Loan Repayment", @@ -357,4 +353,4 @@ "sort_order": "DESC", "states": [], "track_changes": 1 -} \ No newline at end of file +}