Columns
| Column | Type | Size | Nulls | Auto | Default | Children | Parents | Comments | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| id | int4 | 10 | √ | null |
|
|
|||||
| date_ref | date | 13 | null |
|
|
||||||
| status | text | 2147483647 | 'NEW'::text |
|
|
Pickup event type: NEW = new booking, RBK = rebook, RBN = rebook-in, CXL = cancelled, NOS = no-show, AMD = amendment. AMD rows carry signed deltas (room_qty and every revenue column can be negative), so any SUM over this table must include them rather than filtering to NEW. |
|||||
| booking_id | int4 | 10 | null |
|
|
||||||
| booking_item | int4 | 10 | null |
|
|
||||||
| roomtype_id | int4 | 10 | √ | null |
|
|
|||||
| bedtype_id | int4 | 10 | √ | null |
|
|
|||||
| book_type | bpchar | 1 | √ | null |
|
|
|||||
| house_used | bool | 1 | √ | false |
|
|
|||||
| comp | bool | 1 | √ | false |
|
|
|||||
| day_used | bool | 1 | √ | false |
|
|
|||||
| rateplan_id | int4 | 10 | √ | null |
|
|
|||||
| mealtype_id | int4 | 10 | √ | null |
|
|
|||||
| stay_type | bpchar | 1 | √ | null |
|
|
|||||
| arrival | date | 13 | √ | null |
|
|
|||||
| departure | date | 13 | √ | null |
|
|
|||||
| adult | int2 | 5 | √ | 0 |
|
|
|||||
| child | int2 | 5 | √ | 0 |
|
|
|||||
| infant | int2 | 5 | √ | 0 |
|
|
|||||
| extra_adult | int2 | 5 | √ | 0 |
|
|
|||||
| extra_child | int2 | 5 | √ | 0 |
|
|
|||||
| extra_infant | int2 | 5 | √ | 0 |
|
|
|||||
| room_rate | t_money | 15,2 | √ | null |
|
|
Arrival-night rate only – sp_calc_rsv_pickup joins booking_rates on br.charge_date = bi.arrival. It therefore misrepresents variable nightly rates, which is why rate_revenue was added (V20260916.10) as the REVENUE_CALC_TYPE = 0 basis. Kept as the display rate and as the legacy fallback when rate_revenue IS NULL. |
||||
| extra_adult_rate | t_money | 15,2 | √ | null |
|
|
|||||
| extra_child_rate | t_money | 15,2 | √ | null |
|
|
|||||
| extra_infant_rate | t_money | 15,2 | √ | null |
|
|
|||||
| room_charge | t_money | 15,2 | √ | null |
|
|
REVENUE_CALC_TYPE = 1 basis for pickup/pace, copied from booking_items.room_charge. PER SINGLE ROOM: booking_items.room_charge is the total for one room, so readers must multiply by abs(COALESCE(room_qty, 1)) (V20260918.10.1). CAREFUL: despite the name this is NOT the room-only figure that recapitulate.individual_revenue, room_summary.room_charge and guest_history.room_revenue hold – it is the SUM of nightly rates and, for comp/zero-rate items, it also adds the meal amount, so it tracks the type-0 basis rather than type 1. Kept as the frozen figure shown on pickup detail screens and as the last-resort fallback. The real bases are rate_revenue (0), revenue_room_gross (1) and revenue_room_net (2). |
||||
| extra_charge | t_money | 15,2 | √ | null |
|
|
|||||
| other_charge | t_money | 15,2 | √ | null |
|
|
|||||
| total_charge | t_money | 15,2 | √ | null |
|
|
|||||
| promotion_id | int4 | 10 | √ | null |
|
|
|||||
| channel_id | int4 | 10 | √ | null |
|
|
|||||
| origin_id | int4 | 10 | √ | null |
|
|
|||||
| sales_id | int4 | 10 | √ | null |
|
|
|||||
| market_id | int4 | 10 | √ | null |
|
|
|||||
| rsvtype_id | int4 | 10 | √ | null |
|
|
|||||
| lead_time | int4 | 10 | √ | 0 |
|
|
|||||
| return_guest | bool | 1 | √ | false |
|
|
|||||
| guest_id | int4 | 10 | √ | null |
|
|
|||||
| guest_sex | bpchar | 1 | √ | null |
|
|
|||||
| guest_age | int4 | 10 | √ | null |
|
|
|||||
| guest_nation_id | int4 | 10 | √ | null |
|
|
|||||
| guest_lang_id | int4 | 10 | √ | null |
|
|
|||||
| guest_country_id | int4 | 10 | √ | null |
|
|
|||||
| guest_country_res_id | int4 | 10 | √ | null |
|
|
|||||
| guest_city_id | int4 | 10 | √ | null |
|
|
|||||
| guest_occupation_id | int4 | 10 | √ | null |
|
|
|||||
| guest_vip_id | int4 | 10 | √ | null |
|
|
|||||
| guest_name | text | 2147483647 | √ | null |
|
|
|||||
| guest_member_code | text | 2147483647 | √ | null |
|
|
|||||
| room_qty | int2 | 5 | √ | null |
|
|
|||||
| revenue_room_net | t_money | 15,2 | √ | null |
|
|
REVENUE_CALC_TYPE = 2 basis for this pickup event. Room only and NET of every itemizer on the room-charge department, from SUM(sp_booking_rates_breakdown.room_net) over the booking item’s nights. It is revenue_room_gross with every itemizer stripped, which is not the same as subtracting room_service and room_tax when the department carries more. This is NOT room_charge minus tax: room_charge mirrors booking_items.room_charge, which is the sum of nightly rates and still includes meals, so it is not room-only at all. Negative on status = ‘AMD’ rows, mirroring rate_revenue. NULL = no booking_rates rows left to derive it from (cancelled/no-show history); readers use COALESCE(revenue_room_net, revenue_room_gross, room_charge). PER SINGLE ROOM: readers multiply by abs(COALESCE(room_qty, 1)) (V20260918.10.1). |
||||
| rate_revenue | t_money | 15,2 | √ | null |
|
|
Frozen SUM(booking_rates.room_rate) for the booking item at pickup time. REVENUE_CALC_TYPE = 0 basis (Gross Rate: room, meals and inclusions); unlike legacy room_rate, this supports variable nightly rates. Negative on status = ‘AMD’ rows. See also revenue_room_gross (type 1) and revenue_room_net (type 2). PER SINGLE ROOM: readers multiply by abs(COALESCE(room_qty, 1)) (V20260918.10.1). |
||||
| revenue_room_gross | t_money | 15,2 | √ | null |
|
|
REVENUE_CALC_TYPE = 1 basis for this pickup event: Gross Room – room only, with every itemizer on the room-charge department still included, from SUM(sp_booking_rates_breakdown.room) over the booking item’s nights. It is NOT revenue_room_net + room_service + room_tax: those two columns name only the service and tax slices, and a department may carry more (sample’s room department is {SER,VAT,LOC}). revenue_room_net is the authoritative net figure. Negative on status = ‘AMD’ rows, mirroring rate_revenue. NULL = no booking_rates rows left to derive it from (cancelled/no-show history); readers use COALESCE(revenue_room_gross, room_charge). PER SINGLE ROOM: readers multiply by abs(COALESCE(room_qty, 1)) (V20260918.10.1). |
Indexes
| Constraint Name | Type | Sort | Column(s) |
|---|---|---|---|
| pk_rsv_pickup | Primary key | Asc | id |
| idx_rsv_pickup_bedtype_id | Performance | Asc | bedtype_id |
| idx_rsv_pickup_channel_id | Performance | Asc | channel_id |
| idx_rsv_pickup_date_ref | Performance | Asc | date_ref |
| idx_rsv_pickup_guest_city_id | Performance | Asc | guest_city_id |
| idx_rsv_pickup_guest_country_id | Performance | Asc | guest_country_id |
| idx_rsv_pickup_guest_country_res_id | Performance | Asc | guest_country_res_id |
| idx_rsv_pickup_guest_lang_id | Performance | Asc | guest_lang_id |
| idx_rsv_pickup_guest_nation_id | Performance | Asc | guest_nation_id |
| idx_rsv_pickup_guest_occupation_id | Performance | Asc | guest_occupation_id |
| idx_rsv_pickup_guest_vip_id | Performance | Asc | guest_vip_id |
| idx_rsv_pickup_market_id | Performance | Asc | market_id |
| idx_rsv_pickup_mealtype_id | Performance | Asc | mealtype_id |
| idx_rsv_pickup_origin_id | Performance | Asc | origin_id |
| idx_rsv_pickup_promotion_id | Performance | Asc | promotion_id |
| idx_rsv_pickup_rateplan_id | Performance | Asc | rateplan_id |
| idx_rsv_pickup_roomtype_id | Performance | Asc | roomtype_id |
| idx_rsv_pickup_rsvtype_id | Performance | Asc | rsvtype_id |
| idx_rsv_pickup_sales_id | Performance | Asc | sales_id |
| idx_rsv_pickup_status | Performance | Asc | status |
| unq_rsv_pickup | Must be unique | Asc/Asc/Asc | date_ref + booking_item + status |



