mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
feat(server): change the Plaid synced bank name.
This commit is contained in:
@@ -40,11 +40,14 @@ export class PlaidSyncDb {
|
||||
*/
|
||||
public async syncBankAccounts(
|
||||
tenantId: number,
|
||||
plaidAccounts: PlaidAccount[]
|
||||
plaidAccounts: PlaidAccount[],
|
||||
institution: any
|
||||
): Promise<void> {
|
||||
const accountCreateDTOs = R.map(transformPlaidAccountToCreateAccount)(
|
||||
plaidAccounts
|
||||
);
|
||||
const transformToPlaidAccounts =
|
||||
transformPlaidAccountToCreateAccount(institution);
|
||||
|
||||
const accountCreateDTOs = R.map(transformToPlaidAccounts)(plaidAccounts);
|
||||
|
||||
await bluebird.map(
|
||||
accountCreateDTOs,
|
||||
(createAccountDTO: any) =>
|
||||
@@ -162,4 +165,38 @@ export class PlaidSyncDb {
|
||||
|
||||
await PlaidItem.query().findOne({ plaidItemId }).patch({ lastCursor });
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the last feeds updated at of the given Plaid accounts ids.
|
||||
* @param {number} tenantId
|
||||
* @param {string[]} plaidAccountIds
|
||||
*/
|
||||
public async updateLastFeedsUpdatedAt(
|
||||
tenantId: number,
|
||||
plaidAccountIds: string[]
|
||||
) {
|
||||
const { Account } = this.tenancy.models(tenantId);
|
||||
|
||||
await Account.query().whereIn('plaid_account_id', plaidAccountIds).patch({
|
||||
lastFeedsUpdatedAt: new Date(),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the accounts feed active status of the given Plaid accounts ids.
|
||||
* @param {number} tenantId
|
||||
* @param {number[]} plaidAccountIds
|
||||
* @param {boolean} isFeedsActive
|
||||
*/
|
||||
public async updateAccountsFeedsActive(
|
||||
tenantId: number,
|
||||
plaidAccountIds: string[],
|
||||
isFeedsActive: boolean = true
|
||||
) {
|
||||
const { Account } = this.tenancy.models(tenantId);
|
||||
|
||||
await Account.query().whereIn('plaid_account_id', plaidAccountIds).patch({
|
||||
isFeedsActive,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user