Skip to content

Commit

Permalink
Add direct export loggers (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuushhh authored May 10, 2024
1 parent a5cee77 commit 9801581
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/fyle/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def import_and_export_expenses(report_id: str, org_id: str) -> None:
:param org_id: org id
:return: None
"""
logger.info('Import and export expenses report_id: %s, org_id: %s', report_id, org_id)
workspace = Workspace.objects.get(fyle_org_id=org_id)
fyle_credentials = FyleCredential.objects.get(workspace_id=workspace.id)
expense_group_settings = ExpenseGroupSettings.objects.get(workspace_id=workspace.id)
Expand Down Expand Up @@ -278,6 +279,7 @@ def import_and_export_expenses(report_id: str, org_id: str) -> None:
expense_group_ids = [expense_group['id'] for expense_group in expense_groups]

if len(expense_group_ids):
logger.info('Exporting to Netsuite(Direct Export Trigger) workspace_id: %s, expense_group_ids: %s', workspace.id, expense_group_ids)
export_to_netsuite(workspace.id, None, expense_group_ids)

except Configuration.DoesNotExist:
Expand Down
5 changes: 5 additions & 0 deletions apps/netsuite/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __create_chain_and_run(fyle_credentials: FyleCredential, in_progress_expense
chain.append('apps.fyle.helpers.sync_dimensions', fyle_credentials, True)

for task in chain_tasks:
logger.info('Chain task %s, Chain Expense Group %s, Chain Task Log %s', task['target'], task['expense_group'], task['task_log_id'])
chain.append(task['target'], task['expense_group'], task['task_log_id'], task['last_export'])

chain.append('apps.fyle.tasks.post_accounting_export_summary', fyle_credentials.workspace.fyle_org_id, workspace_id, fund_source)
Expand All @@ -43,6 +44,7 @@ def schedule_bills_creation(workspace_id: int, expense_group_ids: List[str], is_
:return: None
"""
if expense_group_ids:
logger.info('Preparing to queue expense groups %s of fund source %s for Bill', expense_group_ids, fund_source)
expense_groups = ExpenseGroup.objects.filter(
Q(tasklog__id__isnull=True) | ~Q(tasklog__status__in=['IN_PROGRESS', 'COMPLETE']),
workspace_id=workspace_id, id__in=expense_group_ids, bill__id__isnull=True, exported_at__isnull=True
Expand Down Expand Up @@ -92,6 +94,7 @@ def schedule_credit_card_charge_creation(workspace_id: int, expense_group_ids: L
:return: None
"""
if expense_group_ids:
logger.info('Preparing to queue expense groups %s of fund source %s for Credit Card Charge', expense_group_ids, fund_source)
expense_groups = ExpenseGroup.objects.filter(
Q(tasklog__id__isnull=True) | ~Q(tasklog__status__in=['IN_PROGRESS', 'COMPLETE']),
workspace_id=workspace_id, id__in=expense_group_ids,
Expand Down Expand Up @@ -148,6 +151,7 @@ def schedule_expense_reports_creation(workspace_id: int, expense_group_ids: List
:return: None
"""
if expense_group_ids:
logger.info('Preparing to queue expense groups %s of fund source %s for Expense Report', expense_group_ids, fund_source)
expense_groups = ExpenseGroup.objects.filter(
Q(tasklog__id__isnull=True) | ~Q(tasklog__status__in=['IN_PROGRESS', 'COMPLETE']),
workspace_id=workspace_id, id__in=expense_group_ids,
Expand Down Expand Up @@ -199,6 +203,7 @@ def schedule_journal_entry_creation(workspace_id: int, expense_group_ids: List[s
:return: None
"""
if expense_group_ids:
logger.info('Preparing to queue expense groups %s of fund source %s Journal Entry', expense_group_ids, fund_source)
expense_groups = ExpenseGroup.objects.filter(
Q(tasklog__id__isnull=True) | ~Q(tasklog__status__in=['IN_PROGRESS', 'COMPLETE']),
workspace_id=workspace_id, id__in=expense_group_ids, journalentry__id__isnull=True, exported_at__isnull=True
Expand Down

0 comments on commit 9801581

Please sign in to comment.