mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +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(),
|
query('search_keyword').optional({ nullable: true }).isString().trim(),
|
||||||
],
|
],
|
||||||
this.asyncMiddleware(this.getCashflowAccounts),
|
this.asyncMiddleware(this.getCashflowAccounts),
|
||||||
this.catchServiceErrors
|
|
||||||
);
|
);
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
@@ -67,22 +66,4 @@ export default class GetCashflowAccounts extends BaseController {
|
|||||||
next(error);
|
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(
|
public async excludeBankTransaction(
|
||||||
tenantId: number,
|
tenantId: number,
|
||||||
bankTransactionId: number
|
uncategorizedTransactionId: number
|
||||||
) {
|
) {
|
||||||
const { UncategorizeCashflowTransaction } = this.tenancy.models(tenantId);
|
const { UncategorizedCashflowTransaction } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
const oldUncategorizedTransaction =
|
const oldUncategorizedTransaction =
|
||||||
await UncategorizeCashflowTransaction.query()
|
await UncategorizedCashflowTransaction.query()
|
||||||
.findById(bankTransactionId)
|
.findById(uncategorizedTransactionId)
|
||||||
.throwIfNotFound();
|
.throwIfNotFound();
|
||||||
|
|
||||||
validateTransactionNotCategorized(oldUncategorizedTransaction);
|
validateTransactionNotCategorized(oldUncategorizedTransaction);
|
||||||
|
|
||||||
return this.uow.withTransaction(tenantId, async (trx) => {
|
return this.uow.withTransaction(tenantId, async (trx) => {
|
||||||
await UncategorizeCashflowTransaction.query(trx)
|
await UncategorizedCashflowTransaction.query(trx)
|
||||||
.findById(bankTransactionId)
|
.findById(uncategorizedTransactionId)
|
||||||
.patch({
|
.patch({
|
||||||
excluded: true,
|
excluded: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,20 +19,20 @@ export class UnexcludeBankTransaction {
|
|||||||
*/
|
*/
|
||||||
public async unexcludeBankTransaction(
|
public async unexcludeBankTransaction(
|
||||||
tenantId: number,
|
tenantId: number,
|
||||||
bankTransactionId: number
|
uncategorizedTransactionId: number
|
||||||
) {
|
) {
|
||||||
const { UncategorizeCashflowTransaction } = this.tenancy.models(tenantId);
|
const { UncategorizedCashflowTransaction } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
const oldUncategorizedTransaction =
|
const oldUncategorizedTransaction =
|
||||||
await UncategorizeCashflowTransaction.query()
|
await UncategorizedCashflowTransaction.query()
|
||||||
.findById(bankTransactionId)
|
.findById(uncategorizedTransactionId)
|
||||||
.throwIfNotFound();
|
.throwIfNotFound();
|
||||||
|
|
||||||
validateTransactionNotCategorized(oldUncategorizedTransaction);
|
validateTransactionNotCategorized(oldUncategorizedTransaction);
|
||||||
|
|
||||||
return this.uow.withTransaction(tenantId, async (trx) => {
|
return this.uow.withTransaction(tenantId, async (trx) => {
|
||||||
await UncategorizeCashflowTransaction.query(trx)
|
await UncategorizedCashflowTransaction.query(trx)
|
||||||
.findById(bankTransactionId)
|
.findById(uncategorizedTransactionId)
|
||||||
.patch({
|
.patch({
|
||||||
excluded: false,
|
excluded: false,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user