Fix #54: Löschreihenfolge korrigiert – invoices vor belege löschen (FK-Constraint)
This commit is contained in:
parent
eb41c910fc
commit
308895419e
1 changed files with 7 additions and 4 deletions
|
|
@ -237,12 +237,15 @@ class Invoice
|
||||||
$invoice = self::find($id);
|
$invoice = self::find($id);
|
||||||
if (!$invoice) return;
|
if (!$invoice) return;
|
||||||
|
|
||||||
if (!empty($invoice['beleg_id'])) {
|
$belegId = !empty($invoice['beleg_id']) ? (int)$invoice['beleg_id'] : null;
|
||||||
Database::execute('DELETE FROM bookings WHERE beleg_id = ?', [$invoice['beleg_id']]);
|
|
||||||
Database::execute('DELETE FROM belege WHERE id = ?', [$invoice['beleg_id']]);
|
|
||||||
}
|
|
||||||
Database::execute('DELETE FROM invoice_lines WHERE invoice_id = ?', [$id]);
|
Database::execute('DELETE FROM invoice_lines WHERE invoice_id = ?', [$id]);
|
||||||
Database::execute('DELETE FROM invoices WHERE id = ?', [$id]);
|
Database::execute('DELETE FROM invoices WHERE id = ?', [$id]);
|
||||||
|
|
||||||
|
if ($belegId !== null) {
|
||||||
|
Database::execute('DELETE FROM bookings WHERE beleg_id = ?', [$belegId]);
|
||||||
|
Database::execute('DELETE FROM belege WHERE id = ?', [$belegId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateRechnungsNr(): string
|
public static function generateRechnungsNr(): string
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue