Merge pull request #28277 from frappe/mergify/bp/develop/pr-28262
fix: Taxjar customer_address fix, currency fix (backport #28262)
diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.js
index d495989..2925db8 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 @@
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.company
+ }
+ };
+ });
+ frm.set_query('tax_account_head', function() {
+ return {
+ filters: {
+ 'company': frm.doc.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 2d17f2e..23ccb7e 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",
+ "company",
+ "column_break_10",
"tax_account_head",
"configuration_cb",
"shipping_account_head",
@@ -68,10 +70,6 @@
"label": "Sandbox API Key"
},
{
- "fieldname": "configuration_cb",
- "fieldtype": "Column Break"
- },
- {
"default": "0",
"depends_on": "taxjar_calculate_tax",
"fieldname": "taxjar_create_transactions",
@@ -104,11 +102,25 @@
"label": "Nexus",
"options": "TaxJar Nexus",
"read_only": 1
+ },
+ {
+ "fieldname": "configuration_cb",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "column_break_10",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "label": "Company",
+ "options": "Company"
}
],
"issingle": 1,
"links": [],
- "modified": "2021-10-06 10:59:13.475442",
+ "modified": "2021-11-08 18:02:29.232090",
"modified_by": "Administrator",
"module": "ERPNext Integrations",
"name": "TaxJar Settings",
diff --git a/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py b/erpnext/erpnext_integrations/doctype/taxjar_settings/taxjar_settings.py
index bfc5e6f..b9f24b6 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 @@
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 2a7243c..a4e2157 100644
--- a/erpnext/erpnext_integrations/taxjar_integration.py
+++ b/erpnext/erpnext_integrations/taxjar_integration.py
@@ -6,7 +6,7 @@
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")
@@ -21,6 +21,7 @@
'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY']
+
def get_client():
taxjar_settings = frappe.get_single("TaxJar Settings")
@@ -158,6 +159,9 @@
if not TAXJAR_CALCULATE_TAX:
return
+ if get_region(doc.company) != 'United States':
+ return
+
if not doc.items:
return
@@ -262,7 +266,7 @@
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.txt b/erpnext/patches.txt
index a60b851..1006e21 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -283,8 +283,8 @@
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")
-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
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 fba9e2c..078c558 100644
--- a/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py
+++ b/erpnext/patches/v13_0/custom_fields_for_taxjar_integration.py
@@ -21,13 +21,17 @@
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',
label='Product Tax Category')
+ ],
+ 'TaxJar Settings': [
+ dict(fieldname='company', fieldtype='Link', insert_after='configuration', options='Company',
+ label='Company')
]
}
create_custom_fields(custom_fields, update=True)