fix: Button to close loan
This commit is contained in:
parent
51c6cf692e
commit
6d27adccfc
@ -21,6 +21,14 @@ frappe.ui.form.on('Loan', {
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("loan_type", function () {
|
||||
return {
|
||||
"filters": {
|
||||
"docstatus": 1
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
$.each(["penalty_income_account", "interest_income_account"], function(i, field) {
|
||||
frm.set_query(field, function () {
|
||||
return {
|
||||
@ -49,19 +57,21 @@ frappe.ui.form.on('Loan', {
|
||||
|
||||
refresh: function (frm) {
|
||||
if (frm.doc.docstatus == 1) {
|
||||
if (["Disbursed", "Partially Disbursed"].includes(frm.doc.status) && (!frm.doc.repay_from_salary)) {
|
||||
frm.add_custom_button(__('Request Loan Closure'), function() {
|
||||
frm.trigger("request_loan_closure");
|
||||
},__('Status'));
|
||||
frm.add_custom_button(__('Loan Repayment'), function() {
|
||||
frm.trigger("make_repayment_entry");
|
||||
},__('Create'));
|
||||
}
|
||||
|
||||
if (frm.doc.status == "Sanctioned" || frm.doc.status == 'Partially Disbursed') {
|
||||
frm.add_custom_button(__('Loan Disbursement'), function() {
|
||||
frm.trigger("make_loan_disbursement");
|
||||
},__('Create'));
|
||||
}
|
||||
|
||||
if (["Disbursed", "Partially Disbursed"].includes(frm.doc.status) && (!frm.doc.repay_from_salary)) {
|
||||
frm.add_custom_button(__('Loan Repayment'), function() {
|
||||
frm.trigger("make_repayment_entry");
|
||||
},__('Create'));
|
||||
|
||||
}
|
||||
|
||||
if (frm.doc.status == "Loan Closure Requested") {
|
||||
frm.add_custom_button(__('Loan Security Unpledge'), function() {
|
||||
frm.trigger("create_loan_security_unpledge");
|
||||
@ -117,6 +127,22 @@ frappe.ui.form.on('Loan', {
|
||||
})
|
||||
},
|
||||
|
||||
request_loan_closure: function(frm) {
|
||||
frappe.confirm(__("Do you really want to close this loan"),
|
||||
function() {
|
||||
frappe.call({
|
||||
args: {
|
||||
'loan': frm.doc.name
|
||||
},
|
||||
method: "erpnext.loan_management.doctype.loan.loan.request_loan_closure",
|
||||
callback: function() {
|
||||
frm.reload_doc();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
create_loan_security_unpledge: function(frm) {
|
||||
frappe.call({
|
||||
method: "erpnext.loan_management.doctype.loan.loan.unpledge_security",
|
||||
|
@ -15,7 +15,7 @@ frappe.ui.form.on(cur_frm.doctype, {
|
||||
frappe.route_options = {
|
||||
voucher_no: frm.doc.name,
|
||||
company: frm.doc.company,
|
||||
from_date: frm.doc.posting_date,
|
||||
from_date: moment(frm.doc.posting_date).format('YYYY-MM-DD'),
|
||||
to_date: moment(frm.doc.modified).format('YYYY-MM-DD'),
|
||||
show_cancelled_entries: frm.doc.docstatus === 2
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user