commit wip
This commit is contained in:
parent
9fa62e0bf2
commit
3f224d8fed
2 changed files with 154 additions and 265 deletions
|
|
@ -31,7 +31,11 @@ with
|
|||
from jsonb_array_elements(status_history_logs::jsonb) status_step
|
||||
order by (status_step ->> 'CreatedDate')::timestamp desc
|
||||
limit 1
|
||||
) as last_status_at_utc
|
||||
) as last_status_at_utc,
|
||||
(
|
||||
select count(*)
|
||||
from jsonb_array_elements(host_user_claim_logs::jsonb) comment
|
||||
) as claims_count
|
||||
from stg_resolutions__incidents
|
||||
),
|
||||
damage_reported_items as (
|
||||
|
|
@ -41,13 +45,16 @@ with
|
|||
damage_report as (
|
||||
select
|
||||
id_incident,
|
||||
count(distinct item ->> 'Id') as number_damaged_items, -- Counting unique damaged items
|
||||
count(distinct item ->> 'Id') as number_damaged_items,
|
||||
sum(
|
||||
coalesce((corrective_measures ->> 'OriginalAmount')::numeric, 0)
|
||||
) as original_value_amount_in_txn_currency,
|
||||
sum(
|
||||
coalesce((corrective_measures ->> 'Amount')::numeric, 0)
|
||||
) as asked_repair_amount,
|
||||
) as asked_repair_amount_in_txn_currency,
|
||||
sum(
|
||||
coalesce((corrective_measures ->> 'SettlementAmount')::numeric, 0)
|
||||
) as accepted_amount
|
||||
) as accepted_amount_in_txn_currency
|
||||
from
|
||||
damage_reported_items,
|
||||
jsonb_array_elements(item -> 'CorrectiveMeasures') as corrective_measures
|
||||
|
|
@ -62,10 +69,7 @@ select
|
|||
current_status_name,
|
||||
is_submission_complete,
|
||||
current_agent_name,
|
||||
read_only_for_customers,
|
||||
status_history_logs,
|
||||
document_version,
|
||||
task_execution_logs,
|
||||
created_at_date,
|
||||
created_date_date,
|
||||
updated_at_date,
|
||||
|
|
@ -87,75 +91,11 @@ select
|
|||
else null
|
||||
end as resolution_time_in_hours,
|
||||
dr.number_damaged_items,
|
||||
dr.asked_repair_amount,
|
||||
dr.accepted_amount,
|
||||
dr.original_value_amount_in_txn_currency,
|
||||
dr.asked_repair_amount_in_txn_currency,
|
||||
dr.accepted_amount_in_txn_currency,
|
||||
|
||||
-- Host Details
|
||||
id_user_host,
|
||||
host_user_claim_logs,
|
||||
host_account_name,
|
||||
|
||||
-- Host Contact Details
|
||||
host_email,
|
||||
host_last_name,
|
||||
host_first_name,
|
||||
host_phone_code,
|
||||
host_phone_number,
|
||||
host_phone_number_with_code,
|
||||
|
||||
-- Guest Details
|
||||
id_user_guest,
|
||||
guest_email,
|
||||
guest_last_name,
|
||||
guest_first_name,
|
||||
guest_phone_code,
|
||||
guest_phone_number,
|
||||
guest_phone_number_with_code,
|
||||
|
||||
-- Guest Deposit Details
|
||||
is_guest_deposit_retained,
|
||||
is_guest_deposit_collected,
|
||||
deposit_retained_amount_in_txn_currency,
|
||||
deposit_retained_currency,
|
||||
|
||||
-- Guest Involvements
|
||||
has_guest_contributed_to_cost,
|
||||
has_host_taken_preventative_steps,
|
||||
guest_contribution_amount_in_txn_currency,
|
||||
guest_contribution_currency,
|
||||
guest_contacted_about_damage,
|
||||
guest_contacted_evidence_files,
|
||||
guest_preventative_steps_details,
|
||||
|
||||
-- Accommodation Details
|
||||
id_accommodation,
|
||||
accommodation_url,
|
||||
accommodation_name,
|
||||
are_pets_allowed,
|
||||
|
||||
-- Booking Details
|
||||
check_in_at_utc,
|
||||
check_in_date_utc,
|
||||
check_out_at_utc,
|
||||
check_out_date_utc,
|
||||
id_booking,
|
||||
booking_status,
|
||||
id_reservation,
|
||||
booking_details,
|
||||
number_of_guests,
|
||||
booking_services,
|
||||
booking_protection,
|
||||
booking_platform_used,
|
||||
booking_platform_reference,
|
||||
|
||||
-- Damage Report
|
||||
before_damage_evidence,
|
||||
original_invoice_evidence,
|
||||
damage_incident_details,
|
||||
has_confirmed_loss,
|
||||
damage_report_items,
|
||||
|
||||
-- Calculator
|
||||
-- Resolutions calculator
|
||||
protection_name,
|
||||
was_overriden,
|
||||
waiver_or_deposit_name,
|
||||
|
|
@ -169,6 +109,53 @@ select
|
|||
calculated_guest_charge_currency,
|
||||
calculated_guest_charge_amount_in_usd
|
||||
|
||||
-- Host Details
|
||||
id_user_host,
|
||||
lt.claims_count,
|
||||
host_account_name,
|
||||
|
||||
-- Host Contact Details
|
||||
host_email,
|
||||
host_last_name,
|
||||
host_first_name,
|
||||
host_phone_code,
|
||||
host_phone_number,
|
||||
|
||||
-- Guest Details
|
||||
id_user_guest,
|
||||
guest_email,
|
||||
guest_last_name,
|
||||
guest_first_name,
|
||||
guest_phone_code,
|
||||
guest_phone_number,
|
||||
|
||||
-- Guest Deposit Details
|
||||
is_guest_deposit_retained,
|
||||
is_guest_deposit_collected,
|
||||
deposit_retained_amount_in_txn_currency,
|
||||
deposit_retained_currency,
|
||||
|
||||
-- Guest Involvements
|
||||
has_guest_contributed_to_cost,
|
||||
has_host_taken_preventative_steps,
|
||||
guest_contribution_amount_in_txn_currency,
|
||||
guest_contribution_currency,
|
||||
guest_contacted_about_damage,
|
||||
|
||||
-- Accommodation Details
|
||||
id_accommodation,
|
||||
accommodation_name,
|
||||
|
||||
-- Booking Details
|
||||
check_in_at_utc,
|
||||
check_in_date_utc,
|
||||
check_out_at_utc,
|
||||
check_out_date_utc,
|
||||
id_booking,
|
||||
booking_status,
|
||||
id_reservation,
|
||||
booking_protection
|
||||
|
||||
from stg_resolutions__incidents i
|
||||
left join logs_timeline lt on i.id_incident = lt.id_incident
|
||||
left join damage_report dr on i.id_incident = dr.id_incident
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue