clean specialTransaction

This commit is contained in:
Pierre-antoine Comby 2020-04-18 15:59:06 +02:00
parent 53748cd534
commit cc97948c24
1 changed files with 11 additions and 0 deletions

View File

@ -252,6 +252,17 @@ class SpecialTransaction(Transaction):
def type(self):
return _('Credit') if isinstance(self.source, NoteSpecial) else _("Debit")
def is_credit(self):
return isinstance(self.source, NoteSpecial)
def is_debit(self):
return isinstance(self.destination, NoteSpecial)
def clean(self):
# SpecialTransaction are only possible with NoteSpecial object
if self.is_credit() == self.is_debit():
raise(ValidationError(_("A special transaction is only possible between a Note associated to a payment method and a User or a Club")))
class MembershipTransaction(Transaction):
"""