mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: exclude bank transaction
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user