diff --git a/models/intermediate/core/int_core__vr_check_in_cover.sql b/models/intermediate/core/int_core__vr_check_in_cover.sql index 5abf059..d4f4ef4 100644 --- a/models/intermediate/core/int_core__vr_check_in_cover.sql +++ b/models/intermediate/core/int_core__vr_check_in_cover.sql @@ -22,90 +22,100 @@ with amount_without_taxes_in_gbp from {{ ref("int_core__guest_journey_payments") }} where product_name = 'CHECKINCOVER' and payment_status in ('PAID', 'REFUNDED') + ), + pre_feature_flag_verification_requests as ( + select + vr.id_verification_request, + vr.uuid_verification_request, + vr.id_verification_set, + vr.id_superhog_verified_set, + vr.id_payment_validation_set, + vr.id_user_guest, + vr.id_user_host, + b.id_booking, + b.id_accommodation, + vr.is_verification_request_complete, + ( + p.total_amount_in_txn_currency is not null + and not b.check_in_sits_in_future + ) as is_past_check_in, + ( + p.total_amount_in_txn_currency is not null + and b.check_in_sits_in_future + and vr.is_verification_request_complete + ) as is_awaiting_check_in, + p.total_amount_in_txn_currency is not null as cover_was_purchased, + ( + p.total_amount_in_txn_currency is null + and vr.is_verification_request_complete + ) as cover_was_rejected, + vr.verification_url, + vr.callback_url, + vr.redirect_url, + vr.logo, + gu.email as guest_email, + gu.last_name as last_name, + gu.first_name as first_name, + gu.phone_number as guest_phone_number, + vr.telephone_code, + vr.guest_phone_number_2, + b.check_in_at_utc, + b.check_in_date_utc, + b.check_out_at_utc, + b.check_out_date_utc, + vr.verification_estimated_started_at_utc as verification_start_at_utc, + vr.verification_estimated_started_date_utc as verification_start_date_utc, + vr.verification_estimated_completed_at_utc as verification_end_at_utc, + vr.verification_estimated_completed_date_utc as verification_end_date_utc, + vr.link_used_at_utc, + vr.link_used_date_utc, + vr.expire_at_utc, + vr.expire_date_utc, + vr.is_deleted, + vr.redirect_name, + vr.id_one_step_link, + vr.success_message, + vr.summary, + vr.rejection_reason, + vr.has_switched_to_mobile, + vr.is_verifier_rejected, + vr.config, + vr.metadata, + vr.created_at_utc, + vr.created_date_utc, + vr.updated_at_utc, + vr.updated_date_utc, + vr.dwh_extracted_at_utc, + p.currency, + p.payment_status, + p.payment_paid_date_utc, + p.total_amount_in_txn_currency, + p.amount_without_taxes_in_txn_currency, + p.total_amount_in_gbp, + p.amount_without_taxes_in_gbp, + ccp.checkin_cover_limit_amount_local_curr, + ( + ccp.checkin_cover_limit_amount_local_curr + * (p.total_amount_in_gbp / p.total_amount_in_txn_currency) + )::numeric(18, 4) as checkin_cover_limit_amount_in_gbp + from int_core__verification_requests vr + left join + int_core__bookings b + on vr.id_verification_request = b.id_verification_request + left join + stg_core__verification_set_to_verification_type vstvt + on vr.id_verification_set = vstvt.id_verification_set + left join + check_in_cover_payments p + on vr.id_verification_request = p.id_verification_request + left join + int_core__check_in_cover_prices ccp + on p.currency = ccp.local_currency_iso_4217 + left join int_core__unified_user gu on gu.id_user = vr.id_user_guest + -- 15 is Check-in cover. + -- Adding this condition results in only keeping guest journeys that offered the + -- check-in cover + where vstvt.id_verification_type = 15 ) -select - vr.id_verification_request, - vr.uuid_verification_request, - vr.id_verification_set, - vr.id_superhog_verified_set, - vr.id_payment_validation_set, - vr.id_user_guest, - vr.id_user_host, - b.id_booking, - b.id_accommodation, - vr.is_verification_request_complete, - ( - p.total_amount_in_txn_currency is not null and not b.check_in_sits_in_future - ) as is_past_check_in, - ( - p.total_amount_in_txn_currency is not null - and b.check_in_sits_in_future - and vr.is_verification_request_complete - ) as is_awaiting_check_in, - p.total_amount_in_txn_currency is not null as cover_was_purchased, - ( - p.total_amount_in_txn_currency is null and vr.is_verification_request_complete - ) as cover_was_rejected, - vr.verification_url, - vr.callback_url, - vr.redirect_url, - vr.logo, - gu.email as guest_email, - gu.last_name as last_name, - gu.first_name as first_name, - gu.phone_number as guest_phone_number, - vr.telephone_code, - vr.guest_phone_number_2, - b.check_in_at_utc, - b.check_in_date_utc, - b.check_out_at_utc, - b.check_out_date_utc, - vr.verification_estimated_started_at_utc as verification_start_at_utc, - vr.verification_estimated_started_date_utc as verification_start_date_utc, - vr.verification_estimated_completed_at_utc as verification_end_at_utc, - vr.verification_estimated_completed_date_utc as verification_end_date_utc, - vr.link_used_at_utc, - vr.link_used_date_utc, - vr.expire_at_utc, - vr.expire_date_utc, - vr.is_deleted, - vr.redirect_name, - vr.id_one_step_link, - vr.success_message, - vr.summary, - vr.rejection_reason, - vr.has_switched_to_mobile, - vr.is_verifier_rejected, - vr.config, - vr.metadata, - vr.created_at_utc, - vr.created_date_utc, - vr.updated_at_utc, - vr.updated_date_utc, - vr.dwh_extracted_at_utc, - p.currency, - p.payment_status, - p.payment_paid_date_utc, - p.total_amount_in_txn_currency, - p.amount_without_taxes_in_txn_currency, - p.total_amount_in_gbp, - p.amount_without_taxes_in_gbp, - ccp.checkin_cover_limit_amount_local_curr, - ( - ccp.checkin_cover_limit_amount_local_curr - * (p.total_amount_in_gbp / p.total_amount_in_txn_currency) - )::numeric(18, 4) as checkin_cover_limit_amount_in_gbp -from int_core__verification_requests vr -left join int_core__bookings b on vr.id_verification_request = b.id_verification_request -left join - stg_core__verification_set_to_verification_type vstvt - on vr.id_verification_set = vstvt.id_verification_set -left join - check_in_cover_payments p on vr.id_verification_request = p.id_verification_request -left join - int_core__check_in_cover_prices ccp on p.currency = ccp.local_currency_iso_4217 -left join int_core__unified_user gu on gu.id_user = vr.id_user_guest --- 15 is Check-in cover. --- Adding this condition results in only keeping guest journeys that offered the --- check-in cover -where vstvt.id_verification_type = 15 +select * +from pre_feature_flag_verification_requests