forked from EvergreenCrypto/docker-finance
container: hledger-flow: gemini: 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
|
||||
@@ -198,8 +198,10 @@ function parse_trades()
|
||||
local _account_currency
|
||||
_account_currency="$(echo $global_in_filename | cut -d"-" -f1 | sed 's:...$::')"
|
||||
|
||||
gawk -v account_currency="$_account_currency" \
|
||||
-v global_year="$global_year" -v global_subaccount="$global_subaccount" \
|
||||
gawk --csv \
|
||||
-v account_currency="$_account_currency" \
|
||||
-v global_year="$global_year" \
|
||||
-v global_subaccount="$global_subaccount" \
|
||||
'{
|
||||
if (NR<2)
|
||||
next
|
||||
@@ -212,9 +214,13 @@ function parse_trades()
|
||||
printf $9 OFS # UID (tid)
|
||||
printf date OFS # Date
|
||||
printf "TRADE" OFS # Type
|
||||
printf $5 OFS # OrderType (type)
|
||||
printf toupper(account_currency) OFS # CurrencyOne (account_currency)
|
||||
printf $7 OFS # CurrencyTwo (fee_currency)
|
||||
printf "\"" $5 "\"" OFS # OrderType (type)
|
||||
|
||||
# CurrencyOne (account_currency)
|
||||
printf "\"" toupper(account_currency) "\"" OFS
|
||||
|
||||
# CurrencyTwo (fee_currency)
|
||||
printf "\"" $7 "\"" OFS
|
||||
|
||||
# TODO: getline an gawk remove-zeros script
|
||||
amount=sprintf("%.8f", $2)
|
||||
@@ -271,14 +277,17 @@ function parse_trades()
|
||||
|
||||
printf "\n"
|
||||
|
||||
}' FS=, OFS=, "$global_in_path" >"$global_out_path"
|
||||
}' OFS=, "$global_in_path" >"$global_out_path"
|
||||
}
|
||||
|
||||
function parse_earn()
|
||||
{
|
||||
lib_preprocess::assert_header "earnTransactionId,transactionId,transactionType,amountCurrency,amount,priceCurrency,priceAmount,dateTime"
|
||||
|
||||
gawk -v global_year="$global_year" -v global_subaccount="$global_subaccount" -M -v PREC=100 \
|
||||
gawk --csv \
|
||||
-v global_year="$global_year" \
|
||||
-v global_subaccount="$global_subaccount" \
|
||||
-M -v PREC=100 \
|
||||
'{
|
||||
if (NR<2)
|
||||
next
|
||||
@@ -292,7 +301,7 @@ function parse_earn()
|
||||
printf date OFS # Date
|
||||
printf "INTEREST" OFS # Type
|
||||
printf "EARN" OFS # OrderType (type)
|
||||
printf $4 OFS # CurrencyOne (amountCurrency)
|
||||
printf "\"" $4 "\""OFS # CurrencyOne (amountCurrency)
|
||||
printf OFS # CurrencyTwo
|
||||
|
||||
# Amount
|
||||
@@ -329,14 +338,16 @@ function parse_earn()
|
||||
|
||||
printf "\n";
|
||||
|
||||
}' FS=, OFS=, "$global_in_path" >"$global_out_path"
|
||||
}' OFS=, "$global_in_path" >"$global_out_path"
|
||||
}
|
||||
|
||||
function parse_card()
|
||||
{
|
||||
lib_preprocess::assert_header "Reference Number,Transaction Post Date,Description of Transaction,Transaction Type,Amount"
|
||||
|
||||
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)
|
||||
next
|
||||
@@ -350,8 +361,13 @@ function parse_card()
|
||||
|
||||
printf $1 OFS # Reference Number
|
||||
printf $2 OFS # Transaction Post Date
|
||||
printf $3 OFS # Description of Transaction
|
||||
printf $4 OFS # Transaction Type
|
||||
|
||||
# Description of Transaction
|
||||
gsub(/%/, "%%", $3)
|
||||
gsub(/"/, "", $3)
|
||||
printf "\"" $3 "\"" OFS
|
||||
|
||||
printf "\"" $4 "\"" OFS # Transaction Type
|
||||
printf $5 OFS # Amount
|
||||
|
||||
direction=($5 ~ /^-/ ? "IN" : "OUT")
|
||||
@@ -361,7 +377,7 @@ function parse_card()
|
||||
|
||||
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