django-hordak icon indicating copy to clipboard operation
django-hordak copied to clipboard

In transaction.legs.all sort debit first.

Open prdpspkt opened this issue 2 years ago • 6 comments

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.

prdpspkt avatar Sep 15 '22 17:09 prdpspkt

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

PetrDlouhy avatar Sep 17 '22 07:09 PetrDlouhy

{% 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.

prdpspkt avatar Sep 18 '22 06:09 prdpspkt

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 avatar Sep 18 '22 10:09 PetrDlouhy

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.

PetrDlouhy avatar Sep 18 '22 10:09 PetrDlouhy

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

prdpspkt avatar Sep 18 '22 11:09 prdpspkt

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.

PetrDlouhy avatar Sep 18 '22 12:09 PetrDlouhy