# Brink mapping for `curated.kitchen_orders`

## Main staging sources

- `staging.brink_sales2_orders`
- `staging.brink_kitchen_get_order_bump_times`
- `staging.brink_settings2_get_destinations`

## Mapping groups

- Business property mappings describe how Brink order content is mapped or could be mapped into curated business fields.
- Technical and ETL property mappings describe lineage, source reconciliation, tenant scoping, and ingestion metadata.

## Business property mappings

| Curated Column | Brink Staging Table | Brink Property Path | Current mapping | Status | Notes |
|---|---|---|---|---|---|
| `guid` | `staging.brink_sales2_orders` | `id_encoded` | `NULL` | `Not mapped` | Direct Brink order identifier. |
| `store_guid` | `N/A` | `N/A` | `NULL` | `Not mapped` | The documented Brink staging model does not expose a store GUID on orders. |
| `destination` | `staging.brink_settings2_get_destinations` | `name` | `NULL` | `Not mapped` | Join on `destination_id`. |
| `is_priority` | `N/A` | `N/A` | `NULL` | `Not mapped` | No documented Brink order priority flag exists. |
| `items_count` | `staging.brink_sales2_orders` | `order_count` | `NULL` | `Not mapped` | Brink already exposes a header count field; `order_entries` counts can be used as secondary validation. |
| `order_type` | `staging.brink_settings2_get_destinations` | `name` | `NULL` | `Not mapped` | Destination is the nearest documented service-channel field. |
| `pos_terminal` | `staging.brink_sales2_orders` | `terminal_id` | `NULL` | `Not mapped` | Direct terminal ID. |
| `preparation_time` | `staging.brink_kitchen_get_order_bump_times` | `(first_send_time, bump_time)` | `NULL` | `Not mapped` | Derived kitchen duration from first send to bump. |
| `done` | `staging.brink_sales2_orders` | `is_closed` | `NULL` | `Not mapped` | Direct completion flag. |
| `create_time` | `staging.brink_sales2_orders` | `opened_time` | `NULL` | `Not mapped` | Best available order-create/open timestamp. |
| `is_deleted` | `N/A` | `N/A` | `NULL` | `Not mapped` | Brink order staging does not expose a soft-delete flag. |
| `external_id` | `staging.brink_sales2_orders` | `id_encoded` | `NULL` | `Not mapped` | Best available external string identifier. |
| `guest_table` | `N/A` | `N/A` | `NULL` | `Not mapped` | No table label is documented on the Brink order payload. |
| `update_time` | `staging.brink_sales2_orders` | `modified_time` | `NULL` | `Not mapped` | Direct last-modified timestamp. |
| `phone` | `N/A` | `N/A` | `NULL` | `Not mapped` | No customer phone field is documented on the order payload. |
| `create_local_time` | `N/A` | `N/A` | `NULL` | `Not mapped` | Brink exposes UTC timestamps, not local integer time mirrors. |
| `customer_guid` | `staging.brink_sales2_orders` | `customer_id` | `NULL` | `Not mapped` | Direct customer GUID reference when present. |
| `smart_order_start_time` | `staging.brink_sales2_orders` | `pickup_time` | `NULL` | `Not mapped` | Best available scheduled/future-order start proxy. |
| `order_messages` | `staging.brink_sales2_orders` | `order_additional_details` | `NULL` | `Not mapped` | Best available order-level message/details field. |
| `customer_name` | `N/A` | `N/A` | `NULL` | `Not mapped` | No customer-name field is documented on the order payload. |
| `seat` | `N/A` | `N/A` | `NULL` | `Not mapped` | No seat number field is documented on the Brink order payload. |
| `order_status` | `N/A` | `N/A` | `NULL` | `Not mapped` | Brink exposes status via booleans such as `is_closed`, `is_future_order`, and `is_refund`, not one numeric status code. |
| `store_name` | `N/A` | `N/A` | `NULL` | `Not mapped` | No store name is documented in the Brink order payloads covered here. |
| `pos_terminal_name` | `staging.brink_settings_get_registers` | `name` | `NULL` | `Not mapped` | Resolve terminal name by joining `staging.brink_sales2_orders` on `terminal_id` to `staging.brink_settings_get_registers` on `register_id`. |
| `order_status_name` | `staging.brink_sales2_orders` | `(is_closed, is_future_order, is_refund)` | `NULL` | `Not mapped` | Derived readable status from the available order booleans. |
| `service_channel` | `staging.brink_settings2_get_destinations` | `name` | `NULL` | `Not mapped` | Join on `destination_id`. |
| `business_date` | `staging.brink_sales2_orders` | `business_date` | `NULL` | `Not mapped` | Direct business date. |
| `create_time_utc` | `staging.brink_sales2_orders` | `opened_time` | `NULL` | `Not mapped` | Direct UTC timestamp. |
| `timezone_name` | `N/A` | `N/A` | `NULL` | `Not mapped` | The documented Brink staging model does not expose timezone metadata. |

## Technical and ETL property mappings

| Curated Column | Brink Staging Table | Brink Property Path | Current mapping | Status | Notes |
|---|---|---|---|---|---|
| `kitchen_order_key` | `N/A` | `N/A` | `NULL` | `Not mapped` | Warehouse-generated key. |
| `source_system` | `N/A` | `N/A` | `constant 'brink_pos'` | `Derived constant` | Warehouse constant, not a Brink API field. |
| `source_order_id` | `staging.brink_sales2_orders` | `order_id` | `NULL` | `Not mapped` | Direct Brink source ID. |
| `tenant_key` | `N/A` | `N/A` | `NULL` | `Not mapped` | Warehouse-generated tenant key. |
| `tenant_name` | `N/A` | `N/A` | `parameter @tenant_id` | `ETL context` | Tenant metadata is outside the documented Brink staging payloads. |
| `_etl_batch_id` | staging.brink_sales2_orders | _etl_batch_id | `_etl_batch_id` | `Mapped` | ETL metadata propagated from staging. |
| `_etl_source_type` | staging.brink_sales2_orders | _etl_source_type | `_etl_source_type` | `Mapped` | ETL metadata propagated from staging. |
| `_etl_ingested_at` | staging.brink_sales2_orders | _etl_ingested_at_utc | `_etl_ingested_at_utc AS _etl_ingested_at` | `Mapped` | ETL metadata propagated from staging. |

## Portal and sample validation

| Curated field | Additional validated source | How to use it |
|---|---|---|
| `destination` | `Settings2.GetDestinations -> Destinations[].(Name, Indicator, IsDelivery)` | Portal WSDL and sample response confirm extra destination metadata that can strengthen service-channel normalization without changing the current mapping. |
| `external_id` | `Sales2.GetOrders -> Orders[].IdNoLocation` | Sample orders confirm `IdNoLocation` exists and can be kept as an extra business-facing order identifier. |
| `customer_guid` | `temp/GetOrders_WithKnownBusinessDate_CallsRealBrinkEndpoint_2024-10-06.xml -> Orders[].CustomerId` | Sample payload confirms the field exists, although many rows are null in the example dataset. |
| `order_messages` | `Sales2.GetOrders -> Orders[].OrderAdditionalDetails` | Sample payload confirms the field exists even when null; keep it as an optional JSON/text details source. |
