fix: Allow creation of loan security pledge from Loan Application for old prices

This commit is contained in:
Deepesh Garg 2020-04-23 13:51:29 +05:30
parent 5239c0e6d5
commit 2daf6dad2e
3 changed files with 4 additions and 3 deletions

View File

@ -31,7 +31,7 @@ frappe.ui.form.on('Loan Application', {
add_toolbar_buttons: function(frm) { add_toolbar_buttons: function(frm) {
if (frm.doc.status == "Approved") { if (frm.doc.status == "Approved") {
if (frm.doc.is_secured) { if (frm.doc.is_secured_loan) {
frappe.db.get_value("Loan Security Pledge", {"loan_application": frm.doc.name, "docstatus": 1}, "name", (r) => { frappe.db.get_value("Loan Security Pledge", {"loan_application": frm.doc.name, "docstatus": 1}, "name", (r) => {
if (!r) { if (!r) {
frm.add_custom_button(__('Loan Security Pledge'), function() { frm.add_custom_button(__('Loan Security Pledge'), function() {

View File

@ -30,7 +30,8 @@ class LoanSecurityPledge(Document):
if not pledge.qty and not pledge.amount: if not pledge.qty and not pledge.amount:
frappe.throw(_("Qty or Amount is mandatroy for loan security")) frappe.throw(_("Qty or Amount is mandatroy for loan security"))
pledge.loan_security_price = get_loan_security_price(pledge.loan_security) if not (self.loan_application and pledge.loan_security_price):
pledge.loan_security_price = get_loan_security_price(pledge.loan_security)
if not pledge.qty: if not pledge.qty:
pledge.qty = cint(pledge.amount/pledge.loan_security_price) pledge.qty = cint(pledge.amount/pledge.loan_security_price)

View File

@ -37,7 +37,7 @@ def get_loan_security_price(loan_security, valid_time=None):
}, 'loan_security_price') }, 'loan_security_price')
if not loan_security_price: if not loan_security_price:
frappe.throw(_("No valid <b>Loan Security Price</b> found for {0}").format(frappe.bold(loan_security))) frappe.throw(_("No valid Loan Security Price found for {0}").format(frappe.bold(loan_security)))
else: else:
return loan_security_price return loan_security_price