diff --git a/container/src/hledger-flow/accounts/chase/chase-shared.bash b/container/src/hledger-flow/accounts/chase/chase-shared.bash index 2e57059..7981fc6 100755 --- a/container/src/hledger-flow/accounts/chase/chase-shared.bash +++ b/container/src/hledger-flow/accounts/chase/chase-shared.bash @@ -2,7 +2,7 @@ # 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 # it under the terms of the GNU General Public License as published by @@ -38,7 +38,9 @@ function parse_credit() { lib_preprocess::assert_header "Transaction Date,Post Date,Description,Category,Type,Amount,Memo" - 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 || $1 !~ global_year) next @@ -46,48 +48,57 @@ function parse_credit() printf $1 OFS # Transaction Date printf $2 OFS # Post Date + # Description sub(/%/, "%%", $3) - printf $3 OFS # Description + gsub(/"/, "", $3) + printf "\"" $3 "\"" OFS - printf $4 OFS # Category - printf $5 OFS # Type + printf "\"" $4 "\"" OFS # Category + printf "\"" $5 "\"" OFS # Type # Amount direction=($6 ~ /^-/ ? "OUT" : "IN") sub(/^-/, "", $6) printf $6 OFS - printf $7 OFS # Memo + # Memo + sub(/%/, "%%", $7) + gsub(/"/, "", $7) + printf "\"" $7 "\"" OFS printf direction OFS printf global_subaccount printf "\n" - }' FS=, OFS=, "$global_in_path" >"$global_out_path" + }' OFS=, "$global_in_path" >"$global_out_path" } function parse_bank() { lib_preprocess::assert_header "Details,Posting Date,Description,Amount,Type,Balance,Check or Slip #" - 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 || $2 !~ global_year) next - printf $1 OFS # Details (CREDIT/DEBIT/DSLIP/etc.) + printf "\"" $1 "\"" OFS # Details (CREDIT/DEBIT/DSLIP/etc.) printf $2 OFS # Posting Date + # Description sub(/%/, "%%", $3) - printf $3 OFS # Description + gsub(/"/, "", $3) + printf "\"" $3 "\"" OFS # Amount direction=($4 ~ /^-/ ? "OUT" : "IN") sub(/^-/, "", $4) printf $4 OFS - printf $5 OFS # Type + printf "\"" $5 "\"" OFS # Type printf $6 OFS # Balance printf $7 OFS # Check or Slip # @@ -96,7 +107,7 @@ function parse_bank() printf "\n" - }' FS=, OFS=, "$global_in_path" >"$global_out_path" + }' OFS=, "$global_in_path" >"$global_out_path" } function main()