adamcharnock / django-hordak

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

What constitutes what makes a leg debit or credit is unclear #53

Closed ahmednofal closed 1 month ago

ahmednofal commented 3 years ago

There are two definitions in horda/models/core.py

The first is https://github.com/adamcharnock/django-hordak/blob/d48d0319b51d4c4811bb57b73ff31a41ef26cd04/hordak/models/core.py#L393

class LegManager(models.Manager):
    def get_by_natural_key(self, uuid):
        return self.get(uuid=uuid)

    def debits(self):
        """Filter for legs that were debits"""
        return self.filter(amount__gt=0)

    def credits(self):
        """Filter for legs that were credits"""
        return self.filter(amount__lt=0)

The second is https://github.com/adamcharnock/django-hordak/blob/d48d0319b51d4c4811bb57b73ff31a41ef26cd04/hordak/models/core.py#L441

def type(self):
        if self.amount.amount < 0:
            return DEBIT
        elif self.amount.amount > 0:
            return CREDIT
        else:
            # This should have been caught earlier by the database integrity check.
            # If you are seeing this then something is wrong with your DB checks.
            raise exceptions.ZeroAmountError()

Now if the amount is < 0 is it debit or credit ?

kingraphaii commented 3 years ago

I think this differs according to account type?

adamcharnock commented 1 month ago

You are right that this is unclear, and we are (slowly) talking about a solution. I'm going to close this in favour of #59, as all these changes are captured there.