From ca403872b3e7b07848d17a8d5bd0833da0bf862c Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Fri, 21 Jun 2024 11:33:03 +0200 Subject: [PATCH] feat: exclude bank transaction --- .../Cashflow/GetCashflowAccounts.ts | 19 ------------------- .../Banking/Exclude/ExcludeBankTransaction.ts | 12 ++++++------ .../Exclude/UnexcludeBankTransaction.ts | 12 ++++++------ 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/packages/server/src/api/controllers/Cashflow/GetCashflowAccounts.ts b/packages/server/src/api/controllers/Cashflow/GetCashflowAccounts.ts index 559a5f4f2..6e0d2dfec 100644 --- a/packages/server/src/api/controllers/Cashflow/GetCashflowAccounts.ts +++ b/packages/server/src/api/controllers/Cashflow/GetCashflowAccounts.ts @@ -31,7 +31,6 @@ export default class GetCashflowAccounts extends BaseController { query('search_keyword').optional({ nullable: true }).isString().trim(), ], this.asyncMiddleware(this.getCashflowAccounts), - this.catchServiceErrors ); return router; } @@ -67,22 +66,4 @@ export default class GetCashflowAccounts extends BaseController { next(error); } }; - - /** - * Catches the service errors. - * @param {Error} error - Error. - * @param {Request} req - Request. - * @param {Response} res - Response. - * @param {NextFunction} next - - */ - private catchServiceErrors( - error, - req: Request, - res: Response, - next: NextFunction - ) { - if (error instanceof ServiceError) { - } - next(error); - } } diff --git a/packages/server/src/services/Banking/Exclude/ExcludeBankTransaction.ts b/packages/server/src/services/Banking/Exclude/ExcludeBankTransaction.ts index 7d23a0f22..39d53d6cd 100644 --- a/packages/server/src/services/Banking/Exclude/ExcludeBankTransaction.ts +++ b/packages/server/src/services/Banking/Exclude/ExcludeBankTransaction.ts @@ -19,20 +19,20 @@ export class ExcludeBankTransaction { */ public async excludeBankTransaction( tenantId: number, - bankTransactionId: number + uncategorizedTransactionId: number ) { - const { UncategorizeCashflowTransaction } = this.tenancy.models(tenantId); + const { UncategorizedCashflowTransaction } = this.tenancy.models(tenantId); const oldUncategorizedTransaction = - await UncategorizeCashflowTransaction.query() - .findById(bankTransactionId) + await UncategorizedCashflowTransaction.query() + .findById(uncategorizedTransactionId) .throwIfNotFound(); validateTransactionNotCategorized(oldUncategorizedTransaction); return this.uow.withTransaction(tenantId, async (trx) => { - await UncategorizeCashflowTransaction.query(trx) - .findById(bankTransactionId) + await UncategorizedCashflowTransaction.query(trx) + .findById(uncategorizedTransactionId) .patch({ excluded: true, }); diff --git a/packages/server/src/services/Banking/Exclude/UnexcludeBankTransaction.ts b/packages/server/src/services/Banking/Exclude/UnexcludeBankTransaction.ts index 159fe373a..9dd23c1a6 100644 --- a/packages/server/src/services/Banking/Exclude/UnexcludeBankTransaction.ts +++ b/packages/server/src/services/Banking/Exclude/UnexcludeBankTransaction.ts @@ -19,20 +19,20 @@ export class UnexcludeBankTransaction { */ public async unexcludeBankTransaction( tenantId: number, - bankTransactionId: number + uncategorizedTransactionId: number ) { - const { UncategorizeCashflowTransaction } = this.tenancy.models(tenantId); + const { UncategorizedCashflowTransaction } = this.tenancy.models(tenantId); const oldUncategorizedTransaction = - await UncategorizeCashflowTransaction.query() - .findById(bankTransactionId) + await UncategorizedCashflowTransaction.query() + .findById(uncategorizedTransactionId) .throwIfNotFound(); validateTransactionNotCategorized(oldUncategorizedTransaction); return this.uow.withTransaction(tenantId, async (trx) => { - await UncategorizeCashflowTransaction.query(trx) - .findById(bankTransactionId) + await UncategorizedCashflowTransaction.query(trx) + .findById(uncategorizedTransactionId) .patch({ excluded: false, });