Skip to content

Commit

Permalink
fix: handle-accounting-export (#394)
Browse files Browse the repository at this point in the history
* fix: handle-accounting-export

* fix comments

---------

Co-authored-by: GitHub Actions <[email protected]>
  • Loading branch information
ruuushhh and GitHub Actions authored Sep 30, 2024
1 parent 8327817 commit 3923796
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions apps/xero/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from typing import List

from dateutil.relativedelta import relativedelta
from django.utils import timezone as django_timezone

from django.db import transaction
from django.utils import timezone as django_timezone
from fyle_accounting_mappings.models import DestinationAttribute, ExpenseAttribute, Mapping
from fyle_integrations_platform_connector import PlatformConnector
from xerosdk.exceptions import UnsuccessfulAuthentication, WrongParamsError
Expand Down Expand Up @@ -300,7 +299,7 @@ def create_bill(
expense_group.response_logs = created_bill
expense_group.save()
resolve_errors_for_exported_expense_group(expense_group)
generate_export_url_and_update_expense(expense_group, 'BILL')

logger.info('Updated Expense Group %s successfully', expense_group.id)

# Assign billable expenses to customers
Expand All @@ -320,12 +319,17 @@ def create_bill(

attach_customer_to_export(xero_connection, task_log)

load_attachments(
xero_connection,
created_bill["Invoices"][0]["InvoiceID"],
"invoices",
expense_group,
)
try:
generate_export_url_and_update_expense(expense_group, 'BILL')
except Exception as e:
logger.error('Error while updating expenses for expense_group_id: %s and posting accounting export summary %s', expense_group.id, e)

load_attachments(
xero_connection,
created_bill["Invoices"][0]["InvoiceID"],
"invoices",
expense_group,
)


def get_linked_transaction_object(export_instance, line_items: list):
Expand Down Expand Up @@ -473,7 +477,7 @@ def create_bank_transaction(
expense_group.response_logs = created_bank_transaction
expense_group.save()
resolve_errors_for_exported_expense_group(expense_group)
generate_export_url_and_update_expense(expense_group, 'BANK TRANSACTION')

logger.info('Updated Expense Group %s successfully', expense_group.id)

# Assign billable expenses to customers
Expand All @@ -497,12 +501,17 @@ def create_bank_transaction(

attach_customer_to_export(xero_connection, task_log)

load_attachments(
xero_connection,
created_bank_transaction["BankTransactions"][0]["BankTransactionID"],
"banktransactions",
expense_group,
)
try:
generate_export_url_and_update_expense(expense_group, 'BANK TRANSACTION')
except Exception as e:
logger.error('Error while updating expenses for expense_group_id: %s and posting accounting export summary %s', expense_group.id, e)

load_attachments(
xero_connection,
created_bank_transaction["BankTransactions"][0]["BankTransactionID"],
"banktransactions",
expense_group,
)


def __validate_expense_group(expense_group: ExpenseGroup):
Expand Down

0 comments on commit 3923796

Please sign in to comment.