container: hledger-flow: coinbase: refactor native/network calc columns

This commit is contained in:
2026-04-01 12:28:02 -07:00
parent 59ec5a9010
commit 71153490eb

View File

@@ -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