When deciding to put bank info on invoices, only look at active methods
authorMagnus Hagander <magnus@hagander.net>
Fri, 11 Apr 2025 08:49:09 +0000 (10:49 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 11 Apr 2025 08:51:03 +0000 (10:51 +0200)
If a payment method that had bank info on it was added to an invoice, we
would include the bank data on the PDF even if the method was not marked
as active. It would still not show on the webpage of available methods,
but if someone forwarded the PDF alone for payment, they would get the
bank info for an inactive method. So fix that.

postgresqleu/invoices/util.py

index 0523fbaea4e9c28a7d23b1e5e3a4980d599de961..9aa5dd0ab7edf1004aa2059f7a662ee824905b52 100644 (file)
@@ -104,7 +104,7 @@ class InvoiceWrapper(object):
         # Include bank info on the invoice if any payment method chosen
         # provides it. If more than one supports it then the one with
         # the highest priority (=lowest sortkey) will be used.
-        for pm in self.invoice.allowedmethods.all():
+        for pm in self.invoice.allowedmethods.filter(active=True):
             if pm.config and 'bankinfo' in pm.config and len(pm.config['bankinfo']) > 1:
                 m = pm.get_implementation()
                 if not (hasattr(m, 'available') and not m.available(self.invoice)):