mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-13 07:53:16 +00:00
Remove a lot of deprecated code.
This commit is contained in:
@@ -65,7 +65,7 @@ class DecryptAttachment extends Command
|
|||||||
$attachment = $repository->findWithoutUser($attachmentId);
|
$attachment = $repository->findWithoutUser($attachmentId);
|
||||||
$attachmentName = trim($this->argument('name'));
|
$attachmentName = trim($this->argument('name'));
|
||||||
$storagePath = realpath(trim($this->argument('directory')));
|
$storagePath = realpath(trim($this->argument('directory')));
|
||||||
if (null === $attachment->id) {
|
if (null === $attachment) {
|
||||||
$this->error(sprintf('No attachment with id #%d', $attachmentId));
|
$this->error(sprintf('No attachment with id #%d', $attachmentId));
|
||||||
Log::error(sprintf('DecryptAttachment: No attachment with id #%d', $attachmentId));
|
Log::error(sprintf('DecryptAttachment: No attachment with id #%d', $attachmentId));
|
||||||
|
|
||||||
|
@@ -262,7 +262,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
|
|
||||||
// store it:
|
// store it:
|
||||||
$this->uploadDisk->put($attachment->fileName(), $encrypted);
|
$this->uploadDisk->put($attachment->fileName(), $encrypted);
|
||||||
$attachment->uploaded = 1; // update attachment
|
$attachment->uploaded = true; // update attachment
|
||||||
$attachment->save();
|
$attachment->save();
|
||||||
$this->attachments->push($attachment);
|
$this->attachments->push($attachment);
|
||||||
|
|
||||||
|
@@ -196,7 +196,7 @@ class TagController extends Controller
|
|||||||
// prep for "all" view.
|
// prep for "all" view.
|
||||||
if ('all' === $moment) {
|
if ('all' === $moment) {
|
||||||
$subTitle = (string)trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
$subTitle = (string)trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
||||||
$start = $this->repository->firstUseDate($tag);
|
$start = $this->repository->firstUseDate($tag) ?? new Carbon;
|
||||||
$end = new Carbon;
|
$end = new Carbon;
|
||||||
$path = route('tags.show', [$tag->id, 'all']);
|
$path = route('tags.show', [$tag->id, 'all']);
|
||||||
}
|
}
|
||||||
@@ -311,8 +311,8 @@ class TagController extends Controller
|
|||||||
// get first and last tag date from tag:
|
// get first and last tag date from tag:
|
||||||
$range = app('preferences')->get('viewRange', '1M')->data;
|
$range = app('preferences')->get('viewRange', '1M')->data;
|
||||||
/** @var Carbon $end */
|
/** @var Carbon $end */
|
||||||
$end = app('navigation')->endOfX($this->repository->lastUseDate($tag), $range, null);
|
$end = app('navigation')->endOfX($this->repository->lastUseDate($tag) ?? new Carbon, $range, null);
|
||||||
$start = $this->repository->firstUseDate($tag);
|
$start = $this->repository->firstUseDate($tag) ?? new Carbon;
|
||||||
|
|
||||||
|
|
||||||
// properties for entries with their amounts.
|
// properties for entries with their amounts.
|
||||||
|
@@ -211,7 +211,7 @@ class ReportFormRequest extends Request
|
|||||||
if (\is_array($set)) {
|
if (\is_array($set)) {
|
||||||
foreach ($set as $tagTag) {
|
foreach ($set as $tagTag) {
|
||||||
$tag = $repository->findByTag($tagTag);
|
$tag = $repository->findByTag($tagTag);
|
||||||
if (null !== $tag->id) {
|
if (null !== $tag) {
|
||||||
$collection->push($tag);
|
$collection->push($tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,8 +22,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Import\Specifics;
|
namespace FireflyIII\Import\Specifics;
|
||||||
|
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RabobankDescription.
|
* Class RabobankDescription.
|
||||||
*
|
*
|
||||||
@@ -66,25 +64,6 @@ class RabobankDescription implements SpecificInterface
|
|||||||
public function run(array $row): array
|
public function run(array $row): array
|
||||||
{
|
{
|
||||||
$row = array_values($row);
|
$row = array_values($row);
|
||||||
Log::debug(sprintf('Now in RabobankSpecific::run(). Row has %d columns', \count($row)));
|
|
||||||
$oppositeAccount = isset($row[5]) ? trim($row[5]) : '';
|
|
||||||
$oppositeName = isset($row[6]) ? trim($row[6]) : '';
|
|
||||||
$alternateName = isset($row[10]) ? trim($row[10]) : '';
|
|
||||||
|
|
||||||
if ('' === $oppositeAccount && '' === $oppositeName) {
|
|
||||||
Log::debug(
|
|
||||||
sprintf(
|
|
||||||
'Rabobank specific: Opposite account and opposite name are' .
|
|
||||||
' both empty. Will use "%s" (from description) instead',
|
|
||||||
$alternateName
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$row[6] = $alternateName;
|
|
||||||
$row[10] = '';
|
|
||||||
}
|
|
||||||
if (!('' === $oppositeAccount && '' === $oppositeName)) {
|
|
||||||
Log::debug('Rabobank specific: either opposite account or name are filled.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TransactionJournal.
|
* Class TransactionJournal.
|
||||||
@@ -62,7 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||||||
*/
|
*/
|
||||||
class TransactionJournal extends Model
|
class TransactionJournal extends Model
|
||||||
{
|
{
|
||||||
use SoftDeletes, TransactionJournalTrait;
|
use SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be casted to native types.
|
* The attributes that should be casted to native types.
|
||||||
@@ -264,6 +266,27 @@ class TransactionJournal extends Model
|
|||||||
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
|
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $query
|
||||||
|
* @param string $table
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isJoined(Builder $query, string $table): bool
|
||||||
|
{
|
||||||
|
$joins = $query->getQuery()->joins;
|
||||||
|
if (null === $joins) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach ($joins as $join) {
|
||||||
|
if ($join->table === $table) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
|
@@ -81,18 +81,12 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $attachmentId
|
* @param int $attachmentId
|
||||||
* @deprecated
|
* @return Attachment|null
|
||||||
* @return Attachment
|
|
||||||
*/
|
*/
|
||||||
public function findWithoutUser(int $attachmentId): Attachment
|
public function findWithoutUser(int $attachmentId): ?Attachment
|
||||||
{
|
{
|
||||||
|
|
||||||
$attachment = Attachment::find($attachmentId);
|
return Attachment::find($attachmentId);
|
||||||
if (null === $attachment) {
|
|
||||||
return new Attachment;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $attachment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -50,10 +50,9 @@ interface AttachmentRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $attachmentId
|
* @param int $attachmentId
|
||||||
* @deprecated
|
* @return Attachment|null
|
||||||
* @return Attachment
|
|
||||||
*/
|
*/
|
||||||
public function findWithoutUser(int $attachmentId): Attachment;
|
public function findWithoutUser(int $attachmentId): ?Attachment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection
|
* @return Collection
|
||||||
|
@@ -921,8 +921,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
// or create one and return it.
|
// or create one and return it.
|
||||||
$limit = new BudgetLimit;
|
$limit = new BudgetLimit;
|
||||||
$limit->budget()->associate($budget);
|
$limit->budget()->associate($budget);
|
||||||
$limit->start_date = $start->format('Y-m-d 00:00:00');
|
$limit->start_date = $start->startOfDay();
|
||||||
$limit->end_date = $end->format('Y-m-d 00:00:00');
|
$limit->end_date = $end->startOfDay();
|
||||||
$limit->amount = $amount;
|
$limit->amount = $amount;
|
||||||
$limit->save();
|
$limit->save();
|
||||||
Log::debug(sprintf('Created new budget limit with ID #%d and amount %s', $limit->id, $amount));
|
Log::debug(sprintf('Created new budget limit with ID #%d and amount %s', $limit->id, $amount));
|
||||||
|
@@ -80,10 +80,9 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ExportJob
|
* @return ExportJob|null
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
public function create(): ExportJob
|
public function create(): ?ExportJob
|
||||||
{
|
{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while ($count < 30) {
|
while ($count < 30) {
|
||||||
@@ -103,7 +102,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
|||||||
++$count;
|
++$count;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ExportJob;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -44,10 +44,9 @@ interface ExportJobRepositoryInterface
|
|||||||
public function cleanup(): bool;
|
public function cleanup(): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ExportJob
|
* @return ExportJob|null
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
public function create(): ExportJob;
|
public function create(): ?ExportJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ExportJob $job
|
* @param ExportJob $job
|
||||||
|
@@ -303,7 +303,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
|
|
||||||
// store it:
|
// store it:
|
||||||
$this->uploadDisk->put($attachment->fileName(), $encrypted);
|
$this->uploadDisk->put($attachment->fileName(), $encrypted);
|
||||||
$attachment->uploaded = 1; // update attachment
|
$attachment->uploaded = true; // update attachment
|
||||||
$attachment->save();
|
$attachment->save();
|
||||||
|
|
||||||
// return it.
|
// return it.
|
||||||
@@ -357,7 +357,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
|
|
||||||
// store it:
|
// store it:
|
||||||
$this->uploadDisk->put($attachment->fileName(), $encrypted);
|
$this->uploadDisk->put($attachment->fileName(), $encrypted);
|
||||||
$attachment->uploaded = 1; // update attachment
|
$attachment->uploaded = true; // update attachment
|
||||||
$attachment->save();
|
$attachment->save();
|
||||||
|
|
||||||
// return it.
|
// return it.
|
||||||
|
@@ -29,7 +29,6 @@ use FireflyIII\Factory\TransactionJournalFactory;
|
|||||||
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Note;
|
|
||||||
use FireflyIII\Models\PiggyBankEvent;
|
use FireflyIII\Models\PiggyBankEvent;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
@@ -59,6 +58,8 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
* @param Account $destination
|
* @param Account $destination
|
||||||
*
|
*
|
||||||
* @return MessageBag
|
* @return MessageBag
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function convert(TransactionJournal $journal, TransactionType $type, Account $source, Account $destination): MessageBag
|
public function convert(TransactionJournal $journal, TransactionType $type, Account $source, Account $destination): MessageBag
|
||||||
{
|
{
|
||||||
@@ -73,9 +74,9 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
$srcTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||||
$destinationTransaction = $journal->transactions()->where('amount', '>', 0)->first();
|
$dstTransaction = $journal->transactions()->where('amount', '>', 0)->first();
|
||||||
if (null === $sourceTransaction || null === $destinationTransaction) {
|
if (null === $srcTransaction || null === $dstTransaction) {
|
||||||
// default message bag that shows errors for everything.
|
// default message bag that shows errors for everything.
|
||||||
|
|
||||||
$messages = new MessageBag;
|
$messages = new MessageBag;
|
||||||
@@ -86,15 +87,18 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
|
|
||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
$sourceTransaction->account_id = $source->id;
|
// update transactions, and update journal:
|
||||||
$sourceTransaction->save();
|
|
||||||
$destinationTransaction->account_id = $destination->id;
|
$srcTransaction->account_id = $source->id;
|
||||||
$destinationTransaction->save();
|
$dstTransaction->account_id = $destination->id;
|
||||||
$journal->transaction_type_id = $type->id;
|
$journal->transaction_type_id = $type->id;
|
||||||
|
$dstTransaction->save();
|
||||||
|
$srcTransaction->save();
|
||||||
$journal->save();
|
$journal->save();
|
||||||
|
|
||||||
// if journal is a transfer now, remove budget:
|
// if journal is a transfer now, remove budget:
|
||||||
if (TransactionType::TRANSFER === $type->type) {
|
if (TransactionType::TRANSFER === $type->type) {
|
||||||
|
|
||||||
$journal->budgets()->detach();
|
$journal->budgets()->detach();
|
||||||
// also from transactions:
|
// also from transactions:
|
||||||
foreach ($journal->transactions as $transaction) {
|
foreach ($journal->transactions as $transaction) {
|
||||||
|
@@ -340,6 +340,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
|||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
*/
|
*/
|
||||||
public function getSuggestedMonthlyAmount(PiggyBank $piggyBank): string
|
public function getSuggestedMonthlyAmount(PiggyBank $piggyBank): string
|
||||||
{
|
{
|
||||||
|
@@ -80,29 +80,12 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
return (string)$set->sum('transaction_amount');
|
return (string)$set->sum('transaction_amount');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $tagId
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
* @return Tag
|
|
||||||
*/
|
|
||||||
public function find(int $tagId): Tag
|
|
||||||
{
|
|
||||||
$tag = $this->user->tags()->find($tagId);
|
|
||||||
if (null === $tag) {
|
|
||||||
$tag = new Tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
*
|
*
|
||||||
* @return Tag
|
* @return Tag|null
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
public function findByTag(string $tag): Tag
|
public function findByTag(string $tag): ?Tag
|
||||||
{
|
{
|
||||||
$tags = $this->user->tags()->get();
|
$tags = $this->user->tags()->get();
|
||||||
/** @var Tag $databaseTag */
|
/** @var Tag $databaseTag */
|
||||||
@@ -112,7 +95,7 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Tag;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,17 +111,16 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Tag $tag
|
* @param Tag $tag
|
||||||
*
|
*
|
||||||
* @return Carbon
|
* @return Carbon|null
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
public function firstUseDate(Tag $tag): Carbon
|
public function firstUseDate(Tag $tag): ?Carbon
|
||||||
{
|
{
|
||||||
$journal = $tag->transactionJournals()->orderBy('date', 'ASC')->first();
|
$journal = $tag->transactionJournals()->orderBy('date', 'ASC')->first();
|
||||||
if (null !== $journal) {
|
if (null !== $journal) {
|
||||||
return $journal->date;
|
return $journal->date;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Carbon;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,17 +142,16 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Tag $tag
|
* @param Tag $tag
|
||||||
*
|
*
|
||||||
* @return Carbon
|
* @return Carbon|null
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
public function lastUseDate(Tag $tag): Carbon
|
public function lastUseDate(Tag $tag): ?Carbon
|
||||||
{
|
{
|
||||||
$journal = $tag->transactionJournals()->orderBy('date', 'DESC')->first();
|
$journal = $tag->transactionJournals()->orderBy('date', 'DESC')->first();
|
||||||
if (null !== $journal) {
|
if (null !== $journal) {
|
||||||
return $journal->date;
|
return $journal->date;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Carbon;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -55,21 +55,12 @@ interface TagRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function earnedInPeriod(Tag $tag, Carbon $start, Carbon $end): string;
|
public function earnedInPeriod(Tag $tag, Carbon $start, Carbon $end): string;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $tagId
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
* @return Tag
|
|
||||||
*/
|
|
||||||
public function find(int $tagId): Tag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
*
|
*
|
||||||
* @return Tag
|
* @return Tag|null
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
public function findByTag(string $tag): Tag;
|
public function findByTag(string $tag):?Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $tagId
|
* @param int $tagId
|
||||||
@@ -82,9 +73,8 @@ interface TagRepositoryInterface
|
|||||||
* @param Tag $tag
|
* @param Tag $tag
|
||||||
*
|
*
|
||||||
* @return Carbon
|
* @return Carbon
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
public function firstUseDate(Tag $tag): Carbon;
|
public function firstUseDate(Tag $tag): ?Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns all the user's tags.
|
* This method returns all the user's tags.
|
||||||
@@ -96,10 +86,9 @@ interface TagRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @param Tag $tag
|
* @param Tag $tag
|
||||||
*
|
*
|
||||||
* @return Carbon
|
* @return Carbon|null
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
public function lastUseDate(Tag $tag): Carbon;
|
public function lastUseDate(Tag $tag): ?Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will return the newest tag (if known) or NULL.
|
* Will return the newest tag (if known) or NULL.
|
||||||
|
@@ -162,22 +162,6 @@ class UserRepository implements UserRepositoryInterface
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $userId
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
* @return User
|
|
||||||
*/
|
|
||||||
public function find(int $userId): User
|
|
||||||
{
|
|
||||||
$user = User::find($userId);
|
|
||||||
if (null !== $user) {
|
|
||||||
return $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new User;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $email
|
* @param string $email
|
||||||
*
|
*
|
||||||
|
@@ -101,14 +101,6 @@ interface UserRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function destroy(User $user): bool;
|
public function destroy(User $user): bool;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $userId
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
* @return User
|
|
||||||
*/
|
|
||||||
public function find(int $userId): User;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $email
|
* @param string $email
|
||||||
*
|
*
|
||||||
|
@@ -1,213 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* BunqInformation.php
|
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Information;
|
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Services\Bunq\Object\Alias;
|
|
||||||
use FireflyIII\Services\Bunq\Object\MonetaryAccountBank;
|
|
||||||
use FireflyIII\Services\Bunq\Request\DeleteDeviceSessionRequest;
|
|
||||||
use FireflyIII\Services\Bunq\Request\DeviceSessionRequest;
|
|
||||||
use FireflyIII\Services\Bunq\Request\ListMonetaryAccountRequest;
|
|
||||||
use FireflyIII\Services\Bunq\Request\ListUserRequest;
|
|
||||||
use FireflyIII\Services\Bunq\Token\SessionToken;
|
|
||||||
use FireflyIII\Support\CacheProperties;
|
|
||||||
use FireflyIII\User;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* @deprecated
|
|
||||||
* Class BunqInformation.
|
|
||||||
*/
|
|
||||||
class BunqInformation implements InformationInterface
|
|
||||||
{
|
|
||||||
/** @var User */
|
|
||||||
private $user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a collection of accounts. Preferrably, these follow a uniform Firefly III format so they can be managed over banks.
|
|
||||||
*
|
|
||||||
* The format for these bank accounts is basically this:
|
|
||||||
*
|
|
||||||
* id: bank specific id
|
|
||||||
* name: bank appointed name
|
|
||||||
* number: account number (usually IBAN)
|
|
||||||
* currency: ISO code of currency
|
|
||||||
* balance: current balance
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* any other fields are optional but can be useful:
|
|
||||||
* image: logo or account specific thing
|
|
||||||
* color: any associated color.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function getAccounts(): array
|
|
||||||
{
|
|
||||||
// cache for an hour:
|
|
||||||
$cache = new CacheProperties;
|
|
||||||
$cache->addProperty('bunq.get-accounts');
|
|
||||||
$cache->addProperty(date('dmy h'));
|
|
||||||
if ($cache->has()) {
|
|
||||||
return $cache->get(); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
Log::debug('Now in getAccounts()');
|
|
||||||
$sessionToken = $this->startSession();
|
|
||||||
$userId = $this->getUserInformation($sessionToken);
|
|
||||||
// get list of Bunq accounts:
|
|
||||||
$accounts = $this->getMonetaryAccounts($sessionToken, $userId);
|
|
||||||
$return = [];
|
|
||||||
/** @var MonetaryAccountBank $account */
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
$current = [
|
|
||||||
'id' => $account->getId(),
|
|
||||||
'name' => $account->getDescription(),
|
|
||||||
'currency' => $account->getCurrency(),
|
|
||||||
'balance' => $account->getBalance()->getValue(),
|
|
||||||
'color' => $account->getSetting()->getColor(),
|
|
||||||
];
|
|
||||||
/** @var Alias $alias */
|
|
||||||
foreach ($account->getAliases() as $alias) {
|
|
||||||
if ('IBAN' === $alias->getType()) {
|
|
||||||
$current['number'] = $alias->getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$return[] = $current;
|
|
||||||
}
|
|
||||||
$cache->store($return);
|
|
||||||
|
|
||||||
$this->closeSession($sessionToken);
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the user for this Prerequisites-routine. Class is expected to implement and save this.
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
*/
|
|
||||||
public function setUser(User $user): void
|
|
||||||
{
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SessionToken $sessionToken
|
|
||||||
*
|
|
||||||
|
|
||||||
*/
|
|
||||||
private function closeSession(SessionToken $sessionToken): void
|
|
||||||
{
|
|
||||||
Log::debug('Going to close session');
|
|
||||||
$apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
|
|
||||||
$serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
|
|
||||||
$privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
|
|
||||||
$request = new DeleteDeviceSessionRequest();
|
|
||||||
$request->setSecret($apiKey);
|
|
||||||
$request->setPrivateKey($privateKey);
|
|
||||||
$request->setServerPublicKey($serverPublicKey);
|
|
||||||
$request->setSessionToken($sessionToken);
|
|
||||||
$request->call();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SessionToken $sessionToken
|
|
||||||
* @param int $userId
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
private function getMonetaryAccounts(SessionToken $sessionToken, int $userId): Collection
|
|
||||||
{
|
|
||||||
$apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
|
|
||||||
$serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
|
|
||||||
$privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
|
|
||||||
$request = new ListMonetaryAccountRequest;
|
|
||||||
|
|
||||||
$request->setSessionToken($sessionToken);
|
|
||||||
$request->setSecret($apiKey);
|
|
||||||
$request->setServerPublicKey($serverPublicKey);
|
|
||||||
$request->setPrivateKey($privateKey);
|
|
||||||
$request->setUserId($userId);
|
|
||||||
$request->call();
|
|
||||||
|
|
||||||
return $request->getMonetaryAccounts();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SessionToken $sessionToken
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
private function getUserInformation(SessionToken $sessionToken): int
|
|
||||||
{
|
|
||||||
$apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
|
|
||||||
$serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
|
|
||||||
$privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
|
|
||||||
$request = new ListUserRequest;
|
|
||||||
$request->setSessionToken($sessionToken);
|
|
||||||
$request->setSecret($apiKey);
|
|
||||||
$request->setServerPublicKey($serverPublicKey);
|
|
||||||
$request->setPrivateKey($privateKey);
|
|
||||||
$request->call();
|
|
||||||
// return the first that isn't null?
|
|
||||||
$company = $request->getUserCompany();
|
|
||||||
if ($company->getId() > 0) {
|
|
||||||
return $company->getId();
|
|
||||||
}
|
|
||||||
$user = $request->getUserPerson();
|
|
||||||
if ($user->getId() > 0) {
|
|
||||||
return $user->getId();
|
|
||||||
}
|
|
||||||
throw new FireflyException('Expected user or company from Bunq, but got neither.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return SessionToken
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
private function startSession(): SessionToken
|
|
||||||
{
|
|
||||||
Log::debug('Now in startSession.');
|
|
||||||
$apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
|
|
||||||
$serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
|
|
||||||
$privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
|
|
||||||
$installationToken = app('preferences')->getForUser($this->user, 'bunq_installation_token')->data;
|
|
||||||
$request = new DeviceSessionRequest();
|
|
||||||
$request->setSecret($apiKey);
|
|
||||||
$request->setServerPublicKey($serverPublicKey);
|
|
||||||
$request->setPrivateKey($privateKey);
|
|
||||||
$request->setInstallationToken($installationToken);
|
|
||||||
$request->call();
|
|
||||||
$sessionToken = $request->getSessionToken();
|
|
||||||
Log::debug(sprintf('Now have got session token: %s', serialize($sessionToken)));
|
|
||||||
|
|
||||||
return $sessionToken;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* InformationInterface.php
|
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Information;
|
|
||||||
|
|
||||||
use FireflyIII\User;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Interface InformationInterface.
|
|
||||||
*/
|
|
||||||
interface InformationInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns a collection of accounts. Preferrably, these follow a uniform Firefly III format so they can be managed over banks.
|
|
||||||
*
|
|
||||||
* The format for these bank accounts is basically this:
|
|
||||||
*
|
|
||||||
* id: bank specific id
|
|
||||||
* name: bank appointed name
|
|
||||||
* number: account number (usually IBAN)
|
|
||||||
* currency: ISO code of currency
|
|
||||||
*
|
|
||||||
* any other fields are optional but can be useful:
|
|
||||||
* image: logo or account specific thing
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getAccounts(): array;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the user for this Prerequisites-routine. Class is expected to implement and save this.
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
*/
|
|
||||||
public function setUser(User $user): void;
|
|
||||||
}
|
|
@@ -1,176 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* TransactionJournalTrait.php
|
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace FireflyIII\Support\Models;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionType;
|
|
||||||
use FireflyIII\Support\CacheProperties;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class TransactionJournalTrait.
|
|
||||||
*
|
|
||||||
* @property int $id
|
|
||||||
* @property Carbon $date
|
|
||||||
* @property string $transaction_type_type
|
|
||||||
* @property TransactionType $transactionType
|
|
||||||
*/
|
|
||||||
trait TransactionJournalTrait
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $query
|
|
||||||
* @param string $table
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function isJoined(Builder $query, string $table): bool
|
|
||||||
{
|
|
||||||
$joins = $query->getQuery()->joins;
|
|
||||||
if (null === $joins) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
foreach ($joins as $join) {
|
|
||||||
if ($join->table === $table) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function destinationAccountList(): Collection
|
|
||||||
{
|
|
||||||
$cache = new CacheProperties;
|
|
||||||
$cache->addProperty($this->id);
|
|
||||||
$cache->addProperty('transaction-journal');
|
|
||||||
$cache->addProperty('destination-account-list');
|
|
||||||
if ($cache->has()) {
|
|
||||||
return $cache->get(); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
$transactions = $this->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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function destinationTransactionList(): Collection
|
|
||||||
{
|
|
||||||
$cache = new CacheProperties;
|
|
||||||
$cache->addProperty($this->id);
|
|
||||||
$cache->addProperty('transaction-journal');
|
|
||||||
$cache->addProperty('destination-transaction-list');
|
|
||||||
if ($cache->has()) {
|
|
||||||
return $cache->get(); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
$list = $this->transactions()->where('amount', '>', 0)->with('account')->get();
|
|
||||||
$cache->store($list);
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function sourceAccountList(): Collection
|
|
||||||
{
|
|
||||||
$cache = new CacheProperties;
|
|
||||||
$cache->addProperty($this->id);
|
|
||||||
$cache->addProperty('transaction-journal');
|
|
||||||
$cache->addProperty('source-account-list');
|
|
||||||
if ($cache->has()) {
|
|
||||||
return $cache->get(); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
$transactions = $this->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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function sourceTransactionList(): Collection
|
|
||||||
{
|
|
||||||
$cache = new CacheProperties;
|
|
||||||
$cache->addProperty($this->id);
|
|
||||||
$cache->addProperty('transaction-journal');
|
|
||||||
$cache->addProperty('source-transaction-list');
|
|
||||||
if ($cache->has()) {
|
|
||||||
return $cache->get(); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
$list = $this->transactions()->where('amount', '<', 0)->with('account')->get();
|
|
||||||
$cache->store($list);
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function transactionTypeStr(): string
|
|
||||||
{
|
|
||||||
$cache = new CacheProperties;
|
|
||||||
$cache->addProperty($this->id);
|
|
||||||
$cache->addProperty('transaction-journal');
|
|
||||||
$cache->addProperty('type-string');
|
|
||||||
if ($cache->has()) {
|
|
||||||
return $cache->get(); // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
|
|
||||||
$typeStr = $this->transaction_type_type ?? $this->transactionType->type;
|
|
||||||
$cache->store($typeStr);
|
|
||||||
|
|
||||||
return $typeStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return HasMany
|
|
||||||
*/
|
|
||||||
abstract public function transactions(): HasMany;
|
|
||||||
}
|
|
@@ -26,6 +26,7 @@ use FireflyIII\Models\Account;
|
|||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use FireflyIII\Support\Twig\Extension\TransactionJournal as TransactionJournalExtension;
|
use FireflyIII\Support\Twig\Extension\TransactionJournal as TransactionJournalExtension;
|
||||||
use Twig_Extension;
|
use Twig_Extension;
|
||||||
@@ -53,7 +54,9 @@ class Journal extends Twig_Extension
|
|||||||
return $cache->get(); // @codeCoverageIgnore
|
return $cache->get(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $journal->destinationAccountList();
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
$list = $repository->getJournalDestinationAccounts($journal);
|
||||||
$array = [];
|
$array = [];
|
||||||
/** @var Account $entry */
|
/** @var Account $entry */
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
@@ -119,7 +122,10 @@ class Journal extends Twig_Extension
|
|||||||
return $cache->get(); // @codeCoverageIgnore
|
return $cache->get(); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $journal->sourceAccountList();
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
|
$list = $repository->getJournalSourceAccounts($journal);
|
||||||
$array = [];
|
$array = [];
|
||||||
/** @var Account $entry */
|
/** @var Account $entry */
|
||||||
foreach ($list as $entry) {
|
foreach ($list as $entry) {
|
||||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +74,11 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
|
|||||||
{
|
{
|
||||||
$fromAccountName = '';
|
$fromAccountName = '';
|
||||||
|
|
||||||
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($journal->sourceAccountList() as $account) {
|
foreach ($repository->getJournalSourceAccounts($journal) as $account) {
|
||||||
$fromAccountName .= strtolower($account->name);
|
$fromAccountName .= strtolower($account->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +74,11 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
|
|||||||
{
|
{
|
||||||
$name = '';
|
$name = '';
|
||||||
|
|
||||||
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($journal->sourceAccountList() as $account) {
|
foreach ($repository->getJournalSourceAccounts($journal) as $account) {
|
||||||
$name .= strtolower($account->name);
|
$name .= strtolower($account->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +74,11 @@ final class FromAccountIs extends AbstractTrigger implements TriggerInterface
|
|||||||
{
|
{
|
||||||
$name = '';
|
$name = '';
|
||||||
|
|
||||||
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($journal->sourceAccountList() as $account) {
|
foreach ($repository->getJournalSourceAccounts($journal) as $account) {
|
||||||
$name .= strtolower($account->name);
|
$name .= strtolower($account->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +74,11 @@ final class FromAccountStarts extends AbstractTrigger implements TriggerInterfac
|
|||||||
{
|
{
|
||||||
$name = '';
|
$name = '';
|
||||||
|
|
||||||
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($journal->sourceAccountList() as $account) {
|
foreach ($repository->getJournalSourceAccounts($journal) as $account) {
|
||||||
$name .= strtolower($account->name);
|
$name .= strtolower($account->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +74,11 @@ final class ToAccountContains extends AbstractTrigger implements TriggerInterfac
|
|||||||
{
|
{
|
||||||
$toAccountName = '';
|
$toAccountName = '';
|
||||||
|
|
||||||
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($journal->destinationAccountList() as $account) {
|
foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
|
||||||
$toAccountName .= strtolower($account->name);
|
$toAccountName .= strtolower($account->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +74,11 @@ final class ToAccountEnds extends AbstractTrigger implements TriggerInterface
|
|||||||
{
|
{
|
||||||
$toAccountName = '';
|
$toAccountName = '';
|
||||||
|
|
||||||
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($journal->destinationAccountList() as $account) {
|
foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
|
||||||
$toAccountName .= strtolower($account->name);
|
$toAccountName .= strtolower($account->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +74,11 @@ final class ToAccountIs extends AbstractTrigger implements TriggerInterface
|
|||||||
{
|
{
|
||||||
$toAccountName = '';
|
$toAccountName = '';
|
||||||
|
|
||||||
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($journal->destinationAccountList() as $account) {
|
foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
|
||||||
$toAccountName .= strtolower($account->name);
|
$toAccountName .= strtolower($account->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,8 +74,11 @@ final class ToAccountStarts extends AbstractTrigger implements TriggerInterface
|
|||||||
{
|
{
|
||||||
$toAccountName = '';
|
$toAccountName = '';
|
||||||
|
|
||||||
|
/** @var JournalRepositoryInterface $repository */
|
||||||
|
$repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($journal->destinationAccountList() as $account) {
|
foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
|
||||||
$toAccountName .= strtolower($account->name);
|
$toAccountName .= strtolower($account->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
app/User.php
22
app/User.php
@@ -219,28 +219,6 @@ class User extends Authenticatable
|
|||||||
return (string)bin2hex($bytes);
|
return (string)bin2hex($bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
* Checks if the user has a role by its name.
|
|
||||||
*
|
|
||||||
* Full credit goes to: https://github.com/Zizaco/entrust
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function hasRole(string $name): bool
|
|
||||||
{
|
|
||||||
foreach ($this->roles as $role) {
|
|
||||||
if ($role->name === $name) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
* Link to import jobs.
|
* Link to import jobs.
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\TransactionRules\Triggers;
|
namespace Tests\Unit\TransactionRules\Triggers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\Triggers\FromAccountContains;
|
use FireflyIII\TransactionRules\Triggers\FromAccountContains;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ class FromAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggered(): void
|
public function testTriggered(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while ($count === 0) {
|
while ($count === 0) {
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
@@ -54,6 +56,7 @@ class FromAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredNot(): void
|
public function testTriggeredNot(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
|
|
||||||
$trigger = FromAccountContains::makeFromStrings('some name' . random_int(1, 234), false);
|
$trigger = FromAccountContains::makeFromStrings('some name' . random_int(1, 234), false);
|
||||||
@@ -66,6 +69,7 @@ class FromAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingEmpty(): void
|
public function testWillMatchEverythingEmpty(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = '';
|
$value = '';
|
||||||
$result = FromAccountContains::willMatchEverything($value);
|
$result = FromAccountContains::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
@@ -76,6 +80,7 @@ class FromAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNotNull(): void
|
public function testWillMatchEverythingNotNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = 'x';
|
$value = 'x';
|
||||||
$result = FromAccountContains::willMatchEverything($value);
|
$result = FromAccountContains::willMatchEverything($value);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
@@ -86,6 +91,7 @@ class FromAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNull(): void
|
public function testWillMatchEverythingNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = null;
|
$value = null;
|
||||||
$result = FromAccountContains::willMatchEverything($value);
|
$result = FromAccountContains::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\TransactionRules\Triggers;
|
namespace Tests\Unit\TransactionRules\Triggers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\Triggers\FromAccountEnds;
|
use FireflyIII\TransactionRules\Triggers\FromAccountEnds;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ class FromAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggered(): void
|
public function testTriggered(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while ($count === 0) {
|
while ($count === 0) {
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
@@ -54,6 +56,7 @@ class FromAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredLonger(): void
|
public function testTriggeredLonger(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while ($count === 0) {
|
while ($count === 0) {
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
@@ -72,6 +75,7 @@ class FromAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredNot(): void
|
public function testTriggeredNot(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
|
|
||||||
$trigger = FromAccountEnds::makeFromStrings('some name' . random_int(1, 234), false);
|
$trigger = FromAccountEnds::makeFromStrings('some name' . random_int(1, 234), false);
|
||||||
@@ -84,6 +88,7 @@ class FromAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingEmpty(): void
|
public function testWillMatchEverythingEmpty(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = '';
|
$value = '';
|
||||||
$result = FromAccountEnds::willMatchEverything($value);
|
$result = FromAccountEnds::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
@@ -94,6 +99,7 @@ class FromAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNotNull(): void
|
public function testWillMatchEverythingNotNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = 'x';
|
$value = 'x';
|
||||||
$result = FromAccountEnds::willMatchEverything($value);
|
$result = FromAccountEnds::willMatchEverything($value);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
@@ -104,6 +110,7 @@ class FromAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNull(): void
|
public function testWillMatchEverythingNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = null;
|
$value = null;
|
||||||
$result = FromAccountEnds::willMatchEverything($value);
|
$result = FromAccountEnds::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\TransactionRules\Triggers;
|
namespace Tests\Unit\TransactionRules\Triggers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\Triggers\FromAccountIs;
|
use FireflyIII\TransactionRules\Triggers\FromAccountIs;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -36,6 +37,7 @@ class FromAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggered(): void
|
public function testTriggered(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$loops = 0; // FINAL LOOP METHOD.
|
$loops = 0; // FINAL LOOP METHOD.
|
||||||
do {
|
do {
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
@@ -62,6 +64,7 @@ class FromAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredNot(): void
|
public function testTriggeredNot(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
|
|
||||||
$trigger = FromAccountIs::makeFromStrings('some name' . random_int(1, 234), false);
|
$trigger = FromAccountIs::makeFromStrings('some name' . random_int(1, 234), false);
|
||||||
@@ -74,6 +77,7 @@ class FromAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingEmpty(): void
|
public function testWillMatchEverythingEmpty(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = '';
|
$value = '';
|
||||||
$result = FromAccountIs::willMatchEverything($value);
|
$result = FromAccountIs::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
@@ -84,6 +88,7 @@ class FromAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNotNull(): void
|
public function testWillMatchEverythingNotNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = 'x';
|
$value = 'x';
|
||||||
$result = FromAccountIs::willMatchEverything($value);
|
$result = FromAccountIs::willMatchEverything($value);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
@@ -94,6 +99,7 @@ class FromAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNull(): void
|
public function testWillMatchEverythingNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = null;
|
$value = null;
|
||||||
$result = FromAccountIs::willMatchEverything($value);
|
$result = FromAccountIs::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\TransactionRules\Triggers;
|
namespace Tests\Unit\TransactionRules\Triggers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\Triggers\FromAccountStarts;
|
use FireflyIII\TransactionRules\Triggers\FromAccountStarts;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -46,6 +47,7 @@ class FromAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggered(): void
|
public function testTriggered(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
Log::debug('In testTriggered()');
|
Log::debug('In testTriggered()');
|
||||||
$loops = 0; // FINAL LOOP METHOD.
|
$loops = 0; // FINAL LOOP METHOD.
|
||||||
do {
|
do {
|
||||||
@@ -77,6 +79,7 @@ class FromAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredLonger(): void
|
public function testTriggeredLonger(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
Log::debug('In testTriggeredLonger()');
|
Log::debug('In testTriggeredLonger()');
|
||||||
$loops = 0; // FINAL LOOP METHOD.
|
$loops = 0; // FINAL LOOP METHOD.
|
||||||
do {
|
do {
|
||||||
@@ -108,6 +111,7 @@ class FromAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredNot(): void
|
public function testTriggeredNot(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
|
|
||||||
$trigger = FromAccountStarts::makeFromStrings('some name' . random_int(1, 234), false);
|
$trigger = FromAccountStarts::makeFromStrings('some name' . random_int(1, 234), false);
|
||||||
@@ -120,6 +124,7 @@ class FromAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingEmpty(): void
|
public function testWillMatchEverythingEmpty(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = '';
|
$value = '';
|
||||||
$result = FromAccountStarts::willMatchEverything($value);
|
$result = FromAccountStarts::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
@@ -130,6 +135,7 @@ class FromAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNotNull(): void
|
public function testWillMatchEverythingNotNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = 'x';
|
$value = 'x';
|
||||||
$result = FromAccountStarts::willMatchEverything($value);
|
$result = FromAccountStarts::willMatchEverything($value);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
@@ -140,6 +146,7 @@ class FromAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNull(): void
|
public function testWillMatchEverythingNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = null;
|
$value = null;
|
||||||
$result = FromAccountStarts::willMatchEverything($value);
|
$result = FromAccountStarts::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\TransactionRules\Triggers;
|
namespace Tests\Unit\TransactionRules\Triggers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\Triggers\ToAccountContains;
|
use FireflyIII\TransactionRules\Triggers\ToAccountContains;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -36,6 +37,8 @@ class ToAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggered(): void
|
public function testTriggered(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
do {
|
do {
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
@@ -56,6 +59,7 @@ class ToAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredNot(): void
|
public function testTriggeredNot(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
do {
|
do {
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
@@ -76,6 +80,7 @@ class ToAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingEmpty(): void
|
public function testWillMatchEverythingEmpty(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = '';
|
$value = '';
|
||||||
$result = ToAccountContains::willMatchEverything($value);
|
$result = ToAccountContains::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
@@ -86,6 +91,7 @@ class ToAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNotNull(): void
|
public function testWillMatchEverythingNotNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = 'x';
|
$value = 'x';
|
||||||
$result = ToAccountContains::willMatchEverything($value);
|
$result = ToAccountContains::willMatchEverything($value);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
@@ -96,6 +102,7 @@ class ToAccountContainsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNull(): void
|
public function testWillMatchEverythingNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = null;
|
$value = null;
|
||||||
$result = ToAccountContains::willMatchEverything($value);
|
$result = ToAccountContains::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\TransactionRules\Triggers;
|
namespace Tests\Unit\TransactionRules\Triggers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\Triggers\ToAccountEnds;
|
use FireflyIII\TransactionRules\Triggers\ToAccountEnds;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -37,6 +38,7 @@ class ToAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggered(): void
|
public function testTriggered(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$loops = 0; // FINAL LOOP METHOD.
|
$loops = 0; // FINAL LOOP METHOD.
|
||||||
do {
|
do {
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
@@ -68,6 +70,7 @@ class ToAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredLonger(): void
|
public function testTriggeredLonger(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$loops = 0; // FINAL LOOP METHOD.
|
$loops = 0; // FINAL LOOP METHOD.
|
||||||
do {
|
do {
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
@@ -98,6 +101,7 @@ class ToAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredNot(): void
|
public function testTriggeredNot(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$loops = 0; // FINAL LOOP METHOD.
|
$loops = 0; // FINAL LOOP METHOD.
|
||||||
do {
|
do {
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
@@ -128,6 +132,7 @@ class ToAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingEmpty(): void
|
public function testWillMatchEverythingEmpty(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = '';
|
$value = '';
|
||||||
$result = ToAccountEnds::willMatchEverything($value);
|
$result = ToAccountEnds::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
@@ -138,6 +143,7 @@ class ToAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNotNull(): void
|
public function testWillMatchEverythingNotNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = 'x';
|
$value = 'x';
|
||||||
$result = ToAccountEnds::willMatchEverything($value);
|
$result = ToAccountEnds::willMatchEverything($value);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
@@ -148,6 +154,7 @@ class ToAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNull(): void
|
public function testWillMatchEverythingNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = null;
|
$value = null;
|
||||||
$result = ToAccountEnds::willMatchEverything($value);
|
$result = ToAccountEnds::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\TransactionRules\Triggers;
|
namespace Tests\Unit\TransactionRules\Triggers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\Triggers\ToAccountIs;
|
use FireflyIII\TransactionRules\Triggers\ToAccountIs;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Log;
|
use Log;
|
||||||
@@ -37,6 +38,7 @@ class ToAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggered(): void
|
public function testTriggered(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$loops = 0; // FINAL LOOP METHOD.
|
$loops = 0; // FINAL LOOP METHOD.
|
||||||
do {
|
do {
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
@@ -64,6 +66,7 @@ class ToAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredNot(): void
|
public function testTriggeredNot(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$loops = 0; // FINAL LOOP METHOD.
|
$loops = 0; // FINAL LOOP METHOD.
|
||||||
do {
|
do {
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
@@ -89,6 +92,7 @@ class ToAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingEmpty(): void
|
public function testWillMatchEverythingEmpty(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = '';
|
$value = '';
|
||||||
$result = ToAccountIs::willMatchEverything($value);
|
$result = ToAccountIs::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
@@ -99,6 +103,7 @@ class ToAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNotNull(): void
|
public function testWillMatchEverythingNotNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = 'x';
|
$value = 'x';
|
||||||
$result = ToAccountIs::willMatchEverything($value);
|
$result = ToAccountIs::willMatchEverything($value);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
@@ -109,6 +114,7 @@ class ToAccountIsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNull(): void
|
public function testWillMatchEverythingNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = null;
|
$value = null;
|
||||||
$result = ToAccountIs::willMatchEverything($value);
|
$result = ToAccountIs::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\TransactionRules\Triggers;
|
namespace Tests\Unit\TransactionRules\Triggers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\Triggers\ToAccountStarts;
|
use FireflyIII\TransactionRules\Triggers\ToAccountStarts;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -37,6 +38,7 @@ class ToAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggered(): void
|
public function testTriggered(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
Log::debug('Now in testTriggered');
|
Log::debug('Now in testTriggered');
|
||||||
|
|
||||||
$loops = 0; // FINAL LOOP METHOD.
|
$loops = 0; // FINAL LOOP METHOD.
|
||||||
@@ -65,6 +67,7 @@ class ToAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredLonger(): void
|
public function testTriggeredLonger(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
Log::debug('Now in testTriggeredLonger');
|
Log::debug('Now in testTriggeredLonger');
|
||||||
|
|
||||||
|
|
||||||
@@ -93,6 +96,7 @@ class ToAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredNot(): void
|
public function testTriggeredNot(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
|
|
||||||
$trigger = ToAccountStarts::makeFromStrings('some name' . random_int(1, 234), false);
|
$trigger = ToAccountStarts::makeFromStrings('some name' . random_int(1, 234), false);
|
||||||
@@ -105,6 +109,7 @@ class ToAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingEmpty(): void
|
public function testWillMatchEverythingEmpty(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = '';
|
$value = '';
|
||||||
$result = ToAccountStarts::willMatchEverything($value);
|
$result = ToAccountStarts::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
@@ -115,6 +120,7 @@ class ToAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNotNull(): void
|
public function testWillMatchEverythingNotNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = 'x';
|
$value = 'x';
|
||||||
$result = ToAccountStarts::willMatchEverything($value);
|
$result = ToAccountStarts::willMatchEverything($value);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
@@ -125,6 +131,7 @@ class ToAccountStartsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testWillMatchEverythingNull(): void
|
public function testWillMatchEverythingNull(): void
|
||||||
{
|
{
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$value = null;
|
$value = null;
|
||||||
$result = ToAccountStarts::willMatchEverything($value);
|
$result = ToAccountStarts::willMatchEverything($value);
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
|
Reference in New Issue
Block a user