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 0a576d6969..514a5fcfaf 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 @@ class LoanBalanceAdjustment(AccountsController): 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 50926d7726..c7b5c03375 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 0c2042ba50..b73dee26b9 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 0aeb448918..4680456211 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 76dc8b462e..3e7dc28f71 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.json @@ -264,11 +264,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", @@ -294,7 +294,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2022-06-21 10:10:07.742298", + "modified": "2022-08-04 17:13:51.964203", "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 07a1d0d850..29da988ce4 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py @@ -149,6 +149,9 @@ class LoanRepayment(AccountsController): "status", "is_secured_loan", "total_payment", + "debit_adjustment_amount", + "credit_adjustment_amount", + "refund_amount", "loan_amount", "disbursed_amount", "total_interest_payable", @@ -398,7 +401,7 @@ class LoanRepayment(AccountsController): 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 hasattr(self, "repay_from_salary") and 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 0ab7beb0fc..15a9c4a85e 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 @@ -57,6 +57,9 @@ class LoanSecurityUnpledge(Document): 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 25aecf673b..ae483f9759 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 @@ from frappe.utils import cint, flt, getdate 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 @@ class LoanWriteOff(AccountsController): 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"))