Excess baggage payment link changes

This commit is contained in:
Stephanos A
2026-08-05 10:37:49 +03:00
parent fa7fb6b7ea
commit d1a15a82e3
6 changed files with 275 additions and 19 deletions

View File

@@ -110,6 +110,43 @@ describe("Money integrity (Tier-2 direct instantiation)", () => {
expect(walletAfter?.balanceMinor).toBe(0);
});
it("accepts a booking reference when logging an excess baggage charge", async () => {
const passenger = await prisma.passenger.create({ data: {} });
const schedule = await makeSchedule(prisma, passenger.id);
const booking = await prisma.booking.create({
data: {
bookingRef: "BAG-REF-001",
passengerId: passenger.id,
scheduleId: schedule.id,
totalMinor: 30_000,
status: "CONFIRMED",
},
});
await prisma.baggageAllowance.create({
data: { seatClassId: IDS.seatClassLocal, maxWeightKg: 20, maxPiecesCount: 2, excessFeePerKg: 80 },
});
const service = new ExcessBaggageService(
prisma as any,
asyncStub(),
asyncStub(),
asyncStub(),
asyncStub(),
asyncStub(),
);
const charge: any = await service.logCharge({
bookingReference: booking.bookingRef,
excessWeightKg: 2,
collectCash: true,
} as any);
expect(charge.bookingId).toBe(booking.id);
expect(charge.feePerKgMinor).toBe(80);
expect(charge.totalMinor).toBe(160);
});
// ── E1 / E2 ────────────────────────────────────────────────────────────────
it("E1/E2 🔴 excess-baggage uses the OLDEST allowance globally (ignores seat class); fee = rate×kg", async () => {
const passenger = await prisma.passenger.create({ data: {} });