From 75e9100a5389eacca8f51c4a7ebe268f641cf2b8 Mon Sep 17 00:00:00 2001 From: Subin Tom Date: Mon, 8 Nov 2021 09:49:11 +0530 Subject: [PATCH 1/5] fix: Fixed customer address variable, sales invoice item field currency issue (cherry picked from commit 904010ab645fdb16f09072c062269945f7747712) --- .../doctype/taxjar_settings/taxjar_settings.py | 4 ++-- erpnext/erpnext_integrations/taxjar_integration.py | 2 +- erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py index bfc5e6f98d..b9f24b65b3 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py @@ -80,9 +80,9 @@ def make_custom_fields(update=True): dict(fieldname='product_tax_category', fieldtype='Link', insert_after='description', options='Product Tax Category', label='Product Tax Category', fetch_from='item_code.product_tax_category'), dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', - label='Tax Collectable', read_only=1), + label='Tax Collectable', read_only=1, options='currency'), dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', - label='Taxable Amount', read_only=1) + label='Taxable Amount', read_only=1, options='currency') ], 'Item': [ dict(fieldname='product_tax_category', fieldtype='Link', insert_after='item_group', options='Product Tax Category', diff --git a/erpnext/erpnext_integrations/taxjar_integration.py b/erpnext/erpnext_integrations/taxjar_integration.py index 2a7243c243..39aac0c407 100644 --- a/erpnext/erpnext_integrations/taxjar_integration.py +++ b/erpnext/erpnext_integrations/taxjar_integration.py @@ -262,7 +262,7 @@ def get_shipping_address_details(doc): if doc.shipping_address_name: shipping_address = frappe.get_doc("Address", doc.shipping_address_name) elif doc.customer_address: - shipping_address = frappe.get_doc("Address", doc.customer_address_name) + shipping_address = frappe.get_doc("Address", doc.customer_address) else: shipping_address = get_company_address_details(doc) diff --git a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py index fba9e2c443..1625e4f17e 100644 --- a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py +++ b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py @@ -21,9 +21,9 @@ def execute(): dict(fieldname='product_tax_category', fieldtype='Link', insert_after='description', options='Product Tax Category', label='Product Tax Category', fetch_from='item_code.product_tax_category'), dict(fieldname='tax_collectable', fieldtype='Currency', insert_after='net_amount', - label='Tax Collectable', read_only=1), + label='Tax Collectable', read_only=1, options='currency'), dict(fieldname='taxable_amount', fieldtype='Currency', insert_after='tax_collectable', - label='Taxable Amount', read_only=1) + label='Taxable Amount', read_only=1, options='currency') ], 'Item': [ dict(fieldname='product_tax_category', fieldtype='Link', insert_after='item_group', options='Product Tax Category', From e51c4ba8a9c96dd28580a8a6e3fcffdb45c7bdb4 Mon Sep 17 00:00:00 2001 From: Subin Tom Date: Mon, 8 Nov 2021 15:16:20 +0530 Subject: [PATCH 2/5] fix: Added company field, filtered account heads (cherry picked from commit 902c03cd375c7b1b2f35cff4dfbc5f1ff3e4cd56) --- .../taxjar_settings/taxjar_settings.js | 17 ++++++++++++++ .../taxjar_settings/taxjar_settings.json | 22 ++++++++++++++----- .../taxjar_integration.py | 6 +++++ .../custom_fields_for_taxjar_integration.py | 4 ++++ 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js index d49598932f..a362ba1f0b 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js @@ -7,6 +7,23 @@ frappe.ui.form.on('TaxJar Settings', { frm.toggle_reqd("sandbox_api_key", frm.doc.is_sandbox); }, + on_load: (frm) => { + frm.set_query('shipping_account_head', function() { + return { + filters: { + 'company': frm.doc.current_company + } + }; + }); + frm.set_query('tax_account_head', function() { + return { + filters: { + 'company': frm.doc.current_company + } + }; + }); + }, + refresh: (frm) => { frm.add_custom_button(__('Update Nexus List'), function() { frm.call({ diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json index 2d17f2ed83..1fda8929e9 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json @@ -14,6 +14,8 @@ "cb_keys", "sandbox_api_key", "configuration", + "current_company", + "column_break_10", "tax_account_head", "configuration_cb", "shipping_account_head", @@ -67,10 +69,6 @@ "fieldtype": "Password", "label": "Sandbox API Key" }, - { - "fieldname": "configuration_cb", - "fieldtype": "Column Break" - }, { "default": "0", "depends_on": "taxjar_calculate_tax", @@ -104,11 +102,25 @@ "label": "Nexus", "options": "TaxJar Nexus", "read_only": 1 + }, + { + "fieldname": "current_company", + "fieldtype": "Link", + "label": "Company", + "options": "Company" + }, + { + "fieldname": "configuration_cb", + "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_10", + "fieldtype": "Column Break" } ], "issingle": 1, "links": [], - "modified": "2021-10-06 10:59:13.475442", + "modified": "2021-11-08 14:40:15.684224", "modified_by": "Administrator", "module": "ERPNext Integrations", "name": "TaxJar Settings", diff --git a/erpnext/erpnext_integrations/taxjar_integration.py b/erpnext/erpnext_integrations/taxjar_integration.py index 39aac0c407..794b281c55 100644 --- a/erpnext/erpnext_integrations/taxjar_integration.py +++ b/erpnext/erpnext_integrations/taxjar_integration.py @@ -19,6 +19,8 @@ SUPPORTED_STATE_CODES = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', ' 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'] +USA_COMPANIES = frappe.get_all('Company', filters = {'country': 'United States'}, fields=['name'], pluck='name') + def get_client(): @@ -158,6 +160,10 @@ def set_sales_tax(doc, method): if not TAXJAR_CALCULATE_TAX: return + taxjar_settings_company = frappe.db.get_single_value('TaxJar Settings','current_company') + if taxjar_settings_company not in USA_COMPANIES: + return + if not doc.items: return diff --git a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py index 1625e4f17e..775e4d8cd5 100644 --- a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py +++ b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py @@ -28,6 +28,10 @@ def execute(): 'Item': [ dict(fieldname='product_tax_category', fieldtype='Link', insert_after='item_group', options='Product Tax Category', label='Product Tax Category') + ], + 'TaxJar Settings': [ + dict(fieldname='current_company', fieldtype='Link', insert_after='configuration', options='Company', + label='Company') ] } create_custom_fields(custom_fields, update=True) From d2915c6bc7330eb245d398dc61bd1d63d13a3b48 Mon Sep 17 00:00:00 2001 From: Subin Tom Date: Mon, 8 Nov 2021 17:59:03 +0530 Subject: [PATCH 3/5] fix: fixed company field, updated patch (cherry picked from commit 7f2d304f32fdf580a354c1dbba58189cdd4f35f2) # Conflicts: # erpnext/patches.txt --- .../doctype/taxjar_settings/taxjar_settings.js | 4 ++-- .../doctype/taxjar_settings/taxjar_settings.json | 9 +-------- erpnext/erpnext_integrations/taxjar_integration.py | 6 ++---- erpnext/patches.txt | 4 ++++ .../v13_0/custom_fields_for_taxjar_integration.py | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js index a362ba1f0b..2925db82e3 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js @@ -11,14 +11,14 @@ frappe.ui.form.on('TaxJar Settings', { frm.set_query('shipping_account_head', function() { return { filters: { - 'company': frm.doc.current_company + 'company': frm.doc.company } }; }); frm.set_query('tax_account_head', function() { return { filters: { - 'company': frm.doc.current_company + 'company': frm.doc.company } }; }); diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json index 1fda8929e9..d9ae5b601c 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json @@ -14,7 +14,6 @@ "cb_keys", "sandbox_api_key", "configuration", - "current_company", "column_break_10", "tax_account_head", "configuration_cb", @@ -103,12 +102,6 @@ "options": "TaxJar Nexus", "read_only": 1 }, - { - "fieldname": "current_company", - "fieldtype": "Link", - "label": "Company", - "options": "Company" - }, { "fieldname": "configuration_cb", "fieldtype": "Column Break" @@ -120,7 +113,7 @@ ], "issingle": 1, "links": [], - "modified": "2021-11-08 14:40:15.684224", + "modified": "2021-11-08 17:57:17.323275", "modified_by": "Administrator", "module": "ERPNext Integrations", "name": "TaxJar Settings", diff --git a/erpnext/erpnext_integrations/taxjar_integration.py b/erpnext/erpnext_integrations/taxjar_integration.py index 794b281c55..1adc1ddb14 100644 --- a/erpnext/erpnext_integrations/taxjar_integration.py +++ b/erpnext/erpnext_integrations/taxjar_integration.py @@ -6,7 +6,7 @@ from frappe import _ from frappe.contacts.doctype.address.address import get_company_address from frappe.utils import cint, flt -from erpnext import get_default_company +from erpnext import get_default_company, get_region TAX_ACCOUNT_HEAD = frappe.db.get_single_value("TaxJar Settings", "tax_account_head") SHIP_ACCOUNT_HEAD = frappe.db.get_single_value("TaxJar Settings", "shipping_account_head") @@ -19,7 +19,6 @@ SUPPORTED_STATE_CODES = ['AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', ' 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'] -USA_COMPANIES = frappe.get_all('Company', filters = {'country': 'United States'}, fields=['name'], pluck='name') @@ -160,8 +159,7 @@ def set_sales_tax(doc, method): if not TAXJAR_CALCULATE_TAX: return - taxjar_settings_company = frappe.db.get_single_value('TaxJar Settings','current_company') - if taxjar_settings_company not in USA_COMPANIES: + if get_region(doc.company): return if not doc.items: diff --git a/erpnext/patches.txt b/erpnext/patches.txt index a60b851c5a..0dcd3b73a3 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -283,8 +283,12 @@ erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries erpnext.patches.v13_0.einvoicing_deprecation_warning execute:frappe.reload_doc("erpnext_integrations", "doctype", "TaxJar Settings") execute:frappe.reload_doc("erpnext_integrations", "doctype", "Product Tax Category") +<<<<<<< HEAD erpnext.patches.v13_0.custom_fields_for_taxjar_integration erpnext.patches.v14_0.delete_einvoicing_doctypes +======= +erpnext.patches.v13_0.custom_fields_for_taxjar_integration #08-11-2021 +>>>>>>> 7f2d304f32 (fix: fixed company field, updated patch) erpnext.patches.v13_0.set_operation_time_based_on_operating_cost erpnext.patches.v13_0.validate_options_for_data_field erpnext.patches.v13_0.create_gst_payment_entry_fields diff --git a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py index 775e4d8cd5..078c558d88 100644 --- a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py +++ b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py @@ -30,7 +30,7 @@ def execute(): label='Product Tax Category') ], 'TaxJar Settings': [ - dict(fieldname='current_company', fieldtype='Link', insert_after='configuration', options='Company', + dict(fieldname='company', fieldtype='Link', insert_after='configuration', options='Company', label='Company') ] } From 45fd819729a73be9e334194e64ad00e81b36dabc Mon Sep 17 00:00:00 2001 From: Subin Tom Date: Mon, 8 Nov 2021 18:03:44 +0530 Subject: [PATCH 4/5] fix: company condition fix, added company field (cherry picked from commit 7ad2717accea61883f98d418b4abed47ca3937a8) --- .../doctype/taxjar_settings/taxjar_settings.json | 9 ++++++++- erpnext/erpnext_integrations/taxjar_integration.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json index d9ae5b601c..23ccb7e4da 100644 --- a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json +++ b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.json @@ -14,6 +14,7 @@ "cb_keys", "sandbox_api_key", "configuration", + "company", "column_break_10", "tax_account_head", "configuration_cb", @@ -109,11 +110,17 @@ { "fieldname": "column_break_10", "fieldtype": "Column Break" + }, + { + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company" } ], "issingle": 1, "links": [], - "modified": "2021-11-08 17:57:17.323275", + "modified": "2021-11-08 18:02:29.232090", "modified_by": "Administrator", "module": "ERPNext Integrations", "name": "TaxJar Settings", diff --git a/erpnext/erpnext_integrations/taxjar_integration.py b/erpnext/erpnext_integrations/taxjar_integration.py index 1adc1ddb14..a4e21579e3 100644 --- a/erpnext/erpnext_integrations/taxjar_integration.py +++ b/erpnext/erpnext_integrations/taxjar_integration.py @@ -159,7 +159,7 @@ def set_sales_tax(doc, method): if not TAXJAR_CALCULATE_TAX: return - if get_region(doc.company): + if get_region(doc.company) != 'United States': return if not doc.items: From 94d70bca9ed8bfbaf28d70569970bd19cf4e23fe Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Mon, 8 Nov 2021 18:48:46 +0530 Subject: [PATCH 5/5] fix: Resolve conflicts --- erpnext/patches.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 0dcd3b73a3..1006e2180f 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -283,12 +283,8 @@ erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries erpnext.patches.v13_0.einvoicing_deprecation_warning execute:frappe.reload_doc("erpnext_integrations", "doctype", "TaxJar Settings") execute:frappe.reload_doc("erpnext_integrations", "doctype", "Product Tax Category") -<<<<<<< HEAD -erpnext.patches.v13_0.custom_fields_for_taxjar_integration erpnext.patches.v14_0.delete_einvoicing_doctypes -======= erpnext.patches.v13_0.custom_fields_for_taxjar_integration #08-11-2021 ->>>>>>> 7f2d304f32 (fix: fixed company field, updated patch) erpnext.patches.v13_0.set_operation_time_based_on_operating_cost erpnext.patches.v13_0.validate_options_for_data_field erpnext.patches.v13_0.create_gst_payment_entry_fields