forked from EvergreenCrypto/docker-finance
container: hledger-flow: ally: add uniform quotes
- Allows undesirable characters in variable-text columns - Related refactoring
This commit is contained in:
@@ -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,17 +38,13 @@ function parse()
|
||||
{
|
||||
lib_preprocess::assert_header "Date, Time, Amount, Type, Description"
|
||||
|
||||
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
|
||||
|
||||
# `Description` cleanup
|
||||
sub(/^ /, "", $5) # may have an empty space in front of line
|
||||
gsub(/, /, " - ") # may have (multiple) commas followed by space
|
||||
gsub(/"/, "", $5) # may have (multiple) quotes
|
||||
sub(/%/, "%%", $5) # remove potential interpretation
|
||||
|
||||
printf $1 OFS # Date
|
||||
printf $2 OFS # Time
|
||||
|
||||
@@ -56,13 +52,18 @@ function parse()
|
||||
printf $3 OFS # Amount
|
||||
|
||||
printf $4 OFS # Type
|
||||
printf $5 OFS # Description
|
||||
|
||||
# Description
|
||||
sub(/^ /, "", $5) # may have an empty space in front of line
|
||||
sub(/%/, "%%", $5) # remove potential interpretation
|
||||
gsub(/"/, "", $5) # remove nested quote(s)
|
||||
printf "\"" $5 "\"" OFS
|
||||
|
||||
printf ($4 ~ /^Withdrawal$/ ? "OUT" : "IN") OFS # Direction
|
||||
printf global_subaccount
|
||||
|
||||
printf "\n"
|
||||
}' FS=, OFS=, "$global_in_path" >"$global_out_path"
|
||||
}' OFS=, "$global_in_path" >"$global_out_path"
|
||||
}
|
||||
|
||||
function main()
|
||||
|
||||
Reference in New Issue
Block a user