Skip to content

Commit

Permalink
Added convert2ofx example.
Browse files Browse the repository at this point in the history
  • Loading branch information
gpaulissen committed Jun 7, 2020
1 parent 8149958 commit 02b5d40
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@ beancount_import/frontend_dist
.coverage
htmlcov/
.*.ofx
*~
16 changes: 14 additions & 2 deletions README.md
Expand Up @@ -12,6 +12,15 @@ each other and with existing transactions.
- Pluggable data source architecture, including existing support for OFX (cash,
investment, and retirement accounts), Mint.com, Amazon.com, and Venmo.

- Due to the existing OFX support and the tool
[ofxstatement](https://github.com/kedder/ofxstatement) it is very easy to
import any financial source provided there is an ofxstatement plugin for
it. Currently the plugin ofxstatement-dutch is part of the setup allowing
you to convert ICSCards PDF files (or PDF converted to TEXT) to an OFX
file. Please note that you need to have the pdftotext utility to convert PDF
to TEXT, please follow the instructions of the [ofxstatement-dutch
README](https://github.com/gpaulissen/ofxstatement-dutch).

- Robustly associates imported transactions with the source data, to
automatically avoid duplicates.

Expand Down Expand Up @@ -124,15 +133,18 @@ The currently supported set of data sources is:
[Morgan Stanley StockPlan Connect](https://stockplanconnect.com).
- [beancount_import.source.ultipro_google](beancount_import/source/ultipro_google.py):
imports Google employee Ultipro payroll statements.
- [beancount_import.source.icscards](beancount_import/source/icscards.py):
imports ICSCards PDF files (after converting them to an OFX file).

Refer to the individual data source documentation for details on configuration.

# Usage

To run Beancount-import, create a Python script that invokes the
`beancount_import.webserver.main` function. Refer to the examples
[fresh](examples/fresh/run.py) and
[manually_entered](examples/manually_entered/run.py).
[fresh](examples/fresh/run.py),
[manually_entered](examples/manually_entered/run.py) and
[convert2ofx](examples/convert2ofx/run.py).

## Errors

Expand Down
5 changes: 5 additions & 0 deletions examples/convert2ofx/accounts.beancount
@@ -0,0 +1,5 @@
1900-01-01 open Liabilities:Credit-Card EUR
ofx_org: ""
ofx_broker_id: ""
ofx_account_type: "cash_only"
account_id: "99999999999"
Empty file.
3 changes: 3 additions & 0 deletions examples/convert2ofx/journal.beancount
@@ -0,0 +1,3 @@
include "accounts.beancount"
include "transactions.beancount"
include "prices.beancount"
Empty file.
45 changes: 45 additions & 0 deletions examples/convert2ofx/run.py
@@ -0,0 +1,45 @@
#!/usr/bin/env python3

import glob
import os
import json
import sys

from beancount_import.source.ofx import convert2ofx

def run_reconcile(extra_args):
import beancount_import.webserver

journal_dir = os.path.dirname(__file__)
data_dir = os.path.join(os.path.dirname(__file__), '..', '..', 'testdata', 'source', 'icscards')
force = False

data_sources = [
dict(
module='beancount_import.source.ofx',
ofx_filenames=(
convert2ofx('nl-icscards', glob.glob(os.path.join(data_dir, 'icscards.txt')), force)
),
checknum_numeric=lambda ofx_filename: False,
check_balance=lambda ofx_filename: False,
),
]

beancount_import.webserver.main(
extra_args,
journal_input=os.path.join(journal_dir, 'journal.beancount'),
ignored_journal=os.path.join(journal_dir, 'ignored.beancount'),
default_output=os.path.join(journal_dir, 'transactions.beancount'),
open_account_output_map=[
('.*', os.path.join(journal_dir, 'accounts.beancount')),
],
balance_account_output_map=[
('.*', os.path.join(journal_dir, 'accounts.beancount')),
],
price_output=os.path.join(journal_dir, 'prices.beancount'),
data_sources=data_sources,
)


if __name__ == '__main__':
run_reconcile(sys.argv[1:])
Empty file.

0 comments on commit 02b5d40

Please sign in to comment.