I admit I don't fully understand the code. But if I add an "or True" to this line, it solves my problem: https://github.com/beancount/beancount/blob/eaeaa64532875f39e7cb7764c33ce4f9a4c78975/beancount/parser/booking_full.py#L930
And as far as I can tell, the pruning I was describing happens here: https://github.com/beancount/beancount/blob/eaeaa64532875f39e7cb7764c33ce4f9a4c78975/beancount/parser/booking_full.py#L1003 -Andrew On Fri, May 30, 2025 at 5:49 AM Martin Blais <[email protected]> wrote: > I don't believe there is any explicit pruning of postings, but I might be > wrong (it's been a while since I touched that code). > This merely requires going one level deeper and debugging where that > posting is getting disappeared. > - install from source > - setup PYTHONPATH to pull from there > - trace the code > - add some printfs > > > On Thu, May 29, 2025 at 8:48 PM Andrew Schwartz <[email protected]> > wrote: > >> 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 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Beancount" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion visit >> https://groups.google.com/d/msgid/beancount/2510bec3-8fa7-4182-bc4d-f68a7820a544n%40googlegroups.com >> <https://groups.google.com/d/msgid/beancount/2510bec3-8fa7-4182-bc4d-f68a7820a544n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Beancount" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/beancount/ucfh1LdSSUU/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/beancount/CAK21%2BhMHvYRz%2Bnm5f5dyGR4-oHBKTTyh7LdAGgAUfGprSUnDvw%40mail.gmail.com > <https://groups.google.com/d/msgid/beancount/CAK21%2BhMHvYRz%2Bnm5f5dyGR4-oHBKTTyh7LdAGgAUfGprSUnDvw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Beancount" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/beancount/CAMn9gMVJy0dUki6%2Bkm8JE6LotbT82Edrjd75gC1nk0ai3Z8e%2Bg%40mail.gmail.com.
