Warenwirtschaft: Bugfix — Logistik-Mail hängt den Lieferschein IMMER an

Kundenmeldung 16.07.2026: Fehlversand an die Rechnungsadresse, weil der
Lieferschein (mit der Lieferadresse) in der Versand-Mail fehlte. Ursache:
MailLogistic hängte ihn nur bei White-Label-Bestellungen an. Jetzt wird der
Lieferschein unabhängig von Logo/White-Label immer mitgesendet; fehlt die
PDF-Datei auf der Platte (Altdaten), wird sie mit bestehender Rechnungsnummer
regeneriert. Dazu tote Duplikat-Klasse app/Mail/MailLogitic.php entfernt
(Tippfehler-Dateiname, definierte dieselbe Klasse in einer Altversion ganz
ohne Lieferschein-Anhang — Kollisionsrisiko im Classmap-Autoload).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-07-16 12:11:37 +00:00
parent 748f259949
commit 7d77314805
3 changed files with 178 additions and 74 deletions

View file

@ -3,6 +3,7 @@
namespace App\Mail;
use App\Models\ShoppingOrder;
use App\Repositories\InvoiceRepository;
use App\Services\Invoice;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
@ -65,21 +66,20 @@ class MailLogistic extends Mailable
'mime' => $mime,
]);
// Wenn mindestens ein White-Label-Produkt enthalten ist, wird der Lieferschein (Etikett-Infos) mit angehängt
$hasWhiteLabel = $this->shopping_order->user_white_label || $this->shopping_order->hasWhitelabelProducts();
if ($hasWhiteLabel) {
$filenameDelivery = Invoice::getDeliveryFilename($this->shopping_order);
$pathDelivery = Invoice::getDownloadPathDelivery($this->shopping_order);
if (! Storage::disk('public')->exists($pathDelivery)) {
return;
}
$fileDelivery = Storage::disk('public')->path($pathDelivery);
$mimeDelivery = Storage::disk('public')->mimeType($pathDelivery);
$mail->attach($fileDelivery, [
'as' => $filenameDelivery,
'mime' => $mimeDelivery,
]); // attach file;
// Kundenanforderung 16.07.2026: Der Lieferschein (mit der Lieferadresse der
// Bestellung) wird IMMER mitgesendet — unabhängig von White-Label/Logo.
// Vorher hing er nur bei White-Label-Bestellungen an; Folge waren
// Fehlversände an die Rechnungsadresse.
$pathDelivery = Invoice::getDownloadPathDelivery($this->shopping_order);
if (! Storage::disk('public')->exists($pathDelivery)) {
// Datei fehlt auf der Platte (Altdaten) — mit bestehender Nummer neu erzeugen
(new InvoiceRepository($this->shopping_order))->update([]);
}
if (Storage::disk('public')->exists($pathDelivery)) {
$mail->attach(Storage::disk('public')->path($pathDelivery), [
'as' => Invoice::getDeliveryFilename($this->shopping_order),
'mime' => Storage::disk('public')->mimeType($pathDelivery),
]);
}
return $mail;

View file

@ -1,59 +0,0 @@
<?php
namespace App\Mail;
use App\User;
use App\Services\Invoice;
use App\Models\ShoppingOrder;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Storage;
use Illuminate\Contracts\Queue\ShouldQueue;
class MailLogistic extends Mailable
{
use Queueable, SerializesModels;
protected $shopping_order;
public $subject;
public function __construct(ShoppingOrder $shopping_order)
{
$this->shopping_order = $shopping_order;
if($shopping_order->user_white_label){
//Bei allen, die ein eigenes Logo haben
$this->subject = 'Partner (mit Logo) - Firma (Vorname Nachname)';
}else{
//Bei allen, die kein Tattoostudio sind
$this->subject = 'Partner - Firma (Vorname Nachname)';
}
}
public function build()
{
$title = false;
$copy1line = false;
$filename = Invoice::getFilename($this->shopping_order);
$path = Invoice::getDownloadPath($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,
]); // attach file;
}
}