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()
def save(self, *args, **kwargs): if self.amount.amount == 0: raise exceptions.ZeroAmountError() return super(Leg, self).save(*args, **kwargs)