Updated host resolutions model
This commit is contained in:
parent
06031a2e79
commit
5256c4ba02
1 changed files with 11 additions and 9 deletions
|
|
@ -1,6 +1,4 @@
|
|||
{% set resolutions_host_payment_account_name = "('RESOLUTIONS - HOST PAYMENT')" %}
|
||||
{% set relevant_transaction_status = "('AUTHORISED')" %}
|
||||
{% set resolutions_credited_account_code = "('316')" %}
|
||||
{% set resolutions_credited_documents = "('ACCRECCREDIT')" %}
|
||||
|
||||
with
|
||||
|
|
@ -13,7 +11,12 @@ with
|
|||
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") }})
|
||||
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,
|
||||
|
|
@ -36,18 +39,18 @@ 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(blt.account_name) in {{ resolutions_host_payment_account_name }}
|
||||
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_class,
|
||||
sdm.document_is_effective_at_end_of_month_utc,
|
||||
sdm.document_issued_date_utc,
|
||||
sdm.id_deal,
|
||||
sdm.quantity,
|
||||
sdm.unit_amount,
|
||||
|
|
@ -59,6 +62,5 @@ select
|
|||
sdm.tax_amount_in_gbp,
|
||||
sdm.document_currency_iso_4217
|
||||
from int_xero__sales_denom_mart sdm
|
||||
where
|
||||
sdm.account_name in {{ resolutions_credited_account_code }}
|
||||
and sdm.document_type in {{ resolutions_credited_documents }}
|
||||
inner join stg_seed__accounting_aggregations aa on aa.account_code = sdm.account_code
|
||||
where sdm.document_type in {{ resolutions_credited_documents }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue