~goorzhel/beancount-categorize

Categorize Beancount transactions
a62b6df3 — Antonio Gurgel 2 months ago
Fix missed spot from `dict` subclassing
6cb584f5 — Antonio Gurgel 2 months ago
Simplify `needs_categorization`
ba5c8ace — Antonio Gurgel 2 months ago
Filter transactions in BCD only once

clone

read-only
https://git.sr.ht/~goorzhel/beancount-categorize
read/write
git@git.sr.ht:~goorzhel/beancount-categorize

You can also use your local clone with git send-email.

#Beancount Categorize

Turn single-legged transactions with ugly memos into balanced transactions with readable metadata.

#Example

$ categorize
"`" to skip a transaction;
^C or ^D to write and quit.

2024-01-01 * "D-CHAT GRILL"
  Liabilities:Card 1.00 USD

  Government | California DMV
  NPO | Feed the Childrens
  Bookstore | 1652 Valencia
>

Here you would enter, e.g., Restaurant | D-Chat Grill. The program confirms the entry and prompts for a Beancount account (or "category").

> ('Restaurant', 'D-Chat Grill')

  Expenses:Arts
  Expenses:Donations
  Expenses:Car
>

After you've set the payee, narration, and account, you may elect to categorize all future transactions with the same memo likewise:

> ('Restaurant', 'D-Chat Grill')
>
Expecting more of these? [y/N]: y
Edit rule before saving? [y/N]: n

#Installation

TODO

#Configuration

If a config file is not present, the default values at ./beancount_categorize/config.py will be used.

#Schema

#skip (list of strings)

Regexes of narrations of transactions that should be skipped.

For example, with skip = ["Padding inserted", "^Pay"], the following transactions would be:

  • Padding inserted: skipped
  • Padding-inserted: categorized
  • Payless Shoe Source: skipped
  • Paddington Station: categorized
  • PayPal: skipped
  • Hell to Pay: categorized
#pos (list of strings)

Known point-of-sale prefixes. categorize will strip these when storing and evaluating rules.

For example, with SQ as a POS prefix, all of these narrations will be matched by the rule regex /^RESTAURANT/:

  • SQ*RESTAURANT
  • SQ *RESTAURANT
  • SQ* RESTAURANT
  • SQ * RESTAURANT
#indent (string)

The indent to prepend to metadata and posting lines.

#Example

skip:
-

pos:
- PAYPAL
- SQ
- TST
indent: "  "

#Usage

categorize assumes an import workflow resembling the following.

bean-extract config.py -f main.beancount download > tmp.beancount

The CLI options are tailored accordingly:

  • -i, --input: The file with the transactions you wish to categorize.
  • -j, --journal: The file with the rest of your Beancount data. It must contain all Open directives or include files that do.
  • -r, --rules: Stored categorization rules.
Do not follow this link