mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-26 16:26:35 -06:00
Refactor findNull to find
This commit is contained in:
parent
b7ae5eda35
commit
70da5917c9
@ -38,8 +38,8 @@ class AccountController extends Controller
|
||||
public function moveTransactions(MoveTransactionsRequest $request): JsonResponse
|
||||
{
|
||||
$accountIds = $request->getAll();
|
||||
$original = $this->repository->findNull($accountIds['original_account']);
|
||||
$destination = $this->repository->findNull($accountIds['destination_account']);
|
||||
$original = $this->repository->find($accountIds['original_account']);
|
||||
$destination = $this->repository->find($accountIds['destination_account']);
|
||||
|
||||
/** @var AccountDestroyService $service */
|
||||
$service = app(AccountDestroyService::class);
|
||||
|
@ -38,7 +38,7 @@ use Illuminate\Http\JsonResponse;
|
||||
*
|
||||
* Shows income information grouped or limited by date.
|
||||
* Ie. all income grouped by account + currency.
|
||||
* See reference nr. 75
|
||||
* See reference nr. 75
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
{
|
||||
@ -74,8 +74,9 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* See reference nr. 76
|
||||
* See reference nr. 77
|
||||
* See reference nr. 76
|
||||
* See reference nr. 77
|
||||
*
|
||||
* @param GenericRequest $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
@ -103,7 +104,7 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* See reference nr. 78
|
||||
* See reference nr. 78
|
||||
*
|
||||
* @param GenericRequest $request
|
||||
*
|
||||
|
@ -78,8 +78,8 @@ class StoreController extends Controller
|
||||
{
|
||||
$manager = $this->getManager();
|
||||
$data = $request->getAll();
|
||||
$inward = $this->journalRepository->findNull($data['inward_id'] ?? 0);
|
||||
$outward = $this->journalRepository->findNull($data['outward_id'] ?? 0);
|
||||
$inward = $this->journalRepository->find($data['inward_id'] ?? 0);
|
||||
$outward = $this->journalRepository->find($data['outward_id'] ?? 0);
|
||||
if (null === $inward || null === $outward) {
|
||||
throw new FireflyException('200024: Source or destination does not exist.');
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ class BasicController extends Controller
|
||||
// format amounts:
|
||||
$keys = array_keys($sums);
|
||||
foreach ($keys as $currencyId) {
|
||||
$currency = $this->currencyRepos->findNull($currencyId);
|
||||
$currency = $this->currencyRepos->find($currencyId);
|
||||
if (null === $currency) {
|
||||
continue;
|
||||
}
|
||||
@ -239,7 +239,7 @@ class BasicController extends Controller
|
||||
$return = [];
|
||||
foreach ($paidAmount as $currencyId => $amount) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
$currency = $this->currencyRepos->findNull((int)$currencyId);
|
||||
$currency = $this->currencyRepos->find((int)$currencyId);
|
||||
if (null === $currency) {
|
||||
continue;
|
||||
}
|
||||
@ -259,7 +259,7 @@ class BasicController extends Controller
|
||||
|
||||
foreach ($unpaidAmount as $currencyId => $amount) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
$currency = $this->currencyRepos->findNull((int)$currencyId);
|
||||
$currency = $this->currencyRepos->find((int)$currencyId);
|
||||
if (null === $currency) {
|
||||
continue;
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ class MoveTransactionsRequest extends FormRequest
|
||||
if (array_key_exists('original_account', $data) && array_key_exists('destination_account', $data)) {
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository->setUser(auth()->user());
|
||||
$original = $repository->findNull((int)$data['original_account']);
|
||||
$destination = $repository->findNull((int)$data['destination_account']);
|
||||
$original = $repository->find((int)$data['original_account']);
|
||||
$destination = $repository->find((int)$data['destination_account']);
|
||||
if ($original->accountType->type !== $destination->accountType->type) {
|
||||
$validator->errors()->add('title', (string)trans('validation.same_account_type'));
|
||||
|
||||
|
@ -53,7 +53,7 @@ class ExportRequest extends FormRequest
|
||||
foreach ($parts as $part) {
|
||||
$accountId = (int)$part;
|
||||
if (0 !== $accountId) {
|
||||
$account = $repository->findNull($accountId);
|
||||
$account = $repository->find($accountId);
|
||||
if (null !== $account && AccountType::ASSET === $account->accountType->type) {
|
||||
$accounts->push($account);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class GenericRequest extends FormRequest
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $accountId) {
|
||||
$accountId = (int)$accountId;
|
||||
$account = $repository->findNull($accountId);
|
||||
$account = $repository->find($accountId);
|
||||
if (null !== $account) {
|
||||
$this->accounts->push($account);
|
||||
}
|
||||
@ -159,7 +159,7 @@ class GenericRequest extends FormRequest
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $budgetId) {
|
||||
$budgetId = (int)$budgetId;
|
||||
$budget = $repository->findNull($budgetId);
|
||||
$budget = $repository->find($budgetId);
|
||||
if (null !== $budgetId) {
|
||||
$this->budgets->push($budget);
|
||||
}
|
||||
@ -191,7 +191,7 @@ class GenericRequest extends FormRequest
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $categoryId) {
|
||||
$categoryId = (int)$categoryId;
|
||||
$category = $repository->findNull($categoryId);
|
||||
$category = $repository->find($categoryId);
|
||||
if (null !== $categoryId) {
|
||||
$this->categories->push($category);
|
||||
}
|
||||
@ -281,7 +281,7 @@ class GenericRequest extends FormRequest
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $tagId) {
|
||||
$tagId = (int)$tagId;
|
||||
$tag = $repository->findNull($tagId);
|
||||
$tag = $repository->find($tagId);
|
||||
if (null !== $tagId) {
|
||||
$this->tags->push($tag);
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ class StoreRequest extends FormRequest
|
||||
$data = $validator->getData();
|
||||
$inwardId = (int)($data['inward_id'] ?? 0);
|
||||
$outwardId = (int)($data['outward_id'] ?? 0);
|
||||
$inward = $journalRepos->findNull($inwardId);
|
||||
$outward = $journalRepos->findNull($outwardId);
|
||||
$inward = $journalRepos->find($inwardId);
|
||||
$outward = $journalRepos->find($outwardId);
|
||||
|
||||
if (null === $inward) {
|
||||
$validator->errors()->add('inward_id', 'Invalid inward ID.');
|
||||
|
@ -104,8 +104,8 @@ class UpdateRequest extends FormRequest
|
||||
|
||||
$inwardId = $data['inward_id'] ?? $existing->source_id;
|
||||
$outwardId = $data['outward_id'] ?? $existing->destination_id;
|
||||
$inward = $journalRepos->findNull((int)$inwardId);
|
||||
$outward = $journalRepos->findNull((int)$outwardId);
|
||||
$inward = $journalRepos->find((int)$inwardId);
|
||||
$outward = $journalRepos->find((int)$outwardId);
|
||||
if (null === $inward) {
|
||||
$inward = $existing->source;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class FixFrontpageAccounts extends Command
|
||||
/** @var string $accountId */
|
||||
foreach ($data as $accountId) {
|
||||
$accountIdInt = (int)$accountId;
|
||||
$account = $repository->findNull($accountIdInt);
|
||||
$account = $repository->find($accountIdInt);
|
||||
if (null !== $account
|
||||
&& in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)
|
||||
&& true === $account->active) {
|
||||
|
@ -213,7 +213,7 @@ class ApplyRules extends Command
|
||||
$accountRepository->setUser($this->getUser());
|
||||
foreach ($accountList as $accountId) {
|
||||
$accountId = (int)$accountId;
|
||||
$account = $accountRepository->findNull($accountId);
|
||||
$account = $accountRepository->find($accountId);
|
||||
if (null !== $account && in_array($account->accountType->type, $this->acceptedAccounts, true)) {
|
||||
$finalList->push($account);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ trait VerifiesAccessToken
|
||||
$userId = (int)$this->option('user');
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->findNull($userId);
|
||||
$user = $repository->find($userId);
|
||||
if (null === $user) {
|
||||
throw new FireflyException('User is unexpectedly NULL');
|
||||
}
|
||||
@ -75,7 +75,7 @@ trait VerifiesAccessToken
|
||||
$token = (string)$this->option('token');
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->findNull($userId);
|
||||
$user = $repository->find($userId);
|
||||
|
||||
if (null === $user) {
|
||||
Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId));
|
||||
|
@ -49,7 +49,7 @@ class APIEventHandler
|
||||
{
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->findNull((int)$event->userId);
|
||||
$user = $repository->find((int)$event->userId);
|
||||
if (null !== $user) {
|
||||
$email = $user->email;
|
||||
|
||||
|
@ -55,7 +55,7 @@ class AutomationHandler
|
||||
Log::debug('In reportJournals.');
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->findNull($event->userId);
|
||||
$user = $repository->find($event->userId);
|
||||
if (null !== $user && 0 !== $event->groups->count()) {
|
||||
|
||||
$email = $user->email;
|
||||
|
@ -119,7 +119,7 @@ class NetWorth implements NetWorthInterface
|
||||
// loop results and add currency information:
|
||||
foreach ($netWorth as $currencyId => $balance) {
|
||||
$result[] = [
|
||||
'currency' => $this->currencyRepos->findNull($currencyId),
|
||||
'currency' => $this->currencyRepos->find($currencyId),
|
||||
'balance' => $balance,
|
||||
];
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class DeleteController extends Controller
|
||||
$type = $account->accountType->type;
|
||||
$typeName = config(sprintf('firefly.shortNamesByFullName.%s', $type));
|
||||
$name = $account->name;
|
||||
$moveTo = $this->repository->findNull((int)$request->get('move_account_before_delete'));
|
||||
$moveTo = $this->repository->find((int)$request->get('move_account_before_delete'));
|
||||
|
||||
$this->repository->destroy($account, $moveTo);
|
||||
|
||||
|
@ -130,7 +130,7 @@ class LinkController extends Controller
|
||||
{
|
||||
Log::channel('audit')->info(sprintf('User destroyed link type #%d', $linkType->id));
|
||||
$name = $linkType->name;
|
||||
$moveTo = $this->repository->findNull((int)$request->get('move_link_type_before_delete'));
|
||||
$moveTo = $this->repository->find((int)$request->get('move_link_type_before_delete'));
|
||||
$this->repository->destroy($linkType, $moveTo);
|
||||
|
||||
$request->session()->flash('success', (string)trans('firefly.deleted_link_type', ['name' => $name]));
|
||||
|
@ -131,7 +131,7 @@ class BudgetLimitController extends Controller
|
||||
Log::debug('Going to store new budget-limit.', $request->all());
|
||||
// first search for existing one and update it if necessary.
|
||||
$currency = $this->currencyRepos->find((int)$request->get('transaction_currency_id'));
|
||||
$budget = $this->repository->findNull((int)$request->get('budget_id'));
|
||||
$budget = $this->repository->find((int)$request->get('budget_id'));
|
||||
if (null === $currency || null === $budget) {
|
||||
throw new FireflyException('No valid currency or budget.');
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ class IndexController extends Controller
|
||||
|
||||
foreach ($budgetIds as $index => $budgetId) {
|
||||
$budgetId = (int)$budgetId;
|
||||
$budget = $repository->findNull($budgetId);
|
||||
$budget = $repository->find($budgetId);
|
||||
if (null !== $budget) {
|
||||
Log::debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1));
|
||||
$repository->setBudgetOrder($budget, $index + 1);
|
||||
|
@ -123,7 +123,7 @@ class AccountController extends Controller
|
||||
// grab the difference and find the currency.
|
||||
$startAmount = $startBalances[$accountId][$currencyId] ?? '0';
|
||||
$diff = bcsub($endAmount, $startAmount);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->findNull($currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
||||
if (0 !== bccomp($diff, '0')) {
|
||||
// store the values in a temporary array.
|
||||
$tempData[] = [
|
||||
@ -568,7 +568,7 @@ class AccountController extends Controller
|
||||
// grab the difference and find the currency.
|
||||
$startAmount = $startBalances[$accountId][$currencyId] ?? '0';
|
||||
$diff = bcsub($endAmount, $startAmount);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->findNull($currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);
|
||||
if (0 !== bccomp($diff, '0')) {
|
||||
// store the values in a temporary array.
|
||||
$tempData[] = [
|
||||
|
@ -78,13 +78,13 @@ class BillController extends Controller
|
||||
$unpaid = $repository->getBillsUnpaidInRangePerCurrency($start, $end); // will be a positive amount.
|
||||
|
||||
foreach ($paid as $currencyId => $amount) {
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->findNull($currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->find($currencyId);
|
||||
$label = (string)trans('firefly.paid_in_currency', ['currency' => $currencies[$currencyId]->name]);
|
||||
$chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol,
|
||||
'currency_code' => $currencies[$currencyId]->code];
|
||||
}
|
||||
foreach ($unpaid as $currencyId => $amount) {
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->findNull($currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->find($currencyId);
|
||||
$label = (string)trans('firefly.unpaid_in_currency', ['currency' => $currencies[$currencyId]->name]);
|
||||
$chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol,
|
||||
'currency_code' => $currencies[$currencyId]->code];
|
||||
|
@ -131,7 +131,7 @@ class JavascriptController extends Controller
|
||||
*/
|
||||
public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response
|
||||
{
|
||||
$account = $repository->findNull((int) $request->get('account'));
|
||||
$account = $repository->find((int) $request->get('account'));
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
if(null !== $account) {
|
||||
$currency = $repository->getAccountCurrency($account) ?? $currency;
|
||||
|
@ -184,7 +184,7 @@ class BoxController extends Controller
|
||||
// format amounts:
|
||||
$keys = array_keys($sums);
|
||||
foreach ($keys as $currencyId) {
|
||||
$currency = $repository->findNull($currencyId);
|
||||
$currency = $repository->find($currencyId);
|
||||
$sums[$currencyId] = app('amount')->formatAnything($currency, $sums[$currencyId], false);
|
||||
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
|
||||
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
|
||||
|
@ -98,7 +98,7 @@ class NewUserController extends Controller
|
||||
// set language preference:
|
||||
app('preferences')->set('language', $language);
|
||||
// Store currency preference from input:
|
||||
$currency = $currencyRepository->findNull((int) $request->input('amount_currency_id_bank_balance'));
|
||||
$currency = $currencyRepository->find((int) $request->input('amount_currency_id_bank_balance'));
|
||||
|
||||
// if is null, set to EUR:
|
||||
if (null === $currency) {
|
||||
|
@ -208,7 +208,7 @@ class TagController extends Controller
|
||||
$count = 0;
|
||||
foreach ($tags as $tagId) {
|
||||
$tagId = (int)$tagId;
|
||||
$tag = $this->repository->findNull($tagId);
|
||||
$tag = $this->repository->find($tagId);
|
||||
if (null !== $tag) {
|
||||
$this->repository->destroy($tag);
|
||||
$count++;
|
||||
|
@ -104,7 +104,7 @@ class BulkController extends Controller
|
||||
|
||||
foreach ($journalIds as $journalId) {
|
||||
$journalId = (int)$journalId;
|
||||
$journal = $this->repository->findNull($journalId);
|
||||
$journal = $this->repository->find($journalId);
|
||||
if (null !== $journal) {
|
||||
$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));
|
||||
$resultB = $this->updateJournalTags($journal, $tagsAction, explode(',', $request->string('tags')));
|
||||
|
@ -123,7 +123,7 @@ class LinkController extends Controller
|
||||
$linkInfo = $request->getLinkInfo();
|
||||
|
||||
Log::debug('We are here (store)');
|
||||
$other = $this->journalRepository->findNull($linkInfo['transaction_journal_id']);
|
||||
$other = $this->journalRepository->find($linkInfo['transaction_journal_id']);
|
||||
if (null === $other) {
|
||||
session()->flash('error', (string)trans('firefly.invalid_link_selection'));
|
||||
|
||||
|
@ -103,7 +103,7 @@ class MassController extends Controller
|
||||
foreach ($ids as $journalId) {
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->repository->findNull((int)$journalId);
|
||||
$journal = $this->repository->find((int)$journalId);
|
||||
if (null !== $journal && (int)$journalId === $journal->id) {
|
||||
$this->repository->destroyJournal($journal);
|
||||
++$count;
|
||||
@ -197,7 +197,7 @@ class MassController extends Controller
|
||||
*/
|
||||
private function updateJournal(int $journalId, MassEditJournalRequest $request): void
|
||||
{
|
||||
$journal = $this->repository->findNull($journalId);
|
||||
$journal = $this->repository->find($journalId);
|
||||
if (null === $journal) {
|
||||
throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId));
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class ReportFormRequest extends FormRequest
|
||||
$collection = new Collection;
|
||||
if (is_array($set)) {
|
||||
foreach ($set as $accountId) {
|
||||
$account = $repository->findNull((int)$accountId);
|
||||
$account = $repository->find((int)$accountId);
|
||||
if (null !== $account) {
|
||||
$collection->push($account);
|
||||
}
|
||||
@ -78,7 +78,7 @@ class ReportFormRequest extends FormRequest
|
||||
$collection = new Collection;
|
||||
if (is_array($set)) {
|
||||
foreach ($set as $budgetId) {
|
||||
$budget = $repository->findNull((int)$budgetId);
|
||||
$budget = $repository->find((int)$budgetId);
|
||||
if (null !== $budget) {
|
||||
$collection->push($budget);
|
||||
}
|
||||
@ -101,7 +101,7 @@ class ReportFormRequest extends FormRequest
|
||||
$collection = new Collection;
|
||||
if (is_array($set)) {
|
||||
foreach ($set as $categoryId) {
|
||||
$category = $repository->findNull((int)$categoryId);
|
||||
$category = $repository->find((int)$categoryId);
|
||||
if (null !== $category) {
|
||||
$collection->push($category);
|
||||
}
|
||||
@ -124,7 +124,7 @@ class ReportFormRequest extends FormRequest
|
||||
$collection = new Collection;
|
||||
if (is_array($set)) {
|
||||
foreach ($set as $accountId) {
|
||||
$account = $repository->findNull((int)$accountId);
|
||||
$account = $repository->find((int)$accountId);
|
||||
if (null !== $account) {
|
||||
$collection->push($account);
|
||||
}
|
||||
@ -209,7 +209,7 @@ class ReportFormRequest extends FormRequest
|
||||
$collection->push($tag);
|
||||
continue;
|
||||
}
|
||||
$tag = $repository->findNull((int)$tagTag);
|
||||
$tag = $repository->find((int)$tagTag);
|
||||
if (null !== $tag) {
|
||||
$collection->push($tag);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
static function (Client $oauthClient) {
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $repository->findNull((int)$oauthClient->user_id);
|
||||
$user = $repository->find((int)$oauthClient->user_id);
|
||||
if (null === $user) {
|
||||
Log::info('OAuth client generated but no user associated.');
|
||||
|
||||
|
@ -130,17 +130,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// See reference nr. 9
|
||||
|
||||
$accounts = $query->get(['accounts.*']);
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
if ($account->iban === $iban) {
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $query->where('iban', $iban)->first(['accounts.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,7 +151,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
$accounts = $query->get(['accounts.*']);
|
||||
|
||||
// See reference nr. 10
|
||||
// See reference nr. 10
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
@ -181,7 +171,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
public function findNull(int $accountId): ?Account
|
||||
public function find(int $accountId): ?Account
|
||||
{
|
||||
return $this->user->accounts()->find($accountId);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ interface AccountRepositoryInterface
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
public function findNull(int $accountId): ?Account;
|
||||
public function find(int $accountId): ?Account;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
|
@ -207,7 +207,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
$sourceId = (int)$journal['destination_account_id'];
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$key = sprintf('%s-%s', $sourceId, $currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId);
|
||||
$report['accounts'][$key] = $report['accounts'][$key] ?? [
|
||||
'id' => $sourceId,
|
||||
'name' => $journal['destination_account_name'],
|
||||
@ -269,7 +269,7 @@ class AccountTasker implements AccountTaskerInterface
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$key = sprintf('%s-%s', $sourceId, $currencyId);
|
||||
if (!array_key_exists($key, $report['accounts'])) {
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId);
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId);
|
||||
$report['accounts'][$key] = [
|
||||
'id' => $sourceId,
|
||||
'name' => $journal['source_account_name'],
|
||||
|
@ -146,18 +146,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
*/
|
||||
public function findByName(string $name): ?Bill
|
||||
{
|
||||
$bills = $this->user->bills()->get(['bills.*']);
|
||||
|
||||
// See reference nr. 6
|
||||
|
||||
/** @var Bill $bill */
|
||||
foreach ($bills as $bill) {
|
||||
if ($bill->name === $name) {
|
||||
return $bill;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->user->bills()->where('name', $name)->first(['bills.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -505,6 +494,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
$currentStart = clone $nextExpectedMatch;
|
||||
}
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
@ -641,7 +631,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
$cache->addProperty('nextDateMatch');
|
||||
$cache->addProperty($date);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
return $cache->get();
|
||||
}
|
||||
// find the most recent date for this bill NOT in the future. Cache this date:
|
||||
$start = clone $bill->date;
|
||||
@ -669,7 +659,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
$cache->addProperty('nextExpectedMatch');
|
||||
$cache->addProperty($date);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
return $cache->get();
|
||||
}
|
||||
// find the most recent date for this bill NOT in the future. Cache this date:
|
||||
$start = clone $bill->date;
|
||||
|
@ -127,7 +127,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
{
|
||||
Log::debug('Now in findBudget()');
|
||||
Log::debug(sprintf('Searching for budget with ID #%d...', $budgetId));
|
||||
$result = $this->findNull((int)$budgetId);
|
||||
$result = $this->find((int)$budgetId);
|
||||
if (null === $result && null !== $budgetName && '' !== $budgetName) {
|
||||
Log::debug(sprintf('Searching for budget with name %s...', $budgetName));
|
||||
$result = $this->findByName((string)$budgetName);
|
||||
@ -164,12 +164,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function findNull(int $budgetId = null): ?Budget
|
||||
public function find(int $budgetId = null): ?Budget
|
||||
{
|
||||
if (null === $budgetId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->user->budgets()->find($budgetId);
|
||||
}
|
||||
|
||||
@ -348,7 +344,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currency = null;
|
||||
if (array_key_exists('currency_id', $data)) {
|
||||
$currency = $repos->findNull((int)$data['currency_id']);
|
||||
$currency = $repos->find((int)$data['currency_id']);
|
||||
}
|
||||
if (array_key_exists('currency_code', $data)) {
|
||||
$currency = $repos->findByCode((string)$data['currency_code']);
|
||||
@ -454,7 +450,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
$currencyId = (int)($data['currency_id'] ?? 0);
|
||||
$currencyCode = (string)($data['currency_code'] ?? '');
|
||||
$currency = $repos->findNull($currencyId);
|
||||
$currency = $repos->find($currencyId);
|
||||
if (null === $currency) {
|
||||
$currency = $repos->findByCodeNull($currencyCode);
|
||||
}
|
||||
|
@ -74,13 +74,12 @@ interface BudgetRepositoryInterface
|
||||
public function findByName(?string $name): ?Budget;
|
||||
|
||||
/**
|
||||
* See reference nr. 12
|
||||
*
|
||||
* @param int|null $budgetId
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
public function findNull(int $budgetId = null): ?Budget;
|
||||
public function find(int $budgetId = null): ?Budget;
|
||||
|
||||
/**
|
||||
* This method returns the oldest journal or transaction date known to this budget.
|
||||
|
@ -87,17 +87,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*/
|
||||
public function findByName(string $name): ?Category
|
||||
{
|
||||
$categories = $this->user->categories()->get(['categories.*']);
|
||||
|
||||
// See reference nr. 7
|
||||
|
||||
foreach ($categories as $category) {
|
||||
if ($category->name === $name) {
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->user->categories()->where('name', $name)->first(['categories.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,7 +101,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
{
|
||||
Log::debug('Now in findCategory()');
|
||||
Log::debug(sprintf('Searching for category with ID #%d...', $categoryId));
|
||||
$result = $this->findNull((int)$categoryId);
|
||||
$result = $this->find((int)$categoryId);
|
||||
if (null === $result) {
|
||||
Log::debug(sprintf('Searching for category with name %s...', $categoryName));
|
||||
$result = $this->findByName((string)$categoryName);
|
||||
@ -135,7 +125,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*
|
||||
* @return Category|null
|
||||
*/
|
||||
public function findNull(int $categoryId): ?Category
|
||||
public function find(int $categoryId): ?Category
|
||||
{
|
||||
return $this->user->categories()->find($categoryId);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @return Category|null
|
||||
*/
|
||||
public function findNull(int $categoryId): ?Category;
|
||||
public function find(int $categoryId): ?Category;
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
|
@ -38,7 +38,6 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\CurrencyDestroyService;
|
||||
use FireflyIII\Services\Internal\Update\CurrencyUpdateService;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
@ -346,20 +345,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find by ID, return NULL if not found.
|
||||
* Used in Import Currency!
|
||||
*
|
||||
* @param int $currencyId
|
||||
*
|
||||
* @return TransactionCurrency|null
|
||||
* @deprecated
|
||||
*/
|
||||
public function findNull(int $currencyId): ?TransactionCurrency
|
||||
{
|
||||
return TransactionCurrency::find($currencyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
|
@ -163,15 +163,6 @@ interface CurrencyRepositoryInterface
|
||||
*/
|
||||
public function findCurrencyNull(?int $currencyId, ?string $currencyCode): ?TransactionCurrency;
|
||||
|
||||
/**
|
||||
* Find by ID, return NULL if not found.
|
||||
*
|
||||
* @param int $currencyId
|
||||
*
|
||||
* @return TransactionCurrency|null
|
||||
*/
|
||||
public function findNull(int $currencyId): ?TransactionCurrency;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
|
@ -87,9 +87,9 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
*/
|
||||
public function findNull(int $journalId): ?TransactionJournal
|
||||
public function find(int $journalId): ?TransactionJournal
|
||||
{
|
||||
return $this->user->transactionJournals()->where('id', $journalId)->first();
|
||||
return $this->user->transactionJournals()->find($journalId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,62 +123,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $transaction->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all destination accounts related to journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param bool $useCache
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournalDestinationAccounts(TransactionJournal $journal, bool $useCache = true): Collection
|
||||
{
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('destination-account-list');
|
||||
if ($useCache && $cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$transactions = $journal->transactions()->where('amount', '>', 0)->orderBy('transactions.account_id')->with('account')->get();
|
||||
$list = new Collection;
|
||||
/** @var Transaction $t */
|
||||
foreach ($transactions as $t) {
|
||||
$list->push($t->account);
|
||||
}
|
||||
$list = $list->unique('id');
|
||||
$cache->store($list);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all source accounts related to journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
* @param bool $useCache
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getJournalSourceAccounts(TransactionJournal $journal, bool $useCache = true): Collection
|
||||
{
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('source-account-list');
|
||||
if ($useCache && $cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$transactions = $journal->transactions()->where('amount', '<', 0)->orderBy('transactions.account_id')->with('account')->get();
|
||||
$list = new Collection;
|
||||
/** @var Transaction $t */
|
||||
foreach ($transactions as $t) {
|
||||
$list->push($t->account);
|
||||
}
|
||||
$list = $list->unique('id');
|
||||
$cache->store($list);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return total amount of journal. Is always positive.
|
||||
*
|
||||
|
@ -58,14 +58,14 @@ interface JournalRepositoryInterface
|
||||
public function findByType(array $types): Collection;
|
||||
|
||||
/**
|
||||
* See reference nr. 1
|
||||
* See reference nr. 1
|
||||
* Find a specific journal.
|
||||
*
|
||||
* @param int $journalId
|
||||
*
|
||||
* @return TransactionJournal|null
|
||||
*/
|
||||
public function findNull(int $journalId): ?TransactionJournal;
|
||||
public function find(int $journalId): ?TransactionJournal;
|
||||
|
||||
/**
|
||||
* Get users very first transaction journal.
|
||||
@ -84,28 +84,6 @@ interface JournalRepositoryInterface
|
||||
*/
|
||||
public function getDestinationAccount(TransactionJournal $journal): Account;
|
||||
|
||||
/**
|
||||
* See reference nr. 2
|
||||
* Return a list of all destination accounts related to journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
* @deprecated
|
||||
*/
|
||||
public function getJournalDestinationAccounts(TransactionJournal $journal): Collection;
|
||||
|
||||
/**
|
||||
* See reference nr. 3
|
||||
* Return a list of all source accounts related to journal.
|
||||
*
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Collection
|
||||
* @deprecated
|
||||
*/
|
||||
public function getJournalSourceAccounts(TransactionJournal $journal): Collection;
|
||||
|
||||
/**
|
||||
* Return total amount of journal. Is always positive.
|
||||
*
|
||||
@ -121,7 +99,7 @@ interface JournalRepositoryInterface
|
||||
public function getLast(): ?TransactionJournal;
|
||||
|
||||
/**
|
||||
* See reference nr. 4
|
||||
* See reference nr. 4
|
||||
*
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
@ -150,7 +128,7 @@ interface JournalRepositoryInterface
|
||||
public function getSourceAccount(TransactionJournal $journal): Account;
|
||||
|
||||
/**
|
||||
* See reference nr. 5
|
||||
* See reference nr. 5
|
||||
*
|
||||
* @param int $journalId
|
||||
*/
|
||||
|
@ -118,7 +118,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
*
|
||||
* @return LinkType|null
|
||||
*/
|
||||
public function findNull(int $linkTypeId): ?LinkType
|
||||
public function find(int $linkTypeId): ?LinkType
|
||||
{
|
||||
return LinkType::find($linkTypeId);
|
||||
}
|
||||
@ -247,7 +247,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
*/
|
||||
public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink
|
||||
{
|
||||
$linkType = $this->findNull((int)($information['link_type_id'] ?? 0));
|
||||
$linkType = $this->find((int)($information['link_type_id'] ?? 0));
|
||||
|
||||
if (null === $linkType) {
|
||||
$linkType = $this->findByName($information['link_type_name']);
|
||||
|
@ -79,7 +79,7 @@ interface LinkTypeRepositoryInterface
|
||||
*
|
||||
* @return LinkType|null
|
||||
*/
|
||||
public function findNull(int $linkTypeId): ?LinkType;
|
||||
public function find(int $linkTypeId): ?LinkType;
|
||||
|
||||
/**
|
||||
* See if such a link already exists (and get it).
|
||||
|
@ -71,14 +71,9 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
*
|
||||
* @return PiggyBank|null
|
||||
*/
|
||||
public function findNull(int $piggyBankId): ?PiggyBank
|
||||
public function find(int $piggyBankId): ?PiggyBank
|
||||
{
|
||||
$piggyBank = $this->user->piggyBanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
|
||||
if (null !== $piggyBank) {
|
||||
return $piggyBank;
|
||||
}
|
||||
|
||||
return null;
|
||||
$piggyBank = $this->user->piggyBanks()->find($piggyBankId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,7 +87,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
Log::debug('Searching for piggy information.');
|
||||
|
||||
if (null !== $piggyBankId) {
|
||||
$searchResult = $this->findNull((int)$piggyBankId);
|
||||
$searchResult = $this->find((int)$piggyBankId);
|
||||
if (null !== $searchResult) {
|
||||
Log::debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId));
|
||||
|
||||
|
@ -115,7 +115,7 @@ interface PiggyBankRepositoryInterface
|
||||
*
|
||||
* @return PiggyBank|null
|
||||
*/
|
||||
public function findNull(int $piggyBankId): ?PiggyBank;
|
||||
public function find(int $piggyBankId): ?PiggyBank;
|
||||
|
||||
/**
|
||||
* @param int|null $piggyBankId
|
||||
|
@ -105,12 +105,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
*/
|
||||
public function find(int $ruleId): ?Rule
|
||||
{
|
||||
$rule = $this->user->rules()->find($ruleId);
|
||||
if (null === $rule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $rule;
|
||||
return $this->user->rules()->find($ruleId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,12 +119,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
*/
|
||||
public function find(int $ruleGroupId): ?RuleGroup
|
||||
{
|
||||
$group = $this->user->ruleGroups()->find($ruleGroupId);
|
||||
if (null === $group) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $group;
|
||||
return $this->user->ruleGroups()->find($ruleGroupId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +113,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
*
|
||||
* @return Tag|null
|
||||
*/
|
||||
public function findNull(int $tagId): ?Tag
|
||||
public function find(int $tagId): ?Tag
|
||||
{
|
||||
return $this->user->tags()->find($tagId);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ interface TagRepositoryInterface
|
||||
*
|
||||
* @return Tag|null
|
||||
*/
|
||||
public function findNull(int $tagId): ?Tag;
|
||||
public function find(int $tagId): ?Tag;
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
|
@ -87,7 +87,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
*/
|
||||
public function find(int $groupId): ?TransactionGroup
|
||||
{
|
||||
return $this->user->transactionGroups()->where('id', $groupId)->first();
|
||||
return $this->user->transactionGroups()->find($groupId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,7 +183,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
*
|
||||
* @return User|null
|
||||
*/
|
||||
public function findNull(int $userId): ?User
|
||||
public function find(int $userId): ?User
|
||||
{
|
||||
return User::find($userId);
|
||||
}
|
||||
@ -269,8 +269,6 @@ class UserRepository implements UserRepositoryInterface
|
||||
*/
|
||||
public function hasRole(User $user, string $role): bool
|
||||
{
|
||||
// See reference nr. 8
|
||||
|
||||
/** @var Role $userRole */
|
||||
foreach ($user->roles as $userRole) {
|
||||
if ($userRole->name === $role) {
|
||||
|
@ -114,7 +114,7 @@ interface UserRepositoryInterface
|
||||
*
|
||||
* @return User|null
|
||||
*/
|
||||
public function findNull(int $userId): ?User;
|
||||
public function find(int $userId): ?User;
|
||||
|
||||
/**
|
||||
* Returns the first user in the DB. Generally only works when there is just one.
|
||||
|
@ -131,7 +131,7 @@ class IsValidAttachmentModel implements Rule
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository->setUser(auth()->user());
|
||||
|
||||
return null !== $repository->findNull($value);
|
||||
return null !== $repository->find($value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,7 +159,7 @@ class IsValidAttachmentModel implements Rule
|
||||
$repository = app(BudgetRepositoryInterface::class);
|
||||
$repository->setUser(auth()->user());
|
||||
|
||||
return null !== $repository->findNull($value);
|
||||
return null !== $repository->find($value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,7 +173,7 @@ class IsValidAttachmentModel implements Rule
|
||||
$repository = app(CategoryRepositoryInterface::class);
|
||||
$repository->setUser(auth()->user());
|
||||
|
||||
return null !== $repository->findNull($value);
|
||||
return null !== $repository->find($value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,7 +186,7 @@ class IsValidAttachmentModel implements Rule
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
$repository->setUser(auth()->user());
|
||||
|
||||
return null !== $repository->findNull($value);
|
||||
return null !== $repository->find($value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,7 +200,7 @@ class IsValidAttachmentModel implements Rule
|
||||
$repository = app(PiggyBankRepositoryInterface::class);
|
||||
$repository->setUser(auth()->user());
|
||||
|
||||
return null !== $repository->findNull($value);
|
||||
return null !== $repository->find($value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,7 +214,7 @@ class IsValidAttachmentModel implements Rule
|
||||
$repository = app(TagRepositoryInterface::class);
|
||||
$repository->setUser(auth()->user());
|
||||
|
||||
return null !== $repository->findNull($value);
|
||||
return null !== $repository->find($value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,7 +96,7 @@ trait JournalServiceTrait
|
||||
$search = null;
|
||||
// first attempt, find by ID.
|
||||
if (null !== $data['id']) {
|
||||
$search = $this->accountRepository->findNull((int) $data['id']);
|
||||
$search = $this->accountRepository->find((int) $data['id']);
|
||||
if (null !== $search && in_array($search->accountType->type, $types, true)) {
|
||||
Log::debug(
|
||||
sprintf('Found "account_id" object: #%d, "%s" of type %s', $search->id, $search->name, $search->accountType->type)
|
||||
|
@ -196,7 +196,7 @@ trait RecurringTransactionTrait
|
||||
$repository->setUser($this->user);
|
||||
|
||||
// if user has submitted an account ID, search for it.
|
||||
$result = $repository->findNull((int)$accountId);
|
||||
$result = $repository->find((int)$accountId);
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class TagOrId implements BinderInterface
|
||||
|
||||
$result = $repository->findByTag($value);
|
||||
if (null === $result) {
|
||||
$result = $repository->findNull((int)$value);
|
||||
$result = $repository->find((int)$value);
|
||||
}
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
|
@ -74,7 +74,7 @@ trait ChartGeneration
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
// See reference nr. 33
|
||||
$currency = $repository->findNull((int)$accountRepos->getMetaValue($account, 'currency_id'));
|
||||
$currency = $repository->find((int)$accountRepos->getMetaValue($account, 'currency_id'));
|
||||
if (null === $currency) {
|
||||
$currency = $default;
|
||||
}
|
||||
|
@ -59,10 +59,10 @@ trait RenderPartialViews
|
||||
|
||||
/** @var BudgetRepositoryInterface $budgetRepository */
|
||||
$budgetRepository = app(BudgetRepositoryInterface::class);
|
||||
$budget = $budgetRepository->findNull((int)$attributes['budgetId']);
|
||||
$budget = $budgetRepository->find((int)$attributes['budgetId']);
|
||||
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
$account = $accountRepos->findNull((int)$attributes['accountId']);
|
||||
$account = $accountRepos->find((int)$attributes['accountId']);
|
||||
|
||||
$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);
|
||||
|
||||
@ -110,7 +110,7 @@ trait RenderPartialViews
|
||||
/** @var PopupReportInterface $popupHelper */
|
||||
$popupHelper = app(PopupReportInterface::class);
|
||||
|
||||
$budget = $budgetRepository->findNull((int)$attributes['budgetId']);
|
||||
$budget = $budgetRepository->find((int)$attributes['budgetId']);
|
||||
if (null === $budget) {
|
||||
$budget = new Budget;
|
||||
}
|
||||
@ -139,7 +139,7 @@ trait RenderPartialViews
|
||||
|
||||
/** @var CategoryRepositoryInterface $categoryRepository */
|
||||
$categoryRepository = app(CategoryRepositoryInterface::class);
|
||||
$category = $categoryRepository->findNull((int)$attributes['categoryId']);
|
||||
$category = $categoryRepository->find((int)$attributes['categoryId']);
|
||||
$journals = $popupHelper->byCategory($category, $attributes);
|
||||
|
||||
try {
|
||||
@ -227,7 +227,7 @@ trait RenderPartialViews
|
||||
/** @var PopupReportInterface $popupHelper */
|
||||
$popupHelper = app(PopupReportInterface::class);
|
||||
|
||||
$account = $accountRepository->findNull((int)$attributes['accountId']);
|
||||
$account = $accountRepository->find((int)$attributes['accountId']);
|
||||
|
||||
if (null === $account) {
|
||||
return 'This is an unknown account. Apologies.';
|
||||
@ -348,7 +348,7 @@ trait RenderPartialViews
|
||||
|
||||
/** @var PopupReportInterface $popupHelper */
|
||||
$popupHelper = app(PopupReportInterface::class);
|
||||
$account = $accountRepository->findNull((int)$attributes['accountId']);
|
||||
$account = $accountRepository->find((int)$attributes['accountId']);
|
||||
|
||||
if (null === $account) {
|
||||
return 'This is an unknown category. Apologies.';
|
||||
|
@ -334,7 +334,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
$this->searchAccount($value, 1, 3);
|
||||
break;
|
||||
case 'source_account_id':
|
||||
$account = $this->accountRepository->findNull((int)$value);
|
||||
$account = $this->accountRepository->find((int)$value);
|
||||
if (null !== $account) {
|
||||
$this->collector->setSourceAccounts(new Collection([$account]));
|
||||
}
|
||||
@ -372,7 +372,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
$this->searchAccount($value, 2, 3);
|
||||
break;
|
||||
case 'destination_account_id':
|
||||
$account = $this->accountRepository->findNull((int)$value);
|
||||
$account = $this->accountRepository->find((int)$value);
|
||||
if (null !== $account) {
|
||||
$this->collector->setDestinationAccounts(new Collection([$account]));
|
||||
}
|
||||
@ -381,7 +381,7 @@ class OperatorQuerySearch implements SearchInterface
|
||||
$parts = explode(',', $value);
|
||||
$collection = new Collection;
|
||||
foreach ($parts as $accountId) {
|
||||
$account = $this->accountRepository->findNull((int)$accountId);
|
||||
$account = $this->accountRepository->find((int)$accountId);
|
||||
if (null !== $account) {
|
||||
$collection->push($account);
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ class SearchRuleEngine implements RuleEngineInterface
|
||||
if (0 !== $journalId) {
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
$repository->setUser($this->user);
|
||||
$journal = $repository->findNull($journalId);
|
||||
$journal = $repository->find($journalId);
|
||||
if (null !== $journal) {
|
||||
$date = $journal->date;
|
||||
Log::debug(sprintf('Found journal #%d with date %s.', $journal->id, $journal->date->format('Y-m-d')));
|
||||
|
@ -263,7 +263,7 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$array['tags'] = json_decode($transactionMeta->value);
|
||||
break;
|
||||
case 'piggy_bank_id':
|
||||
$piggy = $this->piggyRepos->findNull((int)$transactionMeta->value);
|
||||
$piggy = $this->piggyRepos->find((int)$transactionMeta->value);
|
||||
if (null !== $piggy) {
|
||||
$array['piggy_bank_id'] = (string)$piggy->id;
|
||||
$array['piggy_bank_name'] = $piggy->name;
|
||||
@ -284,7 +284,7 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
}
|
||||
break;
|
||||
case 'budget_id':
|
||||
$budget = $this->budgetRepos->findNull((int)$transactionMeta->value);
|
||||
$budget = $this->budgetRepos->find((int)$transactionMeta->value);
|
||||
if (null !== $budget) {
|
||||
$array['budget_id'] = (string)$budget->id;
|
||||
$array['budget_name'] = $budget->name;
|
||||
|
@ -117,7 +117,7 @@ trait DepositValidation
|
||||
// if the user submits an ID only but that ID is not of the correct type,
|
||||
// return false.
|
||||
if (null !== $accountId && null === $accountName) {
|
||||
$search = $this->accountRepository->findNull($accountId);
|
||||
$search = $this->accountRepository->find($accountId);
|
||||
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
|
||||
Log::debug(sprintf('User submitted only an ID (#%d), which is a "%s", so this is not a valid source.', $accountId, $search->accountType->type));
|
||||
$result = false;
|
||||
|
@ -75,7 +75,7 @@ trait LiabilityValidation
|
||||
}
|
||||
|
||||
Log::debug('Destination ID is not null.');
|
||||
$search = $this->accountRepository->findNull($accountId);
|
||||
$search = $this->accountRepository->find($accountId);
|
||||
|
||||
// the source resulted in an account, but it's not of a valid type.
|
||||
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
|
||||
|
@ -115,7 +115,7 @@ trait OBValidation
|
||||
// return false.
|
||||
if (null !== $accountId && null === $accountName) {
|
||||
Log::debug('Source ID is not null, but name is null.');
|
||||
$search = $this->accountRepository->findNull($accountId);
|
||||
$search = $this->accountRepository->find($accountId);
|
||||
|
||||
// the source resulted in an account, but it's not of a valid type.
|
||||
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
|
||||
|
@ -46,7 +46,7 @@ trait ReconciliationValidation
|
||||
|
||||
return false;
|
||||
}
|
||||
$result = $this->accountRepository->findNull($accountId);
|
||||
$result = $this->accountRepository->find($accountId);
|
||||
if (null === $result) {
|
||||
$this->destError = (string)trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => '']);
|
||||
Log::debug('Return FALSE');
|
||||
@ -92,7 +92,7 @@ trait ReconciliationValidation
|
||||
|
||||
return false;
|
||||
}
|
||||
$result = $this->accountRepository->findNull($accountId);
|
||||
$result = $this->accountRepository->find($accountId);
|
||||
$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, AccountType::RECONCILIATION];
|
||||
if (null === $result) {
|
||||
Log::debug('Return FALSE');
|
||||
|
@ -87,7 +87,7 @@ trait WithdrawalValidation
|
||||
|
||||
// if there's an ID it must be of the "validTypes".
|
||||
if (null !== $accountId && 0 !== $accountId) {
|
||||
$found = $this->accountRepository->findNull($accountId);
|
||||
$found = $this->accountRepository->find($accountId);
|
||||
if (null !== $found) {
|
||||
$type = $found->accountType->type;
|
||||
if (in_array($type, $validTypes, true)) {
|
||||
|
@ -228,7 +228,7 @@ class AccountValidator
|
||||
{
|
||||
// find by ID
|
||||
if ($accountId > 0) {
|
||||
$first = $this->accountRepository->findNull($accountId);
|
||||
$first = $this->accountRepository->find($accountId);
|
||||
if ((null !== $first) && in_array($first->accountType->type, $validTypes, true)) {
|
||||
return $first;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user