From ce7a64534bdca8c482af04f3cd5ebc183d3c766c Mon Sep 17 00:00:00 2001 From: fds2610-bot Date: Fri, 15 May 2026 17:12:02 +0200 Subject: [PATCH] Feature: Bankbuchungs-Badge in Beleganzeige unterhalb der Buchungszeilen --- src/Controllers/BelegController.php | 3 +++ src/Models/BankTransaction.php | 13 +++++++++++++ src/Views/belege/detail.php | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/src/Controllers/BelegController.php b/src/Controllers/BelegController.php index 35f6180..1ddd7d1 100644 --- a/src/Controllers/BelegController.php +++ b/src/Controllers/BelegController.php @@ -243,6 +243,8 @@ class BelegController } } + $linkedBankTx = BankTransaction::findByBelegId((int)$beleg['id']); + $view = new View(); $view->render('layout/base.php', [ 'pageTitle' => 'Beleg ' . $beleg['beleg_nr'], @@ -260,6 +262,7 @@ class BelegController 'bankTxSupplier' => $bankTxSupplier, 'bankTxBrutto' => $bankTxBrutto, 'formData' => $bankFormData, + 'linkedBankTx' => $linkedBankTx, ]), ]); } diff --git a/src/Models/BankTransaction.php b/src/Models/BankTransaction.php index 0d0493f..4fde63e 100644 --- a/src/Models/BankTransaction.php +++ b/src/Models/BankTransaction.php @@ -147,6 +147,19 @@ class BankTransaction return ['new' => $new, 'dup' => $dup]; } + public static function findByBelegId(int $belegId): ?array + { + $row = Database::fetchOne( + 'SELECT bt.*, bib.filename AS batch_filename + FROM bank_transactions bt + JOIN bank_import_batches bib ON bib.id = bt.batch_id + WHERE bt.beleg_id = ? + LIMIT 1', + [$belegId] + ); + return $row ?: null; + } + public static function createBatch(int $formatId, string $filename, int $rowCount): int { Database::execute( diff --git a/src/Views/belege/detail.php b/src/Views/belege/detail.php index 454bc73..e96516b 100644 --- a/src/Views/belege/detail.php +++ b/src/Views/belege/detail.php @@ -295,6 +295,28 @@ $suppliers = $suppliers ?? []; + + + + +
+
+ Bankbuchung + + + + + + + = 0 ? '+' : '' ?> € + +
+
+
+ +