mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Remove a lot of deprecated code.
This commit is contained in:
parent
dbf019135a
commit
7c950c3022
@ -65,7 +65,7 @@ class DecryptAttachment extends Command
|
||||
$attachment = $repository->findWithoutUser($attachmentId);
|
||||
$attachmentName = trim($this->argument('name'));
|
||||
$storagePath = realpath(trim($this->argument('directory')));
|
||||
if (null === $attachment->id) {
|
||||
if (null === $attachment) {
|
||||
$this->error(sprintf('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:
|
||||
$this->uploadDisk->put($attachment->fileName(), $encrypted);
|
||||
$attachment->uploaded = 1; // update attachment
|
||||
$attachment->uploaded = true; // update attachment
|
||||
$attachment->save();
|
||||
$this->attachments->push($attachment);
|
||||
|
||||
|
@ -196,7 +196,7 @@ class TagController extends Controller
|
||||
// prep for "all" view.
|
||||
if ('all' === $moment) {
|
||||
$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;
|
||||
$path = route('tags.show', [$tag->id, 'all']);
|
||||
}
|
||||
@ -311,8 +311,8 @@ class TagController extends Controller
|
||||
// get first and last tag date from tag:
|
||||
$range = app('preferences')->get('viewRange', '1M')->data;
|
||||
/** @var Carbon $end */
|
||||
$end = app('navigation')->endOfX($this->repository->lastUseDate($tag), $range, null);
|
||||
$start = $this->repository->firstUseDate($tag);
|
||||
$end = app('navigation')->endOfX($this->repository->lastUseDate($tag) ?? new Carbon, $range, null);
|
||||
$start = $this->repository->firstUseDate($tag) ?? new Carbon;
|
||||
|
||||
|
||||
// properties for entries with their amounts.
|
||||
|
@ -211,7 +211,7 @@ class ReportFormRequest extends Request
|
||||
if (\is_array($set)) {
|
||||
foreach ($set as $tagTag) {
|
||||
$tag = $repository->findByTag($tagTag);
|
||||
if (null !== $tag->id) {
|
||||
if (null !== $tag) {
|
||||
$collection->push($tag);
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Import\Specifics;
|
||||
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class RabobankDescription.
|
||||
*
|
||||
@ -66,25 +64,6 @@ class RabobankDescription implements SpecificInterface
|
||||
public function run(array $row): array
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
|
||||
/**
|
||||
* Class TransactionJournal.
|
||||
@ -62,7 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
use SoftDeletes, TransactionJournalTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* 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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*
|
||||
|
@ -81,18 +81,12 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param int $attachmentId
|
||||
* @deprecated
|
||||
* @return Attachment
|
||||
* @return Attachment|null
|
||||
*/
|
||||
public function findWithoutUser(int $attachmentId): Attachment
|
||||
public function findWithoutUser(int $attachmentId): ?Attachment
|
||||
{
|
||||
|
||||
$attachment = Attachment::find($attachmentId);
|
||||
if (null === $attachment) {
|
||||
return new Attachment;
|
||||
}
|
||||
|
||||
return $attachment;
|
||||
return Attachment::find($attachmentId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,10 +50,9 @@ interface AttachmentRepositoryInterface
|
||||
|
||||
/**
|
||||
* @param int $attachmentId
|
||||
* @deprecated
|
||||
* @return Attachment
|
||||
* @return Attachment|null
|
||||
*/
|
||||
public function findWithoutUser(int $attachmentId): Attachment;
|
||||
public function findWithoutUser(int $attachmentId): ?Attachment;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
|
@ -921,8 +921,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
// or create one and return it.
|
||||
$limit = new BudgetLimit;
|
||||
$limit->budget()->associate($budget);
|
||||
$limit->start_date = $start->format('Y-m-d 00:00:00');
|
||||
$limit->end_date = $end->format('Y-m-d 00:00:00');
|
||||
$limit->start_date = $start->startOfDay();
|
||||
$limit->end_date = $end->startOfDay();
|
||||
$limit->amount = $amount;
|
||||
$limit->save();
|
||||
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
|
||||
* @deprecated
|
||||
* @return ExportJob|null
|
||||
*/
|
||||
public function create(): ExportJob
|
||||
public function create(): ?ExportJob
|
||||
{
|
||||
$count = 0;
|
||||
while ($count < 30) {
|
||||
@ -103,7 +102,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
++$count;
|
||||
}
|
||||
|
||||
return new ExportJob;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,10 +44,9 @@ interface ExportJobRepositoryInterface
|
||||
public function cleanup(): bool;
|
||||
|
||||
/**
|
||||
* @return ExportJob
|
||||
* @deprecated
|
||||
* @return ExportJob|null
|
||||
*/
|
||||
public function create(): ExportJob;
|
||||
public function create(): ?ExportJob;
|
||||
|
||||
/**
|
||||
* @param ExportJob $job
|
||||
|
@ -303,7 +303,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
|
||||
// store it:
|
||||
$this->uploadDisk->put($attachment->fileName(), $encrypted);
|
||||
$attachment->uploaded = 1; // update attachment
|
||||
$attachment->uploaded = true; // update attachment
|
||||
$attachment->save();
|
||||
|
||||
// return it.
|
||||
@ -357,7 +357,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
|
||||
// store it:
|
||||
$this->uploadDisk->put($attachment->fileName(), $encrypted);
|
||||
$attachment->uploaded = 1; // update attachment
|
||||
$attachment->uploaded = true; // update attachment
|
||||
$attachment->save();
|
||||
|
||||
// return it.
|
||||
|
@ -29,7 +29,6 @@ use FireflyIII\Factory\TransactionJournalFactory;
|
||||
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@ -59,6 +58,8 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
* @param Account $destination
|
||||
*
|
||||
* @return MessageBag
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
public function convert(TransactionJournal $journal, TransactionType $type, Account $source, Account $destination): MessageBag
|
||||
{
|
||||
@ -73,9 +74,9 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
return $messages;
|
||||
}
|
||||
|
||||
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
$destinationTransaction = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $sourceTransaction || null === $destinationTransaction) {
|
||||
$srcTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
$dstTransaction = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
if (null === $srcTransaction || null === $dstTransaction) {
|
||||
// default message bag that shows errors for everything.
|
||||
|
||||
$messages = new MessageBag;
|
||||
@ -86,15 +87,18 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
return $messages;
|
||||
}
|
||||
$sourceTransaction->account_id = $source->id;
|
||||
$sourceTransaction->save();
|
||||
$destinationTransaction->account_id = $destination->id;
|
||||
$destinationTransaction->save();
|
||||
// update transactions, and update journal:
|
||||
|
||||
$srcTransaction->account_id = $source->id;
|
||||
$dstTransaction->account_id = $destination->id;
|
||||
$journal->transaction_type_id = $type->id;
|
||||
$dstTransaction->save();
|
||||
$srcTransaction->save();
|
||||
$journal->save();
|
||||
|
||||
// if journal is a transfer now, remove budget:
|
||||
if (TransactionType::TRANSFER === $type->type) {
|
||||
|
||||
$journal->budgets()->detach();
|
||||
// also from transactions:
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
|
@ -340,6 +340,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return string
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function getSuggestedMonthlyAmount(PiggyBank $piggyBank): string
|
||||
{
|
||||
|
@ -80,29 +80,12 @@ class TagRepository implements TagRepositoryInterface
|
||||
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
|
||||
*
|
||||
* @return Tag
|
||||
* @deprecated
|
||||
* @return Tag|null
|
||||
*/
|
||||
public function findByTag(string $tag): Tag
|
||||
public function findByTag(string $tag): ?Tag
|
||||
{
|
||||
$tags = $this->user->tags()->get();
|
||||
/** @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
|
||||
*
|
||||
* @return Carbon
|
||||
* @deprecated
|
||||
* @return Carbon|null
|
||||
*/
|
||||
public function firstUseDate(Tag $tag): Carbon
|
||||
public function firstUseDate(Tag $tag): ?Carbon
|
||||
{
|
||||
$journal = $tag->transactionJournals()->orderBy('date', 'ASC')->first();
|
||||
if (null !== $journal) {
|
||||
return $journal->date;
|
||||
}
|
||||
|
||||
return new Carbon;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,17 +142,16 @@ class TagRepository implements TagRepositoryInterface
|
||||
/**
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return Carbon
|
||||
* @deprecated
|
||||
* @return Carbon|null
|
||||
*/
|
||||
public function lastUseDate(Tag $tag): Carbon
|
||||
public function lastUseDate(Tag $tag): ?Carbon
|
||||
{
|
||||
$journal = $tag->transactionJournals()->orderBy('date', 'DESC')->first();
|
||||
if (null !== $journal) {
|
||||
return $journal->date;
|
||||
}
|
||||
|
||||
return new Carbon;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,21 +55,12 @@ interface TagRepositoryInterface
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @return Tag
|
||||
* @deprecated
|
||||
* @return Tag|null
|
||||
*/
|
||||
public function findByTag(string $tag): Tag;
|
||||
public function findByTag(string $tag):?Tag;
|
||||
|
||||
/**
|
||||
* @param int $tagId
|
||||
@ -82,9 +73,8 @@ interface TagRepositoryInterface
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return Carbon
|
||||
* @deprecated
|
||||
*/
|
||||
public function firstUseDate(Tag $tag): Carbon;
|
||||
public function firstUseDate(Tag $tag): ?Carbon;
|
||||
|
||||
/**
|
||||
* This method returns all the user's tags.
|
||||
@ -96,10 +86,9 @@ interface TagRepositoryInterface
|
||||
/**
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return Carbon
|
||||
* @deprecated
|
||||
* @return Carbon|null
|
||||
*/
|
||||
public function lastUseDate(Tag $tag): Carbon;
|
||||
public function lastUseDate(Tag $tag): ?Carbon;
|
||||
|
||||
/**
|
||||
* Will return the newest tag (if known) or NULL.
|
||||
|
@ -162,22 +162,6 @@ class UserRepository implements UserRepositoryInterface
|
||||
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
|
||||
*
|
||||
|
@ -101,14 +101,6 @@ interface UserRepositoryInterface
|
||||
*/
|
||||
public function destroy(User $user): bool;
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
*
|
||||
* @deprecated
|
||||
* @return User
|
||||
*/
|
||||
public function find(int $userId): User;
|
||||
|
||||
/**
|
||||
* @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\Category;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Twig\Extension\TransactionJournal as TransactionJournalExtension;
|
||||
use Twig_Extension;
|
||||
@ -53,8 +54,10 @@ class Journal extends Twig_Extension
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$list = $journal->destinationAccountList();
|
||||
$array = [];
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
$list = $repository->getJournalDestinationAccounts($journal);
|
||||
$array = [];
|
||||
/** @var Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
if (AccountType::CASH === $entry->accountType->type) {
|
||||
@ -119,7 +122,10 @@ class Journal extends Twig_Extension
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$list = $journal->sourceAccountList();
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
$list = $repository->getJournalSourceAccounts($journal);
|
||||
$array = [];
|
||||
/** @var Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,11 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
|
||||
{
|
||||
$fromAccountName = '';
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($journal->sourceAccountList() as $account) {
|
||||
foreach ($repository->getJournalSourceAccounts($journal) as $account) {
|
||||
$fromAccountName .= strtolower($account->name);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,11 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
$name = '';
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($journal->sourceAccountList() as $account) {
|
||||
foreach ($repository->getJournalSourceAccounts($journal) as $account) {
|
||||
$name .= strtolower($account->name);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,11 @@ final class FromAccountIs extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
$name = '';
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($journal->sourceAccountList() as $account) {
|
||||
foreach ($repository->getJournalSourceAccounts($journal) as $account) {
|
||||
$name .= strtolower($account->name);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,11 @@ final class FromAccountStarts extends AbstractTrigger implements TriggerInterfac
|
||||
{
|
||||
$name = '';
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($journal->sourceAccountList() as $account) {
|
||||
foreach ($repository->getJournalSourceAccounts($journal) as $account) {
|
||||
$name .= strtolower($account->name);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,11 @@ final class ToAccountContains extends AbstractTrigger implements TriggerInterfac
|
||||
{
|
||||
$toAccountName = '';
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($journal->destinationAccountList() as $account) {
|
||||
foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
|
||||
$toAccountName .= strtolower($account->name);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,11 @@ final class ToAccountEnds extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
$toAccountName = '';
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($journal->destinationAccountList() as $account) {
|
||||
foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
|
||||
$toAccountName .= strtolower($account->name);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,11 @@ final class ToAccountIs extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
$toAccountName = '';
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($journal->destinationAccountList() as $account) {
|
||||
foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
|
||||
$toAccountName .= strtolower($account->name);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -73,8 +74,11 @@ final class ToAccountStarts extends AbstractTrigger implements TriggerInterface
|
||||
{
|
||||
$toAccountName = '';
|
||||
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($journal->destinationAccountList() as $account) {
|
||||
foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
|
||||
$toAccountName .= strtolower($account->name);
|
||||
}
|
||||
|
||||
|
22
app/User.php
22
app/User.php
@ -219,28 +219,6 @@ class User extends Authenticatable
|
||||
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
|
||||
* Link to import jobs.
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\FromAccountContains;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -36,6 +37,7 @@ class FromAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$count = 0;
|
||||
while ($count === 0) {
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
@ -54,6 +56,7 @@ class FromAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
|
||||
$trigger = FromAccountContains::makeFromStrings('some name' . random_int(1, 234), false);
|
||||
@ -66,6 +69,7 @@ class FromAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = FromAccountContains::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
@ -76,6 +80,7 @@ class FromAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = FromAccountContains::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
@ -86,6 +91,7 @@ class FromAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = FromAccountContains::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\FromAccountEnds;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -36,6 +37,7 @@ class FromAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$count = 0;
|
||||
while ($count === 0) {
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
@ -54,6 +56,7 @@ class FromAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredLonger(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$count = 0;
|
||||
while ($count === 0) {
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
@ -72,6 +75,7 @@ class FromAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
|
||||
$trigger = FromAccountEnds::makeFromStrings('some name' . random_int(1, 234), false);
|
||||
@ -84,6 +88,7 @@ class FromAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = FromAccountEnds::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
@ -94,6 +99,7 @@ class FromAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = FromAccountEnds::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
@ -104,6 +110,7 @@ class FromAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = FromAccountEnds::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\FromAccountIs;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
@ -36,6 +37,7 @@ class FromAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
do {
|
||||
/** @var TransactionJournal $journal */
|
||||
@ -62,6 +64,7 @@ class FromAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
|
||||
$trigger = FromAccountIs::makeFromStrings('some name' . random_int(1, 234), false);
|
||||
@ -74,6 +77,7 @@ class FromAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
@ -84,6 +88,7 @@ class FromAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
@ -94,6 +99,7 @@ class FromAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\FromAccountStarts;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
@ -46,6 +47,7 @@ class FromAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
Log::debug('In testTriggered()');
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
do {
|
||||
@ -77,6 +79,7 @@ class FromAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredLonger(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
Log::debug('In testTriggeredLonger()');
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
do {
|
||||
@ -108,6 +111,7 @@ class FromAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
|
||||
$trigger = FromAccountStarts::makeFromStrings('some name' . random_int(1, 234), false);
|
||||
@ -120,6 +124,7 @@ class FromAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = FromAccountStarts::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
@ -130,6 +135,7 @@ class FromAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = FromAccountStarts::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
@ -140,6 +146,7 @@ class FromAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = FromAccountStarts::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountContains;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -36,6 +37,8 @@ class ToAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$count = 0;
|
||||
do {
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
@ -56,6 +59,7 @@ class ToAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$count = 0;
|
||||
do {
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
@ -76,6 +80,7 @@ class ToAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = ToAccountContains::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
@ -86,6 +91,7 @@ class ToAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = ToAccountContains::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
@ -96,6 +102,7 @@ class ToAccountContainsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = ToAccountContains::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountEnds;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
@ -37,7 +38,8 @@ class ToAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
do {
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
|
||||
@ -68,7 +70,8 @@ class ToAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredLonger(): void
|
||||
{
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
do {
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
|
||||
@ -98,7 +101,8 @@ class ToAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
do {
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
|
||||
@ -128,8 +132,9 @@ class ToAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$value = '';
|
||||
$result = ToAccountEnds::willMatchEverything($value);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = ToAccountEnds::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
@ -138,8 +143,9 @@ class ToAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$value = 'x';
|
||||
$result = ToAccountEnds::willMatchEverything($value);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = ToAccountEnds::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@ -148,8 +154,9 @@ class ToAccountEndsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$value = null;
|
||||
$result = ToAccountEnds::willMatchEverything($value);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = ToAccountEnds::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountIs;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
@ -37,6 +38,7 @@ class ToAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
do {
|
||||
/** @var TransactionJournal $journal */
|
||||
@ -64,6 +66,7 @@ class ToAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
do {
|
||||
/** @var TransactionJournal $journal */
|
||||
@ -89,6 +92,7 @@ class ToAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
@ -99,6 +103,7 @@ class ToAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
@ -109,6 +114,7 @@ class ToAccountIsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountStarts;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
@ -37,6 +38,7 @@ class ToAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testTriggered(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
Log::debug('Now in testTriggered');
|
||||
|
||||
$loops = 0; // FINAL LOOP METHOD.
|
||||
@ -65,6 +67,7 @@ class ToAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredLonger(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
Log::debug('Now in testTriggeredLonger');
|
||||
|
||||
|
||||
@ -93,7 +96,8 @@ class ToAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredNot(): void
|
||||
{
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
|
||||
$trigger = ToAccountStarts::makeFromStrings('some name' . random_int(1, 234), false);
|
||||
$result = $trigger->triggered($journal);
|
||||
@ -105,8 +109,9 @@ class ToAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$value = '';
|
||||
$result = ToAccountStarts::willMatchEverything($value);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = ToAccountStarts::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
@ -115,8 +120,9 @@ class ToAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$value = 'x';
|
||||
$result = ToAccountStarts::willMatchEverything($value);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = ToAccountStarts::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@ -125,8 +131,9 @@ class ToAccountStartsTest extends TestCase
|
||||
*/
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$value = null;
|
||||
$result = ToAccountStarts::willMatchEverything($value);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = ToAccountStarts::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user