Merged PR 5010: Adds missing payout amount computation for full consistency

# Description

Technically, a payout can be submitted while not in a finished incident state. Likely next step from res perspective is just to close the ticket.

This PR just adds two new fields for completion and consistency, and fixes the completion test so it makes sense.

# 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.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.
This commit is contained in:
Oriol Roqué Paniagua 2025-04-17 08:15:37 +00:00
parent 84eda4554f
commit 6e354e7df1
2 changed files with 36 additions and 0 deletions

View file

@ -235,6 +235,24 @@ select
where not is_booking_completed
) as not_completed_amount_paid_in_gbp,
-- Amount paid from completed bookings with finished incidents
sum(submitted_payout_amount_in_gbp) filter (
where
is_booking_completed
and has_claim
and is_incident_finished
and has_submitted_payout
) as completed_finished_incidents_amount_paid_in_gbp,
-- Amount paid from completed bookings with awaiting finish incidents
sum(submitted_payout_amount_in_gbp) filter (
where
is_booking_completed
and has_claim
and not is_incident_finished
and has_submitted_payout
) as completed_awaiting_finish_incidents_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 (

View file

@ -2874,6 +2874,9 @@ models:
column_B: completed_amount_paid_in_gbp + not_completed_amount_paid_in_gbp
- dbt_expectations.expect_column_pair_values_to_be_equal:
column_A: completed_amount_paid_in_gbp
column_B: completed_finished_incidents_amount_paid_in_gbp + completed_awaiting_finish_incidents_amount_paid_in_gbp
- dbt_expectations.expect_column_pair_values_to_be_equal:
column_A: completed_finished_incidents_amount_paid_in_gbp
column_B: completed_risk_with_submitted_payout_amount_paid_in_gbp + completed_no_risk_with_submitted_payout_amount_paid_in_gbp
columns:
@ -3043,6 +3046,21 @@ models:
Total amount paid in GBP in terms of Resolutions Payouts for
Bookings that are not completed, for reference.
- name: completed_finished_incidents_amount_paid_in_gbp
data_type: numeric
description: |
Total amount paid in GBP in terms of Resolutions Payouts for Completed
Bookings that have had a claim in a finished status.
- name: completed_awaiting_finish_incidents_amount_paid_in_gbp
data_type: numeric
description: |
Total amount paid in GBP in terms of Resolutions Payouts for Completed
Bookings that have had a claim in a status that is not finished. These
Bookings are excluded for the submitted payout-based performance
analysis, as technically the incident has not finished so there might
be further updates.
- name: completed_risk_with_submitted_payout_amount_paid_in_gbp
data_type: numeric
description: |