Ob-ledger-convert provide Babel function to convert any bank/card statement transactions to ledger format which can be used with ledger/hledger/beancount. It provides an org source code block called lc
which can contain any bank/card statement and provide ledger entries as results on execution. The module provides some pre-defined parsers to do the conversion. More parsers can be easily added.
Git clone this repo and then load using use-package
like this
(use-package ob-lc
:load-path "~/git/ob-ledger-convert")
Create the org src block for lc
with the bank/card transactions and then run org-babel-execute-src-block
. Sample below. Also see sample.org for a complete example. The first block below is org babel lc
src block with parameters - :parser
, :account
and :opening-bal
. The second block is the generated ledger entries for the given transactions.
02-04-2023 IMPS/P2A/309115398340/JAYRAJPU/HDFCBANK /Selfcc 13,075.30 39,921.49
02-04-2023 CreditCard Payment XXXX 9999 Ref#MV94QF6T7ZBPMJ 13,075.30 26,846.19
23-04-2023 GST @18% on Charge 2.70 26,843.49
23-04-2023 Consolidated Charges for A/c 15.00 26,828.49
01-05-2023 IMPS/P2A/312113348479/JAYRAJPU/HDFCBANK/Self 140,912.46 167,740.95
01-05-2023 CreditCard Payment XXXX 9999Ref#1AV0DCL01K6JWL 140,912.46 26,828.49
2023-04-02 IMPS/P2A/309115398340/JAYRAJPU/HDFCBANK /Selfcc assets:bank:hdfc -13075.30 INR assets:bank:axis 2023-04-02 CreditCard Payment XXXX 9999 Ref#MV94QF6T7ZBPMJ assets:transfers 13075.30 INR assets:bank:axis 2023-04-23 GST @18% on Charge expenses:misc 2.70 INR assets:bank:axis 2023-04-23 Consolidated Charges for A/c expenses:misc 15.00 INR assets:bank:axis 2023-05-01 IMPS/P2A/312113348479/JAYRAJPU/HDFCBANK/Self assets:bank:hdfc -140912.46 INR assets:bank:axis 2023-05-01 CreditCard Payment XXXX 9999Ref#1AV0DCL01K6JWL assets:transfers 140912.46 INR assets:bank:axis
:verbatim | Output verbatim without parsing. |
:account | This account name. |
:opening-bal | Opening balance for the account. |
:parser | Parser |
Following parsers are supported. See functions starting with ob-lc-parser
in the module file. Currently supported parsers are for Indian bank/cards. Same parser can be used for multiple banks. Parser uses a regex to parse a line and then process it.
Parser | Regex |
---|---|
AXIS | DD-MM-YYYY DESC AMT BAL |
AXIS ACE | DD/MM/YYYY DESC AMT1 CR/DR AMT2 CR/DR |
HDFC, ICICI | DD/MM/YYYY DESC DEBIT CREDIT BAL |
ICICI AmazonPay | DD/MM/YYYY DESC AMT |
IDFC First Bank | DD MMM YY DESC AMT BAL |
Before using ob-lc
, I faced difficulties in parsing PDFs received from bank/card company to extract transaction data. However, with ob-lc
, the process has become much simpler. Now, I can easily copy the transaction lines from the PDF directly into lc
src block. To stay organized, I schedule the processing of credit card and bank statements for the first day of the following month. On the first of each month, I transfer the data from the PDFs into ob-lc
and run org-babel-execute-buffer
. I snooze my statement email to be processed on the first of every month.