apply transaction sign in line items
This commit is contained in:
parent
dd5882a564
commit
487f6701e3
1 changed files with 47 additions and 36 deletions
|
|
@ -14,42 +14,53 @@ select
|
||||||
j.item_code,
|
j.item_code,
|
||||||
j.quantity::numeric,
|
j.quantity::numeric,
|
||||||
j.unit_amount::numeric,
|
j.unit_amount::numeric,
|
||||||
j.line_amount_local_curr::numeric,
|
bt.transaction_sign * j.line_amount_local_curr::numeric as line_amount_local_curr,
|
||||||
(j.line_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
(
|
||||||
18, 4
|
bt.transaction_sign
|
||||||
) as line_amount_in_gbp,
|
* j.line_amount_local_curr::numeric
|
||||||
case
|
* bt.exchange_rate_to_gbp
|
||||||
when bt.line_amount_tax_inclusiveness = 'Inclusive'
|
)::numeric(18, 4) as line_amount_in_gbp,
|
||||||
then j.line_amount_local_curr::numeric - j.tax_amount_local_curr::numeric
|
(
|
||||||
when bt.line_amount_tax_inclusiveness = 'Exclusive'
|
case
|
||||||
then j.line_amount_local_curr::numeric
|
when bt.line_amount_tax_inclusiveness = 'Inclusive'
|
||||||
when bt.line_amount_tax_inclusiveness = 'NoTax'
|
then j.line_amount_local_curr::numeric - j.tax_amount_local_curr::numeric
|
||||||
then j.line_amount_local_curr::numeric
|
when bt.line_amount_tax_inclusiveness = 'Exclusive'
|
||||||
else null
|
then j.line_amount_local_curr::numeric
|
||||||
end as line_amount_wo_taxes_local_curr,
|
when bt.line_amount_tax_inclusiveness = 'NoTax'
|
||||||
case
|
then j.line_amount_local_curr::numeric
|
||||||
when bt.line_amount_tax_inclusiveness = 'Inclusive'
|
else null
|
||||||
then
|
end
|
||||||
(
|
)
|
||||||
(j.line_amount_local_curr::numeric - j.tax_amount_local_curr::numeric)
|
* bt.transaction_sign as line_amount_wo_taxes_local_curr,
|
||||||
* bt.exchange_rate_to_gbp
|
(
|
||||||
)::numeric(18, 4)
|
case
|
||||||
when bt.line_amount_tax_inclusiveness = 'Exclusive'
|
when bt.line_amount_tax_inclusiveness = 'Inclusive'
|
||||||
then
|
then
|
||||||
(j.line_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
(
|
||||||
18, 4
|
(
|
||||||
)
|
j.line_amount_local_curr::numeric
|
||||||
when bt.line_amount_tax_inclusiveness = 'NoTax'
|
- j.tax_amount_local_curr::numeric
|
||||||
then
|
)
|
||||||
(j.line_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
* bt.exchange_rate_to_gbp
|
||||||
18, 4
|
)::numeric(18, 4)
|
||||||
)
|
when bt.line_amount_tax_inclusiveness = 'Exclusive'
|
||||||
else null
|
then
|
||||||
end as line_amount_wo_taxes_in_gbp,
|
(j.line_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
||||||
j.tax_amount_local_curr::numeric,
|
18, 4
|
||||||
(j.tax_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
)
|
||||||
18, 4
|
when bt.line_amount_tax_inclusiveness = 'NoTax'
|
||||||
) as tax_amount_in_gbp,
|
then
|
||||||
|
(j.line_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
||||||
|
18, 4
|
||||||
|
)
|
||||||
|
else null
|
||||||
|
end
|
||||||
|
)
|
||||||
|
* bt.transaction_sign as line_amount_wo_taxes_in_gbp,
|
||||||
|
bt.transaction_sign * j.tax_amount_local_curr::numeric as tax_amount_local_curr,
|
||||||
|
(
|
||||||
|
bt.transaction_sign * j.tax_amount_local_curr::numeric * bt.exchange_rate_to_gbp
|
||||||
|
)::numeric(18, 4) as tax_amount_in_gbp,
|
||||||
j.tax_type,
|
j.tax_type,
|
||||||
bt.transaction_currency_iso_4217
|
bt.transaction_currency_iso_4217
|
||||||
from int_xero__bank_transactions bt
|
from int_xero__bank_transactions bt
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue