Fix: Stornorechnung-PDF beim Erstellen unveränderlich speichern (GoBD)
This commit is contained in:
parent
8c9d109e56
commit
9f1557ae66
1 changed files with 14 additions and 1 deletions
|
|
@ -453,6 +453,15 @@ class InvoiceController
|
||||||
$lines = Invoice::lines($id);
|
$lines = Invoice::lines($id);
|
||||||
$settings = Setting::get();
|
$settings = Setting::get();
|
||||||
|
|
||||||
|
// Bei Stornorechnung Originaldaten für Referenzzeile ergänzen
|
||||||
|
if (!empty($invoice['storno_of_id'])) {
|
||||||
|
$original = Invoice::find((int)$invoice['storno_of_id']);
|
||||||
|
if ($original) {
|
||||||
|
$invoice['original_rechnungs_nr'] = $original['rechnungs_nr'];
|
||||||
|
$invoice['original_rechnungs_datum'] = $original['rechnungs_datum'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PDF zum Zeitpunkt der Finalisierung unveränderlich generieren und speichern (GoBD)
|
// PDF zum Zeitpunkt der Finalisierung unveränderlich generieren und speichern (GoBD)
|
||||||
$svc = new PdfInvoiceService();
|
$svc = new PdfInvoiceService();
|
||||||
$pdf = $svc->renderToString($invoice, $lines, $settings);
|
$pdf = $svc->renderToString($invoice, $lines, $settings);
|
||||||
|
|
@ -478,7 +487,7 @@ class InvoiceController
|
||||||
'rechnungs_nr' => $invoice['rechnungs_nr'],
|
'rechnungs_nr' => $invoice['rechnungs_nr'],
|
||||||
'betrag_brutto' => $invoice['betrag_brutto'],
|
'betrag_brutto' => $invoice['betrag_brutto'],
|
||||||
'belegtyp' => 'Ausgangsrechnung',
|
'belegtyp' => 'Ausgangsrechnung',
|
||||||
'notes' => 'Automatisch erstellt aus Rechnung ' . $invoice['rechnungs_nr'],
|
'notes' => (!empty($invoice['storno_of_id']) ? 'Stornorechnung zu Rechnung ' : 'Automatisch erstellt aus Rechnung ') . $invoice['rechnungs_nr'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
\Steuerkram\Database::execute(
|
\Steuerkram\Database::execute(
|
||||||
|
|
@ -508,6 +517,10 @@ class InvoiceController
|
||||||
public function cancel(array $params): void
|
public function cancel(array $params): void
|
||||||
{
|
{
|
||||||
$stornoId = Invoice::createCancellation((int)$params['id']);
|
$stornoId = Invoice::createCancellation((int)$params['id']);
|
||||||
|
$storno = Invoice::find($stornoId);
|
||||||
|
if ($storno) {
|
||||||
|
$this->createBeleg($storno);
|
||||||
|
}
|
||||||
View::redirect('/invoices/' . $stornoId, 'Stornorechnung erstellt.');
|
View::redirect('/invoices/' . $stornoId, 'Stornorechnung erstellt.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue