9188F587.py 752 B

12345678910111213141516171819202122232425262728
  1. import ledger
  2. eur = ledger.commodities.find_or_create('EUR')
  3. total_eur = ledger.Amount("0.00 EUR")
  4. total_gbp = ledger.Amount("0.00 GBP")
  5. total = ledger.Amount("0.00 EUR")
  6. for post in ledger.read_journal("test/regress/78AB4B87.dat").query("^income:"):
  7. print post.amount
  8. print post.amount.commodity
  9. if post.amount.commodity == "EUR":
  10. total_eur += post.amount
  11. elif post.amount.commodity == "GBP":
  12. total_gbp += post.amount
  13. a = post.amount.value(eur, post.date)
  14. if a:
  15. print "Total is presently: (%s)" % total
  16. print "Converted to EUR: (%s)" % a
  17. total += a
  18. print "Total is now: (%s)" % total
  19. else:
  20. print "Cannot convert '%s'" % post.amount
  21. print
  22. print total