fix: minibar consumptions not showing in deposit release form

Wrong column names in SQL query: price_at_time→price_per_unit,
created_at→recorded_at. Also fixed type mismatch priceAtTime→pricePerUnit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-06 15:28:38 +03:00
parent d686f5abe6
commit 5b46175c91
3 changed files with 6 additions and 6 deletions

View File

@@ -428,15 +428,15 @@ const deposit: FastifyPluginAsync = async (fastify) => {
// Get all minibar consumptions from housekeeping tasks for this room
const { rows } = await db.query(
`SELECT mc.quantity, mc.price_at_time,
`SELECT mc.quantity, mc.price_per_unit,
mi.name AS item_name,
(mc.quantity * mc.price_at_time) AS line_total
(mc.quantity * mc.price_per_unit) AS line_total
FROM minibar_consumptions mc
JOIN minibar_items mi ON mi.id = mc.item_id
JOIN housekeeping_tasks ht ON ht.id = mc.task_id
WHERE ht.room_id = $1 AND ht.hotel_id = $2
AND mc.created_at >= (SELECT check_in FROM bookings WHERE id = $3)
ORDER BY mc.created_at ASC`,
AND mc.recorded_at >= (SELECT check_in FROM bookings WHERE id = $3)
ORDER BY mc.recorded_at ASC`,
[bRows[0].room_id, hotelId, bookingId],
)