Package inquiry, UAT related update

This commit is contained in:
Stephanos A
2026-06-26 13:57:26 +03:00
parent eefbe6e8ed
commit 86c7b2e4eb
23 changed files with 648 additions and 93 deletions

View File

@@ -35,12 +35,16 @@ export class ExcessBaggageAgentController {
getAll(
@Query('status') status?: string,
@Query('bookingRef') bookingRef?: string,
@Query('dateFrom') dateFrom?: string,
@Query('dateTo') dateTo?: string,
@Query('page') page?: string,
@Query('pageSize') pageSize?: string,
) {
return this.service.getAll({
status,
bookingRef,
dateFrom,
dateTo,
page: page ? parseInt(page) : undefined,
pageSize: pageSize ? parseInt(pageSize) : undefined,
});

View File

@@ -7,6 +7,8 @@ import {
import { PrismaService } from '../../common/prisma.service';
import { PaymentClientService } from '../payments/payment-client.service';
import { NotificationsService } from '../notifications/notifications.service';
import { SmsClientService } from '../notifications/sms-client.service';
import { EmailClientService } from '../notifications/email-client.service';
import {
LogExcessBaggageDto,
WaiveChargeDto,
@@ -30,6 +32,8 @@ export class ExcessBaggageService {
private prisma: PrismaService,
private paymentClient: PaymentClientService,
private notifications: NotificationsService,
private smsClient: SmsClientService,
private emailClient: EmailClientService,
) {}
async logCharge(dto: LogExcessBaggageDto) {
@@ -101,23 +105,27 @@ export class ExcessBaggageService {
const amountStr = (charge.totalMinor / 100).toFixed(2);
const msg = `EDR: Excess baggage charge of ${amountStr} ETB for booking ${booking.bookingRef}. Pay here: ${payUrl} (valid 30 min)`;
const recipient = phone ?? email ?? booking.passengerId;
try {
await this.notifications['deliverSms'](recipient, msg);
} catch (err) {
this.logger.warn(`SMS send failed for excess baggage charge ${charge.id}: ${err}`);
if (phone) {
try {
await this.smsClient.sendSms({ to: phone, message: msg });
} catch (err) {
this.logger.warn(`SMS send failed for excess baggage charge ${charge.id}: ${err}`);
}
}
if (email) {
try {
await this.notifications['deliverEmail'](
recipient,
`EDR — Excess baggage payment required (${booking.bookingRef})`,
msg,
);
await this.emailClient.sendEmail({
to: email,
subject: `EDR — Excess baggage payment required (${booking.bookingRef})`,
text: msg,
});
} catch (err) {
this.logger.warn(`Email send failed for excess baggage charge ${charge.id}: ${err}`);
}
}
if (!phone && !email) {
this.logger.warn(`No contact info to send excess baggage payment link for charge ${charge.id}`);
}
}
async getCharge(id: string) {
@@ -227,14 +235,22 @@ export class ExcessBaggageService {
async getAll(filters: {
status?: string;
bookingRef?: string;
dateFrom?: string;
dateTo?: string;
page?: number;
pageSize?: number;
}) {
const { status, bookingRef, page = 1, pageSize = 20 } = filters;
const { status, bookingRef, dateFrom, dateTo, page = 1, pageSize = 20 } = filters;
const skip = (page - 1) * pageSize;
const where: any = {};
if (status) where.status = status;
if (bookingRef) where.booking = { bookingRef: { contains: bookingRef, mode: 'insensitive' } };
if (dateFrom || dateTo) {
where.createdAt = {
...(dateFrom ? { gte: new Date(dateFrom) } : {}),
...(dateTo ? { lte: new Date(new Date(dateTo).setHours(23, 59, 59, 999)) } : {}),
};
}
const [items, total] = await Promise.all([
this.prisma.excessBaggageCharge.findMany({