fix: pending principal- amount
This commit is contained in:
parent
c95b986414
commit
a272d73dd9
@ -163,11 +163,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fetch_from": "against_loan.disbursement_account",
|
"fetch_from": "against_loan.disbursement_account",
|
||||||
|
"fetch_if_empty": 1,
|
||||||
"fieldname": "disbursement_account",
|
"fieldname": "disbursement_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Disbursement Account",
|
"label": "Disbursement Account",
|
||||||
"options": "Account",
|
"options": "Account"
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_16",
|
"fieldname": "column_break_16",
|
||||||
@ -185,7 +185,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-02-17 18:23:44.157598",
|
"modified": "2022-08-04 17:16:04.922444",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Loan Management",
|
"module": "Loan Management",
|
||||||
"name": "Loan Disbursement",
|
"name": "Loan Disbursement",
|
||||||
|
@ -209,6 +209,9 @@ def get_disbursal_amount(loan, on_current_security_price=0):
|
|||||||
"loan_amount",
|
"loan_amount",
|
||||||
"disbursed_amount",
|
"disbursed_amount",
|
||||||
"total_payment",
|
"total_payment",
|
||||||
|
"debit_adjustment_amount",
|
||||||
|
"credit_adjustment_amount",
|
||||||
|
"refund_amount",
|
||||||
"total_principal_paid",
|
"total_principal_paid",
|
||||||
"total_interest_payable",
|
"total_interest_payable",
|
||||||
"status",
|
"status",
|
||||||
|
@ -147,6 +147,9 @@ def make_accrual_interest_entry_for_demand_loans(
|
|||||||
"name",
|
"name",
|
||||||
"total_payment",
|
"total_payment",
|
||||||
"total_amount_paid",
|
"total_amount_paid",
|
||||||
|
"debit_adjustment_amount",
|
||||||
|
"credit_adjustment_amount",
|
||||||
|
"refund_amount",
|
||||||
"loan_account",
|
"loan_account",
|
||||||
"interest_income_account",
|
"interest_income_account",
|
||||||
"loan_amount",
|
"loan_amount",
|
||||||
|
@ -264,11 +264,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fetch_from": "against_loan.payment_account",
|
"fetch_from": "against_loan.payment_account",
|
||||||
|
"fetch_if_empty": 1,
|
||||||
"fieldname": "payment_account",
|
"fieldname": "payment_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Repayment Account",
|
"label": "Repayment Account",
|
||||||
"options": "Account",
|
"options": "Account"
|
||||||
"read_only": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_36",
|
"fieldname": "column_break_36",
|
||||||
@ -294,7 +294,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-06-21 10:10:07.742298",
|
"modified": "2022-08-04 17:13:51.964203",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Loan Management",
|
"module": "Loan Management",
|
||||||
"name": "Loan Repayment",
|
"name": "Loan Repayment",
|
||||||
|
@ -149,6 +149,9 @@ class LoanRepayment(AccountsController):
|
|||||||
"status",
|
"status",
|
||||||
"is_secured_loan",
|
"is_secured_loan",
|
||||||
"total_payment",
|
"total_payment",
|
||||||
|
"debit_adjustment_amount",
|
||||||
|
"credit_adjustment_amount",
|
||||||
|
"refund_amount",
|
||||||
"loan_amount",
|
"loan_amount",
|
||||||
"disbursed_amount",
|
"disbursed_amount",
|
||||||
"total_interest_payable",
|
"total_interest_payable",
|
||||||
|
@ -57,6 +57,9 @@ class LoanSecurityUnpledge(Document):
|
|||||||
self.loan,
|
self.loan,
|
||||||
[
|
[
|
||||||
"total_payment",
|
"total_payment",
|
||||||
|
"debit_adjustment_amount",
|
||||||
|
"credit_adjustment_amount",
|
||||||
|
"refund_amount",
|
||||||
"total_principal_paid",
|
"total_principal_paid",
|
||||||
"loan_amount",
|
"loan_amount",
|
||||||
"total_interest_payable",
|
"total_interest_payable",
|
||||||
|
@ -9,6 +9,9 @@ from frappe.utils import cint, flt, getdate
|
|||||||
import erpnext
|
import erpnext
|
||||||
from erpnext.accounts.general_ledger import make_gl_entries
|
from erpnext.accounts.general_ledger import make_gl_entries
|
||||||
from erpnext.controllers.accounts_controller import AccountsController
|
from erpnext.controllers.accounts_controller import AccountsController
|
||||||
|
from erpnext.loan_management.doctype.loan_repayment.loan_repayment import (
|
||||||
|
get_pending_principal_amount,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class LoanWriteOff(AccountsController):
|
class LoanWriteOff(AccountsController):
|
||||||
@ -22,16 +25,26 @@ class LoanWriteOff(AccountsController):
|
|||||||
|
|
||||||
def validate_write_off_amount(self):
|
def validate_write_off_amount(self):
|
||||||
precision = cint(frappe.db.get_default("currency_precision")) or 2
|
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",
|
"Loan",
|
||||||
self.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(
|
pending_principal_amount = flt(get_pending_principal_amount(loan_details), precision)
|
||||||
flt(total_payment) - flt(interest_payable) - flt(principal_paid) - flt(written_off_amount),
|
|
||||||
precision,
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.write_off_amount > pending_principal_amount:
|
if self.write_off_amount > pending_principal_amount:
|
||||||
frappe.throw(_("Write off amount cannot be greater than pending principal amount"))
|
frappe.throw(_("Write off amount cannot be greater than pending principal amount"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user