Fix: alloc_betrag und bank_tx_id bleiben bei Validierungsfehlern in der Buchungsmaske erhalten
This commit is contained in:
parent
d31e5afa57
commit
2034372210
2 changed files with 26 additions and 11 deletions
|
|
@ -214,19 +214,29 @@ class BookingController
|
||||||
$bookings = \Steuerkram\Models\Booking::forBeleg($belegId);
|
$bookings = \Steuerkram\Models\Booking::forBeleg($belegId);
|
||||||
$accounts = \Steuerkram\Models\Account::all(['aktiv' => 1]);
|
$accounts = \Steuerkram\Models\Account::all(['aktiv' => 1]);
|
||||||
$integrity = \Steuerkram\Models\Beleg::verifyIntegrity($belegId);
|
$integrity = \Steuerkram\Models\Beleg::verifyIntegrity($belegId);
|
||||||
$assets = \Steuerkram\Models\Asset::all();
|
$assets = \Steuerkram\Models\Asset::all();
|
||||||
|
$linked = BankTransaction::findByBelegId($belegId);
|
||||||
|
|
||||||
|
// Bank-Kontext aus POST-Daten wiederherstellen (damit alloc_betrag nach Validierungsfehler erhalten bleibt)
|
||||||
|
$bankTx = null;
|
||||||
|
if (!empty($formData['bank_tx_id'])) {
|
||||||
|
$bankTx = BankTransaction::find((int)$formData['bank_tx_id']);
|
||||||
|
}
|
||||||
|
|
||||||
$view = new View();
|
$view = new View();
|
||||||
$view->render('layout/base.php', [
|
$view->render('layout/base.php', [
|
||||||
'pageTitle' => 'Beleg ' . ($beleg['beleg_nr'] ?? ''),
|
'pageTitle' => 'Beleg ' . ($beleg['beleg_nr'] ?? ''),
|
||||||
'content' => $this->renderView('belege/detail', [
|
'content' => $this->renderView('belege/detail', [
|
||||||
'beleg' => $beleg,
|
'beleg' => $beleg,
|
||||||
'bookings' => $bookings,
|
'bookings' => $bookings,
|
||||||
'integrity' => $integrity,
|
'integrity' => $integrity,
|
||||||
'accounts' => $accounts,
|
'accounts' => $accounts,
|
||||||
'assets' => $assets,
|
'assets' => $assets,
|
||||||
'formErrors' => $errors,
|
'formErrors' => $errors,
|
||||||
'formData' => $formData,
|
'formData' => $formData,
|
||||||
|
'bankTx' => $bankTx,
|
||||||
|
'bankTxBrutto' => $bankTx ? (float)($formData['alloc_betrag'] ?: abs((float)$bankTx['wert'])) : 0.0,
|
||||||
|
'linkedBankTx' => $linked,
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -387,9 +387,14 @@ $suppliers = $suppliers ?? [];
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<form method="post" action="/belege/<?= $h($beleg['id']) ?>/bookings">
|
<form method="post" action="/belege/<?= $h($beleg['id']) ?>/bookings">
|
||||||
<?php if ($bankTx ?? null): ?>
|
<?php
|
||||||
<input type="hidden" name="bank_tx_id" value="<?= (int)$bankTx['id'] ?>">
|
// bank_tx_id und alloc_betrag aus aktiver Session ODER aus POST-Daten beim Re-Render nach Validierungsfehler
|
||||||
<input type="hidden" name="alloc_betrag" value="<?= $h($formData['alloc_betrag'] ?? '') ?>">
|
$effectiveBankTxId = ($bankTx ?? null) ? (int)$bankTx['id'] : (int)($formData['bank_tx_id'] ?? 0);
|
||||||
|
$effectiveAllocBetrag = $formData['alloc_betrag'] ?? '';
|
||||||
|
?>
|
||||||
|
<?php if ($effectiveBankTxId > 0): ?>
|
||||||
|
<input type="hidden" name="bank_tx_id" value="<?= $effectiveBankTxId ?>">
|
||||||
|
<input type="hidden" name="alloc_betrag" value="<?= $h($effectiveAllocBetrag) ?>">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<!-- Buchungstyp -->
|
<!-- Buchungstyp -->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue