First part of a large code cleanup commit.

This commit is contained in:
James Cole 2019-02-12 21:49:28 +01:00
parent b273af341c
commit e0d87aa11e
70 changed files with 336 additions and 354 deletions

View File

@ -43,7 +43,6 @@ use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Log;
use Navigation;
use Symfony\Component\Debug\Exception\FatalThrowableError;
/**
* Class BudgetRepository.
@ -107,7 +106,7 @@ class BudgetRepository implements BudgetRepositoryInterface
// delete limits with amount 0:
try {
BudgetLimit::where('amount', 0)->delete();
} catch (Exception|FatalThrowableError $e) {
} catch (Exception $e) {
Log::debug(sprintf('Could not delete budget limit: %s', $e->getMessage()));
}
Budget::where('order', 0)->update(['order' => 100]);
@ -122,7 +121,7 @@ class BudgetRepository implements BudgetRepositoryInterface
// delete it!
try {
BudgetLimit::find($budgetLimit->id)->delete();
} catch (Exception|FatalThrowableError $e) {
} catch (Exception $e) {
Log::debug(sprintf('Could not delete budget limit: %s', $e->getMessage()));
}
}
@ -863,7 +862,6 @@ class BudgetRepository implements BudgetRepositoryInterface
/**
* @param array $data
*
* @throws FireflyException
* @return BudgetLimit
*/
public function storeBudgetLimit(array $data): BudgetLimit

View File

@ -120,8 +120,8 @@ interface BudgetRepositoryInterface
public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string;
/**
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/

View File

@ -116,6 +116,61 @@ class CategoryRepository implements CategoryRepositoryInterface
return $collector->getTransactions();
}
/**
* A very cryptic method name that means:
*
* Get me the amount earned in this period, grouped per currency, where no category was set.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array
{
/** @var TransactionCollectorInterface $collector */
$collector = app(TransactionCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->withoutCategory();
if ($accounts->count() > 0) {
$collector->setAccounts($accounts);
}
if (0 === $accounts->count()) {
$collector->setAllAssetAccounts();
}
$set = $collector->getTransactions();
$set = $set->filter(
function (Transaction $transaction) {
if (bccomp($transaction->transaction_amount, '0') === 1) {
return $transaction;
}
return null;
}
);
$return = [];
/** @var Transaction $transaction */
foreach ($set as $transaction) {
$currencyId = $transaction->transaction_currency_id;
if (!isset($return[$currencyId])) {
$return[$currencyId] = [
'spent' => '0',
'currency_id' => $currencyId,
'currency_symbol' => $transaction->transaction_currency_symbol,
'currency_code' => $transaction->transaction_currency_code,
'currency_decimal_places' => $transaction->transaction_currency_dp,
];
}
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $transaction->transaction_amount);
}
return $return;
}
/**
* @param Collection $categories
* @param Collection $accounts
@ -237,6 +292,8 @@ class CategoryRepository implements CategoryRepositoryInterface
return $firstJournalDate;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Get all categories with ID's.
*
@ -249,8 +306,6 @@ class CategoryRepository implements CategoryRepositoryInterface
return $this->user->categories()->whereIn('id', $categoryIds)->get();
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Returns a list of all the categories belonging to a user.
*
@ -269,6 +324,8 @@ class CategoryRepository implements CategoryRepositoryInterface
return $set;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Category $category
* @param Collection $accounts
@ -299,8 +356,6 @@ class CategoryRepository implements CategoryRepositoryInterface
return $lastJournalDate;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@ -384,6 +439,8 @@ class CategoryRepository implements CategoryRepositoryInterface
return $result;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@ -482,8 +539,6 @@ class CategoryRepository implements CategoryRepositoryInterface
$this->user = $user;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@ -791,59 +846,4 @@ class CategoryRepository implements CategoryRepositoryInterface
return null;
}
/**
* A very cryptic method name that means:
*
* Get me the amount earned in this period, grouped per currency, where no category was set.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array
{
/** @var TransactionCollectorInterface $collector */
$collector = app(TransactionCollectorInterface::class);
$collector->setUser($this->user);
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->withoutCategory();
if ($accounts->count() > 0) {
$collector->setAccounts($accounts);
}
if (0 === $accounts->count()) {
$collector->setAllAssetAccounts();
}
$set = $collector->getTransactions();
$set = $set->filter(
function (Transaction $transaction) {
if (bccomp($transaction->transaction_amount, '0') === 1) {
return $transaction;
}
return null;
}
);
$return = [];
/** @var Transaction $transaction */
foreach ($set as $transaction) {
$currencyId = $transaction->transaction_currency_id;
if (!isset($return[$currencyId])) {
$return[$currencyId] = [
'spent' => '0',
'currency_id' => $currencyId,
'currency_symbol' => $transaction->transaction_currency_symbol,
'currency_code' => $transaction->transaction_currency_code,
'currency_decimal_places' => $transaction->transaction_currency_dp,
];
}
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $transaction->transaction_amount);
}
return $return;
}
}

View File

@ -62,6 +62,29 @@ interface CategoryRepositoryInterface
*/
public function earnedInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection;
/**
* A very cryptic method name that means:
*
* Get me the amount earned in this period, grouped per currency, where no category was set.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
/**
* @param Collection $categories
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function earnedInPeriodPerCurrency(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/**
* Find a category.
*
@ -96,6 +119,8 @@ interface CategoryRepositoryInterface
*/
public function getByIds(array $categoryIds): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Returns a list of all the categories belonging to a user.
*
@ -114,6 +139,7 @@ interface CategoryRepositoryInterface
public function lastUseDate(Category $category, Collection $accounts): ?Carbon;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@ -133,7 +159,6 @@ interface CategoryRepositoryInterface
*/
public function periodExpensesNoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@ -144,6 +169,8 @@ interface CategoryRepositoryInterface
*/
public function periodIncome(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $accounts
* @param Carbon $start
@ -153,12 +180,15 @@ interface CategoryRepositoryInterface
*/
public function periodIncomeNoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param User $user
*/
public function setUser(User $user);
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@ -169,7 +199,6 @@ interface CategoryRepositoryInterface
*/
public function spentInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
* @param Collection $accounts
@ -180,8 +209,6 @@ interface CategoryRepositoryInterface
*/
public function spentInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* A very cryptic method name that means:
*
@ -195,19 +222,6 @@ interface CategoryRepositoryInterface
*/
public function spentInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
/**
* A very cryptic method name that means:
*
* Get me the amount earned in this period, grouped per currency, where no category was set.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
/**
* @param Collection $categories
* @param Collection $accounts
@ -218,16 +232,6 @@ interface CategoryRepositoryInterface
*/
public function spentInPeriodPerCurrency(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/**
* @param Collection $categories
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return array
*/
public function earnedInPeriodPerCurrency(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/**
* @param Collection $accounts
* @param Carbon $start

View File

@ -22,13 +22,11 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\ExportJob;
use Carbon\Carbon;
use Exception;
use FireflyIII\Models\ExportJob;
use FireflyIII\User;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Log;
/**

View File

@ -40,13 +40,6 @@ use Illuminate\Support\MessageBag;
interface JournalRepositoryInterface
{
/**
* @param TransactionJournalLink $link
*
* @return string
*/
public function getLinkNoteText(TransactionJournalLink $link): string;
/**
* @param TransactionJournal $journal
* @param TransactionType $type
@ -57,9 +50,6 @@ interface JournalRepositoryInterface
*/
public function convert(TransactionJournal $journal, TransactionType $type, Account $source, Account $destination): MessageBag;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param TransactionJournal $journal
*
@ -67,6 +57,9 @@ interface JournalRepositoryInterface
*/
public function countTransactions(TransactionJournal $journal): int;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Deletes a journal.
*
@ -203,6 +196,13 @@ interface JournalRepositoryInterface
*/
public function getJournalTotal(TransactionJournal $journal): string;
/**
* @param TransactionJournalLink $link
*
* @return string
*/
public function getLinkNoteText(TransactionJournalLink $link): string;
/**
* Return Carbon value of a meta field (or NULL).
*

View File

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\LinkType;
use Exception;
use FireflyIII\Models\LinkType;
use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionJournal;
@ -362,7 +363,11 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
return;
}
if (null !== $dbNote && '' === $text) {
$dbNote->delete();
try {
$dbNote->delete();
} catch (Exception $e) {
Log::debug(sprintf('Could not delete note: %s', $e->getMessage()));
}
}
}

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\PiggyBank;
use Carbon\Carbon;
use Exception;
use FireflyIII\Models\Note;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\PiggyBankEvent;
@ -559,7 +560,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
if ('' === $note) {
$dbNote = $piggyBank->notes()->first();
if (null !== $dbNote) {
$dbNote->delete();
try {
$dbNote->delete();
} catch (Exception $e) {
Log::debug(sprintf('Could not delete note: %s', $e->getMessage()));
}
}
return true;

View File

@ -34,21 +34,6 @@ use Illuminate\Support\Collection;
*/
interface RuleRepositoryInterface
{
/**
* @param Rule $rule
*
* @return Collection
*/
public function getRuleActions(Rule $rule): Collection;
/**
* @param Rule $rule
*
* @return Collection
*/
public function getRuleTriggers(Rule $rule): Collection;
/**
* @return int
*/
@ -101,6 +86,20 @@ interface RuleRepositoryInterface
*/
public function getPrimaryTrigger(Rule $rule): string;
/**
* @param Rule $rule
*
* @return Collection
*/
public function getRuleActions(Rule $rule): Collection;
/**
* @param Rule $rule
*
* @return Collection
*/
public function getRuleTriggers(Rule $rule): Collection;
/**
* @param Rule $rule
*

View File

@ -72,13 +72,6 @@ interface RuleGroupRepositoryInterface
*/
public function getActiveRules(RuleGroup $group): Collection;
/**
* @param RuleGroup $group
*
* @return Collection
*/
public function getRules(RuleGroup $group): Collection;
/**
* @param RuleGroup $group
*
@ -105,6 +98,13 @@ interface RuleGroupRepositoryInterface
*/
public function getRuleGroupsWithRules(User $user): Collection;
/**
* @param RuleGroup $group
*
* @return Collection
*/
public function getRules(RuleGroup $group): Collection;
/**
* @param RuleGroup $ruleGroup
*

View File

@ -255,6 +255,7 @@ class TagRepository implements TagRepositoryInterface
/** @var TagFactory $factory */
$factory = app(TagFactory::class);
$factory->setUser($this->user);
return $factory->create($data);
}

View File

@ -32,12 +32,6 @@ use Illuminate\Support\Collection;
interface UserRepositoryInterface
{
/**
* @param User $user
*
* @return string|null
*/
public function getRoleByUser(User $user): ?string;
/**
* Returns a collection of all users.
*
@ -136,6 +130,13 @@ interface UserRepositoryInterface
*/
public function getRole(string $role): ?Role;
/**
* @param User $user
*
* @return string|null
*/
public function getRoleByUser(User $user): ?string;
/**
* Return basic user information.
*

View File

@ -58,10 +58,7 @@ class ZeroOrMore implements Rule
return true;
}
$res = bccomp('0', $value);
if ($res > 0) {
return false;
}
return true;
return !($res > 0);
}
}

View File

@ -62,7 +62,7 @@ class AccountDestroyService
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
// also update recurring transactions:
DB::table('recurrences_transactions')->where('source_id', $account->id)->update(['source_id' => $moveTo->id]);
DB::table('recurrences_transactions')->where('source_id', $account->id)->update(['source_id' => $moveTo->id]);
DB::table('recurrences_transactions')->where('destination_id', $account->id)->update(['destination_id' => $moveTo->id]);
}
$service = app(JournalDestroyService::class);

View File

@ -64,7 +64,7 @@ class EncryptService
throw new FireflyException($message);
}
$newName = sprintf('%s.upload', $key);
$disk = Storage::disk('upload');
$disk = Storage::disk('upload');
$disk->put($newName, $content);
}

View File

@ -222,7 +222,7 @@ trait AccountServiceTrait
/** @var AccountFactory $factory */
$factory = app(AccountFactory::class);
$factory->setUser($user);
return $factory->findOrCreate($opposingAccountName, AccountType::INITIAL_BALANCE);
}

View File

@ -23,10 +23,12 @@ declare(strict_types=1);
namespace FireflyIII\Services\Internal\Support;
use Exception;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Note;
use FireflyIII\Models\RuleAction;
use Illuminate\Support\Collection;
use Log;
/**
* Trait BillServiceTrait
@ -70,7 +72,11 @@ trait BillServiceTrait
if ('' === $note) {
$dbNote = $bill->notes()->first();
if (null !== $dbNote) {
$dbNote->delete(); // @codeCoverageIgnore
try {
$dbNote->delete();
} catch (Exception $e) {
Log::debug(sprintf('Error deleting note: %s', $e->getMessage()));
}
}
return true;

View File

@ -55,7 +55,7 @@ trait JournalServiceTrait
return; // @codeCoverageIgnore
}
foreach ($data['tags'] as $string) {
if (\strlen($string) > 0) {
if ('' != $string) {
$tag = $factory->findOrCreate($string);
if (null !== $tag) {
$set[] = $tag->id;
@ -116,7 +116,7 @@ trait JournalServiceTrait
protected function storeNote(TransactionJournal $journal, ?string $notes): void
{
$notes = (string)$notes;
if (\strlen($notes) > 0) {
if ('' !== $notes) {
$note = $journal->notes()->first();
if (null === $note) {
$note = new Note;

View File

@ -107,7 +107,7 @@ trait TransactionServiceTrait
return $repository->findByName($accountName, [AccountType::ASSET]);
}
// for revenue and expense:
if (\strlen($accountName) > 0) {
if ('' !== $accountName) {
/** @var AccountFactory $factory */
$factory = app(AccountFactory::class);
$factory->setUser($this->user);
@ -218,7 +218,7 @@ trait TransactionServiceTrait
return;
}
// enable currency if not enabled:
if(false === $currency->enabled) {
if (false === $currency->enabled) {
$currency->enabled = true;
$currency->save();
}

View File

@ -28,6 +28,7 @@ use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Services\Internal\Support\BillServiceTrait;
use Log;
/**
* @codeCoverageIgnore
* Class BillUpdateService
@ -59,7 +60,7 @@ class BillUpdateService
/** @var TransactionCurrency $currency */
$currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);
if(null === $currency) {
if (null === $currency) {
// use default currency:
$currency = app('amount')->getDefaultCurrencyByUser($bill->user);
}

View File

@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionType;
use FireflyIII\Services\Internal\Support\JournalServiceTrait;
use Illuminate\Support\Collection;
use Log;
/**
* Class to centralise code that updates a journal given the input by system.
*
@ -38,6 +39,7 @@ use Log;
class JournalUpdateService
{
use JournalServiceTrait;
/**
* Constructor.
*/
@ -159,6 +161,7 @@ class JournalUpdateService
foreach ($journal->transactions as $transaction) {
$service->updateBudget($transaction, $budgetId);
}
return $journal;
}
// clear budget.

View File

@ -27,6 +27,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Services\Internal\Support\TransactionServiceTrait;
use FireflyIII\User;
use Log;
/**
* Class TransactionUpdateService
*/
@ -34,6 +35,9 @@ class TransactionUpdateService
{
use TransactionServiceTrait;
/** @var User */
private $user;
/**
* Constructor.
*/
@ -44,9 +48,6 @@ class TransactionUpdateService
}
}
/** @var User */
private $user;
/**
* @param int $transactionId
*
@ -87,10 +88,10 @@ class TransactionUpdateService
*/
public function update(Transaction $transaction, array $data): Transaction
{
$currency = $this->findCurrency($data['currency_id'], $data['currency_code']);
$journal = $transaction->transactionJournal;
$amount = (string)$data['amount'];
$account = null;
$currency = $this->findCurrency($data['currency_id'], $data['currency_code']);
$journal = $transaction->transactionJournal;
$amount = (string)$data['amount'];
$account = null;
// update description:
$transaction->description = $data['description'];
$foreignAmount = null;

View File

@ -51,7 +51,7 @@ class CLIToken implements BinderInterface
foreach ($users as $user) {
$accessToken = app('preferences')->getForUser($user, 'access_token', null);
if(null !== $accessToken && $accessToken->data === $value) {
if (null !== $accessToken && $accessToken->data === $value) {
Log::info(sprintf('Recognized user #%d (%s) from his acccess token.', $user->id, $user->email));
return $value;

View File

@ -57,10 +57,10 @@ class TagList implements BinderInterface
$collection = $allTags->filter(
function (Tag $tag) use ($list) {
if(\in_array(strtolower($tag->tag), $list, true)) {
if (\in_array(strtolower($tag->tag), $list, true)) {
return true;
}
if(\in_array((string)$tag->id, $list, true)) {
if (\in_array((string)$tag->id, $list, true)) {
return true;
}

View File

@ -25,7 +25,6 @@ namespace FireflyIII\Support\Binder;
use FireflyIII\Models\Tag;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Illuminate\Routing\Route;
use Illuminate\Support\Collection;
use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -38,8 +37,7 @@ class TagOrId implements BinderInterface
* @param string $value
* @param Route $route
*
* @return Collection
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @return Tag
*/
public static function routeBinder(string $value, Route $route): Tag
{

View File

@ -584,8 +584,6 @@ class ExpandedForm
* @param array $options
*
* @return string
* @throws \FireflyIII\Exceptions\FireflyException
*
*/
public function nonSelectableAmount(string $name, $value = null, array $options = null): string
{
@ -914,6 +912,7 @@ class ExpandedForm
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param string $name
* @param string $view
@ -921,11 +920,9 @@ class ExpandedForm
* @param array $options
*
* @return string
* @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function currencyField(string $name, string $view, $value = null, array $options = null): string
protected function allCurrencyField(string $name, string $view, $value = null, array $options = null): string
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@ -934,7 +931,7 @@ class ExpandedForm
$options['step'] = 'any';
$defaultCurrency = $options['currency'] ?? Amt::getDefaultCurrency();
/** @var Collection $currencies */
$currencies = app('amount')->getCurrencies();
$currencies = app('amount')->getAllCurrencies();
unset($options['currency'], $options['placeholder']);
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)
@ -968,6 +965,7 @@ class ExpandedForm
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param string $name
* @param string $view
@ -975,11 +973,9 @@ class ExpandedForm
* @param array $options
*
* @return string
* @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function allCurrencyField(string $name, string $view, $value = null, array $options = null): string
protected function currencyField(string $name, string $view, $value = null, array $options = null): string
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
@ -988,7 +984,7 @@ class ExpandedForm
$options['step'] = 'any';
$defaultCurrency = $options['currency'] ?? Amt::getDefaultCurrency();
/** @var Collection $currencies */
$currencies = app('amount')->getAllCurrencies();
$currencies = app('amount')->getCurrencies();
unset($options['currency'], $options['placeholder']);
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)

View File

@ -74,7 +74,7 @@ class FinTS
* @return SEPAAccount
* @throws FireflyException
*/
public function getAccount(string $accountNumber)
public function getAccount(string $accountNumber): SEPAAccount
{
$accounts = $this->getAccounts();
$filteredAccounts = array_filter(
@ -93,7 +93,7 @@ class FinTS
* @return SEPAAccount[]
* @throws FireflyException
*/
public function getAccounts()
public function getAccounts(): ?array
{
try {
return $this->finTS->getSEPAAccounts();

View File

@ -80,10 +80,7 @@ trait AccountFilter
'cc' => [AccountType::CREDITCARD],
];
$return = $types['all'];
if (isset($types[$type])) {
$return = $types[$type];
}
$return = $types[$type] ?? $types['all'];
return $return; // @codeCoverageIgnore
}

View File

@ -58,10 +58,7 @@ trait TransactionFilter
'specials' => [TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION,],
'default' => [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER,],
];
$return = $types['default'];
if (isset($types[$type])) {
$return = $types[$type];
}
$return = $types[$type] ?? $types['default'];
return $return;

View File

@ -27,7 +27,6 @@ use Carbon\Carbon;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\Tag;
@ -38,8 +37,6 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use Log;
use Throwable;
/**
* Trait AugumentData

View File

@ -30,32 +30,6 @@ namespace FireflyIII\Support\Http\Controllers;
trait BasicDataSupport
{
/**
* Filters empty results from getBudgetPeriodReport.
*
* @param array $data
*
* @return array
*/
protected function filterPeriodReport(array $data): array // helper function for period overview.
{
/**
* @var int $entryId
* @var array $set
*/
foreach ($data as $entryId => $set) {
$sum = '0';
foreach ($set['entries'] as $amount) {
$sum = bcadd($amount, $sum);
}
$data[$entryId]['sum'] = $sum;
if (0 === bccomp('0', $sum)) {
unset($data[$entryId]);
}
}
return $data;
}
/**
* Sum up an array.
*
@ -73,6 +47,33 @@ trait BasicDataSupport
return $sum;
}
/**
* Filters empty results from getBudgetPeriodReport.
*
* @param array $data
*
* @return array
*/
protected function filterPeriodReport(array $data): array // helper function for period overview.
{
/**
* @var int $entryId
* @var array $set
*/
foreach ($data as $entryId => $set) {
$sum = '0';
foreach ($set['entries'] as $amount) {
$sum = bcadd($amount, $sum);
}
$data[$entryId]['sum'] = $sum;
if (0 === bccomp('0', $sum)) {
unset($data[$entryId]);
}
}
return $data;
}
/**
* Find the ID in a given array. Return '0' of not there (amount).
*
@ -83,10 +84,7 @@ trait BasicDataSupport
*/
protected function isInArray(array $array, int $entryId) // helper for data (math, calculations)
{
$result = '0';
if (isset($array[$entryId])) {
$result = $array[$entryId];
}
$result = $array[$entryId] ?? '0';
return $result;
}

View File

@ -51,10 +51,7 @@ trait GetConfigurationData
E_ALL & ~E_NOTICE & ~E_STRICT => 'E_ALL & ~E_NOTICE & ~E_STRICT',
E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR',
];
$result = (string)$value;
if (isset($array[$value])) {
$result = $array[$value];
}
$result = $array[$value] ?? (string)$value;
return $result;
}
@ -188,7 +185,7 @@ trait GetConfigurationData
$routeKey = '';
// user is on page with specific instructions:
if (\strlen($specificPage) > 0) {
if ('' !== $specificPage) {
$routeKey = str_replace('.', '_', $route);
$elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage));
if (\is_array($elements) && \count($elements) > 0) {

View File

@ -351,7 +351,9 @@ trait PeriodOverview
/**
* This shows a period overview for a tag. It goes back in time and lists all relevant transactions and sums.
*
* @param Tag $tag
* @param Tag $tag
*
* @param Carbon $date
*
* @return Collection
*/

View File

@ -305,8 +305,8 @@ trait RenderPartialViews
*/
protected function getCurrentTriggers(Rule $rule): array // get info from object and present.
{
$index = 0;
$triggers = [];
$index = 0;
$triggers = [];
// todo must be repos
$currentTriggers = $rule->ruleTriggers()->orderBy('order', 'ASC')->get();
/** @var RuleTrigger $entry */

View File

@ -54,44 +54,6 @@ use Symfony\Component\HttpFoundation\ParameterBag;
*/
trait RequestInformation
{
/**
* Get info from old input.
*
* @param $array
* @param $old
*
* @return array
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function updateWithPrevious($array, $old): array // update object with new info
{
if (0 === \count($old) || !isset($old['transactions'])) {
return $array;
}
$old = $old['transactions'];
foreach ($old as $index => $row) {
if (isset($array[$index])) {
/** @noinspection SlowArrayOperationsInLoopInspection */
$array[$index] = array_merge($array[$index], $row);
continue;
}
// take some info from first transaction, that should at least exist.
$array[$index] = $row;
$array[$index]['currency_id'] = $array[0]['currency_id'];
$array[$index]['currency_code'] = $array[0]['currency_code'] ?? '';
$array[$index]['currency_symbol'] = $array[0]['currency_symbol'] ?? '';
$array[$index]['foreign_amount'] = round($array[0]['foreign_destination_amount'] ?? '0', 12);
$array[$index]['foreign_currency_id'] = $array[0]['foreign_currency_id'];
$array[$index]['foreign_currency_code'] = $array[0]['foreign_currency_code'];
$array[$index]['foreign_currency_symbol'] = $array[0]['foreign_currency_symbol'];
}
return $array;
}
/**
* Create data-array from a journal.
*
@ -104,7 +66,7 @@ trait RequestInformation
protected function arrayFromJournal(Request $request, TransactionJournal $journal): array // convert user input.
{
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$repository = app(JournalRepositoryInterface::class);
$sourceAccounts = $repository->getJournalSourceAccounts($journal);
$destinationAccounts = $repository->getJournalDestinationAccounts($journal);
$array = [
@ -400,6 +362,44 @@ trait RequestInformation
return $attributes;
}
/**
* Get info from old input.
*
* @param $array
* @param $old
*
* @return array
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function updateWithPrevious($array, $old): array // update object with new info
{
if (0 === \count($old) || !isset($old['transactions'])) {
return $array;
}
$old = $old['transactions'];
foreach ($old as $index => $row) {
if (isset($array[$index])) {
/** @noinspection SlowArrayOperationsInLoopInspection */
$array[$index] = array_merge($array[$index], $row);
continue;
}
// take some info from first transaction, that should at least exist.
$array[$index] = $row;
$array[$index]['currency_id'] = $array[0]['currency_id'];
$array[$index]['currency_code'] = $array[0]['currency_code'] ?? '';
$array[$index]['currency_symbol'] = $array[0]['currency_symbol'] ?? '';
$array[$index]['foreign_amount'] = round($array[0]['foreign_destination_amount'] ?? '0', 12);
$array[$index]['foreign_currency_id'] = $array[0]['foreign_currency_id'];
$array[$index]['foreign_currency_code'] = $array[0]['foreign_currency_code'];
$array[$index]['foreign_currency_symbol'] = $array[0]['foreign_currency_symbol'];
}
return $array;
}
/**
* Validate users new password.
*

View File

@ -151,7 +151,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
{
foreach ($line as $column => $value) {
$value = trim($value);
if (\strlen($value) > 0) {
if ('' != $value) {
$this->examples[$column][] = $value;
}
}
@ -219,7 +219,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
try {
$stmt = (new Statement)->limit(1)->offset(0);
$records = $stmt->process($reader);
$headers = $records->fetchOne(0);
$headers = $records->fetchOne();
// @codeCoverageIgnoreStart
} catch (Exception $e) {
Log::error($e->getMessage());

View File

@ -78,7 +78,6 @@ class ChooseAccountHandler implements FinTSConfigurationInterface
* Get the data necessary to show the configuration screen.
*
* @return array
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function getNextData(): array
{

View File

@ -48,7 +48,6 @@ class NewFinTSJobHandler implements FinTSConfigurationInterface
* @param array $data
*
* @return MessageBag
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function configureJob(array $data): MessageBag
{

View File

@ -152,7 +152,7 @@ class NewYnabJobHandler implements YnabJobConfigurationInterface
$client = new Client();
try {
$res = $client->request('post', $uri, []);
$res = $client->request('post', $uri);
} catch (GuzzleException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());

View File

@ -88,7 +88,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface
// validate each
$ynabId = $this->validYnabAccount($ynabId);
$accountId = $this->validLocalAccount((int)$localId);
if ($accountId !== 0) {
if (0 !== $accountId) {
$final[$ynabId] = $accountId;
}
}

View File

@ -186,7 +186,7 @@ class ImportTransaction
}
$meta = ['sepa-ct-id', 'sepa-ct-op', 'sepa-db', 'sepa-cc', 'sepa-country', 'sepa-batch-id', 'sepa-ep', 'sepa-ci', 'internal-reference', 'date-interest',
'date-invoice', 'date-book', 'date-payment', 'date-process', 'date-due','original-source'];
'date-invoice', 'date-book', 'date-payment', 'date-process', 'date-due', 'original-source'];
Log::debug(sprintf('Now going to check role "%s".', $role));
if (\in_array($role, $meta, true)) {
Log::debug(sprintf('Role "%s" is in allowed meta roles, so store its value "%s".', $role, $columnValue->getValue()));

View File

@ -65,7 +65,9 @@ class PaymentConverter
/**
* Convert a bunq transaction to a usable transaction for Firefly III.
*
* @param BunqPayment $payment
* @param BunqPayment $payment
*
* @param LocalAccount $source
*
* @return array
* @throws FireflyException

View File

@ -39,6 +39,7 @@ class StageFinalHandler
/**
* @return array
* @throws \Exception
*/
public function getTransactions(): array
{

View File

@ -183,7 +183,7 @@ class MappingConverger
$value = trim($value);
$originalRole = $this->roles[$columnIndex] ?? '_ignore';
Log::debug(sprintf('Now at column #%d (%s), value "%s"', $columnIndex, $originalRole, $value));
if ('_ignore' !== $originalRole && \strlen($value) > 0) {
if ('_ignore' !== $originalRole && '' != $value) {
// is a mapped value present?
$mapped = $this->mapping[$columnIndex][$value] ?? 0;

View File

@ -66,13 +66,13 @@ class StageImportDataHandler
/**
* @throws FireflyException
*/
public function run()
public function run(): void
{
Log::debug('Now in StageImportDataHandler::run()');
$localAccount = $this->accountRepository->findNull((int)$this->importJob->configuration['local_account']);
if (null === $localAccount) {
throw new FireflyException(sprintf('Cannot find Firefly account with id #%d ' , $this->importJob->configuration['local_account']));
throw new FireflyException(sprintf('Cannot find Firefly account with id #%d ', $this->importJob->configuration['local_account']));
}
$finTS = app(FinTS::class, ['config' => $this->importJob->configuration]);
$fintTSAccount = $finTS->getAccount($this->importJob->configuration['fints_account']);
@ -143,8 +143,8 @@ class StageImportDataHandler
}
$metadataParser = new MetadataParser();
$description = $metadataParser->getDescription($transaction);
$description = $metadataParser->getDescription($transaction);
$storeData = [
'user' => $this->importJob->user_id,
'type' => $type,

View File

@ -233,8 +233,10 @@ class StageImportDataHandler
if (null === $account) {
throw new FireflyException(sprintf('Cannot find Firefly III asset account with ID #%d. Job must stop now.', $accountId)); // @codeCoverageIgnore
}
if (!\in_array($account->accountType->type ,[AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE, AccountType::DEBT], true)) {
throw new FireflyException(sprintf('Account with ID #%d is not an asset/loan/mortgage/debt account. Job must stop now.', $accountId)); // @codeCoverageIgnore
if (!\in_array($account->accountType->type, [AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE, AccountType::DEBT], true)) {
throw new FireflyException(
sprintf('Account with ID #%d is not an asset/loan/mortgage/debt account. Job must stop now.', $accountId)
); // @codeCoverageIgnore
}
return $account;

View File

@ -38,7 +38,7 @@ class AuditLogger
*/
public function __invoke($logger)
{
$processor = new AuditProcessor;
$processor = new AuditProcessor;
$logger->pushProcessor($processor);
}
}

View File

@ -184,6 +184,7 @@ trait CalculateRangeOccurrences
return $return;
}
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
*

View File

@ -76,10 +76,10 @@ trait CalculateXOccurrences
*/
protected function getXMonthlyOccurrences(Carbon $date, int $count, int $skipMod, string $moment): array
{
$return = [];
$mutator = clone $date;
$total = 0;
$attempts = 0;
$return = [];
$mutator = clone $date;
$total = 0;
$attempts = 0;
$dayOfMonth = (int)$moment;
if ($mutator->day > $dayOfMonth) {
// day has passed already, add a month.

View File

@ -99,7 +99,7 @@ class Search implements SearchInterface
$filteredQuery = str_replace($match, '', $filteredQuery);
}
$filteredQuery = trim(str_replace(['"', "'"], '', $filteredQuery));
if (\strlen($filteredQuery) > 0) {
if ('' != $filteredQuery) {
$this->words = array_map('trim', explode(' ', $filteredQuery));
}
}
@ -251,7 +251,7 @@ class Search implements SearchInterface
private function extractModifier(string $string): void
{
$parts = explode(':', $string);
if (2 === \count($parts) && '' !== trim((string)$parts[1]) && \strlen(trim((string)$parts[0])) > 0) {
if (2 === \count($parts) && '' !== trim((string)$parts[1]) && '' !== trim((string)$parts[0])) {
$type = trim((string)$parts[0]);
$value = trim((string)$parts[1]);
if (\in_array($type, $this->validModifiers, true)) {

View File

@ -23,12 +23,10 @@ declare(strict_types=1);
namespace FireflyIII\Support;
use Carbon\Carbon;
use Crypt;
use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Collection;
use stdClass;
@ -223,7 +221,7 @@ class Steam
* @param \FireflyIII\Models\Account $account
* @param \Carbon\Carbon $date
*
* @return string
* @return array
*/
public function balancePerCurrency(Account $account, Carbon $date): array
{

View File

@ -206,7 +206,7 @@ class Transaction extends Twig_Extension
public function description(TransactionModel $transaction): string
{
$description = $transaction->description;
if (\strlen((string)$transaction->transaction_description) > 0) {
if ('' !== (string)$transaction->transaction_description) {
$description = $transaction->transaction_description . ' (' . $transaction->description . ')';
}

View File

@ -158,8 +158,8 @@ class TransactionJournal extends Twig_Extension
if (null !== $transaction->foreign_currency_id) {
$foreignAmount = $transaction->foreign_amount ?? '0';
$foreignId = $transaction->foreign_currency_id;
$foreign = $transaction->foreignCurrency;
$foreignId = $transaction->foreign_currency_id;
$foreign = $transaction->foreignCurrency;
if (!isset($totals[$foreignId])) {
$totals[$foreignId] = [
'amount' => '0',

View File

@ -102,10 +102,12 @@ class ConvertToDeposit implements ActionInterface
if (TransactionType::WITHDRAWAL === $type) {
Log::debug('Going to transform a withdrawal to a deposit.');
return $this->convertWithdrawal($journal);
}
if (TransactionType::TRANSFER === $type) {
Log::debug('Going to transform a transfer to a deposit.');
return $this->convertTransfer($journal);
}
@ -133,7 +135,7 @@ class ConvertToDeposit implements ActionInterface
// get the action value, or use the original source name in case the action value is empty:
// this becomes a new or existing revenue account.
/** @var Account $source */
$source = $sourceTransactions->first()->account;
$source = $sourceTransactions->first()->account;
$revenueName = '' === $this->action->action_value ? $source->name : $this->action->action_value;
$revenue = $factory->findOrCreate($revenueName, AccountType::REVENUE);

View File

@ -62,22 +62,6 @@ class Processor
$this->actions = new Collection;
}
/**
* @return bool
*/
public function isStrict(): bool
{
return $this->strict;
}
/**
* @param bool $strict
*/
public function setStrict(bool $strict): void
{
$this->strict = $strict;
}
/**
* Return found triggers
*
@ -170,6 +154,22 @@ class Processor
return false;
}
/**
* @return bool
*/
public function isStrict(): bool
{
return $this->strict;
}
/**
* @param bool $strict
*/
public function setStrict(bool $strict): void
{
$this->strict = $strict;
}
/**
* This method will make a Processor that will process each transaction journal using the triggers
* and actions found in the given Rule.

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\TransactionRules;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Models\Rule;
@ -69,10 +68,8 @@ class TransactionMatcher
*/
public function __construct()
{
$this->strict = false;
$this->startDate = null;
$this->endDate = null;
$this->accounts = new Collection;
$this->strict = false;
$this->accounts = new Collection;
Log::debug('Created new transaction matcher');
}
@ -89,6 +86,7 @@ class TransactionMatcher
Log::debug('Now in findTransactionsByRule()');
if (0 === \count($this->rule->ruleTriggers)) {
Log::error('Rule has no triggers!');
return new Collection;
}
@ -290,7 +288,7 @@ class TransactionMatcher
if ($this->accounts->count() > 0) {
$collector->setAccounts($this->accounts);
}
if(null !== $this->startDate && null !== $this->endDate) {
if (null !== $this->startDate && null !== $this->endDate) {
$collector->setRange($this->startDate, $this->endDate);
}

View File

@ -68,7 +68,7 @@ final class NotesAny extends AbstractTrigger implements TriggerInterface
$text = $note->text;
}
if (\strlen($text) > 0) {
if ('' !== $text) {
Log::debug(sprintf('RuleTrigger NotesEmpty for journal #%d: strlen > 0, return true.', $journal->id));
return true;

View File

@ -75,7 +75,7 @@ final class NotesAre extends AbstractTrigger implements TriggerInterface
}
$search = strtolower($this->triggerValue);
if ($text === $search && \strlen($text) > 0) {
if ($text === $search && '' != $text) {
Log::debug(sprintf('RuleTrigger NotesAre for journal #%d: "%s" is "%s", return true.', $journal->id, $text, $search));
return true;

View File

@ -26,9 +26,7 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\Attachment;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use League\Fractal\TransformerAbstract;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class AttachmentTransformer
@ -67,7 +65,7 @@ class AttachmentTransformer extends AbstractTransformer
'created_at' => $attachment->created_at->toAtomString(),
'updated_at' => $attachment->updated_at->toAtomString(),
'attachable_id' => $attachment->attachable_id,
'attachable_type' => str_replace('FireflyIII\\Models\\','',$attachment->attachable_type),
'attachable_type' => str_replace('FireflyIII\\Models\\', '', $attachment->attachable_type),
'md5' => $attachment->md5,
'filename' => $attachment->filename,
'download_uri' => route('api.v1.attachments.download', [$attachment->id]),

View File

@ -86,7 +86,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
$end = $this->parameters->get('end');
if (null !== $start && null !== $end) {
$data['spent_in_budgets'] = $this->getSpentInBudgets();
$data['spent_no_budget'] = $this->spentOutsideBudgets();
$data['spent_no_budget'] = $this->spentOutsideBudgets();
}
return $data;
@ -98,6 +98,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
private function getSpentInBudgets(): array
{
$allActive = $this->repository->getActiveBudgets();
return $this->repository->spentInPeriodMc(
$allActive, new Collection, $this->parameters->get('start'), $this->parameters->get('end')
);
@ -109,7 +110,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
*/
private function spentOutsideBudgets(): array
{
return $this->repository->spentInPeriodWoBudgetMc(new Collection,$this->parameters->get('start'), $this->parameters->get('end'));
return $this->repository->spentInPeriodWoBudgetMc(new Collection, $this->parameters->get('start'), $this->parameters->get('end'));
}
}

View File

@ -24,9 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
use FireflyIII\Models\TransactionCurrency;
use League\Fractal\TransformerAbstract;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class CurrencyTransformer

View File

@ -25,9 +25,7 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\ImportJob;
use League\Fractal\TransformerAbstract;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class ImportJobTransformer
@ -56,11 +54,11 @@ class ImportJobTransformer extends AbstractTransformer
*/
public function transform(ImportJob $importJob): array
{
$tag= $importJob->tag;
$tagId = null;
$tag = $importJob->tag;
$tagId = null;
$tagTag = null;
if(null !== $tag) {
$tagId = $tag->id;
if (null !== $tag) {
$tagId = $tag->id;
$tagTag = $tag->tag;
}
$data = [
@ -79,7 +77,7 @@ class ImportJobTransformer extends AbstractTransformer
'transactions' => json_encode($importJob->transactions),
'errors' => json_encode($importJob->errors),
'links' => [
'links' => [
[
'rel' => 'self',
'uri' => '/import/' . $importJob->key,

View File

@ -25,9 +25,7 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\LinkType;
use League\Fractal\TransformerAbstract;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
*

View File

@ -25,9 +25,7 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\Preference;
use League\Fractal\TransformerAbstract;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class PreferenceTransformer

View File

@ -127,7 +127,6 @@ class RecurrenceTransformer extends AbstractTransformer
* @param Recurrence $recurrence
*
* @return array
* @throws FireflyException
*/
private function getMeta(Recurrence $recurrence): array
{
@ -211,7 +210,6 @@ class RecurrenceTransformer extends AbstractTransformer
* @param RecurrenceTransaction $transaction
*
* @return array
* @throws FireflyException
*/
private function getTransactionMeta(RecurrenceTransaction $transaction): array
{

View File

@ -24,9 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
use FireflyIII\Models\RuleGroup;
use League\Fractal\TransformerAbstract;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class RuleGroupTransformer

View File

@ -24,13 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Tag;
use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item;
use League\Fractal\TransformerAbstract;
use Log;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Class TagTransformer
@ -69,7 +64,7 @@ class TagTransformer extends AbstractTransformer
'date' => $date,
'description' => '' === $tag->description ? null : $tag->description,
'latitude' => null === $tag->latitude ? null : (float)$tag->latitude,
'longitude' => null === $tag->longitude? null : (float)$tag->longitude,
'longitude' => null === $tag->longitude ? null : (float)$tag->longitude,
'zoom_level' => null === $tag->zoomLevel ? null : (int)$tag->zoomLevel,
'links' => [
[

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Transformers;
use FireflyIII\Models\Role;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Log;
@ -36,6 +35,7 @@ class UserTransformer extends AbstractTransformer
{
/** @var UserRepositoryInterface */
private $repository;
/**
* UserTransformer constructor.
*

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Validation;
use Config;
use Crypt;
use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta;
@ -38,7 +37,6 @@ use FireflyIII\Services\Password\Verifier;
use FireflyIII\TransactionRules\Triggers\TriggerInterface;
use FireflyIII\User;
use Google2FA;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Collection;
use Illuminate\Validation\Validator;
@ -562,7 +560,6 @@ class FireflyValidator extends Validator
$type = $existingAccount->accountType;
$ignore = $existingAccount->id;
$value = $value;
/** @var Collection $set */
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();

View File

@ -114,7 +114,7 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$this->assertEquals('withdrawal', $result[0]['type']);
$this->assertEquals('2018-09-17', $result[0]['date']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals($importable->tags, $result[0]['tags']);
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
}
@ -177,7 +177,7 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$today = new Carbon();
$this->assertEquals('transfer', $result[0]['type']);
$this->assertEquals($today->format('Y-m-d'), $result[0]['date']);
$this->assertEquals($today->format('Y-m-d H:i:s'), $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals($euro->id, $result[0]['transactions'][0]['currency_id']);
}
@ -238,12 +238,12 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$this->assertEquals('deposit', $result[0]['type']);
$this->assertEquals('2018-09-17', $result[0]['date']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
$this->assertEquals($revenue->id, $result[0]['transactions'][0]['source_id']);
$this->assertEquals($asset->id, $result[0]['transactions'][0]['destination_id']);
$this->assertEquals('2018-01-02', $result[0]['book_date']);
$this->assertEquals('2018-01-02 00:00:00', $result[0]['book_date']);
}
@ -362,7 +362,7 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$this->assertEquals('transfer', $result[0]['type']);
$this->assertEquals('2018-09-17', $result[0]['date']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals(2, $result[0]['bill_id']); // will NOT be ignored.
$this->assertEquals($importable->billName, $result[0]['bill_name']);
@ -435,7 +435,7 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$this->assertEquals('transfer', $result[0]['type']);
$this->assertEquals('2018-09-17', $result[0]['date']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals(3, $result[0]['bill_id']);
$this->assertEquals($importable->billName, $result[0]['bill_name']);