refactor(bookings): simplify capacity tracking to use seats

Replace 'pax' booking mode with 'seat'
Consolidate inventory summary to track only seat counts
Update database schema and UI for seat-centric capacity
This commit is contained in:
2026-04-13 08:49:54 +08:00
parent c47d0d287e
commit faa998c7e1
12 changed files with 136 additions and 139 deletions

View File

@@ -7,15 +7,15 @@ export default defineEventHandler(async (event) => {
await requireRole(event, 'super_admin')
const body = await readBody<{
totalTables?: number | string | null
totalSeats?: number | string | null
}>(event)
const input = parseBookingCapacityInput(body)
const summary = await getBookingInventorySummary()
assertBadRequest(
input.totalTables === null || (input.totalTables * 10) >= summary.soldCapacitySeats,
`Total tables cannot be lower than the currently sold capacity of ${summary.soldTables} tables and ${summary.soldSeats} seats`
input.totalSeats === null || input.totalSeats >= summary.soldSeats,
`Total seats cannot be lower than the currently sold count of ${summary.soldSeats} seats`
)
const settings = await updateBookingCapacitySettings(input)

View File

@@ -12,7 +12,7 @@ export default defineEventHandler(async (event): Promise<CreateBookingResponse>
const body = await readBody<{
customerName?: string
customerPhone?: string
bookingMode?: BookingMode
bookingMode?: BookingMode | string | null
quantity?: number
ticketType?: TicketType
personInChargeId?: string

View File

@@ -18,7 +18,7 @@ export default defineEventHandler(async (event) => {
const summary = await getBookingInventorySummary()
if (summary.leftCapacitySeats !== null && existingBooking.seatCount > summary.leftCapacitySeats) {
if (summary.leftSeats !== null && existingBooking.seatCount > summary.leftSeats) {
httpError(409, 'Not enough capacity left to confirm this booking')
}