From fb527db4d96d160d5d8f6d4d588a38fee39b6fac Mon Sep 17 00:00:00 2001 From: Daniel Subiabre Date: Wed, 23 Oct 2024 15:05:02 +0200 Subject: [PATCH] Allow to retrieve wallet statements in either direction of an accounting --- src/Repository/WalletStatementRepository.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Repository/WalletStatementRepository.php b/src/Repository/WalletStatementRepository.php index 0e2c511..5277a5e 100644 --- a/src/Repository/WalletStatementRepository.php +++ b/src/Repository/WalletStatementRepository.php @@ -18,6 +18,22 @@ class WalletStatementRepository extends ServiceEntityRepository parent::__construct($registry, WalletStatement::class); } + /** + * @return WalletStatement[] + */ + public function findByAccounting(Accounting $accounting): array + { + return $this->createQueryBuilder('w') + ->join('w.transaction', 'wt', Join::WITH, 'wt.id = w.transaction') + ->where('wt.origin = :val') + ->orWhere('wt.target = :val') + ->setParameter('val', $accounting->getId()) + ->orderBy('w.id', 'ASC') + ->getQuery() + ->getResult() + ; + } + /** * @return WalletStatement[] */