fix: auto-increment setting parsing. (#453)

This commit is contained in:
Ahmed Bouhuolia
2024-05-17 12:49:04 +02:00
committed by GitHub
parent e380c598d3
commit 2ada57a2b4
4 changed files with 14 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
import { difference } from 'lodash';
import { difference, isEmpty } from 'lodash';
import { Service, Inject } from 'typedi';
import { ServiceError } from '@/exceptions';
import {
@@ -244,16 +244,12 @@ export class CommandManualJournalValidators {
/**
* Validates the manual journal number require.
* @param {string} journalNumber
* @throws {ServiceError(ERRORS.MANUAL_JOURNAL_NO_REQUIRED)}
*/
public validateJournalNoRequireWhenAutoNotEnabled = (
tenantId: number,
journalNumber: string
) => {
// Retrieve the next manual journal number.
const autoIncrmenetEnabled =
this.autoIncrement.autoIncrementEnabled(tenantId);
if (!journalNumber || !autoIncrmenetEnabled) {
if (isEmpty(journalNumber)) {
throw new ServiceError(ERRORS.MANUAL_JOURNAL_NO_REQUIRED);
}
};

View File

@@ -99,7 +99,6 @@ export class CreateManualJournalService {
// Validate manual journal number require when auto-increment not enabled.
this.validator.validateJournalNoRequireWhenAutoNotEnabled(
tenantId,
manualJournalDTO.journalNumber
);
// Validate manual journal uniquiness on the storage.