sp_update_guest_stat


Description

Sync one registration into public.guest_history then recompute that guest’s roll-up columns. Idempotent — safe to call repeatedly for the same register_id (the old additive version double-counted). Called from sp_check_out and sp_cancel_checkout; when the registration is no longer checked out the stay row is removed and the roll-up shrinks accordingly.

Parameters

Name Type Mode
register_id integer IN
guest_id integer OUT
visit_count integer OUT
visit_nights integer OUT
last_arrival date OUT
last_departure date OUT
total_revenue t_money OUT
revenues json OUT

Definition