feat(nestjs): migrate to NestJS

This commit is contained in:
Ahmed Bouhuolia
2025-04-07 11:51:24 +02:00
parent f068218a16
commit 55fcc908ef
3779 changed files with 631 additions and 195332 deletions

View File

@@ -0,0 +1,24 @@
import { IManualJournalDTO } from '@/modules/ManualJournals/types/ManualJournals.types';
import { IManualJournalEntryDTO } from '@/modules/ManualJournals/types/ManualJournals.types';
import { ERRORS } from './constants';
import { Injectable } from '@nestjs/common';
import { ServiceError } from '@/modules/Items/ServiceError';
@Injectable()
export class ManualJournalBranchesValidator {
/**
* Validates the DTO entries should have branch id.
* @param {IManualJournalDTO} manualJournalDTO
*/
public validateEntriesHasBranchId = async (
manualJournalDTO: IManualJournalDTO,
) => {
const hasNoIdEntries = manualJournalDTO.entries.filter(
(entry: IManualJournalEntryDTO) =>
!entry.branchId && !manualJournalDTO.branchId,
);
if (hasNoIdEntries.length > 0) {
throw new ServiceError(ERRORS.MANUAL_JOURNAL_ENTRIES_HAVE_NO_BRANCH_ID);
}
};
}