Hi all-
I'm writing a plugin that makes some changes to an entry's postings. It requires that there be an automatic posting so that it knows where to offset the modifications it makes to the postings.
Unfortunately, I'm finding that the automatic posting is pruned by beancount if it has zero amount.
For example, let's say that Assets:BrokerageAccount:OpenPL starts off with a balance of 100.00 USD. I want to update it to 123.45. Normally, I'd just add an entry for 23.45, but I don't know the existing balance. My plugin allows this.
Note that the Pad directive is also an option, but I want to be able to have multiple postings in a single transaction, and that's not allowed by Pad.
For example, let's say that at the start of the day, May 29 2025, Liabilities:GasBill:2025-04 was -100.00
The syntax I'm trying to use is:
2025-05-29 balance Liabilities:GasBill:2025-04 -100.00 USD ; old value
2025-05-29 * "Pay Sample Bill"
Liabilities:GasBill:2025-04 0.00 UNSET
finalbalance: 0.00 USD
Assets:CheckingAccount -123.45 USD
Expenses:Utilities
My plugin works perfectly for the example above. It modifies the entry as follows:
2025-05-29 * "Pay Sample Bill"
Liabilities:GasBill:2025-04 100.00 USD
Assets:CheckingAccount -123.45 USD
Expenses:Utilities 23.45
I have another use case for my plugin, which is that I keep track of my Open P&L in a brokerage account.
This typically involves replacing the old Open P&L with the new Open P&L. I don't remember or care what the old value was. I just want to replace it with the new one.
So, I want to enter this:
2025-05-31 balance Assets:Fidelity:OpenPL 100.00 USD ; the previous value
2025-05-31 * "Fidelity 2025-05 EOM OpenPL"
Assets:Fidelity:OpenPL 0.00 UNSET
finalbalance: 123.45 USD
Income:UnrealizedPL
My plugin is trying to produce this:
2025-05-31 * "Fidelity 2025-05 EOM OpenPL"
Assets:Fidelity:OpenPL 23.45 USD
Income:UnrealizedPL -23.45 USD
Unfortunately, the __automatic__ posting Income:UnrealizedPL appears to be purged by the beancount infrastructure and never makes it to my plugin. As a result, my plugin hits some internal assertions.
Is there any way to disable the pruning of zero-value automatic postings? Perhaps some sort of option?
I assume not, but it can't hurt to ask.
Thanks!
-Andrew