fix: Auto Loan Write Off

This commit is contained in:
Deepesh Garg 2021-01-17 17:39:51 +05:30
parent 914ab7e4b0
commit ec60063155
2 changed files with 16 additions and 14 deletions

View File

@ -202,7 +202,9 @@ def request_loan_closure(loan, posting_date=None):
# checking greater than 0 as there may be some minor precision error # checking greater than 0 as there may be some minor precision error
if pending_amount < write_off_limit: if pending_amount < write_off_limit:
# update status as loan closure requested # Auto create loan write off and update status as loan closure requested
write_off = make_loan_write_off(loan)
write_off.submit()
frappe.db.set_value('Loan', loan, 'status', 'Loan Closure Requested') frappe.db.set_value('Loan', loan, 'status', 'Loan Closure Requested')
else: else:
frappe.throw(_("Cannot close loan as there is an outstanding of {0}").format(pending_amount)) frappe.throw(_("Cannot close loan as there is an outstanding of {0}").format(pending_amount))
@ -336,13 +338,13 @@ def create_loan_security_unpledge(unpledge_map, loan, company, applicant_type, a
return unpledge_request return unpledge_request
def validate_employee_currency_with_company_currency(applicant, company): def validate_employee_currency_with_company_currency(applicant, company):
from erpnext.payroll.doctype.salary_structure_assignment.salary_structure_assignment import get_employee_currency from erpnext.payroll.doctype.salary_structure_assignment.salary_structure_assignment import get_employee_currency
if not applicant: if not applicant:
frappe.throw(_("Please select Applicant")) frappe.throw(_("Please select Applicant"))
if not company: if not company:
frappe.throw(_("Please select Company")) frappe.throw(_("Please select Company"))
employee_currency = get_employee_currency(applicant) employee_currency = get_employee_currency(applicant)
company_currency = erpnext.get_company_currency(company) company_currency = erpnext.get_company_currency(company)
if employee_currency != company_currency: if employee_currency != company_currency:
frappe.throw(_("Loan cannot be repayed from salary for Employee {0} because salary is processed in currency {1}") frappe.throw(_("Loan cannot be repayed from salary for Employee {0} because salary is processed in currency {1}")
.format(applicant, employee_currency)) .format(applicant, employee_currency))

View File

@ -144,17 +144,17 @@
}, },
{ {
"allow_on_submit": 1, "allow_on_submit": 1,
"description": "Pending amount that will be automatically ignored on loan closure request ", "description": "Loan Write Off will be automatically created on loan closure request if pending amount is below this limit",
"fieldname": "write_off_amount", "fieldname": "write_off_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Write Off Amount ", "label": "Auto Write Off Amount ",
"options": "Company:company:default_currency" "options": "Company:company:default_currency"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"is_submittable": 1, "is_submittable": 1,
"links": [], "links": [],
"modified": "2020-10-26 07:13:55.029811", "modified": "2021-01-17 06:51:26.082879",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Loan Management", "module": "Loan Management",
"name": "Loan Type", "name": "Loan Type",