mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-15 19:09:50 +00:00
Auto commit for release 'develop' on 2025-03-14
This commit is contained in:
@@ -47,9 +47,10 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface, UserGroupIn
|
||||
public function findTransaction(int $transactionId): ?Transaction
|
||||
{
|
||||
return Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.user_id', $this->user->id)
|
||||
->where('transactions.id', $transactionId)
|
||||
->first(['transactions.*']);
|
||||
->where('transaction_journals.user_id', $this->user->id)
|
||||
->where('transactions.id', $transactionId)
|
||||
->first(['transactions.*'])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +60,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface, UserGroupIn
|
||||
*/
|
||||
public function getAttachments(TransactionJournal $journal): Collection
|
||||
{
|
||||
$set = $journal->attachments;
|
||||
$set = $journal->attachments;
|
||||
|
||||
$disk = Storage::disk('upload');
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ use Illuminate\Support\Collection;
|
||||
* @method checkUserGroupAccess(UserRoleEnum $role)
|
||||
* @method setUser(null|Authenticatable|User $user)
|
||||
* @method setUserGroupById(int $userGroupId)
|
||||
*
|
||||
*/
|
||||
interface JournalAPIRepositoryInterface
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class JournalCLIRepository
|
||||
@@ -47,9 +46,10 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
|
||||
public function getAllJournals(array $types): Collection
|
||||
{
|
||||
return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereIn('transaction_types.type', $types)
|
||||
->with(['user', 'transactionType', 'transactionCurrency', 'transactions', 'transactions.account'])
|
||||
->get(['transaction_journals.*']);
|
||||
->whereIn('transaction_types.type', $types)
|
||||
->with(['user', 'transactionType', 'transactionCurrency', 'transactions', 'transactions.account'])
|
||||
->get(['transaction_journals.*'])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
|
||||
*/
|
||||
public function getJournalBudgetId(TransactionJournal $journal): int
|
||||
{
|
||||
$budget = $journal->budgets()->first();
|
||||
$budget = $journal->budgets()->first();
|
||||
if (null !== $budget) {
|
||||
return $budget->id;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
|
||||
*/
|
||||
public function getJournalCategoryId(TransactionJournal $journal): int
|
||||
{
|
||||
$category = $journal->categories()->first();
|
||||
$category = $journal->categories()->first();
|
||||
if (null !== $category) {
|
||||
return $category->id;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
|
||||
*/
|
||||
public function getMetaField(TransactionJournal $journal, string $field): ?string
|
||||
{
|
||||
$cache = new CacheProperties();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty('journal-meta-updated');
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty($field);
|
||||
@@ -138,12 +138,12 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
$entry = $journal->transactionJournalMeta()->where('name', $field)->first();
|
||||
$entry = $journal->transactionJournalMeta()->where('name', $field)->first();
|
||||
if (null === $entry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = $entry->data;
|
||||
$value = $entry->data;
|
||||
|
||||
if (is_array($value)) {
|
||||
$return = implode(',', $value);
|
||||
@@ -179,11 +179,12 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
|
||||
public function getSplitJournals(): Collection
|
||||
{
|
||||
$query = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->groupBy('transaction_journals.id');
|
||||
->groupBy('transaction_journals.id')
|
||||
;
|
||||
$result = $query->get(['transaction_journals.id as id', DB::raw('count(transactions.id) as transaction_count')]); // @phpstan-ignore-line
|
||||
$journalIds = [];
|
||||
|
||||
/** @var stdClass $row */
|
||||
/** @var \stdClass $row */
|
||||
foreach ($result as $row) {
|
||||
if ((int) $row->transaction_count > 2) {
|
||||
$journalIds[] = (int) $row->id;
|
||||
@@ -192,7 +193,8 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
|
||||
$journalIds = array_unique($journalIds);
|
||||
|
||||
return TransactionJournal::with(['transactions'])
|
||||
->whereIn('id', $journalIds)->get();
|
||||
->whereIn('id', $journalIds)->get()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,7 +67,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac
|
||||
->transactionJournals()
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereIn('transaction_types.type', $types)
|
||||
->get(['transaction_journals.*']);
|
||||
->get(['transaction_journals.*'])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +102,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac
|
||||
*/
|
||||
public function getJournalTotal(TransactionJournal $journal): string
|
||||
{
|
||||
$cache = new CacheProperties();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('amount-positive');
|
||||
if ($cache->has()) {
|
||||
@@ -150,7 +151,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac
|
||||
return new Carbon($cache->get());
|
||||
}
|
||||
$entry = TransactionJournalMeta::where('transaction_journal_id', $journalId)
|
||||
->where('name', $field)->first();
|
||||
->where('name', $field)->first()
|
||||
;
|
||||
if (null === $entry) {
|
||||
return null;
|
||||
}
|
||||
@@ -193,7 +195,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac
|
||||
public function searchJournalDescriptions(string $search, int $limit): Collection
|
||||
{
|
||||
$query = $this->user->transactionJournals()
|
||||
->orderBy('date', 'DESC');
|
||||
->orderBy('date', 'DESC')
|
||||
;
|
||||
if ('' !== $search) {
|
||||
$query->whereLike('description', sprintf('%%%s%%', $search));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ use Illuminate\Support\Collection;
|
||||
* @method checkUserGroupAccess(UserRoleEnum $role)
|
||||
* @method setUser(null|Authenticatable|User $user)
|
||||
* @method setUserGroupById(int $userGroupId)
|
||||
*
|
||||
*/
|
||||
interface JournalRepositoryInterface
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user