mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
* Bank transfer: Use less cryptic refund references (fixes #4289) * Add condition back in * Fix tests
This commit is contained in:
@@ -30,6 +30,7 @@ from django.templatetags.l10n import localize
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from localflavor.generic.validators import BICValidator
|
from localflavor.generic.validators import BICValidator
|
||||||
|
|
||||||
|
from pretix.base.i18n import language
|
||||||
from pretix.plugins.banktransfer.models import RefundExport
|
from pretix.plugins.banktransfer.models import RefundExport
|
||||||
|
|
||||||
|
|
||||||
@@ -85,12 +86,14 @@ def build_sepa_xml(refund_export: RefundExport, account_holder, iban, bic):
|
|||||||
sepa = SepaTransfer(config, clean=True)
|
sepa = SepaTransfer(config, clean=True)
|
||||||
|
|
||||||
for row in refund_export.rows_data:
|
for row in refund_export.rows_data:
|
||||||
|
with language(row.get("locale", (refund_export.event or refund_export.organizer).settings.locale)):
|
||||||
|
ref = f"{row['id']} {_('Refund')} {row.get('comment') or ''}".strip()[:140]
|
||||||
payment = {
|
payment = {
|
||||||
"name": row['payer'],
|
"name": row['payer'],
|
||||||
"IBAN": row["iban"],
|
"IBAN": row["iban"],
|
||||||
"amount": int(Decimal(row['amount']) * 100), # in euro-cents
|
"amount": int(Decimal(row['amount']) * 100), # in euro-cents
|
||||||
"execution_date": datetime.date.today(),
|
"execution_date": datetime.date.today(),
|
||||||
"description": f"{row['id']} {refund_export.entity_slug} {_('Refund')} {row.get('comment') or ''}".strip()[:140],
|
"description": ref,
|
||||||
}
|
}
|
||||||
if row.get('bic'):
|
if row.get('bic'):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -674,6 +674,7 @@ def _unite_transaction_rows(transaction_rows):
|
|||||||
united_transactions_rows.append({
|
united_transactions_rows.append({
|
||||||
"iban": iban,
|
"iban": iban,
|
||||||
"bic": bic,
|
"bic": bic,
|
||||||
|
"locale": rows[0].get('locale', 'en'),
|
||||||
"id": ", ".join(sorted(set(r['id'] for r in rows))),
|
"id": ", ".join(sorted(set(r['id'] for r in rows))),
|
||||||
"payer": ", ".join(sorted(set(r['payer'] for r in rows))),
|
"payer": ", ".join(sorted(set(r['payer'] for r in rows))),
|
||||||
"amount": sum(r['amount'] for r in rows),
|
"amount": sum(r['amount'] for r in rows),
|
||||||
@@ -726,6 +727,7 @@ class RefundExportListView(ListView):
|
|||||||
"amount": refund.amount,
|
"amount": refund.amount,
|
||||||
"id": refund.full_id,
|
"id": refund.full_id,
|
||||||
"comment": refund.comment,
|
"comment": refund.comment,
|
||||||
|
"locale": refund.order.locale,
|
||||||
**{key: data.get(key) for key in ("payer", "iban", "bic")}
|
**{key: data.get(key) for key in ("payer", "iban", "bic")}
|
||||||
})
|
})
|
||||||
refund.done(user=self.request.user)
|
refund.done(user=self.request.user)
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ def test_unite_transaction_rows():
|
|||||||
'iban': 'DE12345678901234567890',
|
'iban': 'DE12345678901234567890',
|
||||||
'bic': 'HARKE9000',
|
'bic': 'HARKE9000',
|
||||||
'id': "ROLLA-R-1",
|
'id': "ROLLA-R-1",
|
||||||
|
'locale': "en",
|
||||||
'comment': None,
|
'comment': None,
|
||||||
'amount': Decimal("42.23"),
|
'amount': Decimal("42.23"),
|
||||||
},
|
},
|
||||||
@@ -193,6 +194,7 @@ def test_unite_transaction_rows():
|
|||||||
'iban': 'DE111111111111111111111',
|
'iban': 'DE111111111111111111111',
|
||||||
'bic': 'ikswez2020',
|
'bic': 'ikswez2020',
|
||||||
'id': "PARTY-R-1",
|
'id': "PARTY-R-1",
|
||||||
|
'locale': "en",
|
||||||
'comment': None,
|
'comment': None,
|
||||||
'amount': Decimal("6.50"),
|
'amount': Decimal("6.50"),
|
||||||
}
|
}
|
||||||
@@ -206,6 +208,7 @@ def test_unite_transaction_rows():
|
|||||||
'iban': 'DE12345678901234567890',
|
'iban': 'DE12345678901234567890',
|
||||||
'bic': 'HARKE9000',
|
'bic': 'HARKE9000',
|
||||||
'id': "ROLLA-R-1",
|
'id': "ROLLA-R-1",
|
||||||
|
'locale': "en",
|
||||||
'comment': None,
|
'comment': None,
|
||||||
'amount': Decimal("7.77"),
|
'amount': Decimal("7.77"),
|
||||||
},
|
},
|
||||||
@@ -214,6 +217,7 @@ def test_unite_transaction_rows():
|
|||||||
'iban': 'DE111111111111111111111',
|
'iban': 'DE111111111111111111111',
|
||||||
'bic': 'ikswez2020',
|
'bic': 'ikswez2020',
|
||||||
'id': "PARTY-R-2",
|
'id': "PARTY-R-2",
|
||||||
|
'locale': "en",
|
||||||
'comment': None,
|
'comment': None,
|
||||||
'amount': Decimal("13.50"),
|
'amount': Decimal("13.50"),
|
||||||
}
|
}
|
||||||
@@ -225,6 +229,7 @@ def test_unite_transaction_rows():
|
|||||||
'iban': 'DE12345678901234567890',
|
'iban': 'DE12345678901234567890',
|
||||||
'bic': 'HARKE9000',
|
'bic': 'HARKE9000',
|
||||||
'id': "ROLLA-R-1",
|
'id': "ROLLA-R-1",
|
||||||
|
'locale': "en",
|
||||||
'comment': None,
|
'comment': None,
|
||||||
'amount': Decimal("50.00"),
|
'amount': Decimal("50.00"),
|
||||||
},
|
},
|
||||||
@@ -233,6 +238,7 @@ def test_unite_transaction_rows():
|
|||||||
'iban': 'DE111111111111111111111',
|
'iban': 'DE111111111111111111111',
|
||||||
'bic': 'ikswez2020',
|
'bic': 'ikswez2020',
|
||||||
'id': 'PARTY-R-1, PARTY-R-2',
|
'id': 'PARTY-R-1, PARTY-R-2',
|
||||||
|
'locale': "en",
|
||||||
'comment': None,
|
'comment': None,
|
||||||
'amount': Decimal('20.00'),
|
'amount': Decimal('20.00'),
|
||||||
}], key=_row_key_func)
|
}], key=_row_key_func)
|
||||||
|
|||||||
Reference in New Issue
Block a user