diff --git a/models/reporting/xero/schema.yml b/models/reporting/xero/schema.yml index 294d49a..35a5ebc 100644 --- a/models/reporting/xero/schema.yml +++ b/models/reporting/xero/schema.yml @@ -1455,6 +1455,14 @@ models: data_tests: - 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 data_type: text description: "The Level 1 aggregation for Financial reporting." diff --git a/models/reporting/xero/xero__sales_monthly_trends.sql b/models/reporting/xero/xero__sales_monthly_trends.sql index f0ddf5d..b3b1c06 100644 --- a/models/reporting/xero/xero__sales_monthly_trends.sql +++ b/models/reporting/xero/xero__sales_monthly_trends.sql @@ -1,20 +1,25 @@ with int_xero__sales_monthly_trends as ( select * from {{ ref("int_xero__sales_monthly_trends") }} - ) + ), + int_xero__contacts as (select * from {{ ref("int_xero__contacts") }}) select - document_issued_month_utc as document_issued_month_utc, - fiscal_year as fiscal_year, - previous_fiscal_year as previous_fiscal_year, - document_status as document_status, - document_type as document_type, - id_deal as id_deal, - accounting_financial_l1_aggregation as accounting_financial_l1_aggregation, - accounting_financial_l2_aggregation as accounting_financial_l2_aggregation, - accounting_financial_l3_aggregation as accounting_financial_l3_aggregation, - amount_wo_taxes_in_gbp as amount_wo_taxes_in_gbp, - previous_month_amount_wo_taxes_in_gbp as previous_month_amount_wo_taxes_in_gbp, - previous_year_amount_wo_taxes_in_gbp as previous_year_amount_wo_taxes_in_gbp, - ytd_amount_wo_taxes_in_gbp as ytd_amount_wo_taxes_in_gbp, - previous_year_ytd_amount_wo_taxes_in_gbp as previous_year_ytd_amount_wo_taxes_in_gbp -from int_xero__sales_monthly_trends + 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, + smt.id_deal || '-' || c.contact_name as id_deal_contact_name, + 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 +left join int_xero__contacts c on smt.id_deal = c.id_deal