Skip to content

Commit

Permalink
Add example objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrishabh17 committed Jun 5, 2024
1 parent 505fabc commit e85f6b2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/sage300/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,22 @@ def disable_projects(workspace_id: int, projects_to_disable: Dict):
"""
Disable projects in Fyle when the projects are updated in Sage 300.
This is a callback function that is triggered from accounting_mappings.
projects_to_disable object format:
{
'destination_id': {
'value': 'old_project_name',
'updated_value': 'new_project_name'
}
}
"""
filters = {
'workspace_id': workspace_id,
'attribute_type': 'PROJECT',
'value__in': [projects_map['value'] for projects_map in projects_to_disable.values()]
}

# Expense attribute value map is as follows: {old_project_name: destination_id}
expense_attribute_value_map = {v['value']: k for k, v in projects_to_disable.items()}

expense_attributes = ExpenseAttribute.objects.filter(**filters)
Expand Down Expand Up @@ -125,8 +134,10 @@ def update_and_disable_cost_code(workspace_id: int, cost_codes_to_disable: Dict,
'workspace_id': workspace_id
}

# This call will disable the cost codes in Fyle that has old project name
post_dependent_cost_code(dependent_field_setting, platform, filters, is_enabled=False)

# here we are updating the CostCategory with the new project name
bulk_update_payload = []
for destination_id, value in cost_codes_to_disable.items():
cost_categories = CostCategory.objects.filter(
Expand Down

0 comments on commit e85f6b2

Please sign in to comment.