container: hledger-flow: paypal-business: 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
|
# 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
|
||||||
@@ -43,8 +43,9 @@ function parse()
|
|||||||
# Paypal is known to allow commas within description ("Name") and amounts
|
# Paypal is known to allow commas within description ("Name") and amounts
|
||||||
# TODO: refactor xan/sed -> gawk (the sed line should remove non-csv commas and quotations)
|
# TODO: refactor xan/sed -> gawk (the sed line should remove non-csv commas and quotations)
|
||||||
xan select "$(echo "$_header" | sed 's:"::g')" $global_in_path \
|
xan select "$(echo "$_header" | sed 's:"::g')" $global_in_path \
|
||||||
| sed -e 's:, : :g' -e 's:,",:,:g' -e 's:,"\([0-9]*\),:,\1:g' -e 's:,"-\([0-9]*\),:,\1:g' -e 's:"::g' \
|
| gawk --csv \
|
||||||
| gawk -v global_year="$global_year" -v global_subaccount="$global_subaccount" \
|
-v global_year="$global_year" \
|
||||||
|
-v global_subaccount="$global_subaccount" \
|
||||||
'{
|
'{
|
||||||
if (NR<2 || $1 !~ global_year)
|
if (NR<2 || $1 !~ global_year)
|
||||||
next
|
next
|
||||||
@@ -56,12 +57,14 @@ function parse()
|
|||||||
|
|
||||||
printf $1 " " $2 OFS # Date/Time
|
printf $1 " " $2 OFS # Date/Time
|
||||||
|
|
||||||
|
# Name (description)
|
||||||
sub(/%/, "%%", $4)
|
sub(/%/, "%%", $4)
|
||||||
printf $4 OFS # Name (description)
|
gsub(/"/, "", $4)
|
||||||
|
printf "\"" $4 "\"" OFS
|
||||||
|
|
||||||
printf $5 OFS # Type
|
printf "\"" $5 "\"" OFS # Type
|
||||||
printf $6 OFS # Status
|
printf "\"" $6 "\"" OFS # Status
|
||||||
printf $7 OFS # Currency
|
printf "\"" $7 "\"" OFS # Currency
|
||||||
|
|
||||||
# direction will be used in rules
|
# direction will be used in rules
|
||||||
sub(/^-/, "", $8)
|
sub(/^-/, "", $8)
|
||||||
@@ -72,8 +75,10 @@ function parse()
|
|||||||
printf $13 OFS # Transaction ID
|
printf $13 OFS # Transaction ID
|
||||||
printf $(NF-4) OFS # Contact Phone Number
|
printf $(NF-4) OFS # Contact Phone Number
|
||||||
|
|
||||||
|
# Note
|
||||||
sub(/%/, "%%", $(NF-2))
|
sub(/%/, "%%", $(NF-2))
|
||||||
printf $(NF-2) OFS # Note
|
gsub(/"/, "", $(NF-2))
|
||||||
|
printf "\"" $(NF-2) "\"" OFS
|
||||||
|
|
||||||
printf $(NF) OFS # Balance Impact
|
printf $(NF) OFS # Balance Impact
|
||||||
|
|
||||||
@@ -84,7 +89,7 @@ function parse()
|
|||||||
|
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
|
||||||
}' FS=, OFS=, >"$global_out_path"
|
}' OFS=, >"$global_out_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
function main()
|
function main()
|
||||||
|
|||||||
Reference in New Issue
Block a user