-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtransaction_fixes_example.py
More file actions
56 lines (36 loc) · 1.45 KB
/
transaction_fixes_example.py
File metadata and controls
56 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
transaction_fixes_example.py -- stub fixes functions (copy to ~/ledger/transaction_fixes.py)
Each function receives a data.Transaction and returns a (possibly modified) Transaction.
The stubs below return the transaction unchanged — a valid starting point.
Extend with your own rules, e.g.:
if 'Card payment to myStore' in txn.narration:
txn = txn._replace(payee='myStore')
txn = txn._replace(postings=[...])
return txn
Cross-importer rules go in common_fixes(); call it first from each per-importer function.
"""
from beancount.core import data
def common_fixes(txn: data.Transaction) -> data.Transaction:
"""Rules that apply identically across all importers (e.g. well-known payees)."""
return txn
def fixes_zkb(txn: data.Transaction) -> data.Transaction:
txn = common_fixes(txn)
return txn
def fixes_pfg(txn: data.Transaction) -> data.Transaction:
txn = common_fixes(txn)
return txn
def fixes_neon(txn: data.Transaction) -> data.Transaction:
txn = common_fixes(txn)
return txn
def fixes_revolut(txn: data.Transaction) -> data.Transaction:
txn = common_fixes(txn)
return txn
def fixes_ibkr(txn: data.Transaction) -> data.Transaction:
txn = common_fixes(txn)
return txn
def fixes_finpension(txn: data.Transaction) -> data.Transaction:
txn = common_fixes(txn)
return txn
def fixes_halbtax(txn: data.Transaction) -> data.Transaction:
txn = common_fixes(txn)
return txn