2025-01-31 08:33:15 +00:00
|
|
|
with
|
|
|
|
|
int_xero__sales_monthly_trends as (
|
|
|
|
|
select * from {{ ref("int_xero__sales_monthly_trends") }}
|
2025-01-31 09:53:54 +00:00
|
|
|
),
|
|
|
|
|
int_xero__contacts as (select * from {{ ref("int_xero__contacts") }})
|
2025-01-31 08:33:15 +00:00
|
|
|
select
|
2025-01-31 09:53:54 +00:00
|
|
|
smt.document_issued_month_utc as document_issued_month_utc,
|
|
|
|
|
smt.fiscal_year as fiscal_year,
|
|
|
|
|
smt.previous_fiscal_year as previous_fiscal_year,
|
|
|
|
|
smt.document_status as document_status,
|
|
|
|
|
smt.document_type as document_type,
|
|
|
|
|
smt.id_deal as id_deal,
|
|
|
|
|
c.contact_name as contact_name,
|
2025-03-19 08:19:20 +00:00
|
|
|
case
|
|
|
|
|
when c.contact_name is null
|
|
|
|
|
then smt.id_deal
|
|
|
|
|
else smt.id_deal || '-' || c.contact_name
|
|
|
|
|
end as id_deal_contact_name,
|
2025-01-31 09:53:54 +00:00
|
|
|
smt.accounting_financial_l1_aggregation as accounting_financial_l1_aggregation,
|
|
|
|
|
smt.accounting_financial_l2_aggregation as accounting_financial_l2_aggregation,
|
|
|
|
|
smt.accounting_financial_l3_aggregation as accounting_financial_l3_aggregation,
|
|
|
|
|
smt.amount_wo_taxes_in_gbp as amount_wo_taxes_in_gbp,
|
|
|
|
|
smt.previous_month_amount_wo_taxes_in_gbp as previous_month_amount_wo_taxes_in_gbp,
|
|
|
|
|
smt.previous_year_amount_wo_taxes_in_gbp as previous_year_amount_wo_taxes_in_gbp,
|
|
|
|
|
smt.ytd_amount_wo_taxes_in_gbp as ytd_amount_wo_taxes_in_gbp,
|
|
|
|
|
smt.previous_year_ytd_amount_wo_taxes_in_gbp
|
|
|
|
|
as previous_year_ytd_amount_wo_taxes_in_gbp
|
|
|
|
|
from int_xero__sales_monthly_trends smt
|
2025-03-19 08:19:20 +00:00
|
|
|
left join
|
|
|
|
|
int_xero__contacts c
|
|
|
|
|
on smt.id_deal = c.id_deal
|
|
|
|
|
and c.is_latest_updated_contact_per_deal = true
|