Skip to content

Commit

Permalink
use get method instead of Index brackets (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 authored Apr 1, 2024
1 parent 7cb65ac commit c502c87
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 204 deletions.
12 changes: 8 additions & 4 deletions apps/sage300/dependent_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def post_dependent_cost_code(dependent_field_setting: DependentFieldSetting, pla

for project in projects:
payload = []
cost_code_names = []

for cost_code in project['cost_codes']:
if project['job_name'] in existing_projects_in_fyle:
payload.append({
Expand All @@ -93,9 +95,12 @@ def post_dependent_cost_code(dependent_field_setting: DependentFieldSetting, pla
'expense_field_value': cost_code,
'is_enabled': True
})
sleep(0.2)
platform.dependent_fields.bulk_post_dependent_expense_field_values(payload)
posted_cost_codes.append(cost_code)
cost_code_names.append(cost_code)

if payload:
sleep(0.2)
platform.dependent_fields.bulk_post_dependent_expense_field_values(payload)
posted_cost_codes.append(cost_code_names)

return posted_cost_codes

Expand Down Expand Up @@ -131,7 +136,6 @@ def post_dependent_expense_field_values(workspace_id: int, dependent_field_setti
filters['updated_at__gte'] = dependent_field_setting.last_successful_import_at

posted_cost_types = post_dependent_cost_code(dependent_field_setting, platform, filters)

if posted_cost_types:
filters['cost_code_name__in'] = posted_cost_types
post_dependent_cost_type(dependent_field_setting, platform, filters)
Expand Down
17 changes: 9 additions & 8 deletions apps/sage300/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ def _sync_data(self, data, attribute_type, display_name, workspace_id, field_nam
destination_attributes = []
for item in data:
detail = {field: getattr(item, field) for field in field_names}
destination_attributes.append(self._create_destination_attribute(
attribute_type,
display_name,
item.name,
item.id,
item.is_active,
detail
))
if item.name:
destination_attributes.append(self._create_destination_attribute(
attribute_type,
display_name,
item.name,
item.id,
item.is_active,
detail
))

DestinationAttribute.bulk_create_or_update_destination_attributes(
destination_attributes, attribute_type, workspace_id, True)
Expand Down
Loading

0 comments on commit c502c87

Please sign in to comment.