mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat(server): change the Plaid synced bank name.
This commit is contained in:
@@ -25,11 +25,19 @@ export class PlaidUpdateTransactions {
|
||||
const request = { access_token: accessToken };
|
||||
const plaidInstance = new PlaidClientWrapper();
|
||||
const {
|
||||
data: { accounts },
|
||||
data: { accounts, item },
|
||||
} = await plaidInstance.accountsGet(request);
|
||||
|
||||
const plaidAccountsIds = accounts.map((a) => a.account_id);
|
||||
|
||||
const {
|
||||
data: { institution },
|
||||
} = await plaidInstance.institutionsGetById({
|
||||
institution_id: item.institution_id,
|
||||
country_codes: ['US', 'UK'],
|
||||
});
|
||||
// Update the DB.
|
||||
await this.plaidSync.syncBankAccounts(tenantId, accounts);
|
||||
await this.plaidSync.syncBankAccounts(tenantId, accounts, institution);
|
||||
await this.plaidSync.syncAccountsTransactions(
|
||||
tenantId,
|
||||
added.concat(modified)
|
||||
@@ -37,6 +45,12 @@ export class PlaidUpdateTransactions {
|
||||
await this.plaidSync.syncRemoveTransactions(tenantId, removed);
|
||||
await this.plaidSync.syncTransactionsCursor(tenantId, plaidItemId, cursor);
|
||||
|
||||
// Update the last feeds updated at of the updated accounts.
|
||||
await this.plaidSync.updateLastFeedsUpdatedAt(tenantId, plaidAccountsIds);
|
||||
|
||||
// Turn on the accounts feeds flag.
|
||||
await this.plaidSync.updateAccountsFeedsActive(tenantId, plaidAccountsIds);
|
||||
|
||||
return {
|
||||
addedCount: added.length,
|
||||
modifiedCount: modified.length,
|
||||
|
||||
Reference in New Issue
Block a user