container: hledger-flow: coinbase: add uniform quotes

- Allows undesirable characters in variable-text columns
- Related refactoring
This commit is contained in:
2026-02-13 11:02:59 -08:00
parent 597ed3cbe3
commit dadb54d45d

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
@@ -70,7 +70,9 @@ function join_to_header()
function __parse() function __parse()
{ {
gawk -v global_year="$global_year" -v global_subaccount="$global_subaccount" \ gawk --csv \
-v global_year="$global_year" \
-v global_subaccount="$global_subaccount" \
'{ '{
if (NR<2 || $9 !~ global_year) if (NR<2 || $9 !~ global_year)
next next
@@ -91,18 +93,18 @@ function __parse()
printf $3 OFS # info_type printf $3 OFS # info_type
printf $4 OFS # info_status printf $4 OFS # info_status
printf $5 OFS # info_amount_amount printf $5 OFS # info_amount_amount
printf $6 OFS # info_amount_currency printf "\"" $6 "\"" OFS # info_amount_currency
printf $7 OFS # info_native_amount_amount printf $7 OFS # info_native_amount_amount
printf $8 OFS # info_native_amount_currency printf "\"" $8 "\"" OFS # info_native_amount_currency
printf $9 OFS # info_created_at printf $9 OFS # info_created_at
printf $10 OFS # info_resource printf $10 OFS # info_resource
printf $11 OFS # info_resource_path printf $11 OFS # info_resource_path
printf $12 OFS # info_description printf $12 OFS # info_description
printf $13 OFS # info_network_status printf $13 OFS # info_network_status
printf $14 OFS # info_network_network_name printf "\"" $14 "\"" OFS # info_network_network_name
printf $15 OFS # info_network_hash (txid) printf $15 OFS # info_network_hash (txid)
printf("%.8f", $16); printf OFS # info_network_transaction_fee_amount printf("%.8f", $16); printf OFS # info_network_transaction_fee_amount
printf $17 OFS # info_network_transaction_fee_currency printf "\"" $17 "\"" OFS # info_network_transaction_fee_currency
printf $18 OFS # info_to_resource printf $18 OFS # info_to_resource
printf $19 OFS # info_to_address printf $19 OFS # info_to_address
printf $20 OFS # info_to_email printf $20 OFS # info_to_email
@@ -113,25 +115,37 @@ function __parse()
printf $25 OFS # info_cancelable printf $25 OFS # info_cancelable
printf $26 OFS # info_idem printf $26 OFS # info_idem
printf("%.8f", $27); printf OFS # info_buy_total_amount printf("%.8f", $27); printf OFS # info_buy_total_amount
printf $28 OFS # info_buy_total_currency printf "\"" $28 "\"" OFS # info_buy_total_currency
printf("%.8f", $29); printf OFS # info_buy_subtotal_amount printf("%.8f", $29); printf OFS # info_buy_subtotal_amount
printf $30 OFS # info_buy_subtotal_currency printf "\"" $30 "\"" OFS # info_buy_subtotal_currency
printf("%.8f", $31); printf OFS # info_buy_fee_amount printf("%.8f", $31); printf OFS # info_buy_fee_amount
printf $32 OFS # info_buy_fee_currency printf "\"" $32 "\"" OFS # info_buy_fee_currency
printf $33 OFS # info_buy_id printf $33 OFS # info_buy_id
printf $34 OFS # info_buy_payment_method_name
# info_buy_payment_method_name
gsub(/"/, "", $34);
printf "\"" $34 "\"" OFS
printf("%.8f", $35); printf OFS # info_sell_total_amount printf("%.8f", $35); printf OFS # info_sell_total_amount
printf $36 OFS # info_sell_total_currency printf "\"" $36 "\"" OFS # info_sell_total_currency
printf("%.8f", $37); printf OFS # info_sell_subtotal_amount printf("%.8f", $37); printf OFS # info_sell_subtotal_amount
printf $38 OFS # info_sell_subtotal_currency printf "\"" $38 "\"" OFS # info_sell_subtotal_currency
printf("%.8f", $39); printf OFS # info_sell_fee_amount printf("%.8f", $39); printf OFS # info_sell_fee_amount
printf $40 OFS # info_sell_fee_currency printf "\"" $40 "\"" OFS # info_sell_fee_currency
printf $41 OFS # info_sell_id printf $41 OFS # info_sell_id
printf $42 OFS # info_sell_payment_method_name
# info_sell_payment_method_name
gsub(/"/, "", $42);
printf "\"" $42 "\"" OFS
printf("%.8f", $43); printf OFS # info_trade_fee_amount printf("%.8f", $43); printf OFS # info_trade_fee_amount
printf $44 OFS # info_trade_fee_currency printf "\"" $44 "\"" OFS # info_trade_fee_currency
printf $45 OFS # info_trade_id printf $45 OFS # info_trade_id
printf $46 OFS # info_trade_payment_method_name
# info_trade_payment_method_name
gsub(/"/, "", $46);
printf "\"" $46 "\"" OFS
printf("%.8f", $47); printf OFS # info_advanced_trade_fill_fill_price printf("%.8f", $47); printf OFS # info_advanced_trade_fill_fill_price
printf $48 OFS # info_advanced_trade_fill_product_id printf $48 OFS # info_advanced_trade_fill_product_id
printf $49 OFS # info_advanced_trade_fill_order_id printf $49 OFS # info_advanced_trade_fill_order_id
@@ -185,8 +199,8 @@ function __parse()
# #
split($48, pair, "-"); # Pair exists as advanced_trade_fill_product_id split($48, pair, "-"); # Pair exists as advanced_trade_fill_product_id
printf pair[1] OFS # advanced_trade_fill_pair_lhs (left-hand side of the pair) printf "\"" pair[1] "\"" OFS # advanced_trade_fill_pair_lhs (left-hand side of the pair)
printf pair[2] OFS # advanced_trade_fill_pair_rhs (right-hand side of the pair) printf "\"" pair[2] "\"" OFS # advanced_trade_fill_pair_rhs (right-hand side of the pair)
# #
# Advanced Trade: add column for cost-basis (comment2) # Advanced Trade: add column for cost-basis (comment2)
@@ -201,7 +215,7 @@ function __parse()
printf "\n"; printf "\n";
}' FS=, OFS=, }' OFS=,
} }
# #