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
|
|
@ -215,6 +215,13 @@ class BookingController
|
|||
$accounts = \Steuerkram\Models\Account::all(['aktiv' => 1]);
|
||||
$integrity = \Steuerkram\Models\Beleg::verifyIntegrity($belegId);
|
||||
$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->render('layout/base.php', [
|
||||
|
|
@ -227,6 +234,9 @@ class BookingController
|
|||
'assets' => $assets,
|
||||
'formErrors' => $errors,
|
||||
'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>
|
||||
<?php endif; ?>
|
||||
<form method="post" action="/belege/<?= $h($beleg['id']) ?>/bookings">
|
||||
<?php if ($bankTx ?? null): ?>
|
||||
<input type="hidden" name="bank_tx_id" value="<?= (int)$bankTx['id'] ?>">
|
||||
<input type="hidden" name="alloc_betrag" value="<?= $h($formData['alloc_betrag'] ?? '') ?>">
|
||||
<?php
|
||||
// bank_tx_id und alloc_betrag aus aktiver Session ODER aus POST-Daten beim Re-Render nach Validierungsfehler
|
||||
$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; ?>
|
||||
|
||||
<!-- Buchungstyp -->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue