fix: Renamed child table doctype, delete taxes for non nexus state

This commit is contained in:
Subin Tom 2021-09-17 00:10:41 +05:30
parent 11bd42467e
commit 5c18654113
5 changed files with 17 additions and 7 deletions

View File

@ -42,7 +42,7 @@
"modified": "2021-09-14 05:33:06.444710",
"modified_by": "Administrator",
"module": "ERPNext Integrations",
"name": "TaxJar Nexus List",
"name": "TaxJar Nexus",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",

View File

@ -5,5 +5,5 @@
from frappe.model.document import Document
class TaxJarNexusList(Document):
class TaxJarNexus(Document):
pass

View File

@ -100,13 +100,13 @@
"fieldname": "nexus",
"fieldtype": "Table",
"label": "Nexus",
"options": "TaxJar Nexus List",
"options": "TaxJar Nexus",
"read_only": 1
}
],
"issingle": 1,
"links": [],
"modified": "2021-09-14 01:41:55.871028",
"modified": "2021-09-16 08:54:48.444487",
"modified_by": "Administrator",
"module": "ERPNext Integrations",
"name": "TaxJar Settings",

View File

@ -4,7 +4,7 @@ import frappe
import taxjar
from frappe import _
from frappe.contacts.doctype.address.address import get_company_address
from frappe.utils import cint
from frappe.utils import cint, flt
from erpnext import get_default_company
@ -172,8 +172,7 @@ def set_sales_tax(doc, method):
return
# check if delivering within a nexus
if not frappe.db.get_value('TaxJar Nexus List', {'region_code': tax_dict["to_state"]})
return
check_for_nexus(doc, tax_dict)
tax_data = validate_tax_request(tax_dict)
if tax_data is not None:
@ -202,6 +201,17 @@ def set_sales_tax(doc, method):
doc.run_method("calculate_taxes_and_totals")
def check_for_nexus(doc, tax_dict):
if not frappe.db.get_value('TaxJar Nexus', {'region_code': tax_dict["to_state"]}):
for item in doc.get("items"):
item.tax_collectable = flt(0)
item.taxable_amount = flt(0)
for tax in doc.taxes:
if tax.account_head == TAX_ACCOUNT_HEAD:
doc.taxes.remove(tax)
return
def check_sales_tax_exemption(doc):
# if the party is exempt from sales tax, then set all tax account heads to zero
sales_tax_exempted = hasattr(doc, "exempt_from_sales_tax") and doc.exempt_from_sales_tax \