From c65c31659cbc3e3c795d18fa68f177d8d161df93 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Mon, 9 Sep 2024 19:07:54 -0700 Subject: [PATCH] hledger-flow: electrum: fix calculating 'No Data' If electrum-provided prices aren't available, 'No Data' will be given. Attempts to calculate this string will result in 0.00 for fiat values. Do not attempt to calculate this string. Instead, leave the column empty (for bitcoin.tax calculations). --- .../accounts/electrum/electrum-shared.bash | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/container/src/hledger-flow/accounts/electrum/electrum-shared.bash b/container/src/hledger-flow/accounts/electrum/electrum-shared.bash index 4775818..584506f 100755 --- a/container/src/hledger-flow/accounts/electrum/electrum-shared.bash +++ b/container/src/hledger-flow/accounts/electrum/electrum-shared.bash @@ -52,11 +52,24 @@ function parse() value=$4-$6 # Remove fee printf("%.8f", value); printf OFS - sub(/^-/, "", $5) - printf("%.8f", $5); printf OFS # fiat_value + # fiat_value + if ($5 !~ /^No Data$/) + { + sub(/^-/, "", $5) + printf("%.8f", $5) + } + printf OFS - printf("%.8f", $6); printf OFS # fee - printf("%.8f", $7); printf OFS # fiat_fee + # fee + printf("%.8f", $6) + printf OFS + + # fiat_fee + if ($7 !~ /^No Data$/) + { + printf("%.8f", $7) + } + printf OFS # timestamp sub(/ /, "T", $8) # HACK: makes arg-friendly by removing space