automate the schedule

This commit is contained in:
Marshal
2026-06-11 19:42:23 +00:00
parent f85c13ce8c
commit cde3e462ba
28 changed files with 1197 additions and 12 deletions

View File

@@ -12,7 +12,7 @@ import * as fs from "fs";
import * as path from "path";
import * as Handlebars from "handlebars";
import { ConfigService } from "@nestjs/config";
import { SchedulingStatus } from "@edr/types";
// import { SchedulingStatus } from "@edr/types";
import { Booking } from "../bookings/entities/booking.entity";
import {
@@ -125,7 +125,13 @@ export class PaymentService {
if (result.status === ProviderPaymentStatus.SUCCEEDED) {
await this.datasource.transaction(async (mg) => {
await mg.update(Booking, { id: resp.refId }, { status: "PAID" })
const booking = await mg.findOne(Booking, { where: { id: resp.refId } })
if (booking?.status === "AWAITING_PAYMENT") {
// Batch flow: mark paid but keep the reservation — the batch settle job allocates it.
await mg.update(Booking, { id: resp.refId }, { paymentStatus: "PAID" })
} else {
await mg.update(Booking, { id: resp.refId }, { status: "PAID" })
}
await mg.update(PaymentEntity, { id: resp.id }, { status: "success" })
})
}