Merge pull request #22483 from deepeshgarg007/loan_security_shorttfall_fixes

fix: Loan security shortfall fixes
This commit is contained in:
Deepesh Garg 2020-06-27 18:57:14 +05:30 committed by GitHub
commit 1d8b13c943
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 4 deletions

View File

@ -235,8 +235,10 @@ def make_repayment_entry(loan, applicant_type, applicant, loan_type, company, as
@frappe.whitelist() @frappe.whitelist()
def create_loan_security_unpledge(loan, applicant_type, applicant, company, as_dict=1): def create_loan_security_unpledge(loan, applicant_type, applicant, company, as_dict=1):
loan_security_pledge_details = frappe.db.sql(""" 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 WHERE p.parent = lsp.name AND lsp.loan = %s AND lsp.docstatus = 1
GROUP BY p.loan_security
""",(loan), as_dict=1) """,(loan), as_dict=1)
unpledge_request = frappe.new_doc("Loan Security Unpledge") unpledge_request = frappe.new_doc("Loan Security Unpledge")

View File

@ -116,7 +116,7 @@ class LoanRepayment(AccountsController):
def allocate_amounts(self, paid_entries): def allocate_amounts(self, paid_entries):
self.set('repayment_details', []) self.set('repayment_details', [])
self.principal_amount_paid = 0 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: if self.amount_paid - self.penalty_amount > 0 and paid_entries:
interest_paid = self.amount_paid - self.penalty_amount interest_paid = self.amount_paid - self.penalty_amount

View File

@ -1,4 +1,5 @@
{ {
"actions": [],
"autoname": "LM-LSP-.####", "autoname": "LM-LSP-.####",
"creation": "2019-09-03 18:20:31.382887", "creation": "2019-09-03 18:20:31.382887",
"doctype": "DocType", "doctype": "DocType",
@ -46,6 +47,7 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"in_list_view": 1, "in_list_view": 1,
"label": "Loan Security Price", "label": "Loan Security Price",
"options": "Company:company:default_currency",
"reqd": 1 "reqd": 1
}, },
{ {
@ -79,7 +81,8 @@
"read_only": 1 "read_only": 1
} }
], ],
"modified": "2019-10-26 09:46:46.069667", "links": [],
"modified": "2020-06-11 03:41:33.900340",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Loan Management", "module": "Loan Management",
"name": "Loan Security Price", "name": "Loan Security Price",

View File

@ -19,7 +19,9 @@ def update_shortfall_status(loan, security_value):
return return
if security_value >= loan_security_shortfall.shortfall_amount: 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: else:
frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name, frappe.db.set_value("Loan Security Shortfall", loan_security_shortfall.name,
"shortfall_amount", loan_security_shortfall.shortfall_amount - security_value) "shortfall_amount", loan_security_shortfall.shortfall_amount - security_value)