Bank transfer: Hide email form if email was already sent (Z#23128941) (#3570)

Co-authored-by: Mira <weller@rami.io>
This commit is contained in:
Raphael Michel
2023-09-08 14:11:45 +02:00
committed by GitHub
parent b04ec720dc
commit 8dbc7ac5d7
3 changed files with 21 additions and 1 deletions

View File

@@ -530,6 +530,7 @@ class BankTransfer(BasePaymentProvider):
'code': self._code(payment.order),
'order': payment.order,
'amount': payment.amount,
'payment_info': payment.info_data,
'settings': self.settings,
'swiss_qrbill': self.swiss_qrbill(payment),
'eu_barcodes': self.event.currency == 'EUR',

View File

@@ -106,7 +106,20 @@ SCT
{% endif %}
{% if invoice_email_enabled and has_invoices %}
<form method="post" action="{% eventurl event "plugins:banktransfer:mail_invoice" order=order.code secret=order.secret %}">
{% if payment_info.send_invoice_to %}
<p>
{% blocktrans trimmed with recipient=payment_info.send_invoice_to %}
At your request, we sent the invoice directly to {{ recipient }}.
{% endblocktrans %}
<a data-toggle="collapse" data-target="#payment_banktransfer_send_invoice_to" class="btn btn-default btn-xs">
<span class="fa fa-envelope-o"></span>
{% trans "Send again or somewhere else" %}
</a>
</p>
{% endif %}
<form id="payment_banktransfer_send_invoice_to" method="post"
action="{% eventurl event "plugins:banktransfer:mail_invoice" order=order.code secret=order.secret %}"
{% if payment_info.send_invoice_to %}class="collapse"{% endif %}>
{% csrf_token %}
<p>
{% blocktrans trimmed %}

View File

@@ -923,5 +923,11 @@ class SendInvoiceMailView(EventViewMixin, OrderDetailMixin, View):
provider = last_payment.payment_provider
provider.send_invoice_to_alternate_email(self.order, last_invoice, request.POST['email'])
last_payment.info_data = {
**last_payment.info_data,
'send_invoice_to': request.POST['email'],
}
last_payment.save(update_fields=['info'])
messages.success(request, _('Sending the latest invoice via e-mail to {email}.').format(email=request.POST['email']))
return redirect(self.get_order_url())