Skip to content

Commit

Permalink
update doc + fix bug with Money
Browse files Browse the repository at this point in the history
  • Loading branch information
sdementen committed Jun 9, 2019
1 parent 8b9c5e0 commit 7488b93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/source/doc/doc.rst
Expand Up @@ -197,6 +197,18 @@ To export a GnuCash book to the ledger-cli format:

.. command-output:: piecash ledger -h

Or in python


.. ipython:: python
book = open_book(gnucash_books + "simple_sample.gnucash", open_if_lock=True)
from piecash import ledger
# accessing specific objects through the get method
print(ledger(book, locale=True))
For more information on how to use piecash, please refer to the Tutorials on
:doc:`Using existing objects <../tutorial/index_existing>` and
:doc:`Creating new objects <../tutorial/index_new>`,
Expand Down
4 changes: 2 additions & 2 deletions piecash/ledger.py
Expand Up @@ -55,11 +55,11 @@ def _(tr, **kwargs):
_locale = locale.getdefaultlocale()[0]
if Money is None:
raise ValueError(f"You must install Money ('pip install money') to export to ledger in your locale '{_locale}")
s.append(Money(amount=split.value, currency=format_commodity(tr.currency)).format(_locale))
s.append(Money(amount=split.value, currency=tr.currency.mnemonic).format(_locale))
else:
if Money:
# vesion from Money
s.append(str(Money(amount=split.value, currency=format_commodity(tr.currency))))
s.append(str(Money(amount=split.value, currency=tr.currency.mnemonic)))
else:
# local hand made version
s.append("{:10.{}f} {}".format(split.value, tr.currency.precision, format_commodity(tr.currency)))
Expand Down

0 comments on commit 7488b93

Please sign in to comment.