mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: avoid categorize excluded transaction
This commit is contained in:
@@ -12,6 +12,8 @@ import { Knex } from 'knex';
|
||||
import { transformCategorizeTransToCashflow } from './utils';
|
||||
import { CommandCashflowValidator } from './CommandCasflowValidator';
|
||||
import NewCashflowTransactionService from './NewCashflowTransactionService';
|
||||
import { ServiceError } from '@/exceptions';
|
||||
import { ERRORS } from './constants';
|
||||
|
||||
@Service()
|
||||
export class CategorizeCashflowTransaction {
|
||||
@@ -47,6 +49,10 @@ export class CategorizeCashflowTransaction {
|
||||
.findById(uncategorizedTransactionId)
|
||||
.throwIfNotFound();
|
||||
|
||||
// Validate cannot categorize excluded transaction.
|
||||
if (transaction.excluded) {
|
||||
throw new ServiceError(ERRORS.CANNOT_CATEGORIZE_EXCLUDED_TRANSACTION);
|
||||
}
|
||||
// Validates the transaction shouldn't be categorized before.
|
||||
this.commandValidators.validateTransactionShouldNotCategorized(transaction);
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ export const ERRORS = {
|
||||
'UNCATEGORIZED_TRANSACTION_TYPE_INVALID',
|
||||
CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED:
|
||||
'CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED',
|
||||
|
||||
CANNOT_CATEGORIZE_EXCLUDED_TRANSACTION: 'CANNOT_CATEGORIZE_EXCLUDED_TRANSACTION'
|
||||
};
|
||||
|
||||
export enum CASHFLOW_DIRECTION {
|
||||
|
||||
Reference in New Issue
Block a user