Files
edr-platform/apps/edr-freight-api/src/modules/rule-engine/interfaces/rates.repository.interface.ts
Marshal 0d8c63328a add items per wagon map to cargo types and sync bulk rate units
- Implemented  in the  to manage the physical item capacity for each wagon type.
- Added a new migration to create the  column in the  table.
- Introduced  method in  to update rate units when cargo type unit of measure changes.
- Updated booking calculations to consider items per wagon for break-bulk cargo.
- Refactored various components to utilize the new items fit logic and ensure consistent date formatting across the application.
- Added tests for the new display timezone functionality to ensure consistent date/time representation across different user settings.
2026-08-01 09:55:21 +00:00

41 lines
1.7 KiB
TypeScript

import { PaginatedResponse } from '@edr/types';
import { FindManyOptions } from 'typeorm';
import { ListRatesQueryDto } from '../dto/list-rule-engine-query.dto';
import { Rate } from '../entities/rate.entity';
export interface IRatesRepository {
findById(id: string): Promise<Rate | null>;
findLiveRates(): Promise<Rate[]>;
/**
* LIVE rates with the yard / container / cargo relations eagerly joined, so
* lanes can be rendered with human labels (contract rate schedule). Ordered
* for a stable, readable schedule table.
*/
findLiveRatesDetailed(): Promise<Rate[]>;
findByPattern(pattern: {
rateType: string;
/** Omitted for singly-resolved rates — see the repository implementation. */
rateUnit?: string;
containerTypeId?: string | null;
cargoTypeId?: string | null;
tradeDirection?: string | null;
originYardId?: string | null;
destinationYardId?: string | null;
}): Promise<Rate | null>;
findAll(options?: FindManyOptions<Rate>): Promise<Rate[]>;
findAndCount(options?: FindManyOptions<Rate>): Promise<[Rate[], number]>;
findPaged(query: ListRatesQueryDto): Promise<PaginatedResponse<Rate>>;
create(data: Partial<Rate>): Promise<Rate>;
update(id: string, data: Partial<Rate>): Promise<Rate | null>;
softDelete(id: string): Promise<void>;
/**
* Flip a commodity's PER_TON↔PER_ITEM rates to match its unit of measure.
* Both units bill the same stored quantity — only the name differs — so a
* uom change must rename the units or bookings keep quoting "per ton" for
* counted cargo. Returns the number of rates flipped.
*/
syncBulkQuantityUnit(cargoTypeId: string, unitOfMeasure: 'PER_TON' | 'PER_ITEM'): Promise<number>;
}
export const RATES_REPOSITORY = Symbol('RATES_REPOSITORY');