Skip to content

Commit

Permalink
fixed few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
anishfyle committed Jul 29, 2024
1 parent ee1bed4 commit bf2b465
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/qbd/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
def get_item_and_account_name(field_mapping: FieldMapping, expense: Expense):
item_type = field_mapping.item_type
expense_item = None
expense_category = expense.get('category')
expense_category = expense.category

if item_type.upper() in ['PROJECT', 'COST_CENTER']:
expense_item = expense.get(item_type.lower())
expense_item = getattr(field_mapping, item_type.lower())
else:
# Modify item_type to match the format in custom_properties
modified_item_type = item_type.replace('_', ' ').title()
expense_item = expense.get('custom_properties', {}).get(modified_item_type)
expense_item = getattr(expense, 'custom_properties', {}).get(modified_item_type)

if item_type and expense_item and expense_category:
item_mapped_account = QBDMapping.objects.filter(attribute_type=modified_item_type, source_value=expense_item).first()
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def add_field_mappings():
workspace_id=workspace_id,
class_type='COST_CENTER' if workspace_id in [1, 2] else 'PROJECT',
project_type='PROJECT' if workspace_id in [1, 2] else 'COST_CENTER',
item_type='ITEM_TYPE_1' if workspace_id == 1 else 'ITEM_TYPE_2' if workspace_id == 2 else 'ITEM_TYPE_3',
custom_fields=['custom_field_1', 'custom_field_2'] if workspace_id in [1, 2] else ['custom_field_3', 'custom_field_4'],
)


Expand Down

0 comments on commit bf2b465

Please sign in to comment.