Merge pull request #199 into master
4718fcdcontainer: hledger-flow: paypal: update fiat mockup (Aaron Fiore)6fc4a15container: hledger-flow: paypal: support latest fiat header (Aaron Fiore)
This commit was merged in pull request #199.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
# Copyright (C) 2021-2025 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
|
||||
@@ -42,12 +42,13 @@ source "${DOCKER_FINANCE_CONTAINER_REPO}/src/hledger-flow/lib/lib_preprocess.bas
|
||||
|
||||
function parse_report()
|
||||
{
|
||||
lib_preprocess::assert_header "\"Date\",\"Time\",\"TimeZone\",\"Name\",\"Type\",\"Status\",\"Currency\",\"Amount\",\"Receipt ID\",\"Balance\""
|
||||
# Supports "Balance Affecting" reports
|
||||
lib_preprocess::assert_header "\"Date\",\"Time\",\"TimeZone\",\"Name\",\"Type\",\"Status\",\"Currency\",\"Amount\",\"Fees\",\"Total\",\"Exchange Rate\",\"Receipt ID\",\"Balance\",\"Transaction ID\",\"Item Title\""
|
||||
|
||||
# Paypal is known to allow commas within description ("Name") and amounts
|
||||
# NOTE: using custom timezone offset instead of provided timezone
|
||||
# TODO: refactor xsv/sed -> gawk (the sed line should remove non-csv commas and quotations)
|
||||
xsv select "Date,Time,Name,Type,Status,Currency,Amount,Receipt ID,Balance" "$global_in_path" \
|
||||
xsv select "Date,Time,Name,Type,Status,Currency,Amount,Fees,Total,Exchange Rate,Receipt ID,Balance,Transaction ID,Item Title" "$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 -v global_year="$global_year" -v global_subaccount="$global_subaccount" \
|
||||
'{
|
||||
@@ -67,10 +68,6 @@ function parse_report()
|
||||
# Scrap existing alphanum timezone for a timezone offset
|
||||
cmd = "date \"+%F %T %z\" --date="date_time | getline timestamp
|
||||
|
||||
# Need an integer if amount or balance are empty
|
||||
amount=($7 != "" ? $7 : "0")
|
||||
balance=($9 != "" ? $9 : "0")
|
||||
|
||||
# Print
|
||||
printf timestamp OFS # timestamp
|
||||
printf $3 OFS # description (Name)
|
||||
@@ -78,12 +75,23 @@ function parse_report()
|
||||
printf $5 OFS # status
|
||||
printf $6 OFS # currency
|
||||
|
||||
direction=(amount ~ /^-/ ? "OUT" : "IN")
|
||||
sub(/^-/, "", amount)
|
||||
printf amount OFS # amount
|
||||
direction=($7 ~ /^-/ ? "OUT" : "IN")
|
||||
sub(/^-/, "", $7)
|
||||
printf $7 OFS # amount
|
||||
|
||||
printf $8 OFS # code (Receipt ID)
|
||||
printf balance OFS # balance
|
||||
sub(/^-/, "", $8)
|
||||
printf $8 OFS # fees
|
||||
|
||||
sub(/^-/, "", $9)
|
||||
printf $9 OFS # total
|
||||
|
||||
printf $10 OFS # exchange rate
|
||||
|
||||
printf $11 OFS # code (Receipt ID)
|
||||
printf $12 OFS # balance
|
||||
|
||||
printf $13 OFS # txid (Transaction ID)
|
||||
printf $14 OFS # title (Item Title)
|
||||
|
||||
printf direction OFS
|
||||
printf global_subaccount OFS
|
||||
@@ -126,8 +134,13 @@ function parse_crypto()
|
||||
printf OFS # status
|
||||
printf OFS # currency
|
||||
printf OFS # amount
|
||||
printf OFS # fees
|
||||
printf OFS # total
|
||||
printf OFS # exchange rate
|
||||
printf OFS # code (Receipt ID)
|
||||
printf OFS # balance
|
||||
printf OFS # txid (Transaction ID)
|
||||
printf OFS # title (Item Title)
|
||||
|
||||
printf OFS # direction
|
||||
printf global_subaccount OFS
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
fields timestamp,description_,type,status_,currency_,amount_,code_,balance_,direction,subaccount,in_value,in_ticker,out_value,out_ticker,tx_fee_value,tx_fee_ticker,fiat_value
|
||||
fields timestamp,description_,type,status_,currency_,amount_,fees,total,exchange_rate,code_,balance_,txid,title,direction,subaccount,in_value,in_ticker,out_value,out_ticker,tx_fee_value,tx_fee_ticker,fiat_value
|
||||
|
||||
date-format %Y-%m-%d %H:%M:%S %z
|
||||
date %timestamp
|
||||
@@ -30,8 +30,24 @@ comment type:%type, status:%status_, direction:%direction
|
||||
if %description_ ([0-9]|[a-z])
|
||||
comment description:%description_, type:%type, status:%status_, direction:%direction
|
||||
|
||||
if %code_ ([0-9]|[a-z])
|
||||
comment description:%description_, type:%type, status:%status_, code:%code_, direction:%direction
|
||||
if %description_ ([0-9]|[a-z])
|
||||
& %title ([0-9]|[a-z])
|
||||
comment description:%description_, title:%title, type:%type, status:%status_, direction:%direction
|
||||
|
||||
if %description_ ([0-9]|[a-z])
|
||||
& %txid ([0-9]|[a-z])
|
||||
comment description:%description_, type:%type, txid:%txid, status:%status_, direction:%direction
|
||||
|
||||
if %description_ ([0-9]|[a-z])
|
||||
& %txid ([0-9]|[a-z])
|
||||
& %title ([0-9]|[a-z])
|
||||
comment description:%description_, title:%title, type:%type, txid:%txid, status:%status_, direction:%direction
|
||||
|
||||
if %description_ ([0-9]|[a-z])
|
||||
& %txid ([0-9]|[a-z])
|
||||
& %title ([0-9]|[a-z])
|
||||
& %code ([0-9]|[a-z])
|
||||
comment description:%description_, title:%title, type:%type, txid:%txid, status:%status_, code:%code_, direction:%direction
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# IN #
|
||||
@@ -54,6 +70,13 @@ if %direction ^OUT$
|
||||
if %direction ^OUT$
|
||||
account2 expenses:paypal:%subaccount:%currency_
|
||||
|
||||
if %direction ^OUT$
|
||||
& %fees [1-9]
|
||||
account3 assets:paypal:%subaccount:%currency_
|
||||
amount3 -%fees %currency_
|
||||
account4 expenses:paypal:%subaccount:fees:%currency_
|
||||
amount4 %fees %currency_
|
||||
|
||||
if %direction ^OUT$
|
||||
& %description_ ^PayPal$
|
||||
& %type ^Account Hold for Open Authorization$
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
"Date","Time","TimeZone","Name","Type","Status","Currency","Amount","Receipt ID","Balance"
|
||||
"01/01/2021","01:01:01","PDT","","Bank Deposit to PP Account ","Pending","USD","3,000.00","","3,000.00"
|
||||
"02/02/2021","02:02:02","PDT","Foo Bar Inc.","Express Checkout Payment","Completed","USD","-3,000.00","","0.00"
|
||||
"02/02/2021","02:02:03","PDT","Foo Bar Inc.","Payment Refund","Completed","USD","3,000.00","","3,000.00"
|
||||
"03/03/2021","03:03:03","PDT","Baz biz","Subscription Payment","Completed","USD","-123.45","","2,876.55"
|
||||
"03/03/2021","03:03:04","PDT","Baz biz","Payment Refund","Completed","USD","123.45","","3,000.00"
|
||||
"01/01/2022","01:01:01","PST","A Friend","General Payment","Completed","USD","550.00","","3,550.00"
|
||||
"01/01/2022","01:01:01","PST","","General Withdrawal","Completed","USD","-456.78","","3,093.22"
|
||||
"02/02/2022","02:02:02","PST","Company LLC","Express Checkout Payment","Completed","USD","-150.50","","2,942.72"
|
||||
"02/02/2022","02:02:02","PST","","General Card Deposit","Completed","USD","25.00","","2,967.72"
|
||||
"03/03/2022","03:03:03","PST","","General Withdrawal","Completed","USD","-500.00","","2,467.72"
|
||||
"03/03/2022","03:03:03","PDT","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-252.25","","2,215.47"
|
||||
"01/01/2023","01:01:01","PDT","Family member","General Payment","Completed","USD","300.00","","2,515.47"
|
||||
"01/01/2023","01:01:01","PDT","","General Withdrawal","Completed","USD","-200.00","","2,315.47"
|
||||
"02/02/2023","02:02:02","PDT","PayPal","General Bonus","Completed","USD","5.00","","2,320.47"
|
||||
"02/02/2023","02:02:02","PDT","Company LLC","General Payment","Completed","USD","-300.00","","2,020.47"
|
||||
"03/03/2023","03:03:03","PDT","","Bank Deposit to PP Account ","Pending","USD","100.00","","2,120.47"
|
||||
"03/03/2023","03:03:03","PDT","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-100.00","","2,020.47"
|
||||
"Date","Time","TimeZone","Name","Type","Status","Currency","Amount","Fees","Total","Exchange Rate","Receipt ID","Balance","Transaction ID","Item Title"
|
||||
"01/01/2021","01:01:01","PST","","Bank Deposit to PP Account ","Pending","USD","3,000.00","0.00","3,000.00",,"","3,000.00","",""
|
||||
"02/02/2021","02:02:02","PST","Foo Bar Inc.","Express Checkout Payment","Completed","USD","-3,000.00","0.00","-3,000.00",,"",0.00,"",""
|
||||
"02/02/2021","02:02:03","PST","Foo Bar Inc.","Payment Refund","Completed","USD","3,000.00","0.00","3,000.00",,"","3,000.00","",""
|
||||
"03/03/2021","03:03:03","PST","Baz biz","Subscription Payment","Completed","USD","-123.45","0.00","-123.45",,"","2,876.55","",""
|
||||
"03/03/2021","03:03:04","PST","Baz biz","Payment Refund","Completed","USD","123.45","0.00","123.45",,"","3,000.00","",""
|
||||
"01/01/2022","01:01:01","PST","A Friend","General Payment","Completed","USD","550.00","0.00","550.00",,"","3,550.00","XXXXXXXXXXXXXXXX1","My title 01"
|
||||
"01/01/2022","01:01:01","PST","","General Withdrawal","Completed","USD",-456.78,"0.00","-456.78",,"","3,093.22","",""
|
||||
"02/02/2022","02:02:02","PST","Company LLC","Express Checkout Payment","Completed","USD","-150.50","0.00","-150.50",,"","2,942.72","",""
|
||||
"02/02/2022","02:02:02","PST","","General Card Deposit","Completed","USD","25.00","0.00","25.00",,"","2,967.72","",""
|
||||
"03/03/2022","03:03:03","PST","","General Withdrawal","Completed","USD","-500.00","0.00","-500.00",,"","2,467.72","",""
|
||||
"03/03/2022","03:03:03","PST","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-252.25","0.00","-252.25",,"","2,215.47","",""
|
||||
"01/01/2023","01:01:01","PST","Family member","General Payment","Completed","USD","300.00","0.00","300.00",,"","2,515.47","XXXXXXXXXXXXXXXX2","My title 02"
|
||||
"01/01/2023","01:01:01","PST","","General Withdrawal","Completed","USD","-200.00","0.00","-200.00",,"","2,315.47","",""
|
||||
"02/02/2023","02:02:02","PST","PayPal","General Bonus","Completed","USD","5.00","0.00","5.00",,"","2,320.47","",""
|
||||
"02/02/2023","02:02:02","PST","Company LLC","General Payment","Completed","USD","-300.00","0.00","-300.00",,"","2,020.47","",""
|
||||
"03/03/2023","03:03:03","PST","","Bank Deposit to PP Account ","Pending","USD","100.00","0.00","100.00",,"","2,120.47","",""
|
||||
"03/03/2023","03:03:03","PST","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-100.00","10.00","-110.00",,"","2,010.47","",""
|
||||
|
||||
|
@@ -1,18 +1,18 @@
|
||||
"Date","Time","TimeZone","Name","Type","Status","Currency","Amount","Receipt ID","Balance"
|
||||
"01/01/2021","01:01:01","PDT","","Bank Deposit to PP Account ","Pending","USD","3,000.00","","3,000.00"
|
||||
"02/02/2021","02:02:02","PDT","Foo Bar Inc.","Express Checkout Payment","Completed","USD","-3,000.00","","0.00"
|
||||
"02/02/2021","02:02:03","PDT","Foo Bar Inc.","Payment Refund","Completed","USD","3,000.00","","3,000.00"
|
||||
"03/03/2021","03:03:03","PDT","Baz biz","Subscription Payment","Completed","USD","-123.45","","2,876.55"
|
||||
"03/03/2021","03:03:04","PDT","Baz biz","Payment Refund","Completed","USD","123.45","","3,000.00"
|
||||
"01/01/2022","01:01:01","PST","A Friend","General Payment","Completed","USD","550.00","","3,550.00"
|
||||
"01/01/2022","01:01:01","PST","","General Withdrawal","Completed","USD","-456.78","","3,093.22"
|
||||
"02/02/2022","02:02:02","PST","Company LLC","Express Checkout Payment","Completed","USD","-150.50","","2,942.72"
|
||||
"02/02/2022","02:02:02","PST","","General Card Deposit","Completed","USD","25.00","","2,967.72"
|
||||
"03/03/2022","03:03:03","PST","","General Withdrawal","Completed","USD","-500.00","","2,467.72"
|
||||
"03/03/2022","03:03:03","PDT","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-252.25","","2,215.47"
|
||||
"01/01/2023","01:01:01","PDT","Family member","General Payment","Completed","USD","300.00","","2,515.47"
|
||||
"01/01/2023","01:01:01","PDT","","General Withdrawal","Completed","USD","-200.00","","2,315.47"
|
||||
"02/02/2023","02:02:02","PDT","PayPal","General Bonus","Completed","USD","5.00","","2,320.47"
|
||||
"02/02/2023","02:02:02","PDT","Company LLC","General Payment","Completed","USD","-300.00","","2,020.47"
|
||||
"03/03/2023","03:03:03","PDT","","Bank Deposit to PP Account ","Pending","USD","100.00","","2,120.47"
|
||||
"03/03/2023","03:03:03","PDT","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-100.00","","2,020.47"
|
||||
"Date","Time","TimeZone","Name","Type","Status","Currency","Amount","Fees","Total","Exchange Rate","Receipt ID","Balance","Transaction ID","Item Title"
|
||||
"01/01/2021","01:01:01","PST","","Bank Deposit to PP Account ","Pending","USD","3,000.00","0.00","3,000.00",,"","3,000.00","",""
|
||||
"02/02/2021","02:02:02","PST","Foo Bar Inc.","Express Checkout Payment","Completed","USD","-3,000.00","0.00","-3,000.00",,"",0.00,"",""
|
||||
"02/02/2021","02:02:03","PST","Foo Bar Inc.","Payment Refund","Completed","USD","3,000.00","0.00","3,000.00",,"","3,000.00","",""
|
||||
"03/03/2021","03:03:03","PST","Baz biz","Subscription Payment","Completed","USD","-123.45","0.00","-123.45",,"","2,876.55","",""
|
||||
"03/03/2021","03:03:04","PST","Baz biz","Payment Refund","Completed","USD","123.45","0.00","123.45",,"","3,000.00","",""
|
||||
"01/01/2022","01:01:01","PST","A Friend","General Payment","Completed","USD","550.00","0.00","550.00",,"","3,550.00","XXXXXXXXXXXXXXXX1","My title 01"
|
||||
"01/01/2022","01:01:01","PST","","General Withdrawal","Completed","USD",-456.78,"0.00","-456.78",,"","3,093.22","",""
|
||||
"02/02/2022","02:02:02","PST","Company LLC","Express Checkout Payment","Completed","USD","-150.50","0.00","-150.50",,"","2,942.72","",""
|
||||
"02/02/2022","02:02:02","PST","","General Card Deposit","Completed","USD","25.00","0.00","25.00",,"","2,967.72","",""
|
||||
"03/03/2022","03:03:03","PST","","General Withdrawal","Completed","USD","-500.00","0.00","-500.00",,"","2,467.72","",""
|
||||
"03/03/2022","03:03:03","PST","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-252.25","0.00","-252.25",,"","2,215.47","",""
|
||||
"01/01/2023","01:01:01","PST","Family member","General Payment","Completed","USD","300.00","0.00","300.00",,"","2,515.47","XXXXXXXXXXXXXXXX2","My title 02"
|
||||
"01/01/2023","01:01:01","PST","","General Withdrawal","Completed","USD","-200.00","0.00","-200.00",,"","2,315.47","",""
|
||||
"02/02/2023","02:02:02","PST","PayPal","General Bonus","Completed","USD","5.00","0.00","5.00",,"","2,320.47","",""
|
||||
"02/02/2023","02:02:02","PST","Company LLC","General Payment","Completed","USD","-300.00","0.00","-300.00",,"","2,020.47","",""
|
||||
"03/03/2023","03:03:03","PST","","Bank Deposit to PP Account ","Pending","USD","100.00","0.00","100.00",,"","2,120.47","",""
|
||||
"03/03/2023","03:03:03","PST","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-100.00","10.00","-110.00",,"","2,010.47","",""
|
||||
|
||||
|
@@ -1,18 +1,18 @@
|
||||
"Date","Time","TimeZone","Name","Type","Status","Currency","Amount","Receipt ID","Balance"
|
||||
"01/01/2021","01:01:01","PDT","","Bank Deposit to PP Account ","Pending","USD","3,000.00","","3,000.00"
|
||||
"02/02/2021","02:02:02","PDT","Foo Bar Inc.","Express Checkout Payment","Completed","USD","-3,000.00","","0.00"
|
||||
"02/02/2021","02:02:03","PDT","Foo Bar Inc.","Payment Refund","Completed","USD","3,000.00","","3,000.00"
|
||||
"03/03/2021","03:03:03","PDT","Baz biz","Subscription Payment","Completed","USD","-123.45","","2,876.55"
|
||||
"03/03/2021","03:03:04","PDT","Baz biz","Payment Refund","Completed","USD","123.45","","3,000.00"
|
||||
"01/01/2022","01:01:01","PST","A Friend","General Payment","Completed","USD","550.00","","3,550.00"
|
||||
"01/01/2022","01:01:01","PST","","General Withdrawal","Completed","USD","-456.78","","3,093.22"
|
||||
"02/02/2022","02:02:02","PST","Company LLC","Express Checkout Payment","Completed","USD","-150.50","","2,942.72"
|
||||
"02/02/2022","02:02:02","PST","","General Card Deposit","Completed","USD","25.00","","2,967.72"
|
||||
"03/03/2022","03:03:03","PST","","General Withdrawal","Completed","USD","-500.00","","2,467.72"
|
||||
"03/03/2022","03:03:03","PDT","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-252.25","","2,215.47"
|
||||
"01/01/2023","01:01:01","PDT","Family member","General Payment","Completed","USD","300.00","","2,515.47"
|
||||
"01/01/2023","01:01:01","PDT","","General Withdrawal","Completed","USD","-200.00","","2,315.47"
|
||||
"02/02/2023","02:02:02","PDT","PayPal","General Bonus","Completed","USD","5.00","","2,320.47"
|
||||
"02/02/2023","02:02:02","PDT","Company LLC","General Payment","Completed","USD","-300.00","","2,020.47"
|
||||
"03/03/2023","03:03:03","PDT","","Bank Deposit to PP Account ","Pending","USD","100.00","","2,120.47"
|
||||
"03/03/2023","03:03:03","PDT","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-100.00","","2,020.47"
|
||||
"Date","Time","TimeZone","Name","Type","Status","Currency","Amount","Fees","Total","Exchange Rate","Receipt ID","Balance","Transaction ID","Item Title"
|
||||
"01/01/2021","01:01:01","PST","","Bank Deposit to PP Account ","Pending","USD","3,000.00","0.00","3,000.00",,"","3,000.00","",""
|
||||
"02/02/2021","02:02:02","PST","Foo Bar Inc.","Express Checkout Payment","Completed","USD","-3,000.00","0.00","-3,000.00",,"",0.00,"",""
|
||||
"02/02/2021","02:02:03","PST","Foo Bar Inc.","Payment Refund","Completed","USD","3,000.00","0.00","3,000.00",,"","3,000.00","",""
|
||||
"03/03/2021","03:03:03","PST","Baz biz","Subscription Payment","Completed","USD","-123.45","0.00","-123.45",,"","2,876.55","",""
|
||||
"03/03/2021","03:03:04","PST","Baz biz","Payment Refund","Completed","USD","123.45","0.00","123.45",,"","3,000.00","",""
|
||||
"01/01/2022","01:01:01","PST","A Friend","General Payment","Completed","USD","550.00","0.00","550.00",,"","3,550.00","XXXXXXXXXXXXXXXX1","My title 01"
|
||||
"01/01/2022","01:01:01","PST","","General Withdrawal","Completed","USD",-456.78,"0.00","-456.78",,"","3,093.22","",""
|
||||
"02/02/2022","02:02:02","PST","Company LLC","Express Checkout Payment","Completed","USD","-150.50","0.00","-150.50",,"","2,942.72","",""
|
||||
"02/02/2022","02:02:02","PST","","General Card Deposit","Completed","USD","25.00","0.00","25.00",,"","2,967.72","",""
|
||||
"03/03/2022","03:03:03","PST","","General Withdrawal","Completed","USD","-500.00","0.00","-500.00",,"","2,467.72","",""
|
||||
"03/03/2022","03:03:03","PST","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-252.25","0.00","-252.25",,"","2,215.47","",""
|
||||
"01/01/2023","01:01:01","PST","Family member","General Payment","Completed","USD","300.00","0.00","300.00",,"","2,515.47","XXXXXXXXXXXXXXXX2","My title 02"
|
||||
"01/01/2023","01:01:01","PST","","General Withdrawal","Completed","USD","-200.00","0.00","-200.00",,"","2,315.47","",""
|
||||
"02/02/2023","02:02:02","PST","PayPal","General Bonus","Completed","USD","5.00","0.00","5.00",,"","2,320.47","",""
|
||||
"02/02/2023","02:02:02","PST","Company LLC","General Payment","Completed","USD","-300.00","0.00","-300.00",,"","2,020.47","",""
|
||||
"03/03/2023","03:03:03","PST","","Bank Deposit to PP Account ","Pending","USD","100.00","0.00","100.00",,"","2,120.47","",""
|
||||
"03/03/2023","03:03:03","PST","Another Company","PreApproved Payment Bill User Payment","Completed","USD","-100.00","10.00","-110.00",,"","2,010.47","",""
|
||||
|
||||
|
Reference in New Issue
Block a user