Update readme. Refactor toldg a little. Provide example files for testing by the user.
This commit is contained in:
44
example/Makefile
Normal file
44
example/Makefile
Normal file
@@ -0,0 +1,44 @@
|
||||
PY?=python3
|
||||
LEDGER=hledger
|
||||
TOLDG=$(PY) ../toldg.py
|
||||
GETOFX=$(PY) ../getofx.py
|
||||
|
||||
TOLDG_CONFIG=configs/toldg.json
|
||||
GETOFX_CONFIG=configs/getofx.json
|
||||
LEDGER_FILES=$(wildcard processed/*.ldg)
|
||||
OUTPUTDIR=processed
|
||||
LEDGER_ALL=result.ldg
|
||||
|
||||
all: toldg merge
|
||||
|
||||
help:
|
||||
@echo 'Makefile for Ledger automation '
|
||||
@echo ' '
|
||||
@echo 'Usage: '
|
||||
@echo ' make getofx download ofx data and write to CSV '
|
||||
@echo ' make toldg transform CSV files into LDG files '
|
||||
@echo ' make merge merge all ldg files into one '
|
||||
@echo ' make bs show hledger balance '
|
||||
@echo ' make ui open hledger-ui in tree view '
|
||||
@echo ' make clean remove ledger files from output dir'
|
||||
@echo ' '
|
||||
|
||||
getofx:
|
||||
@$(GETOFX) $(GETOFX_CONFIG)
|
||||
|
||||
toldg:
|
||||
@$(TOLDG) $(TOLDG_CONFIG)
|
||||
|
||||
merge:
|
||||
@cat $(LEDGER_FILES) > $(LEDGER_ALL)
|
||||
|
||||
bs:
|
||||
@echo ""
|
||||
@$(LEDGER) bs -V --depth 2 -f $(LEDGER_ALL)
|
||||
|
||||
ui:
|
||||
hledger-ui -V --tree --depth 2 -f $(LEDGER_ALL)
|
||||
|
||||
clean:
|
||||
@[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)/*
|
||||
|
||||
28
example/configs/getofx.json
Normal file
28
example/configs/getofx.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"secret": "s3cr3t",
|
||||
"client": {
|
||||
"url": "https://ofx.bank.com",
|
||||
"userid": "userid",
|
||||
"org": "B1",
|
||||
"clientuid": "clientuid",
|
||||
"fid": "fid",
|
||||
"bankid": "bankid",
|
||||
"version": 220
|
||||
},
|
||||
"accounts": [
|
||||
{
|
||||
"name": "OFX Checking",
|
||||
"accttype": "checking",
|
||||
"acctid": "111111",
|
||||
"csv_file": "inputs/2018_checking.csv",
|
||||
"fields": [ "", "date", "description", "amount", "", "", "" ]
|
||||
},
|
||||
{
|
||||
"name": "OFX Credit",
|
||||
"accttype": "credit",
|
||||
"acctid": "111111",
|
||||
"csv_file": "inputs/2018_credit.csv",
|
||||
"fields": ["date", "", "description", "", "", "amount"]
|
||||
}
|
||||
]
|
||||
}
|
||||
17
example/configs/toldg.json
Normal file
17
example/configs/toldg.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"input_directory": "inputs",
|
||||
"output_directory": "processed",
|
||||
"mappings_directory": "mappings",
|
||||
"csv_configs": [
|
||||
{
|
||||
"account1": "assets:checking",
|
||||
"file_match_regex": ".*_checking\\.csv",
|
||||
"fields": [ "", "date", "description", "amount", "", "", "" ]
|
||||
},
|
||||
{
|
||||
"account1": "liabilities:credit",
|
||||
"file_match_regex": ".*_credit\\.csv",
|
||||
"fields": ["date", "", "description", "", "", "amount"]
|
||||
}
|
||||
]
|
||||
}
|
||||
9
example/inputs/2018_checking.csv
Normal file
9
example/inputs/2018_checking.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
Details,Posting Date,Description,Amount,Type,Balance,Check or Slip #
|
||||
DEBIT,12/24/2018,"KROGER 12/22",-25.87,DEBIT_CARD,0,,
|
||||
DEBIT,12/20/2018,"KROGER 12/19",-47.77,DEBIT_CARD,0,,
|
||||
DEBIT,12/17/2018,"TARGET",-28.77,DEBIT_CARD,0,,
|
||||
DEBIT,12/04/2018,"TARGET",-45.33,DEBIT_CARD,0,,
|
||||
CREDIT,11/30/2018,"EMPLOYER USA LLC QUICKBOOKS",1337.28,ACH_CREDIT,0,,
|
||||
DEBIT,11/06/2018,"KROGER 11/05",-12.97,DEBIT_CARD,3788.97,,
|
||||
CREDIT,11/02/2018,"EMPLOYER USA LLC QUICKBOOKS",1337.50,ACH_CREDIT,0,,
|
||||
DEBIT,10/30/2018,"Payment to credit card ending in 1337 10/30",-59.90,ACCT_XFER,0,,
|
||||
|
6
example/inputs/2018_credit.csv
Normal file
6
example/inputs/2018_credit.csv
Normal file
@@ -0,0 +1,6 @@
|
||||
Transaction Date,Post Date,Description,Category,Type,Amount
|
||||
12/03/2018,12/04/2018,UBER ABO13,Travel,Sale,-29.37
|
||||
11/20/2018,11/21/2018,UBER OBC3E,Travel,Sale,-30.41
|
||||
11/19/2018,11/20/2018,KROGER 1337,Groceries,Sale,-10.74
|
||||
11/18/2018,11/19/2018,METRO #83,Groceries,Sale,-12.34
|
||||
10/30/2018,10/30/2018,Payment Thank You - Web,,Payment,59.90
|
||||
|
5
example/inputs/2018_manual.ldg
Normal file
5
example/inputs/2018_manual.ldg
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
2018/09/06 Opening Balance
|
||||
assets:checking $-479.86
|
||||
equity:opening balances
|
||||
|
||||
2
example/mappings/checking.csv
Normal file
2
example/mappings/checking.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
income:job,EMPLOYER USA LLC QUICKBOOKS
|
||||
assets:transfers:checking-credit,/Payment to credit card ending in 1337/
|
||||
|
4
example/mappings/credit.csv
Normal file
4
example/mappings/credit.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
assets:transfers:checking-credit,Payment Thank You - Web
|
||||
expenses:household,TARGET,credit=-28.77;date=2018/12/17
|
||||
expenses:car,METRO #83,credit=-12.34
|
||||
expenses:car,UBER OBC3E,credit=-30.41;date=2018/11/20
|
||||
|
2
example/mappings/groceries.csv
Normal file
2
example/mappings/groceries.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
expenses:groceries,/KROGER/
|
||||
expenses:groceries,TARGET,credit=-45.33;date=2018/12/04
|
||||
|
57
example/result.ldg
Normal file
57
example/result.ldg
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
2018/12/24 KROGER 12/22 ; DEBIT, 12/24/2018, KROGER 12/22, -25.87, DEBIT_CARD, 0, ,
|
||||
expenses:groceries $ 25.87
|
||||
assets:checking $ -25.87
|
||||
|
||||
2018/12/20 KROGER 12/19 ; DEBIT, 12/20/2018, KROGER 12/19, -47.77, DEBIT_CARD, 0, ,
|
||||
expenses:groceries $ 47.77
|
||||
assets:checking $ -47.77
|
||||
|
||||
2018/12/17 TARGET ; DEBIT, 12/17/2018, TARGET, -28.77, DEBIT_CARD, 0, ,
|
||||
expenses:household $ 28.77
|
||||
assets:checking $ -28.77
|
||||
|
||||
2018/12/04 TARGET ; DEBIT, 12/04/2018, TARGET, -45.33, DEBIT_CARD, 0, ,
|
||||
expenses:groceries $ 45.33
|
||||
assets:checking $ -45.33
|
||||
|
||||
2018/11/30 EMPLOYER USA LLC QUICKBOOKS ; CREDIT, 11/30/2018, EMPLOYER USA LLC QUICKBOOKS, 1337.28, ACH_CREDIT, 0, ,
|
||||
income:job $ -1337.28
|
||||
assets:checking $ 1337.28
|
||||
|
||||
2018/11/06 KROGER 11/05 ; DEBIT, 11/06/2018, KROGER 11/05, -12.97, DEBIT_CARD, 3788.97, ,
|
||||
expenses:groceries $ 12.97
|
||||
assets:checking $ -12.97
|
||||
|
||||
2018/11/02 EMPLOYER USA LLC QUICKBOOKS ; CREDIT, 11/02/2018, EMPLOYER USA LLC QUICKBOOKS, 1337.50, ACH_CREDIT, 0, ,
|
||||
income:job $ -1337.50
|
||||
assets:checking $ 1337.50
|
||||
|
||||
2018/10/30 Payment to credit card ending in 1337 10/30 ; DEBIT, 10/30/2018, Payment to credit card ending in 1337 10/30, -59.90, ACCT_XFER, 0, ,
|
||||
assets:transfers:checking-credit $ 59.90
|
||||
assets:checking $ -59.90
|
||||
|
||||
2018/12/03 UBER ABO13 ; 12/03/2018, 12/04/2018, UBER ABO13, Travel, Sale, -29.37
|
||||
expenses $ 29.37
|
||||
liabilities:credit $ -29.37
|
||||
|
||||
2018/11/20 UBER OBC3E ; 11/20/2018, 11/21/2018, UBER OBC3E, Travel, Sale, -30.41
|
||||
expenses:car $ 30.41
|
||||
liabilities:credit $ -30.41
|
||||
|
||||
2018/11/19 KROGER 1337 ; 11/19/2018, 11/20/2018, KROGER 1337, Groceries, Sale, -10.74
|
||||
expenses:groceries $ 10.74
|
||||
liabilities:credit $ -10.74
|
||||
|
||||
2018/11/18 METRO #83 ; 11/18/2018, 11/19/2018, METRO #83, Groceries, Sale, -12.34
|
||||
expenses:car $ 12.34
|
||||
liabilities:credit $ -12.34
|
||||
|
||||
2018/10/30 Payment Thank You - Web ; 10/30/2018, 10/30/2018, Payment Thank You - Web, , Payment, 59.90
|
||||
assets:transfers:checking-credit $ -59.90
|
||||
liabilities:credit $ 59.90
|
||||
|
||||
2018/09/06 Opening Balance
|
||||
assets:checking $-479.86
|
||||
equity:opening balances
|
||||
|
||||
Reference in New Issue
Block a user