container: hledger-flow: ledger: add uniform quotes

- Allows undesirable characters in variable-text columns
- Related refactoring
This commit is contained in:
2026-02-13 11:26:18 -08:00
parent 3666baed83
commit c650d9bbc9

View File

@@ -2,7 +2,7 @@
# docker-finance | modern accounting for the power-user # docker-finance | modern accounting for the power-user
# #
# Copyright (C) 2021-2025 Aaron Fiore (Founder, Evergreen Crypto LLC) # Copyright (C) 2021-2026 Aaron Fiore (Founder, Evergreen Crypto LLC)
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -39,7 +39,8 @@ function parse()
# NOTE: subaccount (account label) is entered within app. # NOTE: subaccount (account label) is entered within app.
# Label your subaccount as subaccount1:subaccount2:etc # Label your subaccount as subaccount1:subaccount2:etc
gawk -v global_year="$global_year" \ gawk --csv \
-v global_year="$global_year" \
'{ '{
if (NR<2 || $1 !~ global_year) if (NR<2 || $1 !~ global_year)
next next
@@ -53,9 +54,9 @@ function parse()
sub(/\.001Z/, "", $1) sub(/\.001Z/, "", $1)
printf $1 OFS # Operation Date printf $1 OFS # Operation Date
printf $2 OFS # Status printf "\"" $2 "\"" OFS # Status
printf $3 OFS # Currency Ticker printf "\"" $3 "\"" OFS # Currency Ticker
printf $4 OFS # Operation Type printf "\"" $4 "\"" OFS # Operation Type
# Operation Amount (minus fee w/ this regexp) # Operation Amount (minus fee w/ this regexp)
amount=($4 ~ /^OUT$|^DELEGATE$/ ? $5-$6 : $5) amount=($4 ~ /^OUT$|^DELEGATE$/ ? $5-$6 : $5)
@@ -63,9 +64,13 @@ function parse()
printf("%.8f", $6); printf OFS # Operation Fees printf("%.8f", $6); printf OFS # Operation Fees
printf $7 OFS # Operation Hash printf $7 OFS # Operation Hash
printf $8 OFS # Account Name (subaccount)
# Account Name (subaccount)
gsub(/"/, "", $8)
printf "\"" $8 "\"" OFS
printf $9 OFS # Account xpub printf $9 OFS # Account xpub
printf $10 OFS # Countervalue Ticker printf "\"" $10 "\"" OFS # Countervalue Ticker
printf $11 OFS # Countervalue at Operation Date printf $11 OFS # Countervalue at Operation Date
printf $12 OFS # Countervalue at CSV Export printf $12 OFS # Countervalue at CSV Export
@@ -74,7 +79,7 @@ function parse()
printf "\n" printf "\n"
}' FS=, OFS=, "$global_in_path" >"$global_out_path" }' OFS=, "$global_in_path" >"$global_out_path"
} }
function main() function main()