blob: d9dd415296e657ff1528270915865f03590bd4a8 [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) {
6 if (!frappe.boot.active_domains.includes("Non Profit")) {
7 frm.set_df_property('applicant_type', 'options', ['Employee', 'Customer']);
8 frm.refresh_field('applicant_type');
9 }
10
11 if (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual'].includes(frm.doc.doctype)
Deepesh Garg4c726b22020-06-25 15:37:04 +053012 && frm.doc.docstatus > 0) {
Deepesh Gargd1d0a502020-02-26 10:44:24 +053013
14 frm.add_custom_button(__("Accounting Ledger"), function() {
15 frappe.route_options = {
16 voucher_no: frm.doc.name,
Deepesh Garg4c726b22020-06-25 15:37:04 +053017 company: frm.doc.company,
18 from_date: frm.doc.posting_date,
19 to_date: moment(frm.doc.modified).format('YYYY-MM-DD'),
20 show_cancelled_entries: frm.doc.docstatus === 2
Deepesh Gargd1d0a502020-02-26 10:44:24 +053021 };
22
23 frappe.set_route("query-report", "General Ledger");
24 },__("View"));
25 }
26 },
27 applicant: function(frm) {
28 if (!["Loan Application", "Loan"].includes(frm.doc.doctype)) {
29 return;
30 }
31
32 if (frm.doc.applicant) {
33 frappe.model.with_doc(frm.doc.applicant_type, frm.doc.applicant, function() {
34 var applicant = frappe.model.get_doc(frm.doc.applicant_type, frm.doc.applicant);
35 frm.set_value("applicant_name",
36 applicant.employee_name || applicant.member_name);
37 });
38 }
39 else {
40 frm.set_value("applicant_name", null);
41 }
42 }
43});