+import re
from django.db import models
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
fundraiser = models.ForeignKey(Fundraiser, models.PROTECT, blank=True, null=True, verbose_name=_('fundraiser'))
fundraiser_commission = models.IntegerField(_('fundraiser commission'), null=True, blank=True)
+ fundraiser_bonus = models.IntegerField(_('fundraiser bonus'), null=True, blank=True)
fundraiser_bill = models.CharField(_('fundaiser bill number'), max_length=255, blank=True)
amount = models.IntegerField(_('amount'), null=True, blank=True)
notes = models.TextField(_('notes'), blank=True)
needs_redo = models.BooleanField(_('needs redo'), default=False)
- is_cancelled = models.BooleanField(_('is cancelled'), default=False)
+ cancelled_at = models.DateTimeField(_('cancelled at'), null=True, blank=True)
optout = models.BooleanField(_('optout'), default=False)
campaign = models.ForeignKey(Campaign, models.PROTECT, null=True, blank=True, verbose_name=_('campaign'))
+ latest_status = models.CharField(max_length=255, blank=True)
+
class Meta:
verbose_name = _('direct debit')
verbose_name_plural = _('direct debits')
def __str__(self):
- return self.payment_id
+ return "{} {}".format(self.payment_id, self.latest_status)
+
+ def get_latest_status(self):
+ line = self.bankexportfeedbackline_set.order_by('-feedback__created_at').first()
+ if line is None: return ""
+ return line.comment
def save(self, **kwargs):
self.iban_valid = not self.iban_warning() if self.iban else None
+ self.latest_status = self.get_latest_status()
super().save(**kwargs)
@classmethod