Booking currency updates, audit logging updates

This commit is contained in:
Stephanos A
2026-07-15 00:39:53 +03:00
parent 5aa1892e19
commit 25fdf88a77
26 changed files with 169 additions and 64 deletions

View File

@@ -7,9 +7,10 @@ import {
} from './excess-baggage.controller';
import { PaymentsModule } from '../payments/payments.module';
import { NotificationsModule } from '../notifications/notifications.module';
import { AuditModule } from '../../common/audit.module';
@Module({
imports: [HttpModule, PaymentsModule, NotificationsModule],
imports: [HttpModule, PaymentsModule, NotificationsModule, AuditModule],
controllers: [ExcessBaggageAgentController, ExcessBaggagePublicController],
providers: [ExcessBaggageService],
exports: [ExcessBaggageService],

View File

@@ -5,6 +5,7 @@ import {
Logger,
} from '@nestjs/common';
import { PrismaService } from '../../common/prisma.service';
import { AuditService } from '../../common/audit.service';
import { PaymentClientService } from '../payments/payment-client.service';
import { NotificationsService } from '../notifications/notifications.service';
import { SmsClientService } from '../notifications/sms-client.service';
@@ -30,6 +31,7 @@ export class ExcessBaggageService {
constructor(
private prisma: PrismaService,
private auditService: AuditService,
private paymentClient: PaymentClientService,
private notifications: NotificationsService,
private smsClient: SmsClientService,
@@ -91,6 +93,7 @@ export class ExcessBaggageService {
await this.sendPaymentLink(charge, booking, contactPhone, contactEmail);
}
await this.auditService.log({ action: 'CREATE', entityType: 'ExcessBaggageCharge', entityId: charge.id, newData: { bookingId: dto.bookingId, excessWeightKg: dto.excessWeightKg, totalMinor, status } });
return charge;
}
@@ -208,10 +211,12 @@ export class ExcessBaggageService {
if (['PAID', 'CASH_COLLECTED'].includes(charge.status)) {
throw new BadRequestException('Cannot waive a charge that has already been paid');
}
return this.prisma.excessBaggageCharge.update({
const waived = await this.prisma.excessBaggageCharge.update({
where: { id },
data: { status: 'WAIVED', waivedBy: dto.waivedBy, waivedReason: dto.waivedReason },
});
await this.auditService.log({ action: 'UPDATE', entityType: 'ExcessBaggageCharge', entityId: id, newData: { status: 'WAIVED', waivedBy: dto.waivedBy, waivedReason: dto.waivedReason } });
return waived;
}
async resendLink(id: string) {