Fix: PDF-Download liefert gespeicherten Beleg statt neu generierter PDF
This commit is contained in:
parent
58806757fa
commit
8c9d109e56
1 changed files with 17 additions and 2 deletions
|
|
@ -274,7 +274,22 @@ class InvoiceController
|
||||||
$invoice = Invoice::find((int)$params['id']);
|
$invoice = Invoice::find((int)$params['id']);
|
||||||
if (!$invoice) { http_response_code(404); return; }
|
if (!$invoice) { http_response_code(404); return; }
|
||||||
|
|
||||||
// Bei Stornorechnung Originalrechnung laden für Referenzzeile
|
// Gespeicherte PDF aus dem Beleg ausliefern (GoBD: unveränderlicher Stand)
|
||||||
|
if (!empty($invoice['beleg_id'])) {
|
||||||
|
$beleg = Beleg::find((int)$invoice['beleg_id']);
|
||||||
|
$absPath = $beleg
|
||||||
|
? dirname(__DIR__, 2) . '/public/' . $beleg['storage_path']
|
||||||
|
: '';
|
||||||
|
if ($absPath && file_exists($absPath)) {
|
||||||
|
header('Content-Type: application/pdf');
|
||||||
|
header('Content-Disposition: attachment; filename="' . $beleg['filename'] . '"');
|
||||||
|
header('Content-Length: ' . filesize($absPath));
|
||||||
|
readfile($absPath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: PDF on-the-fly generieren (Entwurf oder Beleg noch ohne Datei)
|
||||||
if (!empty($invoice['storno_of_id'])) {
|
if (!empty($invoice['storno_of_id'])) {
|
||||||
$original = Invoice::find((int)$invoice['storno_of_id']);
|
$original = Invoice::find((int)$invoice['storno_of_id']);
|
||||||
if ($original) {
|
if ($original) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue