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.quantity::numeric,
|
||||
j.unit_amount::numeric,
|
||||
j.line_amount_local_curr::numeric,
|
||||
(j.line_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
||||
18, 4
|
||||
) as line_amount_in_gbp,
|
||||
case
|
||||
when bt.line_amount_tax_inclusiveness = 'Inclusive'
|
||||
then j.line_amount_local_curr::numeric - j.tax_amount_local_curr::numeric
|
||||
when bt.line_amount_tax_inclusiveness = 'Exclusive'
|
||||
then j.line_amount_local_curr::numeric
|
||||
when bt.line_amount_tax_inclusiveness = 'NoTax'
|
||||
then j.line_amount_local_curr::numeric
|
||||
else null
|
||||
end as line_amount_wo_taxes_local_curr,
|
||||
case
|
||||
when bt.line_amount_tax_inclusiveness = 'Inclusive'
|
||||
then
|
||||
(
|
||||
(j.line_amount_local_curr::numeric - j.tax_amount_local_curr::numeric)
|
||||
* bt.exchange_rate_to_gbp
|
||||
)::numeric(18, 4)
|
||||
when bt.line_amount_tax_inclusiveness = 'Exclusive'
|
||||
then
|
||||
(j.line_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
||||
18, 4
|
||||
)
|
||||
when bt.line_amount_tax_inclusiveness = 'NoTax'
|
||||
then
|
||||
(j.line_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
||||
18, 4
|
||||
)
|
||||
else null
|
||||
end as line_amount_wo_taxes_in_gbp,
|
||||
j.tax_amount_local_curr::numeric,
|
||||
(j.tax_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
||||
18, 4
|
||||
) as tax_amount_in_gbp,
|
||||
bt.transaction_sign * j.line_amount_local_curr::numeric as line_amount_local_curr,
|
||||
(
|
||||
bt.transaction_sign
|
||||
* j.line_amount_local_curr::numeric
|
||||
* bt.exchange_rate_to_gbp
|
||||
)::numeric(18, 4) as line_amount_in_gbp,
|
||||
(
|
||||
case
|
||||
when bt.line_amount_tax_inclusiveness = 'Inclusive'
|
||||
then j.line_amount_local_curr::numeric - j.tax_amount_local_curr::numeric
|
||||
when bt.line_amount_tax_inclusiveness = 'Exclusive'
|
||||
then j.line_amount_local_curr::numeric
|
||||
when bt.line_amount_tax_inclusiveness = 'NoTax'
|
||||
then j.line_amount_local_curr::numeric
|
||||
else null
|
||||
end
|
||||
)
|
||||
* bt.transaction_sign as line_amount_wo_taxes_local_curr,
|
||||
(
|
||||
case
|
||||
when bt.line_amount_tax_inclusiveness = 'Inclusive'
|
||||
then
|
||||
(
|
||||
(
|
||||
j.line_amount_local_curr::numeric
|
||||
- j.tax_amount_local_curr::numeric
|
||||
)
|
||||
* bt.exchange_rate_to_gbp
|
||||
)::numeric(18, 4)
|
||||
when bt.line_amount_tax_inclusiveness = 'Exclusive'
|
||||
then
|
||||
(j.line_amount_local_curr::numeric * bt.exchange_rate_to_gbp)::numeric(
|
||||
18, 4
|
||||
)
|
||||
when bt.line_amount_tax_inclusiveness = 'NoTax'
|
||||
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,
|
||||
bt.transaction_currency_iso_4217
|
||||
from int_xero__bank_transactions bt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue