Ryan Nowakowski
unread,Jul 24, 2022, 4:26:06 PM7/24/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ledger
Hey Folks,
When I do a ledger.read_journal in python on a file with virtual postings,
has_flag(POST_VIRTUAL) returns False. I would expect it to return True.
Here's a bash run with the details:
$ ledger --version
Ledger 3.2.1-20200518, the command-line accounting tool
Copyright (c) 2003-2019, John Wiegley. All rights reserved.
This program is made available under the terms of the BSD Public License.
See LICENSE file included with the distribution for details and disclaimer.
$ python3 --version
Python 3.9.2
$ cat journal.dat
2022-7-24 August 2022 Budget
[Budget:Expenses:Gas] $200.00
[Budget:Equity] -$200.00
$ cat virtual_posts.py
import ledger
for xact in ledger.read_journal("journal.dat"):
print(repr(xact))
for post in xact.posts():
is_virtual = post.xdata().has_flags(ledger.POST_VIRTUAL)
must_balance = post.xdata().has_flags(ledger.POST_MUST_BALANCE)
print("%r is virtual: %s, must balance: %s" % (post, is_virtual, must_balance))
$ python3 virtual_posts.py journal.dat
<ledger.Transaction object at 0x7f588b011040>
<ledger.Posting object at 0x7f588b0110a0> is virtual: False, must balance: False
<ledger.Posting object at 0x7f588b011100> is virtual: False, must balance: False
Can anyone spot any issues with what I'm doing? If not, should I file a
bug against ledger?
Thanks!
Ryan N