beancount icon indicating copy to clipboard operation
beancount copied to clipboard

Zero-value automatic postings being pruned

Open aschw opened this issue 6 months ago • 2 comments

(As previously discussed here: https://groups.google.com/g/beancount/c/ucfh1LdSSUU )

When a transaction entry has an automatic posting with zero value, the automatic posting is not emitted. This caused an issue for a plugin I am working on.

For example, consider the following entry:

2025-05-29 * "Pay Sample Bill" Liabilities:Foo 0.00 USD Expenses:Bar

A 0.00 USD posting for Liabilities:Foo appears in the journal, but a 0.00 USD posting for Expenses:Bar does not appear.

If I add an "or True" to the condition on this line, then both postings appear in the journal.

https://github.com/beancount/beancount/blob/eaeaa64532875f39e7cb7764c33ce4f9a4c78975/beancount/parser/booking_full.py#L930

As far as I can tell, the pruning happens here: https://github.com/beancount/beancount/blob/eaeaa64532875f39e7cb7764c33ce4f9a4c78975/beancount/parser/booking_full.py#L1003

Thank you!

aschw avatar Jun 02 '25 19:06 aschw

This causes another bug as well: if the account name is invalid, then no error is reported.

sim642 avatar Jul 13 '25 14:07 sim642

The reason for the pruning... I forget, but there must have been a reason. One way to test it out would be to run "bean-query print" with and without a patch to remove the pruning and see how they differ. You'd have to do this on a realistic file to cehck it out.

blais avatar Jul 13 '25 15:07 blais