+ try:
+ self.save_payment_items()
+ except AssertionError:
+ self.save_export_feedback_items()
+
+ def save_payment_items(self):
+ for payment_id, booking_date, is_dd, realised, reject_code in parse_payment_feedback(self.csv.open()):
+ debit = DirectDebit.objects.get(payment_id = payment_id)
+ b, created = self.payment_set.get_or_create(
+ debit=debit,
+ defaults={
+ 'booking_date': booking_date,
+ 'is_dd': is_dd,
+ 'realised': realised,
+ 'reject_code': reject_code,
+ }
+ )
+ if not created:
+ b.booking_date = booking_date
+ b.is_dd = is_dd
+ b.realised = realised
+ b.reject_code = reject_code
+ b.save()
+
+ def save_export_feedback_items(self):
+ for payment_id, status, comment in parse_export_feedback(self.csv.open()):