mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 18:48:11 +00:00
add CUSTOMS type to priority configs and update related logic
This commit is contained in:
@@ -176,13 +176,12 @@ export class RuleEngineService {
|
||||
}
|
||||
|
||||
const serviceType = await this.serviceTypesRepo.findById(input.serviceTypeId);
|
||||
if (serviceType) {
|
||||
priorityScore += serviceType.priorityBonusPoints;
|
||||
}
|
||||
const includesCustoms = serviceType?.includesCustoms ?? false;
|
||||
|
||||
// Additive priority blocks, each keyed on the booking's total wagon count:
|
||||
// - WAGON rules apply regardless of currency.
|
||||
// - CURRENCY rules apply only when the payment currency matches.
|
||||
// - CUSTOMS rules apply only when the service type includes customs.
|
||||
const priorityConfigs = await this.priorityConfigsRepo.findAllActive();
|
||||
const wagonsInRange = (cfg: { minWagonCount: number; maxWagonCount: number }) =>
|
||||
input.totalWagons >= cfg.minWagonCount &&
|
||||
@@ -191,7 +190,8 @@ export class RuleEngineService {
|
||||
for (const cfg of priorityConfigs) {
|
||||
const applies =
|
||||
cfg.type === 'WAGON' ||
|
||||
(cfg.type === 'CURRENCY' && cfg.currency === input.paymentCurrency);
|
||||
(cfg.type === 'CURRENCY' && cfg.currency === input.paymentCurrency) ||
|
||||
(cfg.type === 'CUSTOMS' && includesCustoms);
|
||||
if (applies && wagonsInRange(cfg)) {
|
||||
priorityScore += cfg.scorePoints;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user