adamcharnock / django-hordak

Double entry accounting in Django
http://django-hordak.readthedocs.io
MIT License
254 stars 58 forks source link

In transaction.legs.all sort debit first. #69

Closed prdpspkt closed 5 months ago

prdpspkt commented 2 years ago

In transaction.legs.all debit and credit are not ordered. Sometimes debit comes first and sometimes credit comes first. How to get debit first and then credit.

PetrDlouhy commented 2 years ago

@prdpspkt What part of code are you using? What command (or view) are you calling and what result do you expect?

prdpspkt commented 2 years ago
{% for leg in transaction.legs.all %}
          <div>{{leg.account.name}}: {{leg.balance.amount}}</div> //I need debit here
          <div>{{leg.account.name}}: {{leg.balance.amount}}</div> //I need credit here
{% endfor %}]

but it comes randomly. some time debit first and sometime credit first.

PetrDlouhy commented 2 years ago

You can do it for example like this:

{% for leg in transaction.legs.debits %}
          <div>{{leg.account.name}}: {{leg.balance.amount}}</div>
{% endfor %}
{% for leg in transaction.legs.credits %}
          <div>{{leg.account.name}}: {{leg.balance.amount}}</div>
{% endfor %}

Or by transaction.legs.order_by('amount') in the view.

PetrDlouhy commented 2 years ago

Also PRs are welcome. If you add method to LegManager that returns legs ordered by amount and add tests for that I will accept it.

prdpspkt commented 2 years ago

Thank you. The project is abandoned for long time. Is there any method to generate Trial Balance, P/L and Balance sheet ?

PetrDlouhy commented 2 years ago

The project is not abandoned. I have the rights to the repo and PyPI archive and I am maintaining the code. In fact I released new version just recently. Although I will not do any active development except fixing bugs, incompatibilities and improvements motivated by my own project. I will also accept quality PRs with meaningful new functions.

I don't know anything about those generators. Probably not, but search the documentation and code.