From a66ce050ff0e52734d39b29f0936e3919b37e221 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 15 Jun 2020 16:03:12 +0530 Subject: [PATCH 1/2] fix: Minor fixes in loan --- erpnext/loan_management/doctype/loan/loan.py | 4 +++- .../loan_management/doctype/loan_repayment/loan_repayment.py | 2 +- .../doctype/loan_security_price/loan_security_price.json | 5 ++++- .../loan_security_shortfall/loan_security_shortfall.py | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/erpnext/loan_management/doctype/loan/loan.py b/erpnext/loan_management/doctype/loan/loan.py index 76e10e5ddd..4e805d4a27 100644 --- a/erpnext/loan_management/doctype/loan/loan.py +++ b/erpnext/loan_management/doctype/loan/loan.py @@ -235,8 +235,10 @@ def make_repayment_entry(loan, applicant_type, applicant, loan_type, company, as @frappe.whitelist() def create_loan_security_unpledge(loan, applicant_type, applicant, company, as_dict=1): loan_security_pledge_details = frappe.db.sql(""" - SELECT p.parent, p.loan_security, p.qty as qty FROM `tabLoan Security Pledge` lsp , `tabPledge` p + SELECT p.loan_security, sum(p.qty) as qty + FROM `tabLoan Security Pledge` lsp , `tabPledge` p WHERE p.parent = lsp.name AND lsp.loan = %s AND lsp.docstatus = 1 + GROUP BY p.loan_security """,(loan), as_dict=1) unpledge_request = frappe.new_doc("Loan Security Unpledge") diff --git a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py index c28994e280..9605045777 100644 --- a/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py +++ b/erpnext/loan_management/doctype/loan_repayment/loan_repayment.py @@ -116,7 +116,7 @@ class LoanRepayment(AccountsController): def allocate_amounts(self, paid_entries): self.set('repayment_details', []) self.principal_amount_paid = 0 - interest_paid = 0 + interest_paid = self.amount_paid - self.penalty_amount if self.amount_paid - self.penalty_amount > 0 and paid_entries: interest_paid = self.amount_paid - self.penalty_amount diff --git a/erpnext/loan_management/doctype/loan_security_price/loan_security_price.json b/erpnext/loan_management/doctype/loan_security_price/loan_security_price.json index db260a4a9e..a55b482bd6 100644 --- a/erpnext/loan_management/doctype/loan_security_price/loan_security_price.json +++ b/erpnext/loan_management/doctype/loan_security_price/loan_security_price.json @@ -1,4 +1,5 @@ { + "actions": [], "autoname": "LM-LSP-.####", "creation": "2019-09-03 18:20:31.382887", "doctype": "DocType", @@ -46,6 +47,7 @@ "fieldtype": "Currency", "in_list_view": 1, "label": "Loan Security Price", + "options": "Company:company:default_currency", "reqd": 1 }, { @@ -79,7 +81,8 @@ "read_only": 1 } ], - "modified": "2019-10-26 09:46:46.069667", + "links": [], + "modified": "2020-06-11 03:41:33.900340", "modified_by": "Administrator", "module": "Loan Management", "name": "Loan Security Price", diff --git a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py index 308c4385d3..99cb0b3d62 100644 --- a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py +++ b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py @@ -19,7 +19,9 @@ def update_shortfall_status(loan, security_value): return if security_value >= loan_security_shortfall.shortfall_amount: - frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name, "status", "Completed") + frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name, { + "status", "Completed", + "shortfall_value": loan_security_shortfall.shortfall_amount}) else: frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name, "shortfall_amount", loan_security_shortfall.shortfall_amount - security_value) From 589364856c23aa97f7b235c01d96ab7d6e4b208e Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 27 Jun 2020 18:44:36 +0530 Subject: [PATCH 2/2] fix: Syntax Error --- .../doctype/loan_security_shortfall/loan_security_shortfall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py index 99cb0b3d62..ffd96737a5 100644 --- a/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py +++ b/erpnext/loan_management/doctype/loan_security_shortfall/loan_security_shortfall.py @@ -20,7 +20,7 @@ def update_shortfall_status(loan, security_value): if security_value >= loan_security_shortfall.shortfall_amount: frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name, { - "status", "Completed", + "status": "Completed", "shortfall_value": loan_security_shortfall.shortfall_amount}) else: frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name,