Cerfa mécénat rempli envoyé par email à la confirmation du paiement
Quand un paiement « mécénat » est confirmé, l'email de confirmation porte en pièce jointe le reçu fiscal (cerfa 11580*05) rempli du bénévole, avec une phrase l'annonçant dans le corps. Généré en tâche de fond : un échec de génération envoie l'email sans pièce jointe plutôt que rien. - build_message/send acceptent des pièces jointes - app/mecenat/receipts.py : passage Volunteer → MecenatReceipt, partagé avec l'export coordination - modèle cerfa remplacé par une version pré-remplie avec l'association (organisme bénéficiaire, cases 200/978, signature) ; position de la date du versement ajustée Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5675e1d220
commit
5a0209ce43
@@ -912,6 +912,81 @@ def test_choosing_a_mecenat_option_requires_the_address_step_first(
|
||||
assert fiche["mecenat_country"] == "France"
|
||||
|
||||
|
||||
def _attachments(message) -> list:
|
||||
return [
|
||||
part
|
||||
for part in message.iter_attachments()
|
||||
if part.get_content_disposition() == "attachment"
|
||||
]
|
||||
|
||||
|
||||
def test_mecenat_payment_emails_the_filled_cerfa(raw_client, client, edition, monkeypatch, outbox):
|
||||
client.put(_form_url(edition, "/fields"), json={"fields": ["WILLING_TO_PAY_FEE", "EMAIL"]})
|
||||
client.patch(
|
||||
_form_url(edition), json={"sumup_merchant_code": _MERCHANT, "sumup_api_key": _API_KEY}
|
||||
)
|
||||
option_id = client.post(
|
||||
_form_url(edition, "/payment-options"),
|
||||
json={"label": "Mécénat", "amount": 50, "requires_mecenat_info": True},
|
||||
).json()["id"]
|
||||
token = _submit(
|
||||
raw_client, edition,
|
||||
first_name="Alex", last_name="Martin", hcaptcha_token="x",
|
||||
email="alex@example.org",
|
||||
payment_option_id=option_id,
|
||||
).json()["pending_token"]
|
||||
monkeypatch.setattr(
|
||||
"app.api.forms.create_checkout",
|
||||
lambda **kw: SumUpCheckout(id="co_don", status="PENDING", hosted_checkout_url="https://don"),
|
||||
)
|
||||
raw_client.post(
|
||||
_form_url(edition, f"/public/pending/{token}/mecenat-info"),
|
||||
json={
|
||||
"address": "1 rue du Festival",
|
||||
"city": "Rennes",
|
||||
"postal_code": "35000",
|
||||
"country": "France",
|
||||
},
|
||||
)
|
||||
assert outbox == [] # pas encore payé : ni email ni reçu
|
||||
|
||||
_pay(raw_client, edition, monkeypatch, checkout_id="co_don")
|
||||
|
||||
assert len(outbox) == 1
|
||||
attachments = _attachments(outbox[0])
|
||||
assert len(attachments) == 1
|
||||
assert attachments[0].get_content_type() == "application/pdf"
|
||||
assert attachments[0].get_filename().endswith(".pdf")
|
||||
assert attachments[0].get_content().startswith(b"%PDF")
|
||||
assert "reçu fiscal" in plain_text(outbox[0])
|
||||
|
||||
|
||||
def test_classic_payment_email_has_no_cerfa(raw_client, client, edition, monkeypatch, outbox):
|
||||
client.put(_form_url(edition, "/fields"), json={"fields": ["WILLING_TO_PAY_FEE", "EMAIL"]})
|
||||
client.patch(
|
||||
_form_url(edition), json={"sumup_merchant_code": _MERCHANT, "sumup_api_key": _API_KEY}
|
||||
)
|
||||
option_id = client.post(
|
||||
_form_url(edition, "/payment-options"),
|
||||
json={"label": "Cotisation classique", "amount": 12.5},
|
||||
).json()["id"]
|
||||
monkeypatch.setattr(
|
||||
"app.api.forms.create_checkout",
|
||||
lambda **kw: SumUpCheckout(id="co_1", status="PENDING", hosted_checkout_url="https://x"),
|
||||
)
|
||||
_submit(
|
||||
raw_client, edition,
|
||||
first_name="Alex", last_name="Martin", hcaptcha_token="x",
|
||||
email="alex@example.org",
|
||||
payment_option_id=option_id,
|
||||
)
|
||||
_pay(raw_client, edition, monkeypatch, checkout_id="co_1")
|
||||
|
||||
assert len(outbox) == 1
|
||||
assert _attachments(outbox[0]) == []
|
||||
assert "reçu fiscal" not in plain_text(outbox[0])
|
||||
|
||||
|
||||
def test_mecenat_info_requires_every_field(raw_client, client, edition, monkeypatch):
|
||||
client.put(_form_url(edition, "/fields"), json={"fields": ["WILLING_TO_PAY_FEE"]})
|
||||
client.patch(
|
||||
@@ -1002,3 +1077,4 @@ def test_pending_status_polling_is_rate_limited_per_token(
|
||||
for _ in range(pending_status_limiter.max_attempts):
|
||||
pending_status_limiter.hit(token)
|
||||
assert raw_client.get(_form_url(edition, f"/public/pending/{token}")).status_code == 429
|
||||
|
||||
|
||||
Reference in New Issue
Block a user