From 6cbc293e2561e71f7c552110822da93b0a2bdbb1 Mon Sep 17 00:00:00 2001 From: Yam ZhengLim Date: Fri, 5 Apr 2024 03:14:14 +0000 Subject: [PATCH] Accommodate new service type and update on-time logic --- models/marts/reporting/rep_exchange__daily_orders.sql | 6 ++++-- models/marts/warehouse/fct_exchange__transaction_orders.sql | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/models/marts/reporting/rep_exchange__daily_orders.sql b/models/marts/reporting/rep_exchange__daily_orders.sql index 9ffc8fc..d7a5a8e 100644 --- a/models/marts/reporting/rep_exchange__daily_orders.sql +++ b/models/marts/reporting/rep_exchange__daily_orders.sql @@ -209,8 +209,9 @@ fct_and_dim_joins AS ( -- On time delivery boolean (CIEF internal SLA) CASE -- On-time boolean is null when order is not complete - WHEN service_type IN ('BA') THEN NULL + WHEN service_type IN ('BA', 'RECEIVED-ON-BEHALF') THEN NULL WHEN transaction_status NOT IN ('UPLOADED_BANK_SLIP') THEN NULL + WHEN order_created_datetime < '2023-01-01' THEN NULL WHEN estimated_order_delivery_datetime_website_sla > orders.operation_uploaded_bank_slip_datetime THEN 1 WHEN estimated_order_delivery_datetime_website_sla < orders.operation_uploaded_bank_slip_datetime THEN 0 ELSE -999 @@ -219,8 +220,9 @@ fct_and_dim_joins AS ( -- On time delivery boolean (Customer Expectation) CASE -- On-time boolean is null when order is not complete - WHEN service_type IN ('BA') THEN NULL + WHEN service_type IN ('BA', 'RECEIVED-ON-BEHALF') THEN NULL WHEN transaction_status NOT IN ('UPLOADED_BANK_SLIP') THEN NULL + WHEN order_created_datetime < '2023-01-01' THEN NULL WHEN estimated_order_delivery_datetime_customer_expectation > orders.operation_uploaded_bank_slip_datetime THEN 1 WHEN estimated_order_delivery_datetime_customer_expectation < orders.operation_uploaded_bank_slip_datetime THEN 0 ELSE -999 diff --git a/models/marts/warehouse/fct_exchange__transaction_orders.sql b/models/marts/warehouse/fct_exchange__transaction_orders.sql index 1a15160..d954e12 100644 --- a/models/marts/warehouse/fct_exchange__transaction_orders.sql +++ b/models/marts/warehouse/fct_exchange__transaction_orders.sql @@ -536,6 +536,8 @@ purchase_order_invoice_status_redefined AS ( CASE WHEN order_status IN ('REFUNDED') THEN 'ORDER_REFUNDED' + WHEN order_status IN ('EXPIRED') + THEN 'ORDER_EXPIRED' WHEN order_status IN ('COMPLETED', 'APPROVED') AND cost_status IS NULL THEN 'PENDING_GENERATE_WHITE_FORM' WHEN order_status IN ('COMPLETED', 'APPROVED') AND cost_status IN ('PENDING_VERIFICATION')