add account code
This commit is contained in:
parent
8dc31f3489
commit
854afffc1c
1 changed files with 9 additions and 6 deletions
|
|
@ -1,11 +1,17 @@
|
|||
with
|
||||
int_xero__bank_transactions as (
|
||||
select * from {{ ref("int_xero__bank_transactions") }}
|
||||
)
|
||||
),
|
||||
stg_xero__accounts as (select * from {{ ref("stg_xero__accounts") }})
|
||||
|
||||
select
|
||||
bt.id_bank_transaction,
|
||||
j.id_line_item,
|
||||
j.line_description,
|
||||
j.id_account,
|
||||
j.account_code,
|
||||
a.account_name,
|
||||
j.item_code,
|
||||
j.quantity::numeric,
|
||||
j.unit_amount::numeric,
|
||||
j.line_amount_local_curr::numeric,
|
||||
|
|
@ -47,11 +53,7 @@ select
|
|||
18, 4
|
||||
) as tax_amount_in_gbp,
|
||||
j.tax_type,
|
||||
bt.transaction_currency_iso_4217,
|
||||
j.line_description,
|
||||
j.id_account,
|
||||
j.account_code,
|
||||
j.item_code
|
||||
bt.transaction_currency_iso_4217
|
||||
from int_xero__bank_transactions bt
|
||||
cross join
|
||||
lateral(
|
||||
|
|
@ -73,3 +75,4 @@ cross join
|
|||
(jsonb_array_elements(bt.line_items) ->> 'AccountCode') as account_code,
|
||||
(jsonb_array_elements(bt.line_items) ->> 'ItemCode') as item_code
|
||||
) j
|
||||
left join stg_xero__accounts a on j.account_code = a.account_code
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue