Add properties to get more detailed payment information
authorMagnus Hagander <magnus@hagander.net>
Mon, 26 Feb 2018 15:25:00 +0000 (16:25 +0100)
committerMagnus Hagander <magnus@hagander.net>
Mon, 26 Feb 2018 15:25:00 +0000 (16:25 +0100)
This brings back information, recursively through the steps, for exactly
how a bulk payment or invoice was paid.

postgresqleu/confreg/models.py
postgresqleu/invoices/models.py

index 4a9a9bb40aa2906d84400286952fc58ff9a8e0da..ec80f35b2510b4087344c9c18e2aa420d106323d 100644 (file)
@@ -346,6 +346,18 @@ class BulkPayment(models.Model):
        def adminstring(self):
                return "%s at %s" % (self.user, self.createdat)
 
+       @property
+       def payment_method_description(self):
+               if not self.paidat:
+                       return "not paid."
+               if self.invoice:
+                       if self.invoice.paidat:
+                               return "paid with invoice #{0}.\nInvoice {1}".format(self.invoice.id, self.invoice.payment_method_description)
+                       else:
+                               return "supposedly paid with invoice #{0}, which is not flagged as paid. SOMETHING IS WRONG!".format(self.invoice.id)
+               else:
+                       return "no invoice assigned. SOMETHING IS WRONG!"
+
        def __unicode__(self):
                return u"Bulk payment for %s created %s (%s registrations, %s%s): %s" % (
                        self.conference,
@@ -439,6 +451,22 @@ class ConferenceRegistration(models.Model):
        def is_volunteer(self):
                return self.volunteers_set.exists()
 
+       @property
+       def payment_method_description(self):
+               if not self.payconfirmedat:
+                       return "Not paid."
+               if self.payconfirmedby == "no payment reqd":
+                       return "Registration does not require payment."
+               if self.payconfirmedby == "Multireg/nopay":
+                       return "Registration is part of multi payment batch that does not require payment."
+               if self.payconfirmedby == "Invoice paid":
+                       # XXX dig deeper!
+                       return "Paid by individual invoice #{0}.\n Invoice {1}".format(self.invoice.id, self.invoice.payment_method_description)
+               if self.payconfirmedby == "Bulk paid":
+                       return "Paid by bulk payment #{0}.\n Bulk {1}".format(self.bulkpayment.id, self.bulkpayment.payment_method_description)
+
+               return "Payment details not available"
+
        # For the admin interface (mainly)
        def __unicode__(self):
                return "%s: %s %s <%s>" % (self.conference, self.firstname, self.lastname, self.email)
index effec6365196feacd5bdb22c93e8b54ad62b6778..6c83aa0cdaa6d4ebaeb51c9348e10ecebcb6488a 100644 (file)
@@ -167,6 +167,14 @@ class Invoice(models.Model):
        def autorefund(self):
                return PaymentMethodWrapper(self.paidusing, self).autorefund()
 
+       @property
+       def payment_method_description(self):
+               if not self.paidat:
+                       return "not paid"
+               if self.paidusing:
+                       return "paid using {0}.".format(self.paidusing.name)
+               return "manually flagged as paid."
+
        def __unicode__(self):
                return "Invoice #%s" % self.pk