mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Fix phpstan issues.
This commit is contained in:
@@ -25,6 +25,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\System;
|
||||
|
||||
use function Safe\file_put_contents;
|
||||
use function Safe\json_encode;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Command\Command as CommandAlias;
|
||||
|
@@ -78,8 +78,8 @@ class ScansAttachments extends Command
|
||||
}
|
||||
$tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
|
||||
file_put_contents($tempFileName, $decryptedContent);
|
||||
$attachment->md5 = (string)md5_file($tempFileName);
|
||||
$attachment->mime = (string)mime_content_type($tempFileName);
|
||||
$attachment->md5 = md5_file($tempFileName);
|
||||
$attachment->mime = mime_content_type($tempFileName);
|
||||
$attachment->save();
|
||||
$this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id));
|
||||
}
|
||||
|
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* DestroyedTransactionLink.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\Models\TransactionJournalLink;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class DestroyedTransactionLink
|
||||
*/
|
||||
class DestroyedTransactionLink extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
// @phpstan-ignore-line
|
||||
|
||||
/**
|
||||
* DestroyedTransactionLink constructor.
|
||||
*/
|
||||
public function __construct(private TransactionJournalLink $link) {}
|
||||
}
|
@@ -282,7 +282,7 @@ class PiggyBankFactory
|
||||
|
||||
// create event:
|
||||
Log::debug('linkToAccountIds: Trigger change for positive amount [b].');
|
||||
event(new ChangedAmount($piggyBank, $toBeLinked[$account->id]['current_amount'], null, null));
|
||||
event(new ChangedAmount($piggyBank, $toBeLinked[$account->id]['current_amount'] ?? '0', null, null));
|
||||
}
|
||||
if (!array_key_exists('current_amount', $info)) {
|
||||
$toBeLinked[$account->id] ??= [];
|
||||
|
@@ -184,6 +184,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
|
||||
if ($model instanceof Budget) {
|
||||
$enrichment = new BudgetEnrichment();
|
||||
$enrichment->setUser($model->user);
|
||||
/** @var Budget $model */
|
||||
$model = $enrichment->enrichSingle($model);
|
||||
$transformer = new BudgetTransformer();
|
||||
$basicMessage['content'] = $transformer->transform($model);
|
||||
@@ -196,7 +197,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
|
||||
$parameters = new ParameterBag();
|
||||
$parameters->set('start', $model->start_date);
|
||||
$parameters->set('end', $model->end_date);
|
||||
|
||||
/** @var BudgetLimit $model */
|
||||
$model = $enrichment->enrichSingle($model);
|
||||
$transformer = new BudgetLimitTransformer();
|
||||
$transformer->setParameters($parameters);
|
||||
@@ -295,7 +296,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
|
||||
$this->webhooks = $webhooks;
|
||||
}
|
||||
|
||||
private function getRelevantResponse(array $triggers, WebhookResponseModel $response, $class): string
|
||||
private function getRelevantResponse(array $triggers, WebhookResponseModel $response, string $class): string
|
||||
{
|
||||
// return none if none.
|
||||
if (WebhookResponse::NONE->name === $response->title) {
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Handlers\Events;
|
||||
|
||||
use function Safe\json_encode;
|
||||
use Exception;
|
||||
use FireflyIII\Events\Model\Bill\WarnUserAboutBill;
|
||||
use FireflyIII\Events\Model\Bill\WarnUserAboutOverdueSubscriptions;
|
||||
|
@@ -35,6 +35,8 @@ use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Safe\Exceptions\FileinfoException;
|
||||
use Safe\Exceptions\FilesystemException;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
|
||||
use function Safe\tmpfile;
|
||||
@@ -126,9 +128,10 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
public function saveAttachmentFromApi(Attachment $attachment, string $content): bool
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$resource = tmpfile();
|
||||
if (false === $resource) {
|
||||
Log::error('Cannot create temp-file for file upload.');
|
||||
try {
|
||||
$resource = tmpfile();
|
||||
} catch (FilesystemException $e) {
|
||||
Log::error(sprintf('Cannot create temp-file for file upload: %s', $e->getMessage()));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -141,17 +144,18 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
|
||||
$path = stream_get_meta_data($resource)['uri'];
|
||||
Log::debug(sprintf('Path is %s', $path));
|
||||
$result = fwrite($resource, $content);
|
||||
if (false === $result) {
|
||||
Log::error('Could not write temp file.');
|
||||
try {
|
||||
$result = fwrite($resource, $content);
|
||||
} catch (FilesystemException $e) {
|
||||
Log::error(sprintf('Could not write to temp file: %s', $e->getMessage()));
|
||||
|
||||
return false;
|
||||
}
|
||||
Log::debug(sprintf('Wrote %d bytes to temp file.', $result));
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
if (false === $finfo) {
|
||||
Log::error('Could not open finfo.');
|
||||
fclose($resource);
|
||||
try {
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
} catch (FileinfoException $e) {
|
||||
Log::error(sprintf('Could not open finfo handler: %s', $e->getMessage()));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -171,7 +175,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
$this->uploadDisk->put($file, $content);
|
||||
|
||||
// update attachment.
|
||||
$attachment->md5 = (string) md5_file($path);
|
||||
$attachment->md5 = md5_file($path);
|
||||
$attachment->mime = $mime;
|
||||
$attachment->size = strlen($content);
|
||||
$attachment->uploaded = true;
|
||||
@@ -233,7 +237,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
$attachment = new Attachment(); // create Attachment object.
|
||||
$attachment->user()->associate($user);
|
||||
$attachment->attachable()->associate($model);
|
||||
$attachment->md5 = (string) md5_file($file->getRealPath());
|
||||
$attachment->md5 = md5_file($file->getRealPath());
|
||||
$attachment->filename = $file->getClientOriginalName();
|
||||
$attachment->mime = $file->getMimeType();
|
||||
$attachment->size = $file->getSize();
|
||||
|
@@ -199,7 +199,7 @@ trait MetaCollection
|
||||
|
||||
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -220,7 +220,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdContains(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -232,7 +232,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -244,7 +244,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -256,7 +256,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -268,7 +268,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdEnds(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -280,7 +280,7 @@ trait MetaCollection
|
||||
|
||||
public function externalIdStarts(string $externalId): GroupCollectorInterface
|
||||
{
|
||||
$externalId = (string) json_encode($externalId);
|
||||
$externalId = json_encode($externalId);
|
||||
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -293,7 +293,7 @@ trait MetaCollection
|
||||
public function externalUrlContains(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) json_encode($url);
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', trim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url));
|
||||
@@ -304,7 +304,7 @@ trait MetaCollection
|
||||
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) json_encode($url);
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', trim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $url));
|
||||
@@ -315,7 +315,7 @@ trait MetaCollection
|
||||
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) json_encode($url);
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s', $url));
|
||||
@@ -326,7 +326,7 @@ trait MetaCollection
|
||||
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) json_encode($url);
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||
// var_dump($url);
|
||||
|
||||
@@ -339,7 +339,7 @@ trait MetaCollection
|
||||
public function externalUrlEnds(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) json_encode($url);
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
|
||||
$this->query->where('journal_meta.name', '=', 'external_url');
|
||||
$this->query->whereLike('journal_meta.data', sprintf('%%%s', $url));
|
||||
@@ -350,7 +350,7 @@ trait MetaCollection
|
||||
public function externalUrlStarts(string $url): GroupCollectorInterface
|
||||
{
|
||||
$this->joinMetaDataTables();
|
||||
$url = (string) json_encode($url);
|
||||
$url = json_encode($url);
|
||||
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
|
||||
// var_dump($url);
|
||||
|
||||
@@ -401,7 +401,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceContains(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
// var_dump($internalReference);
|
||||
// exit;
|
||||
@@ -416,7 +416,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -429,7 +429,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -442,7 +442,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -455,7 +455,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -468,7 +468,7 @@ trait MetaCollection
|
||||
|
||||
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
@@ -724,7 +724,7 @@ trait MetaCollection
|
||||
|
||||
public function setInternalReference(string $internalReference): GroupCollectorInterface
|
||||
{
|
||||
$internalReference = (string) json_encode($internalReference);
|
||||
$internalReference = json_encode($internalReference);
|
||||
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
|
||||
|
||||
$this->joinMetaDataTables();
|
||||
|
@@ -51,7 +51,7 @@ class NetWorth implements NetWorthInterface
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private CurrencyRepositoryInterface $currencyRepos;
|
||||
private User $user; // @phpstan-ignore-line
|
||||
private ?UserGroup $userGroup = null; // @phpstan-ignore-line
|
||||
private ?UserGroup $userGroup = null;
|
||||
|
||||
/**
|
||||
* This method collects the user's net worth in ALL the user's currencies
|
||||
|
@@ -34,6 +34,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
|
||||
use Safe\Exceptions\UrlException;
|
||||
use function Safe\parse_url;
|
||||
|
||||
/**
|
||||
@@ -103,8 +104,12 @@ class ForgotPasswordController extends Controller
|
||||
*/
|
||||
private function validateHost(): void
|
||||
{
|
||||
$configuredHost = parse_url((string) config('app.url'), PHP_URL_HOST);
|
||||
if (false === $configuredHost || null === $configuredHost) {
|
||||
try {
|
||||
$configuredHost = parse_url((string)config('app.url'), PHP_URL_HOST);
|
||||
} catch (UrlException $e) {
|
||||
throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.',0, $e);
|
||||
}
|
||||
if (!is_string( $configuredHost)) {
|
||||
throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.');
|
||||
}
|
||||
$host = request()->host();
|
||||
|
@@ -249,8 +249,8 @@ class LoginController extends Controller
|
||||
$allowReset = false;
|
||||
}
|
||||
|
||||
$email = $request?->old('email');
|
||||
$remember = $request?->old('remember');
|
||||
$email = $request->old('email');
|
||||
$remember = $request->old('remember');
|
||||
|
||||
$storeInCookie = config('google2fa.store_in_cookie', false);
|
||||
if (false !== $storeInCookie) {
|
||||
|
@@ -330,6 +330,7 @@ class AccountController extends Controller
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
|
||||
$field = 'amount';
|
||||
if (!array_key_exists($key, $result)) {
|
||||
|
||||
// currency info:
|
||||
@@ -338,7 +339,6 @@ class AccountController extends Controller
|
||||
$currencySymbol = $journal['currency_symbol'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
||||
$field = 'amount';
|
||||
if ($this->convertToPrimary && $this->primaryCurrency->id !== $currencyId) {
|
||||
$field = 'pc_amount';
|
||||
$currencyName = $this->primaryCurrency->name;
|
||||
@@ -437,6 +437,7 @@ class AccountController extends Controller
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
|
||||
$field = 'amount';
|
||||
if (!array_key_exists($key, $result)) {
|
||||
|
||||
// currency info:
|
||||
@@ -445,7 +446,6 @@ class AccountController extends Controller
|
||||
$currencySymbol = $journal['currency_symbol'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
||||
$field = 'amount';
|
||||
if ($this->convertToPrimary && $this->primaryCurrency->id !== $currencyId) {
|
||||
$field = 'pc_amount';
|
||||
$currencyName = $this->primaryCurrency->name;
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\LinkType;
|
||||
|
||||
use FireflyIII\Events\DestroyedTransactionLink;
|
||||
use Exception;
|
||||
use FireflyIII\Models\LinkType;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -31,7 +31,6 @@ use FireflyIII\Models\TransactionJournalLink;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
|
||||
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
|
||||
use Illuminate\Support\Collection;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class LinkTypeRepository.
|
||||
@@ -57,13 +56,13 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
|
||||
|
||||
public function update(LinkType $linkType, array $data): LinkType
|
||||
{
|
||||
if (array_key_exists('name', $data) && '' !== (string) $data['name']) {
|
||||
if (array_key_exists('name', $data) && '' !== (string)$data['name']) {
|
||||
$linkType->name = $data['name'];
|
||||
}
|
||||
if (array_key_exists('inward', $data) && '' !== (string) $data['inward']) {
|
||||
if (array_key_exists('inward', $data) && '' !== (string)$data['inward']) {
|
||||
$linkType->inward = $data['inward'];
|
||||
}
|
||||
if (array_key_exists('outward', $data) && '' !== (string) $data['outward']) {
|
||||
if (array_key_exists('outward', $data) && '' !== (string)$data['outward']) {
|
||||
$linkType->outward = $data['outward'];
|
||||
}
|
||||
$linkType->save();
|
||||
@@ -76,7 +75,6 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
|
||||
*/
|
||||
public function destroyLink(TransactionJournalLink $link): bool
|
||||
{
|
||||
event(new DestroyedTransactionLink($link));
|
||||
$link->delete();
|
||||
|
||||
return true;
|
||||
@@ -117,13 +115,12 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
|
||||
public function getJournalLinks(?LinkType $linkType = null): Collection
|
||||
{
|
||||
$query = TransactionJournalLink::with(['source', 'destination'])
|
||||
->leftJoin('transaction_journals as source_journals', 'journal_links.source_id', '=', 'source_journals.id')
|
||||
->leftJoin('transaction_journals as dest_journals', 'journal_links.destination_id', '=', 'dest_journals.id')
|
||||
->where('source_journals.user_id', $this->user->id)
|
||||
->where('dest_journals.user_id', $this->user->id)
|
||||
->whereNull('source_journals.deleted_at')
|
||||
->whereNull('dest_journals.deleted_at')
|
||||
;
|
||||
->leftJoin('transaction_journals as source_journals', 'journal_links.source_id', '=', 'source_journals.id')
|
||||
->leftJoin('transaction_journals as dest_journals', 'journal_links.destination_id', '=', 'dest_journals.id')
|
||||
->where('source_journals.user_id', $this->user->id)
|
||||
->where('dest_journals.user_id', $this->user->id)
|
||||
->whereNull('source_journals.deleted_at')
|
||||
->whereNull('dest_journals.deleted_at');
|
||||
|
||||
if ($linkType instanceof LinkType) {
|
||||
$query->where('journal_links.link_type_id', $linkType->id);
|
||||
@@ -152,7 +149,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
|
||||
$merged = $outward->merge($inward);
|
||||
|
||||
return $merged->filter(
|
||||
static fn (TransactionJournalLink $link) => null !== $link->source && null !== $link->destination
|
||||
static fn(TransactionJournalLink $link) => null !== $link->source && null !== $link->destination
|
||||
);
|
||||
}
|
||||
|
||||
@@ -175,7 +172,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
|
||||
*/
|
||||
public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink
|
||||
{
|
||||
$linkType = $this->find((int) ($information['link_type_id'] ?? 0));
|
||||
$linkType = $this->find((int)($information['link_type_id'] ?? 0));
|
||||
|
||||
if (!$linkType instanceof LinkType) {
|
||||
$linkType = $this->findByName($information['link_type_name']);
|
||||
@@ -191,7 +188,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$link = new TransactionJournalLink();
|
||||
$link = new TransactionJournalLink();
|
||||
$link->linkType()->associate($linkType);
|
||||
if ('inward' === $information['direction']) {
|
||||
app('log')->debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->inward, $inward->id, $outward->id));
|
||||
@@ -207,7 +204,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
|
||||
$link->save();
|
||||
|
||||
// make note in noteable:
|
||||
$this->setNoteText($link, (string) $information['notes']);
|
||||
$this->setNoteText($link, (string)$information['notes']);
|
||||
|
||||
return $link;
|
||||
}
|
||||
@@ -232,9 +229,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
|
||||
public function findSpecificLink(LinkType $linkType, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink
|
||||
{
|
||||
return TransactionJournalLink::where('link_type_id', $linkType->id)
|
||||
->where('source_id', $inward->id)
|
||||
->where('destination_id', $outward->id)->first()
|
||||
;
|
||||
->where('source_id', $inward->id)
|
||||
->where('destination_id', $outward->id)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,7 +292,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
|
||||
$journalLink->refresh();
|
||||
}
|
||||
|
||||
$journalLink->link_type_id = $data['link_type_id'] ?? $journalLink->link_type_id;
|
||||
$journalLink->link_type_id = $data['link_type_id'] ?? $journalLink->link_type_id;
|
||||
$journalLink->save();
|
||||
if (array_key_exists('notes', $data) && null !== $data['notes']) {
|
||||
$this->setNoteText($journalLink, $data['notes']);
|
||||
|
@@ -25,9 +25,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\JsonApi\Enrichments;
|
||||
|
||||
use function Safe\json_decode;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\RecurrenceRepetitionWeekend;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\CategoryFactory;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -42,7 +42,6 @@ use FireflyIII\Models\RecurrenceRepetition;
|
||||
use FireflyIII\Models\RecurrenceTransaction;
|
||||
use FireflyIII\Models\RecurrenceTransactionMeta;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
@@ -73,7 +72,7 @@ class RecurringEnrichment implements EnrichmentInterface
|
||||
private array $accounts = [];
|
||||
private array $currencies = [];
|
||||
private array $recurrenceIds = [];
|
||||
private TransactionCurrency $primaryCurrency;
|
||||
private readonly TransactionCurrency $primaryCurrency;
|
||||
private bool $convertToPrimary = false;
|
||||
|
||||
public function __construct()
|
||||
@@ -147,9 +146,7 @@ class RecurringEnrichment implements EnrichmentInterface
|
||||
|
||||
/** @var RecurrenceRepetition $repetition */
|
||||
foreach ($set as $repetition) {
|
||||
$recurrence = $this->collection->filter(function (Recurrence $item) use ($repetition) {
|
||||
return (int)$item->id === (int)$repetition->recurrence_id;
|
||||
})->first();
|
||||
$recurrence = $this->collection->filter(fn(Recurrence $item) => (int)$item->id === (int)$repetition->recurrence_id)->first();
|
||||
$fromDate = clone ($recurrence->latest_date ?? $recurrence->first_date);
|
||||
$id = (int)$repetition->recurrence_id;
|
||||
$repId = (int)$repetition->id;
|
||||
|
@@ -27,7 +27,6 @@ namespace Tests\integration\Api\Autocomplete;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\integration\TestCase;
|
||||
use FireflyIII\User;
|
||||
|
||||
/**
|
||||
* Class CurrencyControllerTest
|
||||
|
@@ -39,6 +39,7 @@ final class AccountControllerTest extends TestCase
|
||||
private $user;
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@@ -39,6 +39,7 @@ final class BalanceControllerTest extends TestCase
|
||||
private $user;
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@@ -39,6 +39,7 @@ final class BudgetControllerTest extends TestCase
|
||||
private $user;
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@@ -39,6 +39,7 @@ final class CategoryControllerTest extends TestCase
|
||||
private $user;
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
Reference in New Issue
Block a user