Merged PR 2349: Retrieve account for xero invoices, credit notes and sales denom mart

Discussing with Jamie on how I can retrieve the information from Xero for E-deposit and Guesty, he told me that these go to a dedicated account. Since these are invoiced, they do not go to the bank transactions.
Specifically:
- 220 - E-Deposit Fees
- 219 - Guesty Fees
- 221 - Guesty Administration fee

After debugging the data (and getting confirmation from Jamie that indeed we were having invoices on e-deposit), I see that this info is available in the original json from staging. This PR aims just to retrieve these 3 fields:
- id_account
- account_code
- account_name

This will be used later on to retrieve the rest of API KPIs

Related work items: #18719
This commit is contained in:
Oriol Roqué Paniagua 2024-07-18 15:47:14 +00:00
parent e250763a1c
commit b16cb172b6
4 changed files with 38 additions and 5 deletions

View file

@ -1,10 +1,13 @@
with int_xero__credit_notes as (select * from {{ ref("int_xero__credit_notes") }})
with int_xero__credit_notes as (select * from {{ ref("int_xero__credit_notes") }}),
stg_xero__accounts as (select * from {{ ref("stg_xero__accounts") }})
select
cn.id_credit_note,
j.id_line_item,
j.id_item,
j.item_code,
j.id_account,
j.account_code,
a.account_name,
j.quantity::numeric,
j.unit_amount::numeric,
j.line_amount_local_curr::numeric,
@ -65,5 +68,9 @@ cross join
jsonb_array_elements(cn.line_items) ->> 'TaxAmount'
) as tax_amount_local_curr,
(jsonb_array_elements(cn.line_items) ->> 'TaxType') as tax_type,
(jsonb_array_elements(cn.line_items) ->> 'Description') as line_description
(jsonb_array_elements(cn.line_items) ->> 'Description') as line_description,
(jsonb_array_elements(cn.line_items) ->> 'AccountID') as id_account,
(jsonb_array_elements(cn.line_items) ->> 'AccountCode') as account_code
) j
left join stg_xero__accounts a on j.account_code = a.account_code