Fix for level 2

This commit is contained in:
James Cole
2025-01-03 19:07:29 +01:00
parent 3898c0c0ef
commit 6cd60951ba
16 changed files with 41 additions and 15 deletions

View File

@@ -285,6 +285,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
$currency->save();
// find the budget:
/** @var Budget|null $budget */
$budget = $this->user->budgets()->find((int) $data['budget_id']);
if (null === $budget) {
throw new FireflyException('200004: Budget does not exist.');

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
@@ -89,7 +90,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
$events = $journal->piggyBankEvents()->get();
$events->each(
static function (PiggyBankEvent $event): void {
$event->piggyBank = $event->piggyBank()->withTrashed()->first();
$event->piggyBank = PiggyBank::withTrashed()->find($event->piggy_bank_id);
}
);

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
use Carbon\Carbon;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Support\CacheProperties;
use FireflyIII\User;
@@ -57,7 +58,9 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
if (null !== $budget) {
return $budget->id;
}
$budget = $journal->transactions()->first()->budgets()->first();
/** @var Transaction|null $transaction */
$transaction = $journal->transactions()->first();
$budget = $transaction?->budgets()->first();
if (null !== $budget) {
return $budget->id;
}
@@ -74,7 +77,9 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
if (null !== $category) {
return $category->id;
}
$category = $journal->transactions()->first()->categories()->first();
/** @var Transaction|null $transaction */
$transaction = $journal->transactions()->first();
$category = $transaction?->categories()->first();
if (null !== $category) {
return $category->id;
}

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Repositories\UserGroups\Currency;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\UserGroup;
use FireflyIII\User;
use Illuminate\Support\Collection;
@@ -33,6 +34,8 @@ interface CurrencyRepositoryInterface
{
public function currencyInUse(TransactionCurrency $currency): bool;
public function getUserGroup(): UserGroup;
/**
* Currency is in use where exactly.
*/

View File

@@ -103,4 +103,12 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
return $object;
}
/**
* @return Collection
*/
#[\Override] public function getAll(): Collection
{
return $this->userGroup->currencyExchangeRates()->get();
}
}

View File

@@ -33,6 +33,8 @@ interface ExchangeRateRepositoryInterface
{
public function getRates(TransactionCurrency $from, TransactionCurrency $to): Collection;
public function getAll(): Collection;
public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate;
public function deleteRate(CurrencyExchangeRate $rate): void;