hledger-flow: ledger: add 'Status' column

Refactored for upstream addition.
This commit is contained in:
2024-06-29 23:25:56 -07:00
parent 01ae223762
commit e5706103e6
2 changed files with 18 additions and 17 deletions

View File

@@ -35,7 +35,7 @@ source "${DOCKER_FINANCE_CONTAINER_REPO}/src/hledger-flow/lib/lib_preprocess.bas
function parse() function parse()
{ {
lib_preprocess::assert_header "Operation Date,Currency Ticker,Operation Type,Operation Amount,Operation Fees,Operation Hash,Account Name,Account xpub,Countervalue Ticker,Countervalue at Operation Date,Countervalue at CSV Export" lib_preprocess::assert_header "Operation Date,Status,Currency Ticker,Operation Type,Operation Amount,Operation Fees,Operation Hash,Account Name,Account xpub,Countervalue Ticker,Countervalue at Operation Date,Countervalue at CSV Export"
# NOTE: subaccount (account label) is entered within app. # NOTE: subaccount (account label) is entered within app.
# Label your subaccount as subaccount1:subaccount2:etc # Label your subaccount as subaccount1:subaccount2:etc
@@ -56,22 +56,23 @@ function parse()
gsub(/,1INCH,/,",ONEINCH,") gsub(/,1INCH,/,",ONEINCH,")
printf $1 OFS # Operation Date printf $1 OFS # Operation Date
printf $2 OFS # Currency Ticker printf $2 OFS # Status
printf $3 OFS # Operation Type printf $3 OFS # Currency Ticker
printf $4 OFS # Operation Type
# Operation Amount (minus fee w/ this regexp) # Operation Amount (minus fee w/ this regexp)
amount=($3 ~ /^OUT$|^DELEGATE$/ ? $4-$5 : $4) amount=($4 ~ /^OUT$|^DELEGATE$/ ? $5-$6 : $5)
printf("%.8f", amount); printf OFS printf("%.8f", amount); printf OFS
printf("%.8f", $5); printf OFS # Operation Fees printf("%.8f", $6); printf OFS # Operation Fees
printf $6 OFS # Operation Hash printf $7 OFS # Operation Hash
printf $7 OFS # Account Name (subaccount) printf $8 OFS # Account Name (subaccount)
printf $8 OFS # Account xpub printf $9 OFS # Account xpub
printf $9 OFS # Countervalue Ticker printf $10 OFS # Countervalue Ticker
printf $10 OFS # Countervalue at Operation Date printf $11 OFS # Countervalue at Operation Date
printf $11 OFS # Countervalue at CSV Export printf $12 OFS # Countervalue at CSV Export
direction=($3 ~ /^OUT$|^DELEGATE$/ ? "OUT" : "IN") direction=($4 ~ /^OUT$|^DELEGATE$/ ? "OUT" : "IN")
printf direction printf direction
printf "\n" printf "\n"

View File

@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
fields date,currency_,type,amount_,fees,txid,account_name,xpub,counter_symbol,countervalue_at_op,countervalue_at_export,direction fields date,status_,currency_,type,amount_,fees,txid,account_name,xpub,counter_symbol,countervalue_at_op,countervalue_at_export,direction
date-format %Y-%m-%d %H:%M:%S date-format %Y-%m-%d %H:%M:%S
description %date +0000 description %date +0000
@@ -23,7 +23,7 @@ description %date +0000
account1 assets:ledger:%account_name:%currency_ account1 assets:ledger:%account_name:%currency_
amount %amount_ %currency_ amount %amount_ %currency_
comment type:%type, xpub:%xpub, txid:%txid, direction:%direction comment type:%type, status:%status_, xpub:%xpub, txid:%txid, direction:%direction
if %type ^OUT$ if %type ^OUT$
amount -%amount_ %currency_ amount -%amount_ %currency_
@@ -41,7 +41,7 @@ if %type ^OUT$
amount3 -%fees %currency_ amount3 -%fees %currency_
account4 expenses:ledger:fees:%account_name:%currency_ account4 expenses:ledger:fees:%account_name:%currency_
amount4 %fees %currency_ amount4 %fees %currency_
comment type:%type, xpub:%xpub, txid:%txid, direction:%direction, taxed_as:SPEND comment type:%type, status:%status_, xpub:%xpub, txid:%txid, direction:%direction, taxed_as:SPEND
comment2 comment2
comment3 %date +0000,SPEND,ledger,%currency_,%fees,USD,,FEE comment3 %date +0000,SPEND,ledger,%currency_,%fees,USD,,FEE
# NOTE: comment3 apparently doesn't work (without comment2?) so use comment2 here. # NOTE: comment3 apparently doesn't work (without comment2?) so use comment2 here.
@@ -84,7 +84,7 @@ if %currency_ ^ADA$
amount3 -%fees %currency_ amount3 -%fees %currency_
account4 expenses:ledger:fees:%account_name:%currency_ account4 expenses:ledger:fees:%account_name:%currency_
amount4 %fees %currency_ amount4 %fees %currency_
comment type:%type, xpub:%xpub, txid:%txid, direction:%direction, taxed_as:SPEND comment type:%type, status:%status_, xpub:%xpub, txid:%txid, direction:%direction, taxed_as:SPEND
comment3 %date +0000,SPEND,ledger,%currency_,%fees,USD,,FEE comment3 %date +0000,SPEND,ledger,%currency_,%fees,USD,,FEE
# Will be delegate-key amount, not pledged amount # Will be delegate-key amount, not pledged amount
@@ -97,7 +97,7 @@ if %currency_ ^ADA$
amount3 -%amount_ %currency_ amount3 -%amount_ %currency_
account4 expenses:ledger:fees:%account_name:%currency_ account4 expenses:ledger:fees:%account_name:%currency_
amount4 %amount_ %currency_ amount4 %amount_ %currency_
comment type:%type, xpub:%xpub, txid:%txid, direction:%direction, taxed_as:SPEND comment type:%type, status:%status_, xpub:%xpub, txid:%txid, direction:%direction, taxed_as:SPEND
comment2 Stake key registration withdrawal comment2 Stake key registration withdrawal
comment3 %date +0000,SPEND,ledger,%currency_,%amount_,USD,,FEE comment3 %date +0000,SPEND,ledger,%currency_,%amount_,USD,,FEE