add CUSTOMS type to priority configs and update related logic

This commit is contained in:
Marshal
2026-07-07 16:42:57 +00:00
parent f300600bfa
commit b57840c907
26 changed files with 352 additions and 120 deletions

View File

@@ -17,7 +17,7 @@ export class PriorityConfigsService {
) {}
async findAll(filter: {
type?: 'WAGON' | 'CURRENCY';
type?: 'WAGON' | 'CURRENCY' | 'CUSTOMS';
isActive?: boolean;
page?: number;
pageSize?: number;
@@ -87,12 +87,15 @@ export class PriorityConfigsService {
await this.displayOrder.moveOne(PriorityConfig, 'displayOrder', id, direction);
}
private validateCurrencyField(type: 'WAGON' | 'CURRENCY', currency: string | undefined | null): void {
private validateCurrencyField(
type: 'WAGON' | 'CURRENCY' | 'CUSTOMS',
currency: string | undefined | null,
): void {
if (type === 'CURRENCY' && !currency) {
throw new BadRequestException('currency field is required when type is CURRENCY');
}
if (type === 'WAGON' && currency) {
throw new BadRequestException('currency field must be null when type is WAGON');
if (type !== 'CURRENCY' && currency) {
throw new BadRequestException(`currency field must be null when type is ${type}`);
}
}
}

View File

@@ -76,7 +76,6 @@ export class ServiceTypesService {
includesFirstMile: dto.includesFirstMile ?? false,
includesLastMile: dto.includesLastMile ?? false,
includesCustoms: dto.includesCustoms ?? false,
priorityBonusPoints: dto.priorityBonusPoints ?? 0,
isActive: dto.isActive ?? true,
displayOrder,
});