Hi,
I've been using padding to account for errors in my accounts and bank, for example for transactions which I may have forgotten but are small enough that I don't want to hunt for them. Usually, this goes along the lines of:
2023-12-04 pad Assets:Checking Equity:Adjustments
2023-12-05 balance Assets:Checking 1000 USD
whenever I want to check an account in beancount with my bank. I'm also using plugins which manipulate the transactions. However, beancount loads the padding plugin (ops.pad) before my custom plugins in PLUGINS_PRE(see beancount/loader.py), which leads to padding the accounts with values before manipulation by my plugin. Since the balance directive is in PLUGINS_POST, this leads to an error. For an example, see the following beancount file and plugin file:
; file: temp.beancount
option "operating_currency" "USD"
option "insert_pythonpath" "True"
plugin "plugin_temp"
2020-01-01 open Equity:Adjustments
2020-01-01 open Assets:Checking USD
2020-01-01 open Expenses:Groceries
2023-01-01 pad Assets:Checking Equity:Adjustments
2023-01-02 balance Assets:Checking 1000 USD
2023-02-01 * "Eggs"
Expenses:Groceries 100 USD
Assets:Checking
2023-03-01 pad Assets:Checking Equity:Adjustments
2023-03-02 balance Assets:Checking 700 USD
; file: plugin_temp.py in the same directory
from beancount.core import data
__plugins__ = ('plugin_temp',)
def plugin_temp(entries, unused_options_map):
new_entries = list(e for e in data.filter_txns(entries) if e.flag == '*')
return new_entries + entries, []
With bean-check, this gives the error
Balance failed for 'Assets:Checking': expected 700 USD != accumulated 600 USD (100 too little)
2023-03-02 balance Assets:Checking 700 USD
Is there a particular reason ops.pad is in PLUGINS_PRE and not in PLUGINS_POST? Putting ops.pad in PLUGINS_POST seems to solve this issue.