mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
- rates: min_km/max_km columns, PER_TON_KM unit, ETB|USD currency for last mile - extend UQ_rates_pattern with band start; overlap + shape validation - shared last-mile charge resolver; approve-dialog price estimate endpoint - delivery-fee invoice prices via rules, falls back to vehicle price/km - backoffice: last-mile rate form (mode, container type, band, currency)
43 lines
1.8 KiB
TypeScript
43 lines
1.8 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;
|
|
/** Band start for container last-mile rates; omitted/null elsewhere. */
|
|
minKm?: number | 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');
|