list_display = [
'payment_id', 'acquisition_date',
'iban_valid',
+ 'latest_status',
'bank_submission_date',
'bank_acceptance_date',
'amount', 'first_name', 'last_name',
'fundraiser',
'campaign',
('cancelled_at', EmptyFieldListFilter),
+ 'latest_status',
'needs_redo',
'optout',
'amount',
'sex',
'is_consumer',
+ ('fundraiser_commission', EmptyFieldListFilter),
+ ('fundraiser_bonus', EmptyFieldListFilter),
]
fieldsets = [
(None, {
('postal_code', 'phone'),
'email',
('iban', 'iban_valid', 'iban_warning'),
- 'payment_id',
+ ('payment_id', 'latest_status'),
'agree_contact',
'agree_fundraising',
'agree_newsletter',
('cancelled_at', 'needs_redo', 'optout'),
'submission_date',
'fundraiser_commission',
+ 'fundraiser_bonus',
'fundraiser_bill',
'bank_submission_date',
'bank_acceptance_date',
]
})
]
- readonly_fields = ['agree_contact', 'iban_valid', 'iban_warning']
+ readonly_fields = ['agree_contact', 'iban_valid', 'iban_warning', 'latest_status']
inlines = [BankExportFeedbackLineInline]
def set_bank_submission(m, r, q):
--- /dev/null
+# Generated by Django 2.2.25 on 2022-01-27 12:59
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('pz', '0009_remove_directdebit_is_cancelled'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='directdebit',
+ name='fundraiser_bonus',
+ field=models.IntegerField(blank=True, null=True, verbose_name='fundraiser bonus'),
+ ),
+ migrations.AddField(
+ model_name='directdebit',
+ name='latest_status',
+ field=models.CharField(blank=True, max_length=255),
+ ),
+ ]
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)
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