From 3cfdcee04f1ce94c846b0ba313d025d32b30a969 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 18 Nov 2024 15:36:36 +0530 Subject: [PATCH] fix: Get Tax Mapping --- apps/netsuite/models.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/netsuite/models.py b/apps/netsuite/models.py index b5c104a4..ca7d0123 100644 --- a/apps/netsuite/models.py +++ b/apps/netsuite/models.py @@ -115,12 +115,16 @@ def get_tax_group_mapping(lineitem: Expense = None, workspace_id: int = None): def get_tax_item_id_or_none(expense_group: ExpenseGroup, general_mapping: GeneralMapping, lineitem: Expense = None): tax_code = None - mapping = get_tax_group_mapping(lineitem, expense_group.workspace_id) + mapping_settings: MappingSetting = MappingSetting.objects.filter( + expense_group.workspace_id, destination_field='TAX_ITEM').first() + + if mapping_settings: + mapping = get_tax_group_mapping(lineitem, expense_group.workspace_id) - if mapping: - tax_code = mapping.destination.destination_id - else: - tax_code = general_mapping.default_tax_code_id + if mapping: + tax_code = mapping.destination.destination_id + else: + tax_code = general_mapping.default_tax_code_id return tax_code