aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_save_yield_override
Parameters
Name
Type
Mode
i_rate_id
integer
IN
i_rate_date
date
IN
i_amount
t_money
IN
Definition
DECLARE v_min public.t_money; v_rt citext; v_plan citext; v_prev text; BEGIN IF i_amount IS NOT NULL THEN SELECT COALESCE(p.min_rate, rt.min_rate, 0::public.t_money), rt.code, p.code INTO v_min, v_rt, v_plan FROM public.rate_details d JOIN public.rate_plan p ON p.id = d.rateplan_id JOIN public.room_type rt ON rt.id = d.roomtype_id WHERE d.rate_id = i_rate_id; IF i_amount < v_min THEN PERFORM sp_raise_error('10801', 'Room rate lower than the minimum rate are not allowed (%s - %s, Amount = %s, Minimum = %s)', v_rt, v_plan, i_amount::text, v_min::text); END IF; END IF; v_prev := current_setting('rate_log.action_type', true); PERFORM set_config('rate_log.action_type', 'Y', true); IF i_amount IS NULL THEN UPDATE public.rate_daily SET yield_override = NULL WHERE rate_id = i_rate_id AND rate_date = i_rate_date; ELSE INSERT INTO public.rate_daily AS rdy (rate_id, rate_date, yield_override) VALUES (i_rate_id, i_rate_date, i_amount) ON CONFLICT (rate_id, rate_date) DO UPDATE SET yield_override = excluded.yield_override; END IF; PERFORM set_config('rate_log.action_type', COALESCE(v_prev, ''), true); END