Kundenwunsch 06.10.2026: Ein Kunde kam über die Stripe-Rechnungsseite nicht an seine Rechnung und fragte nach Belegen und einer Rechnungs-E-Mail. - Profil ▸ Rechnungsadresse ▸ Rechnungsversand: Schalter „Rechnungs-PDF an die Konto-E-Mail" (Standard an), optionale „E-Mail für Rechnungen" mit Schalter „Rechnungen als PDF an diese Adresse senden" (Standard an). Neue Spalten an billing_addresses (klein, ohne FULLTEXT). - InvoiceDelivery entscheidet Empfänger und Anhang; gleiche Adresse wie das Konto ergibt eine Mail mit PDF. - Zahlungsbestätigung (STR) und Bestandskunden-Rechnung/-Erinnerung (MAN) folgen der Einstellung; die Fassung an die Rechnungs-E-Mail nennt das Konto, ohne Blindkopie und ohne Login-Button. - StripeInvoicePdf holt das Stripe-PDF einmal und legt es lokal ab (storage/app/private/invoices/stripe); Mailversand wiederholt bei Stripe-Ausfall (5 Versuche). - Rechnungsseite: „PDF öffnen" aus pressekonto, „Beleg bei Stripe" für den Zahlungsbeleg auf der Stripe-Seite. Suite 2.340 grün, einer übersprungen; Larastan und Pint ohne Meldung. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
3.1 KiB
PHP
97 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\Invoice;
|
|
use App\Models\User;
|
|
use App\Services\Billing\ManualInvoicePdfRenderer;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Mail\Attachment;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
/**
|
|
* Rechnung an einen Legacy-Überweisungskunden (MAN-Kreis) mit PDF im
|
|
* Anhang, Bankverbindung, Zahlungsziel und dem Hinweis, dass der
|
|
* Bestandsschutz ohne Zahlung zum Zahlungsziel endet. Als Zahlungs-
|
|
* erinnerung (`$isReminder`) mit gleichem Inhalt im Mahn-Ton.
|
|
*
|
|
* Transaktionsmail: bewusst ohne Opt-out. Die Bounce-Sperrliste greift
|
|
* über `GateOutgoingMail`; der Service prüft sie zusätzlich vorab.
|
|
*
|
|
* Rechnungsversand (06.10.2026): `attachPdf` folgt der Profileinstellung
|
|
* (Standard: an); `forInvoiceRecipient` ist die Fassung an die
|
|
* Rechnungs-E-Mail (siehe InvoiceDelivery), immer mit PDF.
|
|
*/
|
|
class ManualInvoiceIssued extends Mailable implements ShouldQueue
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public string $invoicesUrl;
|
|
|
|
public string $bookingUrl;
|
|
|
|
public string $serviceName;
|
|
|
|
/** @var array{0: string, 1: string}|null */
|
|
public ?array $servicePeriod;
|
|
|
|
/** @var array<string, string> */
|
|
public array $issuer;
|
|
|
|
public function __construct(
|
|
public readonly User $user,
|
|
public readonly Invoice $invoice,
|
|
public readonly bool $isReminder = false,
|
|
public readonly bool $attachPdf = true,
|
|
public readonly bool $forInvoiceRecipient = false,
|
|
) {
|
|
$renderer = app(ManualInvoicePdfRenderer::class);
|
|
|
|
$this->invoicesUrl = route('me.invoices.index');
|
|
$this->bookingUrl = route('me.bookings.index');
|
|
$this->serviceName = $renderer->serviceName($invoice);
|
|
$this->servicePeriod = $renderer->servicePeriod($invoice);
|
|
$this->issuer = array_map(fn (mixed $value): string => (string) $value, (array) config('billing.issuer', []));
|
|
}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
// Die Fassung an die Rechnungs-E-Mail ist ein Duplikat — ohne Blindkopie.
|
|
$bcc = $this->forInvoiceRecipient ? '' : (string) config('legal.contact_email');
|
|
|
|
$subject = $this->isReminder
|
|
? 'Zahlungserinnerung — Rechnung '.$this->invoice->number
|
|
: 'Ihre Rechnung '.$this->invoice->number.' — Bestandsschutz auf pressekonto';
|
|
|
|
return new Envelope(
|
|
subject: $subject,
|
|
bcc: $bcc !== '' ? [$bcc] : [],
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
return new Content(view: 'emails.billing.manual-invoice-issued');
|
|
}
|
|
|
|
/**
|
|
* @return array<int, Attachment>
|
|
*/
|
|
public function attachments(): array
|
|
{
|
|
if (! $this->attachPdf) {
|
|
return [];
|
|
}
|
|
|
|
$renderer = app(ManualInvoicePdfRenderer::class);
|
|
|
|
return [
|
|
Attachment::fromData(fn (): string => $renderer->render($this->invoice), $renderer->filename($this->invoice))
|
|
->withMime('application/pdf'),
|
|
];
|
|
}
|
|
}
|