Merge pull request #327 into master
All checks were successful
docker-finance / all (push) Successful in 31m57s
All checks were successful
docker-finance / all (push) Successful in 31m57s
6bd16952container: hledger-flow: trezor: template: add new FS mockup (Aaron Fiore)35d23958container: hledger-flow: trezor: add v25.9.1+ FS / backward compat (Aaron Fiore)
This commit was merged in pull request #327.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
Timestamp,Date,Time,Type,Transaction ID,Fee,Fee unit,Address,Label,Amount,Amount unit,Fiat (USD),Other
|
||||
1773852733,3/18/2026,9:52:13 AM GMT-7,SENT,XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX123,0.00001234,BTC,bc1qXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX123,New FS tx,0.00012345,BTC,"8.81",
|
||||
|
@@ -36,16 +36,35 @@ source "${DOCKER_FINANCE_CONTAINER_REPO}/src/hledger-flow/lib/lib_preprocess.bas
|
||||
|
||||
[ -z "$global_in_filename" ] && exit 1
|
||||
|
||||
function reseat_fs()
|
||||
{
|
||||
[ -z $1 ] && exit 1
|
||||
local -r _fs="$1"
|
||||
local -r _header="Timestamp${_fs}Date${_fs}Time${_fs}Type${_fs}Transaction ID${_fs}Fee${_fs}Fee unit${_fs}Address${_fs}Label${_fs}Amount${_fs}Amount unit${_fs}Fiat (USD)${_fs}Other"
|
||||
echo "$_header"
|
||||
}
|
||||
|
||||
function parse()
|
||||
{
|
||||
lib_preprocess::assert_header "Timestamp;Date;Time;Type;Transaction ID;Fee;Fee unit;Address;Label;Amount;Amount unit;Fiat (USD);Other"
|
||||
local _gawk=("gawk")
|
||||
local _fs _header
|
||||
|
||||
_header="$(reseat_fs ";")"
|
||||
if lib_preprocess::test_header "$_header"; then
|
||||
_fs="FS=;"
|
||||
else
|
||||
# Since v25.9.1
|
||||
_header="$(reseat_fs ",")"
|
||||
lib_preprocess::assert_header "$_header"
|
||||
_gawk+=("--csv")
|
||||
fi
|
||||
|
||||
# Get subaccount(s) from filename
|
||||
local _subaccount
|
||||
_subaccount="$(echo $global_in_filename | cut -d'_' -f1)"
|
||||
|
||||
# NOTE: subaccount (account label) is entered within the app
|
||||
gawk \
|
||||
"${_gawk[@]}" \
|
||||
-v global_year="$global_year" \
|
||||
-v global_subaccount="$global_subaccount" \
|
||||
-v subaccount="$_subaccount" \
|
||||
@@ -64,7 +83,7 @@ function parse()
|
||||
# skip # Date (N/A)
|
||||
# skip # Time (N/A)
|
||||
|
||||
# Type # TODO: are there more types?
|
||||
# Type (TODO: are there more types?)
|
||||
direction=($4 ~ /^RECV$/ ? "IN" : "OUT")
|
||||
printf $4 OFS
|
||||
|
||||
@@ -80,7 +99,19 @@ function parse()
|
||||
|
||||
printf("%.8f", $10); printf OFS # Amount # TODO: more than 8 places for Ethereum, etc.?
|
||||
printf "\"" $11 "\"" OFS # Amount unit
|
||||
printf "\"" $12 "\"" OFS # Fiat (USD)
|
||||
|
||||
# Fiat (USD)
|
||||
# NOTE: is already quoted since v25.9.1
|
||||
fiat=$12
|
||||
if (fiat ~ /^"/)
|
||||
{
|
||||
printf fiat OFS
|
||||
}
|
||||
else
|
||||
{
|
||||
printf "\"" fiat "\"" OFS
|
||||
}
|
||||
|
||||
printf "\"" $13 "\"" OFS # Other
|
||||
|
||||
printf direction OFS
|
||||
@@ -88,7 +119,7 @@ function parse()
|
||||
|
||||
printf "\n"
|
||||
|
||||
}' FS=\; OFS=, "$global_in_path" >"$global_out_path"
|
||||
}' "$_fs" OFS=, "$global_in_path" >"$global_out_path"
|
||||
}
|
||||
|
||||
function main()
|
||||
|
||||
Reference in New Issue
Block a user