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

What constitutes what makes a leg debit or credit is unclear

Open ahmednofal opened this issue 4 years ago • 1 comments

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 ?

ahmednofal avatar Oct 13 '20 19:10 ahmednofal

I think this differs according to account type?

kingraphaii avatar Jan 13 '21 09:01 kingraphaii