From e44c07c50960ff06299f82504157ca96ee2b9a78 Mon Sep 17 00:00:00 2001 From: Pelle Koster <pelle.koster@geant.org> Date: Tue, 22 Apr 2025 13:12:06 +0200 Subject: [PATCH] make registration types to ignore in error report configurable --- config-example.json | 10 +++++++++- .../stripe_checkout/compare_visit_stripe.py | 11 ++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config-example.json b/config-example.json index 43e4b0d..48260f9 100644 --- a/config-example.json +++ b/config-example.json @@ -7,5 +7,13 @@ "VISIT_EXPO_ID": "18lm2fafttito", "SEND_ERROR_EMAILS_TO": [], "MAX_INVOICE_DUE_DATE": "2025-05-23", - "MAX_BANK_TRANSFER_ALLOWED_DATE": "2025-05-12" + "MAX_BANK_TRANSFER_ALLOWED_DATE": "2025-05-12", + "ERROR_REPORT_IGNORE_REGISTRATION_TYPES": [ + "VIP", + "Staff", + "FTP", + "Partner", + "Online Participant", + "E-NREN" + ] } \ No newline at end of file diff --git a/stripe_checkout/stripe_checkout/compare_visit_stripe.py b/stripe_checkout/stripe_checkout/compare_visit_stripe.py index 41163bb..3e52b5f 100644 --- a/stripe_checkout/stripe_checkout/compare_visit_stripe.py +++ b/stripe_checkout/stripe_checkout/compare_visit_stripe.py @@ -1,3 +1,5 @@ +from typing import Collection +from django.conf import settings import stripe from stripe_checkout.stripe_checkout import visit @@ -36,10 +38,13 @@ class VisitorWrapper(StripeWrapper): class PossibleErrorReporter(CSVReporter): def iter_report_items(self, data): + ignore_registration_types = set( + getattr(settings, "ERROR_REPORT_IGNORE_REGISTRATION_TYPES", []) + ) seen = set() for obj in super().iter_report_items(data): seen.add(obj["Email address"]) - if self._is_suspect(obj): + if self._is_suspect(obj, ignore_registration_types): yield obj unseen_invoices: dict[str, list[dict]] = {} for obj_id, obj in data["stripe"].items(): @@ -60,8 +65,8 @@ class PossibleErrorReporter(CSVReporter): } @staticmethod - def _is_suspect(obj: dict): - if obj["Registration Type"] in {"VIP", "Staff"}: + def _is_suspect(obj: dict, ignore_registration_types: Collection[str]): + if obj["Registration Type"] in ignore_registration_types: return False return obj["Invoice Count"] != 1 -- GitLab