Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesis189 committed Sep 29, 2021
1 parent d3bb920 commit 254b20b
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def on_update(self):
frappe.enqueue('erpnext.regional.united_states.setup.add_product_tax_categories', now=False)

elif fields_already_exist and fields_hidden:
toggle_tax_category_fields('1')
toggle_tax_category_fields(hidden='1')

elif not TAXJAR_CREATE_TRANSACTIONS and not TAXJAR_CALCULATE_TAX and not TAXJAR_SANDBOX_MODE:
toggle_tax_category_fields('0')
else:
toggle_tax_category_fields(hidden='0')

@frappe.whitelist()
def update_nexus_list(self):
Expand All @@ -55,9 +55,9 @@ def update_nexus_list(self):
self.set('nexus', new_nexus_list)
self.save()

def toggle_tax_category_fields(toggle):
frappe.set_value('Custom Field',{'dt':'Sales Invoice Item', 'fieldname':'product_tax_category'},'hidden',toggle)
frappe.set_value('Custom Field',{'dt':'Item', 'fieldname':'product_tax_category'},'hidden',toggle)
def toggle_tax_category_fields(hidden):
frappe.set_value('Custom Field',{'dt':'Sales Invoice Item', 'fieldname':'product_tax_category'},'hidden',hidden)
frappe.set_value('Custom Field',{'dt':'Item', 'fieldname':'product_tax_category'},'hidden',hidden)


def add_product_tax_categories():
Expand All @@ -67,14 +67,12 @@ def add_product_tax_categories():

def create_tax_categories(data):
for d in data:
tax_category = frappe.new_doc('Product Tax Category')
tax_category.description = d.get("description")
tax_category.product_tax_code = d.get("product_tax_code")
tax_category.category_name = d.get("name")
try:
if not frappe.db.exists('Product Tax Category',{'product_tax_code':d.get('product_tax_code')}):
tax_category = frappe.new_doc('Product Tax Category')
tax_category.description = d.get("description")
tax_category.product_tax_code = d.get("product_tax_code")
tax_category.category_name = d.get("name")
tax_category.db_insert()
except frappe.DuplicateEntryError:
pass

def make_custom_fields(update=True):
custom_fields = {
Expand Down

0 comments on commit 254b20b

Please sign in to comment.