Skip to content

Commit

Permalink
Merge branch 'xero-export-log-002' into xero-mapping-003
Browse files Browse the repository at this point in the history
  • Loading branch information
anishfyle committed Mar 15, 2024
2 parents 91f3099 + 3a69aef commit a3b9b51
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion src/app/core/models/db/accounting-export.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,42 @@ export class AccountingExportModel {
return [`https://www-p02.intacct.com/ia/acct/ur.phtml?.r=${expenseGroup.response_logs?.url_id}`, expenseGroup.export_type];
}

static constructXeroExportUrlAndType(expenseGroup: ExpenseGroup): [string, string] {
let exportRedirection = '';
let exportType = '';
let exportId = null;
let accountId = null;
let xeroShortCode = '';

Check failure on line 222 in src/app/core/models/db/accounting-export.model.ts

View workflow job for this annotation

GitHub Actions / lint

'xeroShortCode' is never reassigned. Use 'const' instead
const xeroUrl = 'https://go.xero.com';
if ('Invoices' in expenseGroup.response_logs && expenseGroup.response_logs.Invoices) {
exportType = 'Bill';
exportId = expenseGroup.response_logs.Invoices[0].InvoiceID;
if (xeroShortCode) {
exportRedirection = `${xeroUrl}/organisationlogin/default.aspx?shortcode=${xeroShortCode}&redirecturl=/AccountsPayable/Edit.aspx?InvoiceID=${exportId}`;
} else {
exportRedirection = `${xeroUrl}/AccountsPayable/View.aspx?invoiceID=${exportId}`;
}
} else if ('BankTransactions' in expenseGroup.response_logs && expenseGroup.response_logs.BankTransactions) {
exportType = 'Bank Transaction';
exportId = expenseGroup.response_logs.BankTransactions[0].BankTransactionID;
accountId = expenseGroup.response_logs.BankTransactions[0].BankAccount.AccountID;
if (xeroShortCode) {
exportRedirection = `${xeroUrl}/organisationlogin/default.aspx?shortcode=${xeroShortCode}&redirecturl=/Bank/ViewTransaction.aspx?bankTransactionID=${exportId}`;
} else {
exportRedirection = `${xeroUrl}/Bank/ViewTransaction.aspx?bankTransactionID=${exportId}&accountID=${accountId}`;
}
}

return [exportRedirection, exportType];
}

static constructExportUrlAndType(appName: AppName, expenseGroup: ExpenseGroup): [string, string] {
if (appName === AppName.QBO) {
return this.constructQBOExportUrlAndType(expenseGroup);
} else if (appName === AppName.INTACCT) {
return this.constructIntacctExportUrlAndType(expenseGroup);
} else if (appName == AppName.XERO) {

Check failure on line 251 in src/app/core/models/db/accounting-export.model.ts

View workflow job for this annotation

GitHub Actions / lint

Expected '===' and instead saw '=='
return this.constructXeroExportUrlAndType(expenseGroup);
}

return ['', ''];
Expand All @@ -229,7 +260,7 @@ export class AccountingExportModel {
const referenceNumber = this.getFyleReferenceNumber(referenceType, expenseGroup.expenses[0]);

const [url, exportType] = this.constructExportUrlAndType(appName, expenseGroup);

console.log(appName, expenseGroup);

Check failure on line 263 in src/app/core/models/db/accounting-export.model.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
return {
exportedAt: expenseGroup.exported_at,
employee: [expenseGroup.expenses[0].employee_name, expenseGroup.description.employee_email],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class XeroCompleteExportLogComponent implements OnInit {
this.totalCount = accountingExportResponse.count;

const accountingExports: AccountingExportList[] = accountingExportResponse.results.map((accountingExport: ExpenseGroup) =>
AccountingExportModel.parseExpenseGroupAPIResponseToExportLog(accountingExport, this.org_id, AppName.QBO)
AccountingExportModel.parseExpenseGroupAPIResponseToExportLog(accountingExport, this.org_id, AppName.XERO)
);
this.filteredAccountingExports = accountingExports;
this.accountingExports = [...this.filteredAccountingExports];
Expand Down

0 comments on commit a3b9b51

Please sign in to comment.