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) { |
Deepesh Garg | 9945ccc | 2020-10-18 22:25:24 +0530 | [diff] [blame] | 6 | 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] | 7 | && frm.doc.docstatus > 0) { |
Deepesh Garg | d1d0a50 | 2020-02-26 10:44:24 +0530 | [diff] [blame] | 8 | |
| 9 | frm.add_custom_button(__("Accounting Ledger"), function() { |
| 10 | frappe.route_options = { |
| 11 | voucher_no: frm.doc.name, |
Deepesh Garg | 8a55ec1 | 2020-06-25 15:34:01 +0530 | [diff] [blame] | 12 | company: frm.doc.company, |
Deepesh Garg | 6d27adc | 2020-10-10 23:28:39 +0530 | [diff] [blame] | 13 | from_date: moment(frm.doc.posting_date).format('YYYY-MM-DD'), |
Deepesh Garg | 8a55ec1 | 2020-06-25 15:34:01 +0530 | [diff] [blame] | 14 | to_date: moment(frm.doc.modified).format('YYYY-MM-DD'), |
| 15 | show_cancelled_entries: frm.doc.docstatus === 2 |
Deepesh Garg | d1d0a50 | 2020-02-26 10:44:24 +0530 | [diff] [blame] | 16 | }; |
| 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 Menat | 4551d7d | 2021-08-19 13:41:10 +0530 | [diff] [blame] | 38 | }); |