Merged PR 5015: Xero Resolutions

# Description

New model for Resolutions payments

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

Related work items: #29373
This commit is contained in:
Joaquin Ossa 2025-04-25 14:32:49 +00:00
commit b230bf8f47
2 changed files with 165 additions and 0 deletions

View file

@ -0,0 +1,66 @@
{% set relevant_transaction_status = "('AUTHORISED')" %}
{% set resolutions_credited_documents = "('ACCRECCREDIT')" %}
with
int_xero__sales_denom_mart as (
select * from {{ ref("int_xero__sales_denom_mart") }}
),
int_xero__bank_transactions as (
select * from {{ ref("int_xero__bank_transactions") }}
),
int_xero__bank_transaction_line_items as (
select * from {{ ref("int_xero__bank_transaction_line_items") }}
),
int_xero__contacts as (select * from {{ ref("int_xero__contacts") }}),
stg_seed__accounting_aggregations as (
select *
from {{ ref("stg_seed__accounting_aggregations") }}
where root_aggregation = 'Host Resolutions Payments'
)
select
blt.id_line_item,
'bank transaction' as document_class,
blt.id_account,
blt.account_code,
blt.account_name,
blt.line_description,
bt.transaction_date_utc,
xc.id_deal,
blt.quantity,
blt.unit_amount,
blt.line_amount_local_curr,
blt.line_amount_in_gbp,
blt.line_amount_wo_taxes_local_curr,
blt.line_amount_wo_taxes_in_gbp,
blt.tax_amount_local_curr,
blt.tax_amount_in_gbp,
blt.transaction_currency_iso_4217
from int_xero__bank_transactions bt
inner join
int_xero__bank_transaction_line_items blt
on bt.id_bank_transaction = blt.id_bank_transaction
and upper(bt.transaction_status) in {{ relevant_transaction_status }}
left join int_xero__contacts xc on xc.id_contact = bt.id_contact
inner join stg_seed__accounting_aggregations aa on aa.account_code = blt.account_code
union all
select
sdm.id_line_item,
sdm.document_class,
sdm.id_account,
sdm.account_code,
sdm.account_name,
sdm.line_description,
sdm.document_issued_date_utc,
sdm.id_deal,
sdm.quantity,
sdm.unit_amount,
sdm.line_amount_local_curr,
sdm.line_amount_in_gbp,
sdm.line_amount_wo_taxes_local_curr,
sdm.line_amount_wo_taxes_in_gbp,
sdm.tax_amount_local_curr,
sdm.tax_amount_in_gbp,
sdm.document_currency_iso_4217
from int_xero__sales_denom_mart sdm
inner join stg_seed__accounting_aggregations aa on aa.account_code = sdm.account_code
where sdm.document_type in {{ resolutions_credited_documents }}

View file

@ -453,3 +453,102 @@ models:
description: |
"Year-to-date (YTD) total of sales amount without taxes (GBP) from the start of the previous fiscal
year up to the same month."
- name: int_xero__host_resolutions_payments
description: |
This model provides a view of transactions related to resolutions, including details
such as transaction date, associated account, and transaction amount.
Previously, all resolution-related transaction data was stored in the `int_xero__bank_transactions`
model. However, some resolution transactions have been, and will continue to be, credited through
the standard invoicing process — these are stored in the `int_xero__sales_denom_mart` model.
This model is built by joining the `int_xero__bank_transactions` and `int_xero__sales_denom_mart`
models to provide a unified view of resolution transactions.
columns:
- name: id_line_item
data_type: text
description: "Unique identifier of the line item associated with the transaction."
data_tests:
- not_null
- unique
- name: id_account
data_type: text
description: "Unique identifier of the account associated with the transaction."
data_tests:
- not_null
- name: account_code
data_type: text
description: "The code of the account associated with the transaction."
data_tests:
- not_null
- name: account_name
data_type: text
description: "The name of the account associated with the transaction."
data_tests:
- not_null
- name: line_description
data_type: text
description: "Description of the transaction line item."
- name: document_class
data_type: text
description: "Indicates whether the record belongs in an a credit note or a bank transaction."
data_tests:
- not_null
- accepted_values:
values:
- "credit note"
- "bank transaction"
- name: transaction_date_utc
data_type: date
description: "The date of the transaction in UTC."
- name: id_deal
data_type: text
description: |
"Unique identifier of an account associated with the transaction."
- name: quantity
data_type: numeric
description: "The quantity of transactions."
- name: unit_amount
data_type: numeric
description: "The unit amount of the transaction."
- name: line_amount_local_curr
data_type: numeric
description: "The transaction amount in the local currency."
- name: line_amount_in_gbp
data_type: numeric
description: "The transaction amount in GBP."
- name: line_amount_wo_taxes_local_curr
data_type: numeric
description: "The transaction amount without taxes in the local currency."
- name: line_amount_wo_taxes_in_gbp
data_type: numeric
description: "The transaction amount without taxes in GBP."
- name: tax_amount_local_curr
data_type: numeric
description: "The tax amount in the local currency."
- name: tax_amount_in_gbp
data_type: numeric
description: "The tax amount in GBP."
- name: transaction_currency_iso_4217
data_type: character varying
description: "The currency of the transaction, represented in ISO 4217 format."