blob: 3a47a88cbe7f90444650cedd2e46a605803d48fe [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)
12 && frm.doc.docstatus == 1) {
13
14 frm.add_custom_button(__("Accounting Ledger"), function() {
15 frappe.route_options = {
16 voucher_no: frm.doc.name,
17 company: frm.doc.company
18 };
19
20 frappe.set_route("query-report", "General Ledger");
21 },__("View"));
22 }
23 },
24 applicant: function(frm) {
25 if (!["Loan Application", "Loan"].includes(frm.doc.doctype)) {
26 return;
27 }
28
29 if (frm.doc.applicant) {
30 frappe.model.with_doc(frm.doc.applicant_type, frm.doc.applicant, function() {
31 var applicant = frappe.model.get_doc(frm.doc.applicant_type, frm.doc.applicant);
32 frm.set_value("applicant_name",
33 applicant.employee_name || applicant.member_name);
34 });
35 }
36 else {
37 frm.set_value("applicant_name", null);
38 }
39 }
40});