This commit is contained in:
Marshal
2026-07-17 13:57:59 +00:00
parent 3a697e12f2
commit 6467173c76
12 changed files with 642 additions and 46 deletions

View File

@@ -37,6 +37,8 @@ export class RatesRepository implements IRatesRepository {
containerTypeId?: string | null;
cargoTypeId?: string | null;
tradeDirection?: string | null;
originYardId?: string | null;
destinationYardId?: string | null;
}): Promise<Rate | null> {
const qb = this.repo
.createQueryBuilder('rate')
@@ -59,6 +61,18 @@ export class RatesRepository implements IRatesRepository {
} else {
qb.andWhere('rate.trade_direction IS NULL');
}
if (pattern.originYardId) {
qb.andWhere('rate.origin_yard_id = :originYardId', { originYardId: pattern.originYardId });
} else {
qb.andWhere('rate.origin_yard_id IS NULL');
}
if (pattern.destinationYardId) {
qb.andWhere('rate.destination_yard_id = :destinationYardId', {
destinationYardId: pattern.destinationYardId,
});
} else {
qb.andWhere('rate.destination_yard_id IS NULL');
}
return qb.getOne();
}
@@ -75,6 +89,10 @@ export class RatesRepository implements IRatesRepository {
findPaged(query: ListRatesQueryDto): Promise<PaginatedResponse<Rate>> {
const qb = this.repo
.createQueryBuilder('rate')
// The admin table shows the leg a base-freight rate prices — without the
// yards joined the route columns have only ids to render.
.leftJoinAndSelect('rate.originYard', 'originYard')
.leftJoinAndSelect('rate.destinationYard', 'destinationYard')
.orderBy('rate.createdAt', query.sortOrder ?? 'DESC');
if (query.status) {