1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 09:58:23 +02:00

Add transaction type field

This commit is contained in:
Yohann D'ANELLO
2020-03-16 12:11:16 +01:00
committed by Bombar Maxime
parent a1f37f0eea
commit 7b98244360
8 changed files with 245 additions and 195 deletions

View File

@ -107,7 +107,24 @@ class Transaction(PolymorphicModel):
verbose_name=_('quantity'),
default=1,
)
amount = models.PositiveIntegerField(verbose_name=_('amount'), )
amount = models.PositiveIntegerField(
verbose_name=_('amount'),
)
type = models.CharField(
verbose_name=_('type'),
choices=(
('gift', _('Gift')),
('transfer', _('Transfer')),
('template', _('Template')),
('credit', _('Credit')),
('debit', _('Debit')),
('membership', _('membership transaction')),
),
default='transfer',
max_length=10,
)
reason = models.CharField(
verbose_name=_('reason'),
max_length=255,
@ -158,10 +175,6 @@ class Transaction(PolymorphicModel):
def total(self):
return self.amount * self.quantity
@property
def type(self):
return _('transfer')
class TemplateTransaction(Transaction):
"""
@ -178,10 +191,6 @@ class TemplateTransaction(Transaction):
on_delete=models.PROTECT,
)
@property
def type(self):
return _('template')
class SpecialTransaction(Transaction):
"""
@ -200,7 +209,8 @@ class SpecialTransaction(Transaction):
bank = models.CharField(
max_length=255,
verbose_name=_("bank")
verbose_name=_("bank"),
blank=True,
)
@ -219,7 +229,3 @@ class MembershipTransaction(Transaction):
class Meta:
verbose_name = _("membership transaction")
verbose_name_plural = _("membership transactions")
@property
def type(self):
return _('membership')