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
|
with
|
||||||
int_xero__bank_transactions as (
|
int_xero__bank_transactions as (
|
||||||
select * from {{ ref("int_xero__bank_transactions") }}
|
select * from {{ ref("int_xero__bank_transactions") }}
|
||||||
)
|
),
|
||||||
|
stg_xero__accounts as (select * from {{ ref("stg_xero__accounts") }})
|
||||||
|
|
||||||
select
|
select
|
||||||
bt.id_bank_transaction,
|
bt.id_bank_transaction,
|
||||||
j.id_line_item,
|
j.id_line_item,
|
||||||
|
j.line_description,
|
||||||
|
j.id_account,
|
||||||
|
j.account_code,
|
||||||
|
a.account_name,
|
||||||
|
j.item_code,
|
||||||
j.quantity::numeric,
|
j.quantity::numeric,
|
||||||
j.unit_amount::numeric,
|
j.unit_amount::numeric,
|
||||||
j.line_amount_local_curr::numeric,
|
j.line_amount_local_curr::numeric,
|
||||||
|
|
@ -47,11 +53,7 @@ select
|
||||||
18, 4
|
18, 4
|
||||||
) as tax_amount_in_gbp,
|
) as tax_amount_in_gbp,
|
||||||
j.tax_type,
|
j.tax_type,
|
||||||
bt.transaction_currency_iso_4217,
|
bt.transaction_currency_iso_4217
|
||||||
j.line_description,
|
|
||||||
j.id_account,
|
|
||||||
j.account_code,
|
|
||||||
j.item_code
|
|
||||||
from int_xero__bank_transactions bt
|
from int_xero__bank_transactions bt
|
||||||
cross join
|
cross join
|
||||||
lateral(
|
lateral(
|
||||||
|
|
@ -73,3 +75,4 @@ cross join
|
||||||
(jsonb_array_elements(bt.line_items) ->> 'AccountCode') as account_code,
|
(jsonb_array_elements(bt.line_items) ->> 'AccountCode') as account_code,
|
||||||
(jsonb_array_elements(bt.line_items) ->> 'ItemCode') as item_code
|
(jsonb_array_elements(bt.line_items) ->> 'ItemCode') as item_code
|
||||||
) j
|
) 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