Deepesh Garg | d1d0a50 | 2020-02-26 10:44:24 +0530 | [diff] [blame] | 1 | // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors |
| 2 | // For license information, please see license.txt |
| 3 | |
| 4 | frappe.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 | |
Deepesh Garg | 9945ccc | 2020-10-18 22:25:24 +0530 | [diff] [blame] | 11 | if (['Loan Disbursement', 'Loan Repayment', 'Loan Interest Accrual', 'Loan Write Off'].includes(frm.doc.doctype) |
Deepesh Garg | 8a55ec1 | 2020-06-25 15:34:01 +0530 | [diff] [blame] | 12 | && frm.doc.docstatus > 0) { |
Deepesh Garg | d1d0a50 | 2020-02-26 10:44:24 +0530 | [diff] [blame] | 13 | |
| 14 | frm.add_custom_button(__("Accounting Ledger"), function() { |
| 15 | frappe.route_options = { |
| 16 | voucher_no: frm.doc.name, |
Deepesh Garg | 8a55ec1 | 2020-06-25 15:34:01 +0530 | [diff] [blame] | 17 | company: frm.doc.company, |
Deepesh Garg | 6d27adc | 2020-10-10 23:28:39 +0530 | [diff] [blame] | 18 | from_date: moment(frm.doc.posting_date).format('YYYY-MM-DD'), |
Deepesh Garg | 8a55ec1 | 2020-06-25 15:34:01 +0530 | [diff] [blame] | 19 | to_date: moment(frm.doc.modified).format('YYYY-MM-DD'), |
| 20 | show_cancelled_entries: frm.doc.docstatus === 2 |
Deepesh Garg | d1d0a50 | 2020-02-26 10:44:24 +0530 | [diff] [blame] | 21 | }; |
| 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 | }); |