blob: 247e30b84393c1ffd9eba128c645cae6c97daea0 [file] [log] [blame]
Deepesh Gargd1d0a502020-02-26 10:44:24 +05301// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
2// For license information, please see license.txt
3
4frappe.ui.form.on(cur_frm.doctype, {
5 refresh: function(frm) {
Deepesh Garg9945ccc2020-10-18 22:25:24 +05306 if (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual', 'Loan Write Off'].includes(frm.doc.doctype)
Deepesh Garg8a55ec12020-06-25 15:34:01 +05307 && frm.doc.docstatus > 0) {
Deepesh Gargd1d0a502020-02-26 10:44:24 +05308
9 frm.add_custom_button(__("Accounting Ledger"), function() {
10 frappe.route_options = {
11 voucher_no: frm.doc.name,
Deepesh Garg8a55ec12020-06-25 15:34:01 +053012 company: frm.doc.company,
Deepesh Garg6d27adc2020-10-10 23:28:39 +053013 from_date: moment(frm.doc.posting_date).format('YYYY-MM-DD'),
Deepesh Garg8a55ec12020-06-25 15:34:01 +053014 to_date: moment(frm.doc.modified).format('YYYY-MM-DD'),
15 show_cancelled_entries: frm.doc.docstatus === 2
Deepesh Gargd1d0a502020-02-26 10:44:24 +053016 };
17
18 frappe.set_route("query-report", "General Ledger");
19 },__("View"));
20 }
21 },
22 applicant: function(frm) {
23 if (!["Loan Application", "Loan"].includes(frm.doc.doctype)) {
24 return;
25 }
26
27 if (frm.doc.applicant) {
28 frappe.model.with_doc(frm.doc.applicant_type, frm.doc.applicant, function() {
29 var applicant = frappe.model.get_doc(frm.doc.applicant_type, frm.doc.applicant);
30 frm.set_value("applicant_name",
31 applicant.employee_name || applicant.member_name);
32 });
33 }
34 else {
35 frm.set_value("applicant_name", null);
36 }
37 }
Ankush Menat4551d7d2021-08-19 13:41:10 +053038});