Merged PR 4236: Propagate contact name for reporting purposes only

# Description

Propagates contact name and id_deal + contact name combination for PBI in xero - sales monthly trends

# 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.

Propagate contact name for reporting purposes only

Related work items: #26618
This commit is contained in:
Oriol Roqué Paniagua 2025-01-31 09:53:54 +00:00
parent f55c618cfa
commit 353972984e
2 changed files with 29 additions and 16 deletions

View file

@ -1455,6 +1455,14 @@ models:
data_tests: data_tests:
- not_null - not_null
- name: contact_name
data_type: text
description: "The name of the contact associated with the deal."
- name: id_deal_contact_name
data_type: text
description: "A concatenation of the deal ID and contact name."
- name: accounting_financial_l1_aggregation - name: accounting_financial_l1_aggregation
data_type: text data_type: text
description: "The Level 1 aggregation for Financial reporting." description: "The Level 1 aggregation for Financial reporting."

View file

@ -1,20 +1,25 @@
with with
int_xero__sales_monthly_trends as ( int_xero__sales_monthly_trends as (
select * from {{ ref("int_xero__sales_monthly_trends") }} select * from {{ ref("int_xero__sales_monthly_trends") }}
) ),
int_xero__contacts as (select * from {{ ref("int_xero__contacts") }})
select select
document_issued_month_utc as document_issued_month_utc, smt.document_issued_month_utc as document_issued_month_utc,
fiscal_year as fiscal_year, smt.fiscal_year as fiscal_year,
previous_fiscal_year as previous_fiscal_year, smt.previous_fiscal_year as previous_fiscal_year,
document_status as document_status, smt.document_status as document_status,
document_type as document_type, smt.document_type as document_type,
id_deal as id_deal, smt.id_deal as id_deal,
accounting_financial_l1_aggregation as accounting_financial_l1_aggregation, c.contact_name as contact_name,
accounting_financial_l2_aggregation as accounting_financial_l2_aggregation, smt.id_deal || '-' || c.contact_name as id_deal_contact_name,
accounting_financial_l3_aggregation as accounting_financial_l3_aggregation, smt.accounting_financial_l1_aggregation as accounting_financial_l1_aggregation,
amount_wo_taxes_in_gbp as amount_wo_taxes_in_gbp, smt.accounting_financial_l2_aggregation as accounting_financial_l2_aggregation,
previous_month_amount_wo_taxes_in_gbp as previous_month_amount_wo_taxes_in_gbp, smt.accounting_financial_l3_aggregation as accounting_financial_l3_aggregation,
previous_year_amount_wo_taxes_in_gbp as previous_year_amount_wo_taxes_in_gbp, smt.amount_wo_taxes_in_gbp as amount_wo_taxes_in_gbp,
ytd_amount_wo_taxes_in_gbp as ytd_amount_wo_taxes_in_gbp, smt.previous_month_amount_wo_taxes_in_gbp as previous_month_amount_wo_taxes_in_gbp,
previous_year_ytd_amount_wo_taxes_in_gbp as previous_year_ytd_amount_wo_taxes_in_gbp smt.previous_year_amount_wo_taxes_in_gbp as previous_year_amount_wo_taxes_in_gbp,
from int_xero__sales_monthly_trends 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
left join int_xero__contacts c on smt.id_deal = c.id_deal