feat: early check-in / late checkout fees with room-level configuration

- DB migration 016: add early_checkin_fee, late_checkout_fee to rooms table
- Backend rooms: support new fee columns in POST/PATCH
- Backend hotel-settings GET: also returns check_in_time, check_out_time
- Room type + RoomPayload: add earlyCheckinFee, lateCheckoutFee fields
- RoomModal: add fee amount inputs in pricing section
- SettingsPage: add toggles for early_checkin_enabled / late_checkout_enabled
- BookingDetailPanel: on check-in shows fee warning + adds payment record if
  current time is before checkInTime and fee is set on the room; same logic
  for check-out after checkOutTime

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 19:24:36 +03:00
parent 9f1dd0c8c9
commit edd493e24e
8 changed files with 195 additions and 25 deletions

View File

@@ -24,14 +24,18 @@ const hotelSettings: FastifyPluginAsync = async (fastify) => {
const hotelId = await getHotelId(slug)
if (!hotelId) return reply.code(404).send({ error: 'Hotel not found' })
const { rows } = await db.query(
'SELECT key, value FROM hotel_settings WHERE hotel_id = $1',
[hotelId],
)
const [{ rows: settingsRows }, { rows: hotelRows }] = await Promise.all([
db.query('SELECT key, value FROM hotel_settings WHERE hotel_id = $1', [hotelId]),
db.query('SELECT check_in_time, check_out_time FROM hotels WHERE id = $1', [hotelId]),
])
const out: Record<string, unknown> = {}
for (const row of rows) {
for (const row of settingsRows) {
out[row.key] = row.value
}
if (hotelRows[0]) {
out.check_in_time = hotelRows[0].check_in_time
out.check_out_time = hotelRows[0].check_out_time
}
return out
},
)