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:
@@ -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],
|
||||
)
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ function DepositWidget({ slug, bookingId }: { slug: string; bookingId: string })
|
||||
const [yookassaMsg, setYookassaMsg] = useState<string | null>(null)
|
||||
const [releaseError, setReleaseError] = useState<string | null>(null)
|
||||
const [presets, setPresets] = useState<DepositPreset[]>([])
|
||||
const [minibarItems, setMinibarItems] = useState<Array<{ itemName: string; quantity: number; priceAtTime: number; lineTotal: number }>>([])
|
||||
const [minibarItems, setMinibarItems] = useState<Array<{ itemName: string; quantity: number; pricePerUnit: number; lineTotal: number }>>([])
|
||||
const [minibarTotal, setMinibarTotal] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -773,7 +773,7 @@ export const api = {
|
||||
req<void>('DELETE', `/api/hotels/${slug}/bookings/${bookingId}/deposit`),
|
||||
|
||||
getMinibarForBooking: (slug: string, bookingId: string) =>
|
||||
req<{ items: Array<{ itemName: string; quantity: number; priceAtTime: number; lineTotal: number }>; total: number }>(
|
||||
req<{ items: Array<{ itemName: string; quantity: number; pricePerUnit: number; lineTotal: number }>; total: number }>(
|
||||
'GET', `/api/hotels/${slug}/bookings/${bookingId}/deposit/minibar`,
|
||||
),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user