Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle-accounting-export #394

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading