Skip to content

Commit

Permalink
Prevent error when trying to get payment information for too many months
Browse files Browse the repository at this point in the history
  • Loading branch information
FestplattenSchnitzel committed Oct 2, 2024
1 parent bd18e9e commit cf11d98
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions sipa/blueprints/usersuite.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""Blueprint for Usersuite components
"""
from collections import OrderedDict

import logging
import math
from collections import OrderedDict
from datetime import datetime
from decimal import Decimal
from io import BytesIO

from babel.numbers import format_currency
Expand Down Expand Up @@ -118,6 +121,13 @@ def index():
else:
months = payment_form.months.default

payment_form._fields["months"].validators[0].max = math.floor(
# Maximum value for EPC QR code, see https://de.wikipedia.org/wiki/EPC-QR-Code#EPC-QR-Code_Dateninhalt
Decimal("999999999.99")
/ current_app.config["MEMBERSHIP_CONTRIBUTION"]
* 100
)

datasource = current_user.datasource
context = dict(rows=rows,
webmailer_url=datasource.webmailer_url,
Expand Down Expand Up @@ -217,8 +227,11 @@ def render_payment_details(details: PaymentDetails, months):
gettext("IBAN"): details.iban,
gettext("BIC"): details.bic,
gettext("Verwendungszweck"): details.purpose,
gettext("Betrag"): format_currency(months * current_app.config['MEMBERSHIP_CONTRIBUTION'] / 100, 'EUR',
locale='de_DE')
gettext("Betrag"): format_currency(
Decimal(months) * current_app.config["MEMBERSHIP_CONTRIBUTION"] / 100,
"EUR",
locale="de_DE",
),
}


Expand Down

0 comments on commit cf11d98

Please sign in to comment.