Merged PR 5001: Payouts amounts attributed to Bookings
# Description Adds monetary value in terms of payouts for further understanding of the potential impact on improving the flagging. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #29284
This commit is contained in:
parent
e981cc1739
commit
4922fce426
2 changed files with 81 additions and 3 deletions
|
|
@ -26,7 +26,7 @@ with
|
|||
deduplicated_incidents as (
|
||||
select
|
||||
id_booking,
|
||||
sum(accepted_amount_in_gbp) as booking_accepted_amount_in_gbp,
|
||||
sum(submitted_payout_amount_in_gbp) as submitted_payout_amount_in_gbp,
|
||||
case
|
||||
when sum(submitted_payout_amount_in_gbp) > 0 then true else false
|
||||
end as has_submitted_payout,
|
||||
|
|
@ -89,7 +89,10 @@ with
|
|||
ndpb.is_booking_flagged_as_risk,
|
||||
case when di.id_booking is not null then true else false end as has_claim,
|
||||
coalesce(di.has_submitted_payout, false) as has_submitted_payout,
|
||||
coalesce(di.is_incident_finished, false) as is_incident_finished
|
||||
coalesce(di.is_incident_finished, false) as is_incident_finished,
|
||||
coalesce(
|
||||
submitted_payout_amount_in_gbp, 0
|
||||
) as submitted_payout_amount_in_gbp
|
||||
from new_dash_protected_bookings ndpb
|
||||
left join deduplicated_incidents di on ndpb.id_booking = di.id_booking
|
||||
)
|
||||
|
|
@ -216,5 +219,42 @@ select
|
|||
and has_submitted_payout
|
||||
and has_claim
|
||||
and is_incident_finished
|
||||
) as completed_no_risk_with_submitted_payout_bookings
|
||||
) as completed_no_risk_with_submitted_payout_bookings,
|
||||
|
||||
-- ADDITIONAL PAYOUT INPUT - FOR CONFUSION MATRIX 2: RISK vs. PAYOUT --
|
||||
-- Total amount paid for all bookings
|
||||
sum(submitted_payout_amount_in_gbp) as total_amount_paid_in_gbp,
|
||||
|
||||
-- Amount paid from completed bookings
|
||||
sum(submitted_payout_amount_in_gbp) filter (
|
||||
where is_booking_completed
|
||||
) as completed_amount_paid_in_gbp,
|
||||
|
||||
-- Amount paid from not completed bookings
|
||||
sum(submitted_payout_amount_in_gbp) filter (
|
||||
where not is_booking_completed
|
||||
) as not_completed_amount_paid_in_gbp,
|
||||
|
||||
-- Completed with Risk, Incident is finished and with Submitted Payout --
|
||||
-- True Positives - How much did we pay?
|
||||
sum(submitted_payout_amount_in_gbp) filter (
|
||||
where
|
||||
is_booking_completed
|
||||
and is_booking_flagged_as_risk
|
||||
and has_claim
|
||||
and has_submitted_payout
|
||||
and is_incident_finished
|
||||
) as completed_risk_with_submitted_payout_amount_paid_in_gbp,
|
||||
|
||||
-- Completed without Risk and with Submitted Payout
|
||||
-- False Negative - How much did we pay?
|
||||
sum(submitted_payout_amount_in_gbp) filter (
|
||||
where
|
||||
is_booking_completed
|
||||
and not is_booking_flagged_as_risk
|
||||
and has_submitted_payout
|
||||
and has_claim
|
||||
and is_incident_finished
|
||||
) as completed_no_risk_with_submitted_payout_amount_paid_in_gbp
|
||||
|
||||
from bookings_with_incidents
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue