Skip to content

Commit

Permalink
Resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuushhh committed Feb 14, 2024
1 parent 82c6a2b commit d7fd491
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions apps/xero/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,22 @@
from typing import List

from django.db import transaction

from fyle_accounting_mappings.models import DestinationAttribute, ExpenseAttribute, Mapping

from fyle_integrations_platform_connector import PlatformConnector

from fyle_xero_api.exceptions import BulkError

from xerosdk.exceptions import UnsuccessfulAuthentication, WrongParamsError

from apps.fyle.models import Expense, ExpenseGroup, Reimbursement
from apps.fyle.actions import update_complete_expenses, update_expenses_in_progress
from apps.fyle.enums import FundSourceEnum, FyleAttributeEnum, PlatformExpensesEnum

from apps.fyle.models import Expense, ExpenseGroup, Reimbursement
from apps.fyle.tasks import post_accounting_export_summary
from apps.mappings.models import GeneralMapping, TenantMapping

from apps.tasks.enums import ErrorTypeEnum, TaskLogStatusEnum, TaskLogTypeEnum
from apps.tasks.models import Error, TaskLog
from apps.tasks.enums import TaskLogStatusEnum, TaskLogTypeEnum, ErrorTypeEnum

from apps.workspaces.models import FyleCredential, Workspace, WorkspaceGeneralSettings, XeroCredentials

from apps.xero.exceptions import handle_xero_exceptions
from apps.xero.models import BankTransaction, BankTransactionLineItem, Bill, BillLineItem, Payment
from apps.xero.utils import XeroConnector
from apps.fyle.actions import update_expenses_in_progress, update_complete_expenses
from apps.fyle.tasks import post_accounting_export_summary

from fyle_xero_api.exceptions import BulkError

logger = logging.getLogger(__name__)
logger.level = logging.INFO
Expand Down Expand Up @@ -841,14 +832,21 @@ def generate_export_url_and_update_expense(expense_group: ExpenseGroup, export_t
:param expense_group: Expense Group
:return: None
"""
workspace = Workspace.objects.get(id=expense_group.workspace_id)
try:
if export_type == 'BILL':
export_id = expense_group.response_logs['Invoices'][0]['InvoiceID']
url = f'https://go.xero.com/AccountsPayable/View.aspx?invoiceID={export_id}'
if workspace.xero_short_code:
url = f'https://go.xero.com/organisationlogin/default.aspx?shortcode={workspace.xero_short_code}&redirecturl=/AccountsPayable/Edit.aspx?InvoiceID={export_id}'
else:
url = f'https://go.xero.com/AccountsPayable/View.aspx?invoiceID={export_id}'
else:
export_id = expense_group.response_logs['BankTransactions'][0]['BankTransactionID']
account_id = expense_group.response_logs['BankTransactions'][0]['BankAccount.AccountID']
url = f'https://go.xero.com/Bank/ViewTransaction.aspx?bankTransactionID={export_id}&accountID={account_id}'
account_id = expense_group.response_logs['BankTransactions'][0]['BankAccount']['AccountID']
if workspace.xero_short_code:
url = f'https://go.xero.com/organisationlogin/default.aspx?shortcode={workspace.xero_short_code}&redirecturl=/Bank/ViewTransaction.aspx?bankTransactionID={export_id}'
else:
url = f'https://go.xero.com/Bank/ViewTransaction.aspx?bankTransactionID={export_id}&accountID={account_id}'
except Exception as error:
# Defaulting it to Intacct app url, worst case scenario if we're not able to parse it properly
url = 'https://go.xero.com'
Expand Down

0 comments on commit d7fd491

Please sign in to comment.