Skip to content

Commit

Permalink
Fixed the import_log related comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrishabh17 committed Jun 20, 2024
1 parent 1b0209b commit f384ba4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions apps/sage300/dependent_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def post_dependent_cost_code(import_log: ImportLog, dependent_field_setting: Dep
projects = CostCategory.objects.filter(**filters).values('job_name').annotate(cost_codes=ArrayAgg('cost_code_name', distinct=True))
projects_from_categories = [project['job_name'] for project in projects]
posted_cost_codes = []
total_batches = 0
processed_batches = 0
is_errored = False

Expand Down Expand Up @@ -104,17 +103,16 @@ def post_dependent_cost_code(import_log: ImportLog, dependent_field_setting: Dep
if payload:
sleep(0.2)
try:
total_batches += 1
platform.dependent_fields.bulk_post_dependent_expense_field_values(payload)
posted_cost_codes.extend(cost_code_names)
processed_batches += 1
except Exception as exception:
is_errored = True
logger.error(f'Exception while posting dependent cost code | Error: {exception} | Payload: {payload}')

import_log.status = 'COMPLETE'
import_log.status = 'PARTIALLY_FAILED' if is_errored else 'COMPLETE'
import_log.error_log = []
import_log.total_batches_count = total_batches
import_log.total_batches_count = len(existing_projects_in_fyle)
import_log.processed_batches_count = processed_batches
import_log.save()

Expand All @@ -125,7 +123,6 @@ def post_dependent_cost_code(import_log: ImportLog, dependent_field_setting: Dep
def post_dependent_cost_type(import_log: ImportLog, dependent_field_setting: DependentFieldSetting, platform: PlatformConnector, filters: Dict, posted_cost_codes: List = []):
cost_categories = CostCategory.objects.filter(is_imported=False, **filters).values('cost_code_name').annotate(cost_categories=ArrayAgg('name', distinct=True))
is_errored = False
total_batches = 0
processed_batches = 0

for category in cost_categories:
Expand All @@ -143,17 +140,16 @@ def post_dependent_cost_type(import_log: ImportLog, dependent_field_setting: Dep
if payload:
sleep(0.2)
try:
total_batches += 1
platform.dependent_fields.bulk_post_dependent_expense_field_values(payload)
CostCategory.objects.filter(cost_code_name=category['cost_code_name']).update(is_imported=True)
processed_batches += 1
except Exception as exception:
is_errored = True
logger.error(f'Exception while posting dependent cost type | Error: {exception} | Payload: {payload}')

import_log.status = 'COMPLETE'
import_log.status = 'PARTIALLY_FAILED' if is_errored else 'COMPLETE'
import_log.error_log = []
import_log.total_batches_count = total_batches
import_log.total_batches_count = len(cost_categories)
import_log.processed_batches_count = processed_batches
import_log.save()

Expand Down

0 comments on commit f384ba4

Please sign in to comment.