diff --git a/container/src/hledger-flow/accounts/coinbase/coinbase-shared.bash b/container/src/hledger-flow/accounts/coinbase/coinbase-shared.bash index 0897613..ee9ef72 100755 --- a/container/src/hledger-flow/accounts/coinbase/coinbase-shared.bash +++ b/container/src/hledger-flow/accounts/coinbase/coinbase-shared.bash @@ -176,15 +176,37 @@ function __parse() # managed within the rules file. # - if ($7 > 0 && $5 > 0) {printf("%.8f", $7 / $5)}; printf OFS # native_amount_price - if ($7 > 0 && $5 > 0) {printf("%.8f", ($7 / $5) * $16)}; printf OFS # native_network_transaction_fee_amount + if ($7 > 0 && $5 > 0) + { + native_amount_price = $7 / $5 + printf("%.8f", native_amount_price); printf OFS + + native_network_transaction_fee_amount = native_amount_price * $16 + printf("%.8f", native_network_transaction_fee_amount); printf OFS + } + else + { + printf OFS # native_amount_price + printf OFS # native_network_transaction_fee_amount + } # # Add new columns to calculate the difference between amount and network fee # - if ($16 > 0) {printf("%.8f", $5 - $16)}; printf OFS # network_transaction_amount_amount - if ($16 > 0) {printf("%.8f", ($5 - $16) * ($7 / $5))}; printf OFS # native_network_transaction_amount + if ($16 > 0) + { + network_transaction_amount_amount = $5 - $16 + printf("%.8f", network_transaction_amount_amount); printf OFS + + native_network_transaction_amount = network_transaction_amount_amount * native_amount_price + printf("%.8f", native_network_transaction_amount); printf OFS + } + else + { + printf OFS # network_transaction_amount_amount + printf OFS # native_network_transaction_amount + } # # Advanced Trade: add new column for calculating real value amount