Skip to content

Commit

Permalink
fixup! Enable submission of repayment requests
Browse files Browse the repository at this point in the history
  • Loading branch information
FestplattenSchnitzel committed Oct 17, 2023
1 parent ec24e8e commit 54756f0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions sipa/blueprints/usersuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
from datetime import datetime
from decimal import Decimal
from functools import partial
from schwifty import IBAN

from babel.numbers import format_currency
Expand Down Expand Up @@ -669,20 +670,16 @@ def request_repayment_confirm():
"""

beneficiary = request.args.get("beneficiary", None)
iban = request.args.get("iban", None, lambda x: IBAN(x, validate_bban=True))
amount = request.args.get("amount", None, lambda x: Decimal(x))
iban = request.args.get("iban", None, partial(IBAN, validate_bban=True))
amount = request.args.get("amount", None, Decimal)

form = RequestRepaymentConfirmForm()

if None not in (beneficiary, iban, amount):
balance = current_user.finance_information.balance.raw_value
iban_str = str(iban)

form.beneficiary.data = beneficiary
# Insert a space every 4 characters of the IBAN
form.iban.data = " ".join(
iban_str[i : i + 4] for i in range(0, len(iban_str), 4)
)
form.iban.data = iban.formatted
form.bic.data = str(iban.bic)
form.bank.data = iban.bank_name
form.amount.data = amount
Expand Down

0 comments on commit 54756f0

Please sign in to comment.