fix: Added company field, filtered account heads
This commit is contained in:
@@ -7,6 +7,23 @@ frappe.ui.form.on('TaxJar Settings', {
|
|||||||
frm.toggle_reqd("sandbox_api_key", frm.doc.is_sandbox);
|
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) => {
|
refresh: (frm) => {
|
||||||
frm.add_custom_button(__('Update Nexus List'), function() {
|
frm.add_custom_button(__('Update Nexus List'), function() {
|
||||||
frm.call({
|
frm.call({
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
"cb_keys",
|
"cb_keys",
|
||||||
"sandbox_api_key",
|
"sandbox_api_key",
|
||||||
"configuration",
|
"configuration",
|
||||||
|
"current_company",
|
||||||
|
"column_break_10",
|
||||||
"tax_account_head",
|
"tax_account_head",
|
||||||
"configuration_cb",
|
"configuration_cb",
|
||||||
"shipping_account_head",
|
"shipping_account_head",
|
||||||
@@ -67,10 +69,6 @@
|
|||||||
"fieldtype": "Password",
|
"fieldtype": "Password",
|
||||||
"label": "Sandbox API Key"
|
"label": "Sandbox API Key"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "configuration_cb",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"depends_on": "taxjar_calculate_tax",
|
"depends_on": "taxjar_calculate_tax",
|
||||||
@@ -104,11 +102,25 @@
|
|||||||
"label": "Nexus",
|
"label": "Nexus",
|
||||||
"options": "TaxJar Nexus",
|
"options": "TaxJar Nexus",
|
||||||
"read_only": 1
|
"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,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-10-06 10:59:13.475442",
|
"modified": "2021-11-08 14:40:15.684224",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "ERPNext Integrations",
|
"module": "ERPNext Integrations",
|
||||||
"name": "TaxJar Settings",
|
"name": "TaxJar Settings",
|
||||||
|
|||||||
@@ -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',
|
'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',
|
'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD',
|
||||||
'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY']
|
'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():
|
def get_client():
|
||||||
@@ -158,6 +160,10 @@ def set_sales_tax(doc, method):
|
|||||||
if not TAXJAR_CALCULATE_TAX:
|
if not TAXJAR_CALCULATE_TAX:
|
||||||
return
|
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:
|
if not doc.items:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ def execute():
|
|||||||
'Item': [
|
'Item': [
|
||||||
dict(fieldname='product_tax_category', fieldtype='Link', insert_after='item_group', options='Product Tax Category',
|
dict(fieldname='product_tax_category', fieldtype='Link', insert_after='item_group', options='Product Tax Category',
|
||||||
label='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)
|
create_custom_fields(custom_fields, update=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user