Skip to content

Commit

Permalink
use .get method instead of Index brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 committed Apr 1, 2024
1 parent 5c17efc commit 1f32f8d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
14 changes: 8 additions & 6 deletions apps/sage300/dependent_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ 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)

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

return posted_cost_codes

Expand Down Expand Up @@ -127,11 +129,11 @@ def post_dependent_expense_field_values(workspace_id: int, dependent_field_setti
'workspace_id': workspace_id
}

if dependent_field_setting.last_successful_import_at:
filters['updated_at__gte'] = dependent_field_setting.last_successful_import_at
# if dependent_field_setting.last_successful_import_at:
# filters['updated_at__gte'] = dependent_field_setting.last_successful_import_at

posted_cost_types = post_dependent_cost_code(dependent_field_setting, platform, filters)

print('postted cost tyoes', posted_cost_types)
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

0 comments on commit 1f32f8d

Please sign in to comment.