blob: 88973e36b6abc01516b8774566108d9c4975391e [file] [log] [blame]
Deepesh Garg6e2c13f2019-12-10 15:55:05 +05301erpnext.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 Gargcebf8032020-09-01 16:15:28 +05309 supplier_address: function(frm) {
10 frm.trigger('get_tax_template');
11 },
Deepesh Garg6e2c13f2019-12-10 15:55:05 +053012 tax_category: function(frm) {
13 frm.trigger('get_tax_template');
14 },
Deepesh Garg96a5e4e2020-12-16 13:00:55 +053015 customer_address: function(frm) {
16 frm.trigger('get_tax_template');
17 },
Deepesh Garg6e2c13f2019-12-10 15:55:05 +053018 get_tax_template: function(frm) {
Marica0c818922020-08-05 16:47:41 +053019 if (!frm.doc.company) return;
20
Deepesh Garg6e2c13f2019-12-10 15:55:05 +053021 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 Gargc41f9f02022-05-20 15:33:03 +053025 'company_address': frm.doc.company_address,
Deepesh Garga7670852020-12-04 18:07:46 +053026 'supplier_address': frm.doc.supplier_address,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +053027 'customer': frm.doc.customer,
28 'supplier': frm.doc.supplier,
29 'supplier_gstin': frm.doc.supplier_gstin,
30 'company_gstin': frm.doc.company_gstin,
31 'tax_category': frm.doc.tax_category
32 };
33
34 frappe.call({
35 method: 'erpnext.regional.india.utils.get_regional_address_details',
36 args: {
37 party_details: JSON.stringify(party_details),
38 doctype: frm.doc.doctype,
pateljannat1d5d8632020-11-19 20:11:45 +053039 company: frm.doc.company
Deepesh Garg6e2c13f2019-12-10 15:55:05 +053040 },
Rushabh Mehta34fc5282020-12-16 09:43:57 +053041 debounce: 2000,
Deepesh Garg6e2c13f2019-12-10 15:55:05 +053042 callback: function(r) {
43 if(r.message) {
44 frm.set_value('taxes_and_charges', r.message.taxes_and_charges);
Deepesh Gargb4be2922021-01-28 13:09:56 +053045 frm.set_value('taxes', r.message.taxes);
pateljannat8c9b60e2020-11-18 12:51:13 +053046 frm.set_value('place_of_supply', r.message.place_of_supply);
Deepesh Garg6e2c13f2019-12-10 15:55:05 +053047 }
48 }
49 });
50 }
51 });
Deepesh Gargb4be2922021-01-28 13:09:56 +053052}