Skip to content

Firefly III: a personal finances manager

Add custom method.

James Coledb2cab3cef22
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 8a8cb8a908..26f3cc12f7 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -641,4 +641,34 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
return $factory->create($data);
}
+
+ #[\Override] public function periodCollection(Account $account, Carbon $start, Carbon $end): array
+ {
+ return $account->transactions()
+ ->leftJoin('transaction_journals','transaction_journals.id','=','transactions.transaction_journal_id')
+ ->leftJoin('transaction_types','transaction_types.id','=','transaction_journals.transaction_type_id')
+ ->leftJoin('transaction_currencies','transaction_currencies.id','=','transactions.transaction_currency_id')
+ ->leftJoin('transaction_currencies as foreign_currencies','foreign_currencies.id','=','transactions.foreign_currency_id')
+ ->where('transaction_journals.date','>=',$start)
+ ->where('transaction_journals.date','<=',$end)
+ ->get([
+ // currencies
+ 'transaction_currencies.id as currency_id',
+ 'transaction_currencies.code as currency_code',
+ 'transaction_currencies.name as currency_name',
+ 'transaction_currencies.symbol as currency_symbol',
+ 'transaction_currencies.decimal_places as currency_decimal_places',
+
+ // foreign
+ 'foreign_currencies.id as foreign_currency_id',
+ 'foreign_currencies.code as foreign_currency_code',
+ 'foreign_currencies.name as foreign_currency_name',
+ 'foreign_currencies.symbol as foreign_currency_symbol',
+ 'foreign_currencies.decimal_places as foreign_decimal_places',
+
+ // fields
+ 'transaction_journals.date', 'transaction_types.type', 'transaction_journals.transaction_currency_id', 'transactions.amount'])
+ ->toArray();
+
+ }
}
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index 006b2d7eed..6bfb568c28 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -71,6 +71,8 @@ interface AccountRepositoryInterface
public function findByName(string $name, array $types): ?Account;
+ public function periodCollection(Account $account, Carbon $start, Carbon $end): array;
+
public function getAccountBalances(Account $account): Collection;
public function getAccountCurrency(Account $account): ?TransactionCurrency;