mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
Compare commits
3 Commits
all-contri
...
v0.18.10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cd0405078 | ||
|
|
783102449f | ||
|
|
ae617b2e1d |
@@ -132,15 +132,6 @@
|
|||||||
"contributions": [
|
"contributions": [
|
||||||
"bug"
|
"bug"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"login": "oleynikd",
|
|
||||||
"name": "Denis",
|
|
||||||
"avatar_url": "https://avatars.githubusercontent.com/u/3976868?v=4",
|
|
||||||
"profile": "https://github.com/oleynikd",
|
|
||||||
"contributions": [
|
|
||||||
"bug"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 7,
|
"contributorsPerLine": 7,
|
||||||
|
|||||||
@@ -126,9 +126,6 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|||||||
<td align="center" valign="top" width="14.28%"><a href="http://vederis.id"><img src="https://avatars.githubusercontent.com/u/13505006?v=4?s=100" width="100px;" alt="Vederis Leunardus"/><br /><sub><b>Vederis Leunardus</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/commits?author=cloudsbird" title="Code">💻</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="http://vederis.id"><img src="https://avatars.githubusercontent.com/u/13505006?v=4?s=100" width="100px;" alt="Vederis Leunardus"/><br /><sub><b>Vederis Leunardus</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/commits?author=cloudsbird" title="Code">💻</a></td>
|
||||||
<td align="center" valign="top" width="14.28%"><a href="http://www.pivoten.com"><img src="https://avatars.githubusercontent.com/u/104120598?v=4?s=100" width="100px;" alt="Chris Cantrell"/><br /><sub><b>Chris Cantrell</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Accantrell72" title="Bug reports">🐛</a></td>
|
<td align="center" valign="top" width="14.28%"><a href="http://www.pivoten.com"><img src="https://avatars.githubusercontent.com/u/104120598?v=4?s=100" width="100px;" alt="Chris Cantrell"/><br /><sub><b>Chris Cantrell</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Accantrell72" title="Bug reports">🐛</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="14.28%"><a href="https://github.com/oleynikd"><img src="https://avatars.githubusercontent.com/u/3976868?v=4?s=100" width="100px;" alt="Denis"/><br /><sub><b>Denis</b></sub></a><br /><a href="https://github.com/bigcapitalhq/bigcapital/issues?q=author%3Aoleynikd" title="Bug reports">🐛</a></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,12 @@ import { NextFunction, Request, Response, Router } from 'express';
|
|||||||
import BaseController from '@/api/controllers/BaseController';
|
import BaseController from '@/api/controllers/BaseController';
|
||||||
import { CashflowApplication } from '@/services/Cashflow/CashflowApplication';
|
import { CashflowApplication } from '@/services/Cashflow/CashflowApplication';
|
||||||
import { GetBankAccountSummary } from '@/services/Banking/BankAccounts/GetBankAccountSummary';
|
import { GetBankAccountSummary } from '@/services/Banking/BankAccounts/GetBankAccountSummary';
|
||||||
import { BankAccountsApplication } from '@/services/Banking/BankAccounts/BankAccountsApplication';
|
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class BankAccountsController extends BaseController {
|
export class BankAccountsController extends BaseController {
|
||||||
@Inject()
|
@Inject()
|
||||||
private getBankAccountSummaryService: GetBankAccountSummary;
|
private getBankAccountSummaryService: GetBankAccountSummary;
|
||||||
|
|
||||||
@Inject()
|
|
||||||
private bankAccountsApp: BankAccountsApplication;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Router constructor.
|
* Router constructor.
|
||||||
*/
|
*/
|
||||||
@@ -20,11 +16,6 @@ export class BankAccountsController extends BaseController {
|
|||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.get('/:bankAccountId/meta', this.getBankAccountSummary.bind(this));
|
router.get('/:bankAccountId/meta', this.getBankAccountSummary.bind(this));
|
||||||
router.post(
|
|
||||||
'/:bankAccountId/disconnect',
|
|
||||||
this.disconnectBankAccount.bind(this)
|
|
||||||
);
|
|
||||||
router.post('/:bankAccountId/update', this.refreshBankAccount.bind(this));
|
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
@@ -55,58 +46,4 @@ export class BankAccountsController extends BaseController {
|
|||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Disonnect the given bank account.
|
|
||||||
* @param {Request} req
|
|
||||||
* @param {Response} res
|
|
||||||
* @param {NextFunction} next
|
|
||||||
* @returns {Promise<Response|null>}
|
|
||||||
*/
|
|
||||||
async disconnectBankAccount(
|
|
||||||
req: Request<{ bankAccountId: number }>,
|
|
||||||
res: Response,
|
|
||||||
next: NextFunction
|
|
||||||
) {
|
|
||||||
const { bankAccountId } = req.params;
|
|
||||||
const { tenantId } = req;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.bankAccountsApp.disconnectBankAccount(tenantId, bankAccountId);
|
|
||||||
|
|
||||||
return res.status(200).send({
|
|
||||||
id: bankAccountId,
|
|
||||||
message: 'The bank account has been disconnected.',
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
next(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh the given bank account.
|
|
||||||
* @param {Request} req
|
|
||||||
* @param {Response} res
|
|
||||||
* @param {NextFunction} next
|
|
||||||
* @returns {Promise<Response|null>}
|
|
||||||
*/
|
|
||||||
async refreshBankAccount(
|
|
||||||
req: Request<{ bankAccountId: number }>,
|
|
||||||
res: Response,
|
|
||||||
next: NextFunction
|
|
||||||
) {
|
|
||||||
const { bankAccountId } = req.params;
|
|
||||||
const { tenantId } = req;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.bankAccountsApp.refreshBankAccount(tenantId, bankAccountId);
|
|
||||||
|
|
||||||
return res.status(200).send({
|
|
||||||
id: bankAccountId,
|
|
||||||
message: 'The bank account has been disconnected.',
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
next(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { Inject, Service } from 'typedi';
|
import { Inject, Service } from 'typedi';
|
||||||
import { body, param, query } from 'express-validator';
|
import { param } from 'express-validator';
|
||||||
import { NextFunction, Request, Response, Router } from 'express';
|
import { NextFunction, Request, Response, Router, query } from 'express';
|
||||||
import BaseController from '../BaseController';
|
import BaseController from '../BaseController';
|
||||||
import { ExcludeBankTransactionsApplication } from '@/services/Banking/Exclude/ExcludeBankTransactionsApplication';
|
import { ExcludeBankTransactionsApplication } from '@/services/Banking/Exclude/ExcludeBankTransactionsApplication';
|
||||||
import { map, parseInt, trim } from 'lodash';
|
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class ExcludeBankTransactionsController extends BaseController {
|
export class ExcludeBankTransactionsController extends BaseController {
|
||||||
@@ -16,21 +15,9 @@ export class ExcludeBankTransactionsController extends BaseController {
|
|||||||
public router() {
|
public router() {
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.put(
|
|
||||||
'/transactions/exclude',
|
|
||||||
[body('ids').exists()],
|
|
||||||
this.validationResult,
|
|
||||||
this.excludeBulkBankTransactions.bind(this)
|
|
||||||
);
|
|
||||||
router.put(
|
|
||||||
'/transactions/unexclude',
|
|
||||||
[body('ids').exists()],
|
|
||||||
this.validationResult,
|
|
||||||
this.unexcludeBulkBankTransactins.bind(this)
|
|
||||||
);
|
|
||||||
router.put(
|
router.put(
|
||||||
'/transactions/:transactionId/exclude',
|
'/transactions/:transactionId/exclude',
|
||||||
[param('transactionId').exists().toInt()],
|
[param('transactionId').exists()],
|
||||||
this.validationResult,
|
this.validationResult,
|
||||||
this.excludeBankTransaction.bind(this)
|
this.excludeBankTransaction.bind(this)
|
||||||
);
|
);
|
||||||
@@ -107,63 +94,6 @@ export class ExcludeBankTransactionsController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Exclude bank transactions in bulk.
|
|
||||||
* @param {Request} req
|
|
||||||
* @param {Response} res
|
|
||||||
* @param {NextFunction} next
|
|
||||||
*/
|
|
||||||
private async excludeBulkBankTransactions(
|
|
||||||
req: Request,
|
|
||||||
res: Response,
|
|
||||||
next: NextFunction
|
|
||||||
) {
|
|
||||||
const { tenantId } = req;
|
|
||||||
const { ids } = this.matchedBodyData(req);
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.excludeBankTransactionApp.excludeBankTransactions(
|
|
||||||
tenantId,
|
|
||||||
ids
|
|
||||||
);
|
|
||||||
return res.status(200).send({
|
|
||||||
message: 'The given bank transactions have been excluded',
|
|
||||||
ids,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
next(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unexclude the given bank transactions in bulk.
|
|
||||||
* @param {Request} req
|
|
||||||
* @param {Response} res
|
|
||||||
* @param {NextFunction} next
|
|
||||||
* @returns {Promise<Response | null>}
|
|
||||||
*/
|
|
||||||
private async unexcludeBulkBankTransactins(
|
|
||||||
req: Request,
|
|
||||||
res: Response,
|
|
||||||
next: NextFunction
|
|
||||||
): Promise<Response | null> {
|
|
||||||
const { tenantId } = req;
|
|
||||||
const { ids } = this.matchedBodyData(req);
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.excludeBankTransactionApp.unexcludeBankTransactions(
|
|
||||||
tenantId,
|
|
||||||
ids
|
|
||||||
);
|
|
||||||
return res.status(200).send({
|
|
||||||
message: 'The given bank transactions have been excluded',
|
|
||||||
ids,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
next(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the excluded uncategorized bank transactions.
|
* Retrieves the excluded uncategorized bank transactions.
|
||||||
* @param {Request} req
|
* @param {Request} req
|
||||||
@@ -179,6 +109,7 @@ export class ExcludeBankTransactionsController extends BaseController {
|
|||||||
const { tenantId } = req;
|
const { tenantId } = req;
|
||||||
const filter = this.matchedBodyData(req);
|
const filter = this.matchedBodyData(req);
|
||||||
|
|
||||||
|
console.log('123');
|
||||||
try {
|
try {
|
||||||
const data =
|
const data =
|
||||||
await this.excludeBankTransactionApp.getExcludedBankTransactions(
|
await this.excludeBankTransactionApp.getExcludedBankTransactions(
|
||||||
|
|||||||
@@ -236,10 +236,6 @@ module.exports = {
|
|||||||
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
||||||
endpoint: process.env.S3_ENDPOINT,
|
endpoint: process.env.S3_ENDPOINT,
|
||||||
bucket: process.env.S3_BUCKET || 'bigcapital-documents',
|
bucket: process.env.S3_BUCKET || 'bigcapital-documents',
|
||||||
forcePathStyle: parseBoolean(
|
|
||||||
defaultTo(process.env.S3_FORCE_PATH_STYLE, false),
|
|
||||||
false
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
loops: {
|
loops: {
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
exports.up = function (knex) {
|
|
||||||
return knex.schema.table('accounts', (table) => {
|
|
||||||
table.string('plaid_item_id').nullable();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.down = function (knex) {
|
|
||||||
return knex.schema.table('accounts', (table) => {
|
|
||||||
table.dropColumn('plaid_item_id');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
exports.up = function (knex) {
|
|
||||||
return knex.schema
|
|
||||||
.table('accounts', (table) => {
|
|
||||||
table
|
|
||||||
.boolean('is_syncing_owner')
|
|
||||||
.defaultTo(false)
|
|
||||||
.after('is_feeds_active');
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
return knex('accounts')
|
|
||||||
.whereNotNull('plaid_item_id')
|
|
||||||
.orWhereNotNull('plaid_account_id')
|
|
||||||
.update('is_syncing_owner', true);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.down = function (knex) {
|
|
||||||
table.dropColumn('is_syncing_owner');
|
|
||||||
};
|
|
||||||
@@ -15,7 +15,6 @@ export interface IAccountDTO {
|
|||||||
export interface IAccountCreateDTO extends IAccountDTO {
|
export interface IAccountCreateDTO extends IAccountDTO {
|
||||||
currencyCode?: string;
|
currencyCode?: string;
|
||||||
plaidAccountId?: string;
|
plaidAccountId?: string;
|
||||||
plaidItemId?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IAccountEditDTO extends IAccountDTO {}
|
export interface IAccountEditDTO extends IAccountDTO {}
|
||||||
@@ -38,8 +37,6 @@ export interface IAccount {
|
|||||||
accountNormal: string;
|
accountNormal: string;
|
||||||
accountParentType: string;
|
accountParentType: string;
|
||||||
bankBalance: string;
|
bankBalance: string;
|
||||||
plaidItemId: number | null
|
|
||||||
lastFeedsUpdatedAt: Date;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AccountNormal {
|
export enum AccountNormal {
|
||||||
|
|||||||
@@ -1,12 +1,69 @@
|
|||||||
|
import { forEach } from 'lodash';
|
||||||
import { Configuration, PlaidApi, PlaidEnvironments } from 'plaid';
|
import { Configuration, PlaidApi, PlaidEnvironments } from 'plaid';
|
||||||
|
import { createPlaidApiEvent } from './PlaidApiEventsDBSync';
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
|
|
||||||
|
const OPTIONS = { clientApp: 'Plaid-Pattern' };
|
||||||
|
|
||||||
|
// We want to log requests to / responses from the Plaid API (via the Plaid client), as this data
|
||||||
|
// can be useful for troubleshooting.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logging function for Plaid client methods that use an access_token as an argument. Associates
|
||||||
|
* the Plaid API event log entry with the item and user the request is for.
|
||||||
|
*
|
||||||
|
* @param {string} clientMethod the name of the Plaid client method called.
|
||||||
|
* @param {Array} clientMethodArgs the arguments passed to the Plaid client method.
|
||||||
|
* @param {Object} response the response from the Plaid client.
|
||||||
|
*/
|
||||||
|
const defaultLogger = async (clientMethod, clientMethodArgs, response) => {
|
||||||
|
const accessToken = clientMethodArgs[0].access_token;
|
||||||
|
// const { id: itemId, user_id: userId } = await retrieveItemByPlaidAccessToken(
|
||||||
|
// accessToken
|
||||||
|
// );
|
||||||
|
// await createPlaidApiEvent(1, 1, clientMethod, clientMethodArgs, response);
|
||||||
|
|
||||||
|
// console.log(response);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logging function for Plaid client methods that do not use access_token as an argument. These
|
||||||
|
* Plaid API event log entries will not be associated with an item or user.
|
||||||
|
*
|
||||||
|
* @param {string} clientMethod the name of the Plaid client method called.
|
||||||
|
* @param {Array} clientMethodArgs the arguments passed to the Plaid client method.
|
||||||
|
* @param {Object} response the response from the Plaid client.
|
||||||
|
*/
|
||||||
|
const noAccessTokenLogger = async (
|
||||||
|
clientMethod,
|
||||||
|
clientMethodArgs,
|
||||||
|
response
|
||||||
|
) => {
|
||||||
|
// console.log(response);
|
||||||
|
|
||||||
|
// await createPlaidApiEvent(
|
||||||
|
// undefined,
|
||||||
|
// undefined,
|
||||||
|
// clientMethod,
|
||||||
|
// clientMethodArgs,
|
||||||
|
// response
|
||||||
|
// );
|
||||||
|
};
|
||||||
|
|
||||||
|
// Plaid client methods used in this app, mapped to their appropriate logging functions.
|
||||||
|
const clientMethodLoggingFns = {
|
||||||
|
accountsGet: defaultLogger,
|
||||||
|
institutionsGet: noAccessTokenLogger,
|
||||||
|
institutionsGetById: noAccessTokenLogger,
|
||||||
|
itemPublicTokenExchange: noAccessTokenLogger,
|
||||||
|
itemRemove: defaultLogger,
|
||||||
|
linkTokenCreate: noAccessTokenLogger,
|
||||||
|
transactionsSync: defaultLogger,
|
||||||
|
sandboxItemResetLogin: defaultLogger,
|
||||||
|
};
|
||||||
// Wrapper for the Plaid client. This allows us to easily log data for all Plaid client requests.
|
// Wrapper for the Plaid client. This allows us to easily log data for all Plaid client requests.
|
||||||
export class PlaidClientWrapper {
|
export class PlaidClientWrapper {
|
||||||
private static instance: PlaidClientWrapper;
|
constructor() {
|
||||||
private client: PlaidApi;
|
|
||||||
|
|
||||||
private constructor() {
|
|
||||||
// Initialize the Plaid client.
|
// Initialize the Plaid client.
|
||||||
const configuration = new Configuration({
|
const configuration = new Configuration({
|
||||||
basePath: PlaidEnvironments[config.plaid.env],
|
basePath: PlaidEnvironments[config.plaid.env],
|
||||||
@@ -18,13 +75,26 @@ export class PlaidClientWrapper {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
this.client = new PlaidApi(configuration);
|
this.client = new PlaidApi(configuration);
|
||||||
|
|
||||||
|
// Wrap the Plaid client methods to add a logging function.
|
||||||
|
forEach(clientMethodLoggingFns, (logFn, method) => {
|
||||||
|
this[method] = this.createWrappedClientMethod(method, logFn);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getClient(): PlaidApi {
|
// Allows us to log API request data for troubleshooting purposes.
|
||||||
if (!PlaidClientWrapper.instance) {
|
createWrappedClientMethod(clientMethod, log) {
|
||||||
PlaidClientWrapper.instance = new PlaidClientWrapper();
|
return async (...args) => {
|
||||||
}
|
try {
|
||||||
return PlaidClientWrapper.instance.client;
|
const res = await this.client[clientMethod](...args);
|
||||||
|
await log(clientMethod, args, res);
|
||||||
|
return res;
|
||||||
|
} catch (err) {
|
||||||
|
await log(clientMethod, args, err?.response?.data);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,5 +8,4 @@ export const s3 = new S3Client({
|
|||||||
secretAccessKey: config.s3.secretAccessKey,
|
secretAccessKey: config.s3.secretAccessKey,
|
||||||
},
|
},
|
||||||
endpoint: config.s3.endpoint,
|
endpoint: config.s3.endpoint,
|
||||||
forcePathStyle: config.s3.forcePathStyle,
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ import { UnlinkBankRuleOnDeleteBankRule } from '@/services/Banking/Rules/events/
|
|||||||
import { DecrementUncategorizedTransactionOnMatching } from '@/services/Banking/Matching/events/DecrementUncategorizedTransactionsOnMatch';
|
import { DecrementUncategorizedTransactionOnMatching } from '@/services/Banking/Matching/events/DecrementUncategorizedTransactionsOnMatch';
|
||||||
import { DecrementUncategorizedTransactionOnExclude } from '@/services/Banking/Exclude/events/DecrementUncategorizedTransactionOnExclude';
|
import { DecrementUncategorizedTransactionOnExclude } from '@/services/Banking/Exclude/events/DecrementUncategorizedTransactionOnExclude';
|
||||||
import { DecrementUncategorizedTransactionOnCategorize } from '@/services/Cashflow/subscribers/DecrementUncategorizedTransactionOnCategorize';
|
import { DecrementUncategorizedTransactionOnCategorize } from '@/services/Cashflow/subscribers/DecrementUncategorizedTransactionOnCategorize';
|
||||||
import { DisconnectPlaidItemOnAccountDeleted } from '@/services/Banking/BankAccounts/events/DisconnectPlaidItemOnAccountDeleted';
|
|
||||||
import { LoopsEventsSubscriber } from '@/services/Loops/LoopsEventsSubscriber';
|
import { LoopsEventsSubscriber } from '@/services/Loops/LoopsEventsSubscriber';
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
@@ -276,7 +275,6 @@ export const susbcribers = () => {
|
|||||||
|
|
||||||
// Plaid
|
// Plaid
|
||||||
RecognizeSyncedBankTranasctions,
|
RecognizeSyncedBankTranasctions,
|
||||||
DisconnectPlaidItemOnAccountDeleted,
|
|
||||||
|
|
||||||
// Loops
|
// Loops
|
||||||
LoopsEventsSubscriber
|
LoopsEventsSubscriber
|
||||||
|
|||||||
@@ -197,7 +197,6 @@ export default class Account extends mixin(TenantModel, [
|
|||||||
const ExpenseEntry = require('models/ExpenseCategory');
|
const ExpenseEntry = require('models/ExpenseCategory');
|
||||||
const ItemEntry = require('models/ItemEntry');
|
const ItemEntry = require('models/ItemEntry');
|
||||||
const UncategorizedTransaction = require('models/UncategorizedCashflowTransaction');
|
const UncategorizedTransaction = require('models/UncategorizedCashflowTransaction');
|
||||||
const PlaidItem = require('models/PlaidItem');
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
@@ -322,18 +321,6 @@ export default class Account extends mixin(TenantModel, [
|
|||||||
query.where('categorized', false);
|
query.where('categorized', false);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Account model may belongs to a Plaid item.
|
|
||||||
*/
|
|
||||||
plaidItem: {
|
|
||||||
relation: Model.BelongsToOneRelation,
|
|
||||||
modelClass: PlaidItem.default,
|
|
||||||
join: {
|
|
||||||
from: 'accounts.plaidItemId',
|
|
||||||
to: 'plaid_items.plaidItemId',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,7 @@ export class AccountTransformer extends Transformer {
|
|||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
public includeAttributes = (): string[] => {
|
public includeAttributes = (): string[] => {
|
||||||
return [
|
return ['formattedAmount', 'flattenName', 'bankBalanceFormatted'];
|
||||||
'formattedAmount',
|
|
||||||
'flattenName',
|
|
||||||
'bankBalanceFormatted',
|
|
||||||
'lastFeedsUpdatedAtFormatted',
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,15 +52,6 @@ export class AccountTransformer extends Transformer {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the formatted last feeds update at.
|
|
||||||
* @param {IAccount} account
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
protected lastFeedsUpdatedAtFormatted = (account: IAccount): string => {
|
|
||||||
return this.formatDate(account.lastFeedsUpdatedAt);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transformes the accounts collection to flat or nested array.
|
* Transformes the accounts collection to flat or nested array.
|
||||||
* @param {IAccount[]}
|
* @param {IAccount[]}
|
||||||
|
|||||||
@@ -96,11 +96,6 @@ export class CreateAccount {
|
|||||||
...createAccountDTO,
|
...createAccountDTO,
|
||||||
slug: kebabCase(createAccountDTO.name),
|
slug: kebabCase(createAccountDTO.name),
|
||||||
currencyCode: createAccountDTO.currencyCode || baseCurrency,
|
currencyCode: createAccountDTO.currencyCode || baseCurrency,
|
||||||
|
|
||||||
// Mark the account is Plaid owner since Plaid item/account is defined on creating.
|
|
||||||
isSyncingOwner: Boolean(
|
|
||||||
createAccountDTO.plaidAccountId || createAccountDTO.plaidItemId
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -122,7 +117,12 @@ export class CreateAccount {
|
|||||||
const tenantMeta = await TenantMetadata.query().findOne({ tenantId });
|
const tenantMeta = await TenantMetadata.query().findOne({ tenantId });
|
||||||
|
|
||||||
// Authorize the account creation.
|
// Authorize the account creation.
|
||||||
await this.authorize(tenantId, accountDTO, tenantMeta.baseCurrency, params);
|
await this.authorize(
|
||||||
|
tenantId,
|
||||||
|
accountDTO,
|
||||||
|
tenantMeta.baseCurrency,
|
||||||
|
params
|
||||||
|
);
|
||||||
// Transformes the DTO to model.
|
// Transformes the DTO to model.
|
||||||
const accountInputModel = this.transformDTOToModel(
|
const accountInputModel = this.transformDTOToModel(
|
||||||
accountDTO,
|
accountDTO,
|
||||||
@@ -157,3 +157,4 @@ export class CreateAccount {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import { Inject, Service } from 'typedi';
|
|
||||||
import { DisconnectBankAccount } from './DisconnectBankAccount';
|
|
||||||
import { RefreshBankAccountService } from './RefreshBankAccount';
|
|
||||||
|
|
||||||
@Service()
|
|
||||||
export class BankAccountsApplication {
|
|
||||||
@Inject()
|
|
||||||
private disconnectBankAccountService: DisconnectBankAccount;
|
|
||||||
|
|
||||||
@Inject()
|
|
||||||
private refreshBankAccountService: RefreshBankAccountService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnects the given bank account.
|
|
||||||
* @param {number} tenantId
|
|
||||||
* @param {number} bankAccountId
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
async disconnectBankAccount(tenantId: number, bankAccountId: number) {
|
|
||||||
return this.disconnectBankAccountService.disconnectBankAccount(
|
|
||||||
tenantId,
|
|
||||||
bankAccountId
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh the bank transactions of the given bank account.
|
|
||||||
* @param {number} tenantId
|
|
||||||
* @param {number} bankAccountId
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
async refreshBankAccount(tenantId: number, bankAccountId: number) {
|
|
||||||
return this.refreshBankAccountService.refreshBankAccount(
|
|
||||||
tenantId,
|
|
||||||
bankAccountId
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
import { Inject, Service } from 'typedi';
|
|
||||||
import { ServiceError } from '@/exceptions';
|
|
||||||
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
|
|
||||||
import { PlaidClientWrapper } from '@/lib/Plaid';
|
|
||||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
|
||||||
import UnitOfWork from '@/services/UnitOfWork';
|
|
||||||
import events from '@/subscribers/events';
|
|
||||||
import {
|
|
||||||
ERRORS,
|
|
||||||
IBankAccountDisconnectedEventPayload,
|
|
||||||
IBankAccountDisconnectingEventPayload,
|
|
||||||
} from './types';
|
|
||||||
import { ACCOUNT_TYPE } from '@/data/AccountTypes';
|
|
||||||
|
|
||||||
@Service()
|
|
||||||
export class DisconnectBankAccount {
|
|
||||||
@Inject()
|
|
||||||
private tenancy: HasTenancyService;
|
|
||||||
|
|
||||||
@Inject()
|
|
||||||
private eventPublisher: EventPublisher;
|
|
||||||
|
|
||||||
@Inject()
|
|
||||||
private uow: UnitOfWork;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnects the given bank account.
|
|
||||||
* @param {number} tenantId
|
|
||||||
* @param {number} bankAccountId
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
public async disconnectBankAccount(tenantId: number, bankAccountId: number) {
|
|
||||||
const { Account, PlaidItem } = this.tenancy.models(tenantId);
|
|
||||||
|
|
||||||
// Retrieve the bank account or throw not found error.
|
|
||||||
const account = await Account.query()
|
|
||||||
.findById(bankAccountId)
|
|
||||||
.whereIn('account_type', [ACCOUNT_TYPE.CASH, ACCOUNT_TYPE.BANK])
|
|
||||||
.withGraphFetched('plaidItem')
|
|
||||||
.throwIfNotFound();
|
|
||||||
|
|
||||||
const oldPlaidItem = account.plaidItem;
|
|
||||||
|
|
||||||
if (!oldPlaidItem) {
|
|
||||||
throw new ServiceError(ERRORS.BANK_ACCOUNT_NOT_CONNECTED);
|
|
||||||
}
|
|
||||||
const plaidInstance = PlaidClientWrapper.getClient();
|
|
||||||
|
|
||||||
return this.uow.withTransaction(tenantId, async (trx: Knex.Transaction) => {
|
|
||||||
// Triggers `onBankAccountDisconnecting` event.
|
|
||||||
await this.eventPublisher.emitAsync(events.bankAccount.onDisconnecting, {
|
|
||||||
tenantId,
|
|
||||||
bankAccountId,
|
|
||||||
} as IBankAccountDisconnectingEventPayload);
|
|
||||||
|
|
||||||
// Remove the Plaid item from the system.
|
|
||||||
await PlaidItem.query(trx).findById(account.plaidItemId).delete();
|
|
||||||
|
|
||||||
// Remove the plaid item association to the bank account.
|
|
||||||
await Account.query(trx).findById(bankAccountId).patch({
|
|
||||||
plaidAccountId: null,
|
|
||||||
plaidItemId: null,
|
|
||||||
isFeedsActive: false,
|
|
||||||
});
|
|
||||||
// Remove the Plaid item.
|
|
||||||
await plaidInstance.itemRemove({
|
|
||||||
access_token: oldPlaidItem.plaidAccessToken,
|
|
||||||
});
|
|
||||||
// Triggers `onBankAccountDisconnected` event.
|
|
||||||
await this.eventPublisher.emitAsync(events.bankAccount.onDisconnected, {
|
|
||||||
tenantId,
|
|
||||||
bankAccountId,
|
|
||||||
trx,
|
|
||||||
} as IBankAccountDisconnectedEventPayload);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import { Inject, Service } from 'typedi';
|
|
||||||
import { ServiceError } from '@/exceptions';
|
|
||||||
import { PlaidClientWrapper } from '@/lib/Plaid';
|
|
||||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
|
||||||
import { ERRORS } from './types';
|
|
||||||
|
|
||||||
@Service()
|
|
||||||
export class RefreshBankAccountService {
|
|
||||||
@Inject()
|
|
||||||
private tenancy: HasTenancyService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Asks Plaid to trigger syncing the given bank account.
|
|
||||||
* @param {number} tenantId
|
|
||||||
* @param {number} bankAccountId
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
public async refreshBankAccount(tenantId: number, bankAccountId: number) {
|
|
||||||
const { Account } = this.tenancy.models(tenantId);
|
|
||||||
|
|
||||||
const bankAccount = await Account.query()
|
|
||||||
.findById(bankAccountId)
|
|
||||||
.withGraphFetched('plaidItem')
|
|
||||||
.throwIfNotFound();
|
|
||||||
|
|
||||||
// Can't continue if the given account is not linked with Plaid item.
|
|
||||||
if (!bankAccount.plaidItem) {
|
|
||||||
throw new ServiceError(ERRORS.BANK_ACCOUNT_NOT_CONNECTED);
|
|
||||||
}
|
|
||||||
const plaidInstance = PlaidClientWrapper.getClient();
|
|
||||||
|
|
||||||
await plaidInstance.transactionsRefresh({
|
|
||||||
access_token: bankAccount.plaidItem.plaidAccessToken,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
import { Inject, Service } from 'typedi';
|
|
||||||
import { IAccountEventDeletedPayload } from '@/interfaces';
|
|
||||||
import { PlaidClientWrapper } from '@/lib/Plaid';
|
|
||||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
|
||||||
import events from '@/subscribers/events';
|
|
||||||
|
|
||||||
@Service()
|
|
||||||
export class DisconnectPlaidItemOnAccountDeleted {
|
|
||||||
@Inject()
|
|
||||||
private tenancy: HasTenancyService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor method.
|
|
||||||
*/
|
|
||||||
public attach(bus) {
|
|
||||||
bus.subscribe(
|
|
||||||
events.accounts.onDeleted,
|
|
||||||
this.handleDisconnectPlaidItemOnAccountDelete.bind(this)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes Plaid item from the system and Plaid once the account deleted.
|
|
||||||
* @param {IAccountEventDeletedPayload} payload
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
private async handleDisconnectPlaidItemOnAccountDelete({
|
|
||||||
tenantId,
|
|
||||||
oldAccount,
|
|
||||||
trx,
|
|
||||||
}: IAccountEventDeletedPayload) {
|
|
||||||
const { PlaidItem, Account } = this.tenancy.models(tenantId);
|
|
||||||
|
|
||||||
// Can't continue if the deleted account is not linked to Plaid item.
|
|
||||||
if (!oldAccount.plaidItemId) return;
|
|
||||||
|
|
||||||
// Retrieves the Plaid item that associated to the deleted account.
|
|
||||||
const oldPlaidItem = await PlaidItem.query(trx).findOne(
|
|
||||||
'plaidItemId',
|
|
||||||
oldAccount.plaidItemId
|
|
||||||
);
|
|
||||||
// Unlink the Plaid item from all account before deleting it.
|
|
||||||
await Account.query(trx)
|
|
||||||
.where('plaidItemId', oldAccount.plaidItemId)
|
|
||||||
.patch({
|
|
||||||
plaidAccountId: null,
|
|
||||||
plaidItemId: null,
|
|
||||||
});
|
|
||||||
// Remove the Plaid item from the system.
|
|
||||||
await PlaidItem.query(trx)
|
|
||||||
.findOne('plaidItemId', oldAccount.plaidItemId)
|
|
||||||
.delete();
|
|
||||||
|
|
||||||
if (oldPlaidItem) {
|
|
||||||
const plaidInstance = PlaidClientWrapper.getClient();
|
|
||||||
|
|
||||||
// Remove the Plaid item.
|
|
||||||
await plaidInstance.itemRemove({
|
|
||||||
access_token: oldPlaidItem.plaidAccessToken,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { Knex } from 'knex';
|
|
||||||
|
|
||||||
export interface IBankAccountDisconnectingEventPayload {
|
|
||||||
tenantId: number;
|
|
||||||
bankAccountId: number;
|
|
||||||
trx: Knex.Transaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IBankAccountDisconnectedEventPayload {
|
|
||||||
tenantId: number;
|
|
||||||
bankAccountId: number;
|
|
||||||
trx: Knex.Transaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ERRORS = {
|
|
||||||
BANK_ACCOUNT_NOT_CONNECTED: 'BANK_ACCOUNT_NOT_CONNECTED',
|
|
||||||
};
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import { Inject, Service } from 'typedi';
|
|
||||||
import PromisePool from '@supercharge/promise-pool';
|
|
||||||
import { castArray } from 'lodash';
|
|
||||||
import { ExcludeBankTransaction } from './ExcludeBankTransaction';
|
|
||||||
|
|
||||||
@Service()
|
|
||||||
export class ExcludeBankTransactions {
|
|
||||||
@Inject()
|
|
||||||
private excludeBankTransaction: ExcludeBankTransaction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exclude bank transactions in bulk.
|
|
||||||
* @param {number} tenantId
|
|
||||||
* @param {number} bankTransactionIds
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
public async excludeBankTransactions(
|
|
||||||
tenantId: number,
|
|
||||||
bankTransactionIds: Array<number> | number
|
|
||||||
) {
|
|
||||||
const _bankTransactionIds = castArray(bankTransactionIds);
|
|
||||||
|
|
||||||
await PromisePool.withConcurrency(1)
|
|
||||||
.for(_bankTransactionIds)
|
|
||||||
.process((bankTransactionId: number) => {
|
|
||||||
return this.excludeBankTransaction.excludeBankTransaction(
|
|
||||||
tenantId,
|
|
||||||
bankTransactionId
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,6 @@ import { ExcludeBankTransaction } from './ExcludeBankTransaction';
|
|||||||
import { UnexcludeBankTransaction } from './UnexcludeBankTransaction';
|
import { UnexcludeBankTransaction } from './UnexcludeBankTransaction';
|
||||||
import { GetExcludedBankTransactionsService } from './GetExcludedBankTransactions';
|
import { GetExcludedBankTransactionsService } from './GetExcludedBankTransactions';
|
||||||
import { ExcludedBankTransactionsQuery } from './_types';
|
import { ExcludedBankTransactionsQuery } from './_types';
|
||||||
import { UnexcludeBankTransactions } from './UnexcludeBankTransactions';
|
|
||||||
import { ExcludeBankTransactions } from './ExcludeBankTransactions';
|
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export class ExcludeBankTransactionsApplication {
|
export class ExcludeBankTransactionsApplication {
|
||||||
@@ -17,12 +15,6 @@ export class ExcludeBankTransactionsApplication {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private getExcludedBankTransactionsService: GetExcludedBankTransactionsService;
|
private getExcludedBankTransactionsService: GetExcludedBankTransactionsService;
|
||||||
|
|
||||||
@Inject()
|
|
||||||
private excludeBankTransactionsService: ExcludeBankTransactions;
|
|
||||||
|
|
||||||
@Inject()
|
|
||||||
private unexcludeBankTransactionsService: UnexcludeBankTransactions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a bank transaction as excluded.
|
* Marks a bank transaction as excluded.
|
||||||
* @param {number} tenantId - The ID of the tenant.
|
* @param {number} tenantId - The ID of the tenant.
|
||||||
@@ -64,36 +56,4 @@ export class ExcludeBankTransactionsApplication {
|
|||||||
filter
|
filter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Exclude the given bank transactions in bulk.
|
|
||||||
* @param {number} tenantId
|
|
||||||
* @param {Array<number> | number} bankTransactionIds
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
public excludeBankTransactions(
|
|
||||||
tenantId: number,
|
|
||||||
bankTransactionIds: Array<number> | number
|
|
||||||
): Promise<void> {
|
|
||||||
return this.excludeBankTransactionsService.excludeBankTransactions(
|
|
||||||
tenantId,
|
|
||||||
bankTransactionIds
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exclude the given bank transactions in bulk.
|
|
||||||
* @param {number} tenantId
|
|
||||||
* @param {Array<number> | number} bankTransactionIds
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
public unexcludeBankTransactions(
|
|
||||||
tenantId: number,
|
|
||||||
bankTransactionIds: Array<number> | number
|
|
||||||
): Promise<void> {
|
|
||||||
return this.unexcludeBankTransactionsService.unexcludeBankTransactions(
|
|
||||||
tenantId,
|
|
||||||
bankTransactionIds
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
import { Inject, Service } from 'typedi';
|
|
||||||
import PromisePool from '@supercharge/promise-pool';
|
|
||||||
import { UnexcludeBankTransaction } from './UnexcludeBankTransaction';
|
|
||||||
import { castArray } from 'lodash';
|
|
||||||
|
|
||||||
@Service()
|
|
||||||
export class UnexcludeBankTransactions {
|
|
||||||
@Inject()
|
|
||||||
private unexcludeBankTransaction: UnexcludeBankTransaction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unexclude bank transactions in bulk.
|
|
||||||
* @param {number} tenantId
|
|
||||||
* @param {number} bankTransactionIds
|
|
||||||
*/
|
|
||||||
public async unexcludeBankTransactions(
|
|
||||||
tenantId: number,
|
|
||||||
bankTransactionIds: Array<number> | number
|
|
||||||
) {
|
|
||||||
const _bankTransactionIds = castArray(bankTransactionIds);
|
|
||||||
|
|
||||||
await PromisePool.withConcurrency(1)
|
|
||||||
.for(_bankTransactionIds)
|
|
||||||
.process((bankTransactionId: number) => {
|
|
||||||
return this.unexcludeBankTransaction.unexcludeBankTransaction(
|
|
||||||
tenantId,
|
|
||||||
bankTransactionId
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -28,7 +28,7 @@ export class PlaidItemService {
|
|||||||
const { PlaidItem } = this.tenancy.models(tenantId);
|
const { PlaidItem } = this.tenancy.models(tenantId);
|
||||||
const { publicToken, institutionId } = itemDTO;
|
const { publicToken, institutionId } = itemDTO;
|
||||||
|
|
||||||
const plaidInstance = PlaidClientWrapper.getClient();
|
const plaidInstance = new PlaidClientWrapper();
|
||||||
|
|
||||||
// Exchange the public token for a private access token and store with the item.
|
// Exchange the public token for a private access token and store with the item.
|
||||||
const response = await plaidInstance.itemPublicTokenExchange({
|
const response = await plaidInstance.itemPublicTokenExchange({
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class PlaidLinkTokenService {
|
|||||||
webhook: config.plaid.linkWebhook,
|
webhook: config.plaid.linkWebhook,
|
||||||
access_token: accessToken,
|
access_token: accessToken,
|
||||||
};
|
};
|
||||||
const plaidInstance = PlaidClientWrapper.getClient();
|
const plaidInstance = new PlaidClientWrapper();
|
||||||
const createResponse = await plaidInstance.linkTokenCreate(linkTokenParams);
|
const createResponse = await plaidInstance.linkTokenCreate(linkTokenParams);
|
||||||
|
|
||||||
return createResponse.data;
|
return createResponse.data;
|
||||||
|
|||||||
@@ -2,11 +2,6 @@ import * as R from 'ramda';
|
|||||||
import { Inject, Service } from 'typedi';
|
import { Inject, Service } from 'typedi';
|
||||||
import bluebird from 'bluebird';
|
import bluebird from 'bluebird';
|
||||||
import { entries, groupBy } from 'lodash';
|
import { entries, groupBy } from 'lodash';
|
||||||
import {
|
|
||||||
AccountBase as PlaidAccountBase,
|
|
||||||
Item as PlaidItem,
|
|
||||||
Institution as PlaidInstitution,
|
|
||||||
} from 'plaid';
|
|
||||||
import { CreateAccount } from '@/services/Accounts/CreateAccount';
|
import { CreateAccount } from '@/services/Accounts/CreateAccount';
|
||||||
import {
|
import {
|
||||||
IAccountCreateDTO,
|
IAccountCreateDTO,
|
||||||
@@ -58,7 +53,6 @@ export class PlaidSyncDb {
|
|||||||
trx?: Knex.Transaction
|
trx?: Knex.Transaction
|
||||||
) {
|
) {
|
||||||
const { Account } = this.tenancy.models(tenantId);
|
const { Account } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
const plaidAccount = await Account.query().findOne(
|
const plaidAccount = await Account.query().findOne(
|
||||||
'plaidAccountId',
|
'plaidAccountId',
|
||||||
createBankAccountDTO.plaidAccountId
|
createBankAccountDTO.plaidAccountId
|
||||||
@@ -83,15 +77,13 @@ export class PlaidSyncDb {
|
|||||||
*/
|
*/
|
||||||
public async syncBankAccounts(
|
public async syncBankAccounts(
|
||||||
tenantId: number,
|
tenantId: number,
|
||||||
plaidAccounts: PlaidAccountBase[],
|
plaidAccounts: PlaidAccount[],
|
||||||
institution: PlaidInstitution,
|
institution: any,
|
||||||
item: PlaidItem,
|
|
||||||
trx?: Knex.Transaction
|
trx?: Knex.Transaction
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const transformToPlaidAccounts = transformPlaidAccountToCreateAccount(
|
const transformToPlaidAccounts =
|
||||||
item,
|
transformPlaidAccountToCreateAccount(institution);
|
||||||
institution
|
|
||||||
);
|
|
||||||
const accountCreateDTOs = R.map(transformToPlaidAccounts)(plaidAccounts);
|
const accountCreateDTOs = R.map(transformToPlaidAccounts)(plaidAccounts);
|
||||||
|
|
||||||
await bluebird.map(
|
await bluebird.map(
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export class PlaidUpdateTransactions {
|
|||||||
await this.fetchTransactionUpdates(tenantId, plaidItemId);
|
await this.fetchTransactionUpdates(tenantId, plaidItemId);
|
||||||
|
|
||||||
const request = { access_token: accessToken };
|
const request = { access_token: accessToken };
|
||||||
const plaidInstance = PlaidClientWrapper.getClient();
|
const plaidInstance = new PlaidClientWrapper();
|
||||||
const {
|
const {
|
||||||
data: { accounts, item },
|
data: { accounts, item },
|
||||||
} = await plaidInstance.accountsGet(request);
|
} = await plaidInstance.accountsGet(request);
|
||||||
@@ -66,13 +66,7 @@ export class PlaidUpdateTransactions {
|
|||||||
country_codes: ['US', 'UK'],
|
country_codes: ['US', 'UK'],
|
||||||
});
|
});
|
||||||
// Sync bank accounts.
|
// Sync bank accounts.
|
||||||
await this.plaidSync.syncBankAccounts(
|
await this.plaidSync.syncBankAccounts(tenantId, accounts, institution, trx);
|
||||||
tenantId,
|
|
||||||
accounts,
|
|
||||||
institution,
|
|
||||||
item,
|
|
||||||
trx
|
|
||||||
);
|
|
||||||
// Sync bank account transactions.
|
// Sync bank account transactions.
|
||||||
await this.plaidSync.syncAccountsTransactions(
|
await this.plaidSync.syncAccountsTransactions(
|
||||||
tenantId,
|
tenantId,
|
||||||
@@ -147,7 +141,7 @@ export class PlaidUpdateTransactions {
|
|||||||
cursor: cursor,
|
cursor: cursor,
|
||||||
count: batchSize,
|
count: batchSize,
|
||||||
};
|
};
|
||||||
const plaidInstance = PlaidClientWrapper.getClient();
|
const plaidInstance = new PlaidClientWrapper();
|
||||||
const response = await plaidInstance.transactionsSync(request);
|
const response = await plaidInstance.transactionsSync(request);
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
// Add this page of results
|
// Add this page of results
|
||||||
|
|||||||
@@ -1,28 +1,18 @@
|
|||||||
import * as R from 'ramda';
|
import * as R from 'ramda';
|
||||||
import {
|
|
||||||
Item as PlaidItem,
|
|
||||||
Institution as PlaidInstitution,
|
|
||||||
AccountBase as PlaidAccount,
|
|
||||||
} from 'plaid';
|
|
||||||
import {
|
import {
|
||||||
CreateUncategorizedTransactionDTO,
|
CreateUncategorizedTransactionDTO,
|
||||||
IAccountCreateDTO,
|
IAccountCreateDTO,
|
||||||
|
PlaidAccount,
|
||||||
PlaidTransaction,
|
PlaidTransaction,
|
||||||
} from '@/interfaces';
|
} from '@/interfaces';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transformes the Plaid account to create cashflow account DTO.
|
* Transformes the Plaid account to create cashflow account DTO.
|
||||||
* @param {PlaidItem} item -
|
* @param {PlaidAccount} plaidAccount
|
||||||
* @param {PlaidInstitution} institution -
|
|
||||||
* @param {PlaidAccount} plaidAccount -
|
|
||||||
* @returns {IAccountCreateDTO}
|
* @returns {IAccountCreateDTO}
|
||||||
*/
|
*/
|
||||||
export const transformPlaidAccountToCreateAccount = R.curry(
|
export const transformPlaidAccountToCreateAccount = R.curry(
|
||||||
(
|
(institution: any, plaidAccount: PlaidAccount): IAccountCreateDTO => {
|
||||||
item: PlaidItem,
|
|
||||||
institution: PlaidInstitution,
|
|
||||||
plaidAccount: PlaidAccount
|
|
||||||
): IAccountCreateDTO => {
|
|
||||||
return {
|
return {
|
||||||
name: `${institution.name} - ${plaidAccount.name}`,
|
name: `${institution.name} - ${plaidAccount.name}`,
|
||||||
code: '',
|
code: '',
|
||||||
@@ -30,10 +20,9 @@ export const transformPlaidAccountToCreateAccount = R.curry(
|
|||||||
currencyCode: plaidAccount.balances.iso_currency_code,
|
currencyCode: plaidAccount.balances.iso_currency_code,
|
||||||
accountType: 'cash',
|
accountType: 'cash',
|
||||||
active: true,
|
active: true,
|
||||||
|
plaidAccountId: plaidAccount.account_id,
|
||||||
bankBalance: plaidAccount.balances.current,
|
bankBalance: plaidAccount.balances.current,
|
||||||
accountMask: plaidAccount.mask,
|
accountMask: plaidAccount.mask,
|
||||||
plaidAccountId: plaidAccount.account_id,
|
|
||||||
plaidItemId: item.item_id,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -658,11 +658,6 @@ export default {
|
|||||||
onUnexcluded: 'onBankTransactionUnexcluded',
|
onUnexcluded: 'onBankTransactionUnexcluded',
|
||||||
},
|
},
|
||||||
|
|
||||||
bankAccount: {
|
|
||||||
onDisconnecting: 'onBankAccountDisconnecting',
|
|
||||||
onDisconnected: 'onBankAccountDisconnected',
|
|
||||||
},
|
|
||||||
|
|
||||||
// Import files.
|
// Import files.
|
||||||
import: {
|
import: {
|
||||||
onImportCommitted: 'onImportFileCommitted',
|
onImportCommitted: 'onImportFileCommitted',
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
import { Position, Toaster, Intent } from '@blueprintjs/core';
|
import { Position, Toaster, Intent } from '@blueprintjs/core';
|
||||||
|
|
||||||
export const AppToaster = Toaster.create({
|
export const AppToaster = Toaster.create({
|
||||||
position: Position.TOP,
|
position: Position.RIGHT_BOTTOM,
|
||||||
intent: Intent.WARNING,
|
intent: Intent.WARNING,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,19 +11,13 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
|
||||||
Tooltip,
|
|
||||||
MenuDivider,
|
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { isEmpty } from 'lodash';
|
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
DashboardActionsBar,
|
DashboardActionsBar,
|
||||||
DashboardRowsHeightButton,
|
DashboardRowsHeightButton,
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
AppToaster,
|
|
||||||
If,
|
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
|
|
||||||
import { CashFlowMenuItems } from './utils';
|
import { CashFlowMenuItems } from './utils';
|
||||||
@@ -39,13 +33,6 @@ import withSettings from '@/containers/Settings/withSettings';
|
|||||||
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
import withSettingsActions from '@/containers/Settings/withSettingsActions';
|
||||||
|
|
||||||
import { compose } from '@/utils';
|
import { compose } from '@/utils';
|
||||||
import {
|
|
||||||
useDisconnectBankAccount,
|
|
||||||
useUpdateBankAccount,
|
|
||||||
useExcludeUncategorizedTransactions,
|
|
||||||
useUnexcludeUncategorizedTransactions,
|
|
||||||
} from '@/hooks/query/bank-rules';
|
|
||||||
import { withBanking } from '../withBanking';
|
|
||||||
|
|
||||||
function AccountTransactionsActionsBar({
|
function AccountTransactionsActionsBar({
|
||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
@@ -56,27 +43,17 @@ function AccountTransactionsActionsBar({
|
|||||||
|
|
||||||
// #withSettingsActions
|
// #withSettingsActions
|
||||||
addSetting,
|
addSetting,
|
||||||
|
|
||||||
// #withBanking
|
|
||||||
uncategorizedTransationsIdsSelected,
|
|
||||||
excludedTransactionsIdsSelected,
|
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { accountId, currentAccount } = useAccountTransactionsContext();
|
const { accountId } = useAccountTransactionsContext();
|
||||||
|
|
||||||
// Refresh cashflow infinity transactions hook.
|
// Refresh cashflow infinity transactions hook.
|
||||||
const { refresh } = useRefreshCashflowTransactionsInfinity();
|
const { refresh } = useRefreshCashflowTransactionsInfinity();
|
||||||
|
|
||||||
const { mutateAsync: disconnectBankAccount } = useDisconnectBankAccount();
|
|
||||||
const { mutateAsync: updateBankAccount } = useUpdateBankAccount();
|
|
||||||
|
|
||||||
// Retrieves the money in/out buttons options.
|
// Retrieves the money in/out buttons options.
|
||||||
const addMoneyInOptions = useMemo(() => getAddMoneyInOptions(), []);
|
const addMoneyInOptions = useMemo(() => getAddMoneyInOptions(), []);
|
||||||
const addMoneyOutOptions = useMemo(() => getAddMoneyOutOptions(), []);
|
const addMoneyOutOptions = useMemo(() => getAddMoneyOutOptions(), []);
|
||||||
|
|
||||||
const isFeedsActive = !!currentAccount.is_feeds_active;
|
|
||||||
const isSyncingOwner = currentAccount.is_syncing_owner;
|
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('cashflowTransactions', 'tableSize', size);
|
addSetting('cashflowTransactions', 'tableSize', size);
|
||||||
@@ -105,92 +82,11 @@ function AccountTransactionsActionsBar({
|
|||||||
const handleBankRulesClick = () => {
|
const handleBankRulesClick = () => {
|
||||||
history.push(`/bank-rules?accountId=${accountId}`);
|
history.push(`/bank-rules?accountId=${accountId}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles the bank account disconnect click.
|
|
||||||
const handleDisconnectClick = () => {
|
|
||||||
disconnectBankAccount({ bankAccountId: accountId })
|
|
||||||
.then(() => {
|
|
||||||
AppToaster.show({
|
|
||||||
message: 'The bank account has been disconnected.',
|
|
||||||
intent: Intent.SUCCESS,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
AppToaster.show({
|
|
||||||
message: 'Something went wrong.',
|
|
||||||
intent: Intent.DANGER,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
// handles the bank update button click.
|
|
||||||
const handleBankUpdateClick = () => {
|
|
||||||
updateBankAccount({ bankAccountId: accountId })
|
|
||||||
.then(() => {
|
|
||||||
AppToaster.show({
|
|
||||||
message: 'The transactions of the bank account has been updated.',
|
|
||||||
intent: Intent.SUCCESS,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
AppToaster.show({
|
|
||||||
message: 'Something went wrong.',
|
|
||||||
intent: Intent.DANGER,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
// Handle the refresh button click.
|
// Handle the refresh button click.
|
||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
const {
|
|
||||||
mutateAsync: excludeUncategorizedTransactions,
|
|
||||||
isLoading: isExcludingLoading,
|
|
||||||
} = useExcludeUncategorizedTransactions();
|
|
||||||
|
|
||||||
const {
|
|
||||||
mutateAsync: unexcludeUncategorizedTransactions,
|
|
||||||
isLoading: isUnexcludingLoading,
|
|
||||||
} = useUnexcludeUncategorizedTransactions();
|
|
||||||
|
|
||||||
// Handles the exclude uncategorized transactions in bulk.
|
|
||||||
const handleExcludeUncategorizedBtnClick = () => {
|
|
||||||
excludeUncategorizedTransactions({
|
|
||||||
ids: uncategorizedTransationsIdsSelected,
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
AppToaster.show({
|
|
||||||
message: 'The selected transactions have been excluded.',
|
|
||||||
intent: Intent.SUCCESS,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
AppToaster.show({
|
|
||||||
message: 'Something went wrong',
|
|
||||||
intent: Intent.DANGER,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Handles the unexclude categorized button click.
|
|
||||||
const handleUnexcludeUncategorizedBtnClick = () => {
|
|
||||||
unexcludeUncategorizedTransactions({
|
|
||||||
ids: excludedTransactionsIdsSelected,
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
AppToaster.show({
|
|
||||||
message: 'The selected excluded transactions have been unexcluded.',
|
|
||||||
intent: Intent.SUCCESS,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
AppToaster.show({
|
|
||||||
message: 'Something went wrong',
|
|
||||||
intent: Intent.DANGER,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -233,45 +129,6 @@ function AccountTransactionsActionsBar({
|
|||||||
onChange={handleTableRowSizeChange}
|
onChange={handleTableRowSizeChange}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
|
||||||
<If condition={isSyncingOwner}>
|
|
||||||
<Tooltip
|
|
||||||
content={
|
|
||||||
isFeedsActive
|
|
||||||
? 'The bank syncing is active'
|
|
||||||
: 'The bank syncing is disconnected'
|
|
||||||
}
|
|
||||||
minimal={true}
|
|
||||||
position={Position.BOTTOM}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
icon={<Icon icon="feed" iconSize={16} />}
|
|
||||||
intent={isFeedsActive ? Intent.SUCCESS : Intent.DANGER}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</If>
|
|
||||||
|
|
||||||
{!isEmpty(uncategorizedTransationsIdsSelected) && (
|
|
||||||
<Button
|
|
||||||
icon={<Icon icon="disable" iconSize={16} />}
|
|
||||||
text={'Exclude'}
|
|
||||||
onClick={handleExcludeUncategorizedBtnClick}
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
intent={Intent.DANGER}
|
|
||||||
disabled={isExcludingLoading}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{!isEmpty(excludedTransactionsIdsSelected) && (
|
|
||||||
<Button
|
|
||||||
icon={<Icon icon="disable" iconSize={16} />}
|
|
||||||
text={'Unexclude'}
|
|
||||||
onClick={handleUnexcludeUncategorizedBtnClick}
|
|
||||||
className={Classes.MINIMAL}
|
|
||||||
intent={Intent.DANGER}
|
|
||||||
disabled={isUnexcludingLoading}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
|
||||||
<NavbarGroup align={Alignment.RIGHT}>
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
@@ -284,15 +141,7 @@ function AccountTransactionsActionsBar({
|
|||||||
}}
|
}}
|
||||||
content={
|
content={
|
||||||
<Menu>
|
<Menu>
|
||||||
<If condition={isSyncingOwner && isFeedsActive}>
|
|
||||||
<MenuItem onClick={handleBankUpdateClick} text={'Update'} />
|
|
||||||
<MenuDivider />
|
|
||||||
</If>
|
|
||||||
<MenuItem onClick={handleBankRulesClick} text={'Bank rules'} />
|
<MenuItem onClick={handleBankRulesClick} text={'Bank rules'} />
|
||||||
|
|
||||||
<If condition={isSyncingOwner && isFeedsActive}>
|
|
||||||
<MenuItem onClick={handleDisconnectClick} text={'Disconnect'} />
|
|
||||||
</If>
|
|
||||||
</Menu>
|
</Menu>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -315,13 +164,4 @@ export default compose(
|
|||||||
withSettings(({ cashflowTransactionsSettings }) => ({
|
withSettings(({ cashflowTransactionsSettings }) => ({
|
||||||
cashflowTansactionsTableSize: cashflowTransactionsSettings?.tableSize,
|
cashflowTansactionsTableSize: cashflowTransactionsSettings?.tableSize,
|
||||||
})),
|
})),
|
||||||
withBanking(
|
|
||||||
({
|
|
||||||
uncategorizedTransationsIdsSelected,
|
|
||||||
excludedTransactionsIdsSelected,
|
|
||||||
}) => ({
|
|
||||||
uncategorizedTransationsIdsSelected,
|
|
||||||
excludedTransactionsIdsSelected,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
)(AccountTransactionsActionsBar);
|
)(AccountTransactionsActionsBar);
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ function AccountTransactionsDataTable({
|
|||||||
|
|
||||||
// #withBankingActions
|
// #withBankingActions
|
||||||
setUncategorizedTransactionIdForMatching,
|
setUncategorizedTransactionIdForMatching,
|
||||||
setUncategorizedTransactionsSelected,
|
|
||||||
}) {
|
}) {
|
||||||
// Retrieve table columns.
|
// Retrieve table columns.
|
||||||
const columns = useAccountUncategorizedTransactionsColumns();
|
const columns = useAccountUncategorizedTransactionsColumns();
|
||||||
@@ -74,19 +73,12 @@ function AccountTransactionsDataTable({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle selected rows change.
|
|
||||||
const handleSelectedRowsChange = (selected) => {
|
|
||||||
const _selectedIds = selected?.map((row) => row.original.id);
|
|
||||||
setUncategorizedTransactionsSelected(_selectedIds);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CashflowTransactionsTable
|
<CashflowTransactionsTable
|
||||||
noInitialFetch={true}
|
noInitialFetch={true}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={uncategorizedTransactions || []}
|
data={uncategorizedTransactions || []}
|
||||||
sticky={true}
|
sticky={true}
|
||||||
selectionColumn={true}
|
|
||||||
loading={isUncategorizedTransactionsLoading}
|
loading={isUncategorizedTransactionsLoading}
|
||||||
headerLoading={isUncategorizedTransactionsLoading}
|
headerLoading={isUncategorizedTransactionsLoading}
|
||||||
expandColumnSpace={1}
|
expandColumnSpace={1}
|
||||||
@@ -107,7 +99,6 @@ function AccountTransactionsDataTable({
|
|||||||
'There is no uncategorized transactions in the current account.'
|
'There is no uncategorized transactions in the current account.'
|
||||||
}
|
}
|
||||||
className="table-constrant"
|
className="table-constrant"
|
||||||
onSelectedRowsChange={handleSelectedRowsChange}
|
|
||||||
payload={{
|
payload={{
|
||||||
onExclude: handleExcludeTransaction,
|
onExclude: handleExcludeTransaction,
|
||||||
onCategorize: handleCategorizeBtnClick,
|
onCategorize: handleCategorizeBtnClick,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Intent } from '@blueprintjs/core';
|
import { Intent } from '@blueprintjs/core';
|
||||||
import * as R from 'ramda';
|
|
||||||
import {
|
import {
|
||||||
DataTable,
|
DataTable,
|
||||||
TableFastCell,
|
TableFastCell,
|
||||||
@@ -19,20 +19,11 @@ import { useExcludedTransactionsBoot } from './ExcludedTransactionsTableBoot';
|
|||||||
|
|
||||||
import { ActionsMenu } from './_components';
|
import { ActionsMenu } from './_components';
|
||||||
import { useUnexcludeUncategorizedTransaction } from '@/hooks/query/bank-rules';
|
import { useUnexcludeUncategorizedTransaction } from '@/hooks/query/bank-rules';
|
||||||
import {
|
|
||||||
WithBankingActionsProps,
|
|
||||||
withBankingActions,
|
|
||||||
} from '../../withBankingActions';
|
|
||||||
|
|
||||||
interface ExcludeTransactionsTableProps extends WithBankingActionsProps {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the recognized account transactions datatable.
|
* Renders the recognized account transactions datatable.
|
||||||
*/
|
*/
|
||||||
function ExcludedTransactionsTableRoot({
|
export function ExcludedTransactionsTable() {
|
||||||
// #withBankingActions
|
|
||||||
setExcludedTransactionsSelected,
|
|
||||||
}: ExcludeTransactionsTableProps) {
|
|
||||||
const { excludedBankTransactions } = useExcludedTransactionsBoot();
|
const { excludedBankTransactions } = useExcludedTransactionsBoot();
|
||||||
const { mutateAsync: unexcludeBankTransaction } =
|
const { mutateAsync: unexcludeBankTransaction } =
|
||||||
useUnexcludeUncategorizedTransaction();
|
useUnexcludeUncategorizedTransaction();
|
||||||
@@ -64,12 +55,6 @@ function ExcludedTransactionsTableRoot({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle selected rows change.
|
|
||||||
const handleSelectedRowsChange = (selected) => {
|
|
||||||
const _selectedIds = selected?.map((row) => row.original.id);
|
|
||||||
setExcludedTransactionsSelected(_selectedIds);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CashflowTransactionsTable
|
<CashflowTransactionsTable
|
||||||
noInitialFetch={true}
|
noInitialFetch={true}
|
||||||
@@ -95,8 +80,6 @@ function ExcludedTransactionsTableRoot({
|
|||||||
onColumnResizing={handleColumnResizing}
|
onColumnResizing={handleColumnResizing}
|
||||||
noResults={'There is no excluded bank transactions.'}
|
noResults={'There is no excluded bank transactions.'}
|
||||||
className="table-constrant"
|
className="table-constrant"
|
||||||
selectionColumn={true}
|
|
||||||
onSelectedRowsChange={handleSelectedRowsChange}
|
|
||||||
payload={{
|
payload={{
|
||||||
onRestore: handleRestoreClick,
|
onRestore: handleRestoreClick,
|
||||||
}}
|
}}
|
||||||
@@ -104,10 +87,6 @@ function ExcludedTransactionsTableRoot({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ExcludedTransactionsTable = R.compose(withBankingActions)(
|
|
||||||
ExcludedTransactionsTableRoot,
|
|
||||||
);
|
|
||||||
|
|
||||||
const DashboardConstrantTable = styled(DataTable)`
|
const DashboardConstrantTable = styled(DataTable)`
|
||||||
.table {
|
.table {
|
||||||
.thead {
|
.thead {
|
||||||
|
|||||||
@@ -1,27 +1,8 @@
|
|||||||
// @ts-nocheck
|
import { ExcludedTransactionsTable } from "../ExcludedTransactions/ExcludedTransactionsTable";
|
||||||
import { useEffect } from 'react';
|
import { ExcludedBankTransactionsTableBoot } from "../ExcludedTransactions/ExcludedTransactionsTableBoot";
|
||||||
import * as R from 'ramda';
|
import { AccountTransactionsCard } from "./AccountTransactionsCard";
|
||||||
import {
|
|
||||||
WithBankingActionsProps,
|
|
||||||
withBankingActions,
|
|
||||||
} from '../../withBankingActions';
|
|
||||||
import { ExcludedTransactionsTable } from '../ExcludedTransactions/ExcludedTransactionsTable';
|
|
||||||
import { ExcludedBankTransactionsTableBoot } from '../ExcludedTransactions/ExcludedTransactionsTableBoot';
|
|
||||||
import { AccountTransactionsCard } from './AccountTransactionsCard';
|
|
||||||
|
|
||||||
interface AccountExcludedTransactionsProps extends WithBankingActionsProps {}
|
|
||||||
|
|
||||||
function AccountExcludedTransactionsRoot({
|
|
||||||
// #withBankingActions
|
|
||||||
resetExcludedTransactionsSelected,
|
|
||||||
}: AccountExcludedTransactionsProps) {
|
|
||||||
useEffect(
|
|
||||||
() => () => {
|
|
||||||
resetExcludedTransactionsSelected();
|
|
||||||
},
|
|
||||||
[resetExcludedTransactionsSelected],
|
|
||||||
);
|
|
||||||
|
|
||||||
|
export function AccountExcludedTransactions() {
|
||||||
return (
|
return (
|
||||||
<ExcludedBankTransactionsTableBoot>
|
<ExcludedBankTransactionsTableBoot>
|
||||||
<AccountTransactionsCard>
|
<AccountTransactionsCard>
|
||||||
@@ -30,7 +11,3 @@ function AccountExcludedTransactionsRoot({
|
|||||||
</ExcludedBankTransactionsTableBoot>
|
</ExcludedBankTransactionsTableBoot>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AccountExcludedTransactions = R.compose(withBankingActions)(
|
|
||||||
AccountExcludedTransactionsRoot,
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -1,26 +1,8 @@
|
|||||||
import * as R from 'ramda';
|
|
||||||
import { useEffect } from 'react';
|
|
||||||
import AccountTransactionsUncategorizedTable from '../AccountTransactionsUncategorizedTable';
|
import AccountTransactionsUncategorizedTable from '../AccountTransactionsUncategorizedTable';
|
||||||
import { AccountUncategorizedTransactionsBoot } from '../AllTransactionsUncategorizedBoot';
|
import { AccountUncategorizedTransactionsBoot } from '../AllTransactionsUncategorizedBoot';
|
||||||
import { AccountTransactionsCard } from './AccountTransactionsCard';
|
import { AccountTransactionsCard } from './AccountTransactionsCard';
|
||||||
import {
|
|
||||||
WithBankingActionsProps,
|
|
||||||
withBankingActions,
|
|
||||||
} from '../../withBankingActions';
|
|
||||||
|
|
||||||
interface AccountUncategorizedTransactionsAllRootProps
|
|
||||||
extends WithBankingActionsProps {}
|
|
||||||
|
|
||||||
function AccountUncategorizedTransactionsAllRoot({
|
|
||||||
resetUncategorizedTransactionsSelected,
|
|
||||||
}: AccountUncategorizedTransactionsAllRootProps) {
|
|
||||||
useEffect(
|
|
||||||
() => () => {
|
|
||||||
resetUncategorizedTransactionsSelected();
|
|
||||||
},
|
|
||||||
[resetUncategorizedTransactionsSelected],
|
|
||||||
);
|
|
||||||
|
|
||||||
|
export function AccountUncategorizedTransactionsAll() {
|
||||||
return (
|
return (
|
||||||
<AccountUncategorizedTransactionsBoot>
|
<AccountUncategorizedTransactionsBoot>
|
||||||
<AccountTransactionsCard>
|
<AccountTransactionsCard>
|
||||||
@@ -29,7 +11,3 @@ function AccountUncategorizedTransactionsAllRoot({
|
|||||||
</AccountUncategorizedTransactionsBoot>
|
</AccountUncategorizedTransactionsBoot>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AccountUncategorizedTransactionsAll = R.compose(
|
|
||||||
withBankingActions,
|
|
||||||
)(AccountUncategorizedTransactionsAllRoot);
|
|
||||||
|
|||||||
@@ -13,11 +13,6 @@ export const withBanking = (mapState) => {
|
|||||||
|
|
||||||
reconcileMatchingTransactionPendingAmount:
|
reconcileMatchingTransactionPendingAmount:
|
||||||
state.plaid.openReconcileMatchingTransaction.pending,
|
state.plaid.openReconcileMatchingTransaction.pending,
|
||||||
|
|
||||||
uncategorizedTransationsIdsSelected:
|
|
||||||
state.plaid.uncategorizedTransactionsSelected,
|
|
||||||
|
|
||||||
excludedTransactionsIdsSelected: state.plaid.excludedTransactionsSelected,
|
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import {
|
|||||||
setUncategorizedTransactionIdForMatching,
|
setUncategorizedTransactionIdForMatching,
|
||||||
openReconcileMatchingTransaction,
|
openReconcileMatchingTransaction,
|
||||||
closeReconcileMatchingTransaction,
|
closeReconcileMatchingTransaction,
|
||||||
setUncategorizedTransactionsSelected,
|
|
||||||
resetUncategorizedTransactionsSelected,
|
|
||||||
resetExcludedTransactionsSelected,
|
|
||||||
setExcludedTransactionsSelected,
|
|
||||||
} from '@/store/banking/banking.reducer';
|
} from '@/store/banking/banking.reducer';
|
||||||
|
|
||||||
export interface WithBankingActionsProps {
|
export interface WithBankingActionsProps {
|
||||||
@@ -17,12 +13,6 @@ export interface WithBankingActionsProps {
|
|||||||
) => void;
|
) => void;
|
||||||
openReconcileMatchingTransaction: (pendingAmount: number) => void;
|
openReconcileMatchingTransaction: (pendingAmount: number) => void;
|
||||||
closeReconcileMatchingTransaction: () => void;
|
closeReconcileMatchingTransaction: () => void;
|
||||||
|
|
||||||
setUncategorizedTransactionsSelected: (ids: Array<string | number>) => void;
|
|
||||||
resetUncategorizedTransactionsSelected: () => void;
|
|
||||||
|
|
||||||
setExcludedTransactionsSelected: (ids: Array<string | number>) => void;
|
|
||||||
resetExcludedTransactionsSelected: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDipatchToProps = (dispatch: any): WithBankingActionsProps => ({
|
const mapDipatchToProps = (dispatch: any): WithBankingActionsProps => ({
|
||||||
@@ -38,40 +28,6 @@ const mapDipatchToProps = (dispatch: any): WithBankingActionsProps => ({
|
|||||||
dispatch(openReconcileMatchingTransaction({ pending: pendingAmount })),
|
dispatch(openReconcileMatchingTransaction({ pending: pendingAmount })),
|
||||||
closeReconcileMatchingTransaction: () =>
|
closeReconcileMatchingTransaction: () =>
|
||||||
dispatch(closeReconcileMatchingTransaction()),
|
dispatch(closeReconcileMatchingTransaction()),
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the selected uncategorized transactions.
|
|
||||||
* @param {Array<string | number>} ids
|
|
||||||
*/
|
|
||||||
setUncategorizedTransactionsSelected: (ids: Array<string | number>) =>
|
|
||||||
dispatch(
|
|
||||||
setUncategorizedTransactionsSelected({
|
|
||||||
transactionIds: ids,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the selected uncategorized transactions.
|
|
||||||
*/
|
|
||||||
resetUncategorizedTransactionsSelected: () =>
|
|
||||||
dispatch(resetUncategorizedTransactionsSelected()),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets excluded selected transactions.
|
|
||||||
* @param {Array<string | number>} ids
|
|
||||||
*/
|
|
||||||
setExcludedTransactionsSelected: (ids: Array<string | number>) =>
|
|
||||||
dispatch(
|
|
||||||
setExcludedTransactionsSelected({
|
|
||||||
ids,
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the excluded selected transactions
|
|
||||||
*/
|
|
||||||
resetExcludedTransactionsSelected: () =>
|
|
||||||
dispatch(resetExcludedTransactionsSelected()),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const withBankingActions = connect<
|
export const withBankingActions = connect<
|
||||||
|
|||||||
@@ -61,76 +61,6 @@ export function useCreateBankRule(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DisconnectBankAccountRes {}
|
|
||||||
interface DisconnectBankAccountValues {
|
|
||||||
bankAccountId: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnects the given bank account.
|
|
||||||
* @param {UseMutationOptions<DisconnectBankAccountRes, Error, DisconnectBankAccountValues>} options
|
|
||||||
* @returns {UseMutationResult<DisconnectBankAccountRes, Error, DisconnectBankAccountValues>}
|
|
||||||
*/
|
|
||||||
export function useDisconnectBankAccount(
|
|
||||||
options?: UseMutationOptions<
|
|
||||||
DisconnectBankAccountRes,
|
|
||||||
Error,
|
|
||||||
DisconnectBankAccountValues
|
|
||||||
>,
|
|
||||||
): UseMutationResult<
|
|
||||||
DisconnectBankAccountRes,
|
|
||||||
Error,
|
|
||||||
DisconnectBankAccountValues
|
|
||||||
> {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const apiRequest = useApiRequest();
|
|
||||||
|
|
||||||
return useMutation<
|
|
||||||
DisconnectBankAccountRes,
|
|
||||||
Error,
|
|
||||||
DisconnectBankAccountValues
|
|
||||||
>(
|
|
||||||
({ bankAccountId }) =>
|
|
||||||
apiRequest.post(`/banking/bank_accounts/${bankAccountId}/disconnect`),
|
|
||||||
{
|
|
||||||
...options,
|
|
||||||
onSuccess: (res, values) => {
|
|
||||||
queryClient.invalidateQueries([t.ACCOUNT, values.bankAccountId]);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface UpdateBankAccountRes {}
|
|
||||||
interface UpdateBankAccountValues {
|
|
||||||
bankAccountId: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the bank transactions of the bank account.
|
|
||||||
* @param {UseMutationOptions<UpdateBankAccountRes, Error, UpdateBankAccountValues>}
|
|
||||||
* @returns {UseMutationResult<UpdateBankAccountRes, Error, UpdateBankAccountValues>}
|
|
||||||
*/
|
|
||||||
export function useUpdateBankAccount(
|
|
||||||
options?: UseMutationOptions<
|
|
||||||
UpdateBankAccountRes,
|
|
||||||
Error,
|
|
||||||
UpdateBankAccountValues
|
|
||||||
>,
|
|
||||||
): UseMutationResult<UpdateBankAccountRes, Error, UpdateBankAccountValues> {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const apiRequest = useApiRequest();
|
|
||||||
|
|
||||||
return useMutation<DisconnectBankAccountRes, Error, UpdateBankAccountValues>(
|
|
||||||
({ bankAccountId }) =>
|
|
||||||
apiRequest.post(`/banking/bank_accounts/${bankAccountId}/update`),
|
|
||||||
{
|
|
||||||
...options,
|
|
||||||
onSuccess: () => {},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface EditBankRuleValues {
|
interface EditBankRuleValues {
|
||||||
id: number;
|
id: number;
|
||||||
value: any;
|
value: any;
|
||||||
@@ -265,20 +195,6 @@ export function useGetBankTransactionsMatches(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const onValidateExcludeUncategorizedTransaction = (queryClient) => {
|
|
||||||
// Invalidate queries.
|
|
||||||
queryClient.invalidateQueries(QUERY_KEY.EXCLUDED_BANK_TRANSACTIONS_INFINITY);
|
|
||||||
queryClient.invalidateQueries(
|
|
||||||
t.CASHFLOW_ACCOUNT_UNCATEGORIZED_TRANSACTIONS_INFINITY,
|
|
||||||
);
|
|
||||||
// Invalidate accounts.
|
|
||||||
queryClient.invalidateQueries(t.ACCOUNTS);
|
|
||||||
queryClient.invalidateQueries(t.ACCOUNT);
|
|
||||||
|
|
||||||
// invalidate bank account summary.
|
|
||||||
queryClient.invalidateQueries(QUERY_KEY.BANK_ACCOUNT_SUMMARY_META);
|
|
||||||
};
|
|
||||||
|
|
||||||
type ExcludeUncategorizedTransactionValue = number;
|
type ExcludeUncategorizedTransactionValue = number;
|
||||||
|
|
||||||
interface ExcludeUncategorizedTransactionRes {}
|
interface ExcludeUncategorizedTransactionRes {}
|
||||||
@@ -312,7 +228,19 @@ export function useExcludeUncategorizedTransaction(
|
|||||||
),
|
),
|
||||||
{
|
{
|
||||||
onSuccess: (res, id) => {
|
onSuccess: (res, id) => {
|
||||||
onValidateExcludeUncategorizedTransaction(queryClient);
|
// Invalidate queries.
|
||||||
|
queryClient.invalidateQueries(
|
||||||
|
QUERY_KEY.EXCLUDED_BANK_TRANSACTIONS_INFINITY,
|
||||||
|
);
|
||||||
|
queryClient.invalidateQueries(
|
||||||
|
t.CASHFLOW_ACCOUNT_UNCATEGORIZED_TRANSACTIONS_INFINITY,
|
||||||
|
);
|
||||||
|
// Invalidate accounts.
|
||||||
|
queryClient.invalidateQueries(t.ACCOUNTS);
|
||||||
|
queryClient.invalidateQueries(t.ACCOUNT);
|
||||||
|
|
||||||
|
// invalidate bank account summary.
|
||||||
|
queryClient.invalidateQueries(QUERY_KEY.BANK_ACCOUNT_SUMMARY_META);
|
||||||
},
|
},
|
||||||
...options,
|
...options,
|
||||||
},
|
},
|
||||||
@@ -353,83 +281,19 @@ export function useUnexcludeUncategorizedTransaction(
|
|||||||
),
|
),
|
||||||
{
|
{
|
||||||
onSuccess: (res, id) => {
|
onSuccess: (res, id) => {
|
||||||
onValidateExcludeUncategorizedTransaction(queryClient);
|
// Invalidate queries.
|
||||||
},
|
queryClient.invalidateQueries(
|
||||||
...options,
|
QUERY_KEY.EXCLUDED_BANK_TRANSACTIONS_INFINITY,
|
||||||
},
|
);
|
||||||
);
|
queryClient.invalidateQueries(
|
||||||
}
|
t.CASHFLOW_ACCOUNT_UNCATEGORIZED_TRANSACTIONS_INFINITY,
|
||||||
|
);
|
||||||
|
// Invalidate accounts.
|
||||||
|
queryClient.invalidateQueries(t.ACCOUNTS);
|
||||||
|
queryClient.invalidateQueries(t.ACCOUNT);
|
||||||
|
|
||||||
type ExcludeBankTransactionsValue = { ids: Array<number | string> };
|
// Invalidate bank account summary.
|
||||||
interface ExcludeBankTransactionsResponse {}
|
queryClient.invalidateQueries(QUERY_KEY.BANK_ACCOUNT_SUMMARY_META);
|
||||||
|
|
||||||
/**
|
|
||||||
* Excludes the uncategorized bank transactions in bulk.
|
|
||||||
* @param {UseMutationResult<ExcludeBankTransactionsResponse, Error, ExcludeBankTransactionValue>} options
|
|
||||||
* @returns {UseMutationResult<ExcludeBankTransactionsResponse, Error, ExcludeBankTransactionValue>}
|
|
||||||
*/
|
|
||||||
export function useExcludeUncategorizedTransactions(
|
|
||||||
options?: UseMutationOptions<
|
|
||||||
ExcludeBankTransactionsResponse,
|
|
||||||
Error,
|
|
||||||
ExcludeBankTransactionsValue
|
|
||||||
>,
|
|
||||||
): UseMutationResult<
|
|
||||||
ExcludeBankTransactionsResponse,
|
|
||||||
Error,
|
|
||||||
ExcludeBankTransactionsValue
|
|
||||||
> {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const apiRequest = useApiRequest();
|
|
||||||
|
|
||||||
return useMutation<
|
|
||||||
ExcludeBankTransactionsResponse,
|
|
||||||
Error,
|
|
||||||
ExcludeBankTransactionsValue
|
|
||||||
>(
|
|
||||||
(value: { ids: Array<number | string> }) =>
|
|
||||||
apiRequest.put(`/cashflow/transactions/exclude`, { ids: value.ids }),
|
|
||||||
{
|
|
||||||
onSuccess: (res, id) => {
|
|
||||||
onValidateExcludeUncategorizedTransaction(queryClient);
|
|
||||||
},
|
|
||||||
...options,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
type UnexcludeBankTransactionsValue = { ids: Array<number | string> };
|
|
||||||
interface UnexcludeBankTransactionsResponse {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Excludes the uncategorized bank transactions in bulk.
|
|
||||||
* @param {UseMutationResult<UnexcludeBankTransactionsResponse, Error, ExcludeBankTransactionValue>} options
|
|
||||||
* @returns {UseMutationResult<UnexcludeBankTransactionsResponse, Error, ExcludeBankTransactionValue>}
|
|
||||||
*/
|
|
||||||
export function useUnexcludeUncategorizedTransactions(
|
|
||||||
options?: UseMutationOptions<
|
|
||||||
UnexcludeBankTransactionsResponse,
|
|
||||||
Error,
|
|
||||||
UnexcludeBankTransactionsValue
|
|
||||||
>,
|
|
||||||
): UseMutationResult<
|
|
||||||
UnexcludeBankTransactionsResponse,
|
|
||||||
Error,
|
|
||||||
UnexcludeBankTransactionsValue
|
|
||||||
> {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const apiRequest = useApiRequest();
|
|
||||||
|
|
||||||
return useMutation<
|
|
||||||
UnexcludeBankTransactionsResponse,
|
|
||||||
Error,
|
|
||||||
UnexcludeBankTransactionsValue
|
|
||||||
>(
|
|
||||||
(value: { ids: Array<number | string> }) =>
|
|
||||||
apiRequest.put(`/cashflow/transactions/unexclude`, { ids: value.ids }),
|
|
||||||
{
|
|
||||||
onSuccess: (res, id) => {
|
|
||||||
onValidateExcludeUncategorizedTransaction(queryClient);
|
|
||||||
},
|
},
|
||||||
...options,
|
...options,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -635,11 +635,4 @@ export default {
|
|||||||
],
|
],
|
||||||
viewBox: '0 0 16 16',
|
viewBox: '0 0 16 16',
|
||||||
},
|
},
|
||||||
|
|
||||||
feed: {
|
|
||||||
path: [
|
|
||||||
'M1.99,11.99c-1.1,0-2,0.9-2,2s0.9,2,2,2s2-0.9,2-2S3.1,11.99,1.99,11.99zM2.99,7.99c-0.55,0-1,0.45-1,1s0.45,1,1,1c1.66,0,3,1.34,3,3c0,0.55,0.45,1,1,1s1-0.45,1-1C7.99,10.23,5.75,7.99,2.99,7.99zM2.99,3.99c-0.55,0-1,0.45-1,1s0.45,1,1,1c3.87,0,7,3.13,7,7c0,0.55,0.45,1,1,1s1-0.45,1-1C11.99,8.02,7.96,3.99,2.99,3.99zM2.99-0.01c-0.55,0-1,0.45-1,1s0.45,1,1,1c6.08,0,11,4.92,11,11c0,0.55,0.45,1,1,1s1-0.45,1-1C15.99,5.81,10.17-0.01,2.99-0.01z',
|
|
||||||
],
|
|
||||||
viewBox: '0 0 16 16',
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ interface StorePlaidState {
|
|||||||
openMatchingTransactionAside: boolean;
|
openMatchingTransactionAside: boolean;
|
||||||
uncategorizedTransactionIdForMatching: number | null;
|
uncategorizedTransactionIdForMatching: number | null;
|
||||||
openReconcileMatchingTransaction: { isOpen: boolean; pending: number };
|
openReconcileMatchingTransaction: { isOpen: boolean; pending: number };
|
||||||
|
|
||||||
uncategorizedTransactionsSelected: Array<number | string>;
|
|
||||||
excludedTransactionsSelected: Array<number | string>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PlaidSlice = createSlice({
|
export const PlaidSlice = createSlice({
|
||||||
@@ -20,8 +17,6 @@ export const PlaidSlice = createSlice({
|
|||||||
isOpen: false,
|
isOpen: false,
|
||||||
pending: 0,
|
pending: 0,
|
||||||
},
|
},
|
||||||
uncategorizedTransactionsSelected: [],
|
|
||||||
excludedTransactionsSelected: [],
|
|
||||||
} as StorePlaidState,
|
} as StorePlaidState,
|
||||||
reducers: {
|
reducers: {
|
||||||
setPlaidId: (state: StorePlaidState, action: PayloadAction<string>) => {
|
setPlaidId: (state: StorePlaidState, action: PayloadAction<string>) => {
|
||||||
@@ -57,46 +52,6 @@ export const PlaidSlice = createSlice({
|
|||||||
state.openReconcileMatchingTransaction.isOpen = false;
|
state.openReconcileMatchingTransaction.isOpen = false;
|
||||||
state.openReconcileMatchingTransaction.pending = 0;
|
state.openReconcileMatchingTransaction.pending = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the selected uncategorized transactions.
|
|
||||||
* @param {StorePlaidState} state
|
|
||||||
* @param {PayloadAction<{ transactionIds: Array<string | number> }>} action
|
|
||||||
*/
|
|
||||||
setUncategorizedTransactionsSelected: (
|
|
||||||
state: StorePlaidState,
|
|
||||||
action: PayloadAction<{ transactionIds: Array<string | number> }>,
|
|
||||||
) => {
|
|
||||||
state.uncategorizedTransactionsSelected = action.payload.transactionIds;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the selected uncategorized transactions.
|
|
||||||
* @param {StorePlaidState} state
|
|
||||||
*/
|
|
||||||
resetUncategorizedTransactionsSelected: (state: StorePlaidState) => {
|
|
||||||
state.uncategorizedTransactionsSelected = [];
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets excluded selected transactions.
|
|
||||||
* @param {StorePlaidState} state
|
|
||||||
* @param {PayloadAction<{ ids: Array<string | number> }>} action
|
|
||||||
*/
|
|
||||||
setExcludedTransactionsSelected: (
|
|
||||||
state: StorePlaidState,
|
|
||||||
action: PayloadAction<{ ids: Array<string | number> }>,
|
|
||||||
) => {
|
|
||||||
state.excludedTransactionsSelected = action.payload.ids;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the excluded selected transactions
|
|
||||||
* @param {StorePlaidState} state
|
|
||||||
*/
|
|
||||||
resetExcludedTransactionsSelected: (state: StorePlaidState) => {
|
|
||||||
state.excludedTransactionsSelected = [];
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -107,10 +62,6 @@ export const {
|
|||||||
closeMatchingTransactionAside,
|
closeMatchingTransactionAside,
|
||||||
openReconcileMatchingTransaction,
|
openReconcileMatchingTransaction,
|
||||||
closeReconcileMatchingTransaction,
|
closeReconcileMatchingTransaction,
|
||||||
setUncategorizedTransactionsSelected,
|
|
||||||
resetUncategorizedTransactionsSelected,
|
|
||||||
setExcludedTransactionsSelected,
|
|
||||||
resetExcludedTransactionsSelected,
|
|
||||||
} = PlaidSlice.actions;
|
} = PlaidSlice.actions;
|
||||||
|
|
||||||
export const getPlaidToken = (state: any) => state.plaid.plaidToken;
|
export const getPlaidToken = (state: any) => state.plaid.plaidToken;
|
||||||
|
|||||||
@@ -128,14 +128,18 @@
|
|||||||
cursor: auto;
|
cursor: auto;
|
||||||
|
|
||||||
&,
|
&,
|
||||||
&::before {
|
&:hover {
|
||||||
height: 15px;
|
height: 15px;
|
||||||
width: 15px;
|
width: 15px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bp4-control.bp4-checkbox input:not(:checked):not(:indeterminate) ~ .bp4-control-indicator{
|
.bp4-control.bp4-checkbox {
|
||||||
box-shadow: inset 0 0 0 1px #C5CBD3;
|
|
||||||
|
input:checked~.bp4-control-indicator,
|
||||||
|
input:indeterminate~.bp4-control-indicator {
|
||||||
|
border-color: #0052ff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.skeleton {
|
.skeleton {
|
||||||
|
|||||||
@@ -208,16 +208,12 @@ $dashboard-views-bar-height: 44px;
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.#{$ns}-minimal.#{$ns}-intent-danger {
|
&.#{$ns}-minimal.#{$ns}-intent-danger {
|
||||||
color: rgb(194, 48, 48);
|
color: #c23030;
|
||||||
|
|
||||||
&:not(.bp4-disabled)
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus {
|
&:focus {
|
||||||
background: rgba(219, 55, 55, 0.1);
|
background: rgba(219, 55, 55, 0.1);
|
||||||
}
|
}
|
||||||
&.bp4-disabled{
|
|
||||||
color: rgb(194, 48, 48, 0.6);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
&.#{$ns}-minimal.#{$ns}-intent-success{
|
&.#{$ns}-minimal.#{$ns}-intent-success{
|
||||||
color: #1c6e42;
|
color: #1c6e42;
|
||||||
|
|||||||
Reference in New Issue
Block a user