mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 04:10:32 +00:00
feat: add bank balance column to account
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.table('accounts', (table) => {
|
||||
table.string('plaid_account_id');
|
||||
table.string('account_mask').nullable();
|
||||
table.decimal('bank_balance', 15, 5);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.table('cashflow_transactions', (table) => {
|
||||
table.string('plaid_transaction_id');
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function (knex) {};
|
||||
@@ -8,6 +8,8 @@ export interface IAccountDTO {
|
||||
accountType: string;
|
||||
parentAccountId?: number;
|
||||
active: boolean;
|
||||
bankBalance?: number;
|
||||
accountMask?: string;
|
||||
}
|
||||
|
||||
export interface IAccountCreateDTO extends IAccountDTO {
|
||||
@@ -34,6 +36,7 @@ export interface IAccount {
|
||||
type?: any[];
|
||||
accountNormal: string;
|
||||
accountParentType: string;
|
||||
bankBalance: string;
|
||||
}
|
||||
|
||||
export enum AccountNormal {
|
||||
@@ -155,10 +158,9 @@ export enum AccountAction {
|
||||
TransactionsLocking = 'TransactionsLocking',
|
||||
}
|
||||
|
||||
|
||||
export enum TaxRateAction {
|
||||
CREATE = 'Create',
|
||||
EDIT = 'Edit',
|
||||
DELETE = 'Delete',
|
||||
VIEW = 'View',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ export interface ICashflowCommandDTO {
|
||||
|
||||
publish: boolean;
|
||||
branchId?: number;
|
||||
plaidTransactionId?: string;
|
||||
}
|
||||
|
||||
export interface ICashflowNewCommandDTO extends ICashflowCommandDTO {
|
||||
|
||||
@@ -13,7 +13,7 @@ export class AccountTransformer extends Transformer {
|
||||
* @returns {Array}
|
||||
*/
|
||||
public includeAttributes = (): string[] => {
|
||||
return ['formattedAmount', 'flattenName'];
|
||||
return ['formattedAmount', 'flattenName', 'bankBalanceFormatted'];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -41,6 +41,17 @@ export class AccountTransformer extends Transformer {
|
||||
return formatNumber(account.amount, { currencyCode: account.currencyCode });
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the formatted bank balance.
|
||||
* @param {IAccount} account
|
||||
* @returns {string}
|
||||
*/
|
||||
protected bankBalanceFormatted = (account: IAccount): string => {
|
||||
return formatNumber(account.bankBalance, {
|
||||
currencyCode: account.currencyCode,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Transformes the accounts collection to flat or nested array.
|
||||
* @param {IAccount[]}
|
||||
|
||||
@@ -27,7 +27,7 @@ export class PlaidApplication {
|
||||
* @param {PlaidItemDTO} itemDTO
|
||||
* @returns
|
||||
*/
|
||||
public exchangeToken(tenantId: number, itemDTO: PlaidItemDTO) {
|
||||
public exchangeToken(tenantId: number, itemDTO: PlaidItemDTO): Promise<void> {
|
||||
return this.plaidItemService.item(tenantId, itemDTO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import * as R from 'ramda';
|
||||
import { IAccountCreateDTO, ICashflowNewCommandDTO } from '@/interfaces';
|
||||
import { PlaidAccount, PlaidTransaction } from './_types';
|
||||
import {
|
||||
IAccountCreateDTO,
|
||||
ICashflowNewCommandDTO,
|
||||
PlaidAccount,
|
||||
PlaidTransaction,
|
||||
} from '@/interfaces';
|
||||
|
||||
/**
|
||||
* Transformes the Plaid account to create cashflow account DTO.
|
||||
@@ -18,6 +22,8 @@ export const transformPlaidAccountToCreateAccount = (
|
||||
accountType: 'cash',
|
||||
active: true,
|
||||
plaidAccountId: plaidAccount.account_id,
|
||||
bankBalance: plaidAccount.balances.current,
|
||||
accountMask: plaidAccount.mask,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -48,6 +54,7 @@ export const transformPlaidTrxsToCashflowCreate = R.curry(
|
||||
|
||||
// transactionNumber: string;
|
||||
// referenceNo: string;
|
||||
plaidTransactionId: plaidTranasction.transaction_id,
|
||||
publish: true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export default class NewCashflowTransactionService {
|
||||
'cashflowAccountId',
|
||||
'creditAccountId',
|
||||
'branchId',
|
||||
'plaidAccountId'
|
||||
'plaidTransactionId',
|
||||
]);
|
||||
// Retreive the next invoice number.
|
||||
const autoNextNumber =
|
||||
@@ -125,7 +125,7 @@ export default class NewCashflowTransactionService {
|
||||
public newCashflowTransaction = async (
|
||||
tenantId: number,
|
||||
newTransactionDTO: ICashflowNewCommandDTO,
|
||||
userId?: number
|
||||
userId?: number
|
||||
): Promise<{ cashflowTransaction: ICashflowTransaction }> => {
|
||||
const { CashflowTransaction, Account } = this.tenancy.models(tenantId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user