On Sun, May 12, 2013 at 1:54 AM, oleg dashevskii
<[email protected]>wrote:
> So, how can I solve this problem?
The "xml" output format is basically the same as "balance", not "register"
As for the rest of it, I'd probably go to the python interface. It works
OK, but is a bit rough around the edges (You can add/subtract amounts, but
no multiplication, etc.)
My generic python boilerplate, if anyone is interested:
---
#!/usr/bin/env python
# must be run via `ledger python <thisfile>.py <journalfile>`
import ledger
import sys
journal = ledger.read_journal(sys.argv[1])
# create a USD commodity
comms = ledger.commodities
usd = comms.find_or_create('$')
# return an amount for the balance
def balance_for_account(acctname):
account = journal.find_account_re(acctname)
return balance_posts_subaccts(account)
# recursively determine the balance for all posts/subaccounts in given
account
def balance_posts_subaccts(account):
total = ledger.Balance()
for post in account.posts():
total += post.amount
for subacct in account.accounts():
total += balance_posts_subaccts(subacct)
return total
print balance_for_account("Equity:Accounts").value(usd);
--
- Zack
--
---
You received this message because you are subscribed to the Google Groups
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.