fix(reservations): reset stale budget category when it no longer exists

If the budget category stored in reservation metadata was deleted, the
form would re-submit it on next save, resurrecting the deleted category.
Now validates against live budget items on form init and falls back to
auto-generation when the stored category is gone.

Closes #442
This commit is contained in:
jubnl
2026-04-05 22:45:34 +02:00
parent f45f56318a
commit 411d8620ba

View File

@@ -141,7 +141,7 @@ export function ReservationModal({ isOpen, onClose, onSave, reservation, days, p
hotel_start_day: (() => { const acc = accommodations.find(a => a.id == reservation.accommodation_id); return acc?.start_day_id || '' })(), hotel_start_day: (() => { const acc = accommodations.find(a => a.id == reservation.accommodation_id); return acc?.start_day_id || '' })(),
hotel_end_day: (() => { const acc = accommodations.find(a => a.id == reservation.accommodation_id); return acc?.end_day_id || '' })(), hotel_end_day: (() => { const acc = accommodations.find(a => a.id == reservation.accommodation_id); return acc?.end_day_id || '' })(),
price: meta.price || '', price: meta.price || '',
budget_category: meta.budget_category || '', budget_category: (meta.budget_category && budgetItems.some(i => i.category === meta.budget_category)) ? meta.budget_category : '',
}) })
} else { } else {
setForm({ setForm({