mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix: validate exclude and unexclude uncategorized transaction
This commit is contained in:
@@ -3,6 +3,8 @@ import UncategorizedCashflowTransaction from '@/models/UncategorizedCashflowTran
|
||||
|
||||
const ERRORS = {
|
||||
TRANSACTION_ALREADY_CATEGORIZED: 'TRANSACTION_ALREADY_CATEGORIZED',
|
||||
TRANSACTION_ALREADY_EXCLUDED: 'TRANSACTION_ALREADY_EXCLUDED',
|
||||
TRANSACTION_NOT_EXCLUDED: 'TRANSACTION_NOT_EXCLUDED',
|
||||
};
|
||||
|
||||
export const validateTransactionNotCategorized = (
|
||||
@@ -12,3 +14,19 @@ export const validateTransactionNotCategorized = (
|
||||
throw new ServiceError(ERRORS.TRANSACTION_ALREADY_CATEGORIZED);
|
||||
}
|
||||
};
|
||||
|
||||
export const validateTransactionNotExcluded = (
|
||||
transaction: UncategorizedCashflowTransaction
|
||||
) => {
|
||||
if (transaction.isExcluded) {
|
||||
throw new ServiceError(ERRORS.TRANSACTION_ALREADY_EXCLUDED);
|
||||
}
|
||||
};
|
||||
|
||||
export const validateTransactionShouldBeExcluded = (
|
||||
transaction: UncategorizedCashflowTransaction
|
||||
) => {
|
||||
if (!transaction.isExcluded) {
|
||||
throw new ServiceError(ERRORS.TRANSACTION_NOT_EXCLUDED);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user