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 ?? [];
+
+
+
+
+