Skip to content

Commit

Permalink
save tax item and tax group seperately in the destination attribute t…
Browse files Browse the repository at this point in the history
…able (#483)
  • Loading branch information
NileshPant1999 authored Feb 8, 2024
1 parent 524632e commit c16055d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/netsuite/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,8 @@ def sync_tax_items(self):
tax_items_generator = self.connection.tax_items.get_all_generator()
tax_groups_generator = self.connection.tax_groups.get_all_generator()

attributes = []
tax_item_attributes = []
tax_group_attributes = []

for tax_items in tax_items_generator:
for tax_item in tax_items:
Expand All @@ -888,7 +889,7 @@ def sync_tax_items(self):
value = self.get_tax_code_name(tax_item['itemId'], tax_item['taxType']['name'], tax_rate)

if tax_rate >= 0:
attributes.append({
tax_item_attributes.append({
'attribute_type': 'TAX_ITEM',
'display_name': 'Tax Item',
'value': value,
Expand All @@ -899,6 +900,9 @@ def sync_tax_items(self):
}
})

DestinationAttribute.bulk_create_or_update_destination_attributes(
tax_item_attributes, 'TAX_ITEM', self.workspace_id, True)

for tax_groups in tax_groups_generator:
for tax_group in tax_groups:
if not tax_group['isInactive'] and tax_group['itemId']:
Expand All @@ -911,7 +915,7 @@ def sync_tax_items(self):
tax_type = tax_group['taxType']['name'] if tax_group['taxType'] else None
value = self.get_tax_code_name(tax_group['itemId'], tax_type, tax_rate)
if tax_rate >= 0:
attributes.append({
tax_group_attributes.append({
'attribute_type': 'TAX_ITEM',
'display_name': 'Tax Item',
'value': value,
Expand All @@ -923,7 +927,7 @@ def sync_tax_items(self):
})

DestinationAttribute.bulk_create_or_update_destination_attributes(
attributes, 'TAX_ITEM', self.workspace_id, True)
tax_group_attributes, 'TAX_ITEM', self.workspace_id, True)

return []

Expand Down

0 comments on commit c16055d

Please sign in to comment.