Der SalesController rief InvoiceRepository::createCancellation() auf, die Methode existierte aber nicht — jeder Storno-Versuch endete im 500er. Die Stornorechnung wird jetzt aus demselben Nummernkreis wie die Rechnung erzeugt (pdf.cancellation_invoice, Rechnungs-Briefpapier), als cancellation_invoice am Auftrag gespeichert und der Zähler erhöht. Optional geht eine Storno-Mail mit angehängter Stornorechnung (MailCancellation, Texte email.cancellation_title/_copy1line) statt der Rechnungs-Mail an den Kunden. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\ShoppingOrder;
|
|
use App\Services\Invoice;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Storage;
|
|
|
|
class MailCancellation extends Mailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
protected $shopping_order;
|
|
|
|
public $subject;
|
|
|
|
public function __construct(ShoppingOrder $shopping_order)
|
|
{
|
|
$this->shopping_order = $shopping_order;
|
|
$this->subject = 'Stornorechnung zu Deiner Bestellung: '.$shopping_order->getLastShoppingPayment('reference');
|
|
}
|
|
|
|
public function build()
|
|
{
|
|
$title = __('email.cancellation_title');
|
|
$copy1line = __('email.cancellation_copy1line').Invoice::getNumber($this->shopping_order);
|
|
|
|
$filename = Invoice::getCancellationFilename($this->shopping_order);
|
|
$path = Invoice::getCancellationDownloadPath($this->shopping_order);
|
|
if (! Storage::disk('public')->exists($path)) {
|
|
return;
|
|
}
|
|
$file = Storage::disk('public')->path($path);
|
|
$mime = Storage::disk('public')->mimeType($path);
|
|
|
|
return $this->view('emails.blank')->with([
|
|
'title' => $title,
|
|
'copy1line' => $copy1line,
|
|
])->attach($file, [
|
|
'as' => $filename,
|
|
'mime' => $mime,
|
|
]);
|
|
}
|
|
}
|