Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 1 | erpnext.setup_auto_gst_taxation = (doctype) => { |
| 2 | frappe.ui.form.on(doctype, { |
| 3 | company_address: function(frm) { |
| 4 | frm.trigger('get_tax_template'); |
| 5 | }, |
| 6 | shipping_address: function(frm) { |
| 7 | frm.trigger('get_tax_template'); |
| 8 | }, |
Deepesh Garg | cebf803 | 2020-09-01 16:15:28 +0530 | [diff] [blame] | 9 | supplier_address: function(frm) { |
| 10 | frm.trigger('get_tax_template'); |
| 11 | }, |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 12 | tax_category: function(frm) { |
| 13 | frm.trigger('get_tax_template'); |
| 14 | }, |
Deepesh Garg | 96a5e4e | 2020-12-16 13:00:55 +0530 | [diff] [blame] | 15 | customer_address: function(frm) { |
| 16 | frm.trigger('get_tax_template'); |
| 17 | }, |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 18 | get_tax_template: function(frm) { |
Marica | 0c81892 | 2020-08-05 16:47:41 +0530 | [diff] [blame] | 19 | if (!frm.doc.company) return; |
| 20 | |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 21 | let party_details = { |
| 22 | 'shipping_address': frm.doc.shipping_address || '', |
| 23 | 'shipping_address_name': frm.doc.shipping_address_name || '', |
| 24 | 'customer_address': frm.doc.customer_address || '', |
Deepesh Garg | a767085 | 2020-12-04 18:07:46 +0530 | [diff] [blame] | 25 | 'supplier_address': frm.doc.supplier_address, |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 26 | 'customer': frm.doc.customer, |
| 27 | 'supplier': frm.doc.supplier, |
| 28 | 'supplier_gstin': frm.doc.supplier_gstin, |
| 29 | 'company_gstin': frm.doc.company_gstin, |
| 30 | 'tax_category': frm.doc.tax_category |
| 31 | }; |
| 32 | |
| 33 | frappe.call({ |
| 34 | method: 'erpnext.regional.india.utils.get_regional_address_details', |
| 35 | args: { |
| 36 | party_details: JSON.stringify(party_details), |
| 37 | doctype: frm.doc.doctype, |
pateljannat | 1d5d863 | 2020-11-19 20:11:45 +0530 | [diff] [blame] | 38 | company: frm.doc.company |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 39 | }, |
| 40 | callback: function(r) { |
| 41 | if(r.message) { |
| 42 | frm.set_value('taxes_and_charges', r.message.taxes_and_charges); |
pateljannat | 8c9b60e | 2020-11-18 12:51:13 +0530 | [diff] [blame] | 43 | frm.set_value('place_of_supply', r.message.place_of_supply); |
Deepesh Garg | 15ff6a5 | 2020-02-18 12:28:41 +0530 | [diff] [blame] | 44 | } else if (frm.doc.is_internal_supplier || frm.doc.is_internal_customer) { |
| 45 | frm.set_value('taxes_and_charges', ''); |
| 46 | frm.set_value('taxes', []); |
Deepesh Garg | 6e2c13f | 2019-12-10 15:55:05 +0530 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | }); |
| 50 | } |
| 51 | }); |
| 52 | }; |
| 53 | |