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:
parent
e250763a1c
commit
b16cb172b6
4 changed files with 38 additions and 5 deletions
|
|
@ -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
|
||||
|
|
@ -1,10 +1,14 @@
|
|||
with int_xero__invoices as (select * from {{ ref("int_xero__invoices") }})
|
||||
with int_xero__invoices as (select * from {{ ref("int_xero__invoices") }}),
|
||||
stg_xero__accounts as (select * from {{ ref("stg_xero__accounts") }})
|
||||
|
||||
select
|
||||
i.id_invoice,
|
||||
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,
|
||||
|
|
@ -59,5 +63,9 @@ cross join
|
|||
jsonb_array_elements(i.line_items) ->> 'TaxAmount'
|
||||
) as tax_amount_local_curr,
|
||||
(jsonb_array_elements(i.line_items) ->> 'TaxType') as tax_type,
|
||||
(jsonb_array_elements(i.line_items) ->> 'Description') as line_description
|
||||
(jsonb_array_elements(i.line_items) ->> 'Description') as line_description,
|
||||
|
||||
(jsonb_array_elements(i.line_items) ->> 'AccountID') as id_account,
|
||||
(jsonb_array_elements(i.line_items) ->> 'AccountCode') as account_code
|
||||
) j
|
||||
left join stg_xero__accounts a on j.account_code = a.account_code
|
||||
|
|
@ -12,6 +12,9 @@ select
|
|||
ili.id_line_item as id_line_item,
|
||||
ili.id_item as id_item,
|
||||
'invoice' as document_class,
|
||||
ili.id_account,
|
||||
ili.account_code,
|
||||
ili.account_name,
|
||||
ili.item_code as item_code,
|
||||
ili.quantity as quantity,
|
||||
ili.unit_amount as unit_amount,
|
||||
|
|
@ -58,6 +61,9 @@ select
|
|||
cnli.id_line_item,
|
||||
cnli.id_item,
|
||||
'credit note' as document_class,
|
||||
cnli.id_account,
|
||||
cnli.account_code,
|
||||
cnli.account_name,
|
||||
cnli.item_code,
|
||||
cnli.quantity,
|
||||
cnli.unit_amount,
|
||||
|
|
|
|||
|
|
@ -81,6 +81,18 @@ models:
|
|||
values:
|
||||
- 'invoice'
|
||||
- 'credit note'
|
||||
|
||||
- name: id_account
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: account_code
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: account_name
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: item_code
|
||||
data_type: text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue