Code cleanup [skip ci]

This commit is contained in:
James Cole 2018-06-06 21:23:00 +02:00
parent 20044427b4
commit 4a12d4d156
75 changed files with 319 additions and 341 deletions

View File

@ -26,8 +26,6 @@ namespace FireflyIII\Api\V1\Controllers;
use Carbon\Carbon;
use Carbon\Exceptions\InvalidDateException;
use FireflyConfig;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;

View File

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers;
use FireflyIII\Api\V1\Requests\BillRequest;
use FireflyIII\Api\V1\Requests\CurrencyRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency;
@ -178,7 +177,7 @@ class CurrencyController extends Controller
/**
* @param CurrencyRequest $request
* @param CurrencyRequest $request
* @param TransactionCurrency $currency
*
* @return JsonResponse

View File

@ -86,8 +86,8 @@ class BillRequest extends Request
break;
case 'PUT':
case 'PATCH':
$bill = $this->route()->parameter('bill');
$rules['name'] .= ',' . $bill->id;
$bill = $this->route()->parameter('bill');
$rules['name'] .= ',' . $bill->id;
break;
}

View File

@ -184,7 +184,7 @@ class UpgradeDatabase extends Command
]
);
}
if($bill->amount_max === $bill->amount_min) {
if ($bill->amount_max === $bill->amount_min) {
RuleTrigger::create(
[
'rule_id' => $rule->id,

View File

@ -164,7 +164,8 @@ class VerifyDatabase extends Command
if (isset($results[$key]) && $results[$key] !== $category) {
$this->error(
sprintf(
'Transaction #%d referred to the wrong category. Was category #%d but is fixed to be category #%d.', $obj->transaction_journal_id, $category, $results[$key]
'Transaction #%d referred to the wrong category. Was category #%d but is fixed to be category #%d.', $obj->transaction_journal_id,
$category, $results[$key]
)
);
DB::table('category_transaction')->where('id', $obj->ct_id)->update(['category_id' => $results[$key]]);
@ -184,14 +185,15 @@ class VerifyDatabase extends Command
->get(['transactions.id', 'transaction_journal_id', 'identifier', 'budget_transaction.budget_id', 'budget_transaction.id as ct_id']);
$results = [];
foreach ($set as $obj) {
$key = $obj->transaction_journal_id . '-' . $obj->identifier;
$key = $obj->transaction_journal_id . '-' . $obj->identifier;
$budget = (int)$obj->budget_id;
// value exists and is not budget:
if (isset($results[$key]) && $results[$key] !== $budget) {
$this->error(
sprintf(
'Transaction #%d referred to the wrong budget. Was budget #%d but is fixed to be budget #%d.', $obj->transaction_journal_id, $budget, $results[$key]
'Transaction #%d referred to the wrong budget. Was budget #%d but is fixed to be budget #%d.', $obj->transaction_journal_id, $budget,
$results[$key]
)
);
DB::table('budget_transaction')->where('id', $obj->ct_id)->update(['budget_id' => $results[$key]]);

View File

@ -132,20 +132,20 @@ class Handler extends ExceptionHandler
$doMailError = env('SEND_ERROR_MESSAGE', true);
if (
// if the user wants us to mail:
$doMailError === true &&
((
// and if is one of these error instances
$exception instanceof FireflyException
|| $exception instanceof ErrorException
|| $exception instanceof OAuthServerException
$doMailError === true
&& ((
// and if is one of these error instances
$exception instanceof FireflyException
|| $exception instanceof ErrorException
|| $exception instanceof OAuthServerException
)
|| (
// or this one, but it's a JSON exception.
$exception instanceof AuthenticationException
&& Request::expectsJson() === true
))
) {
)
|| (
// or this one, but it's a JSON exception.
$exception instanceof AuthenticationException
&& Request::expectsJson() === true
))
) {
// then, send email
$userData = [
'id' => 0,

View File

@ -36,12 +36,12 @@ use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\ExportJob;
use FireflyIII\Models\Note;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Storage;
use ZipArchive;
use FireflyIII\Models\TransactionJournal;
/**
* Class ExpandedProcessor.

View File

@ -71,6 +71,7 @@ class TransactionCurrencyFactory
if ('' === $currencyCode && $currencyId === 0) {
Log::warning('Cannot find anything on empty currency code and empty currency ID!');
return null;
}

View File

@ -97,12 +97,12 @@ class TransactionFactory
$description = $journal->description === $data['description'] ? null : $data['description'];
// type of source account depends on journal type:
$sourceType = $this->accountType($journal, 'source');
$sourceType = $this->accountType($journal, 'source');
Log::debug(sprintf('Expect source account to be of type %s', $sourceType));
$sourceAccount = $this->findAccount($sourceType, $data['source_id'], $data['source_name']);
// same for destination account:
$destinationType = $this->accountType($journal, 'destination');
$destinationType = $this->accountType($journal, 'destination');
Log::debug(sprintf('Expect source destination to be of type %s', $destinationType));
$destinationAccount = $this->findAccount($destinationType, $data['destination_id'], $data['destination_name']);
// first make a "negative" (source) transaction based on the data in the array.

View File

@ -28,7 +28,6 @@ use Exception;
use FireflyIII\Mail\AccessTokenCreatedMail;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Laravel\Passport\Events\AccessTokenCreated;
use Laravel\Passport\Token;
use Log;
use Mail;
use Request;

View File

@ -37,14 +37,14 @@ interface AttachmentHelperInterface
*
* @return string
*/
public function getAttachmentLocation(Attachment $attachment): string;
public function getAttachmentContent(Attachment $attachment): string;
/**
* @param Attachment $attachment
*
* @return string
*/
public function getAttachmentContent(Attachment $attachment): string;
public function getAttachmentLocation(Attachment $attachment): string;
/**
* @return Collection

View File

@ -96,7 +96,7 @@ class BudgetController extends Controller
// if today is between start and end, use the diff in days between end and today (days left)
// otherwise, use diff between start and end.
$today = new Carbon;
Log::debug(sprintf('Start is %s, end is %s, today is %s', $start->format('Y-m-d'), $end->format('Y-m-d'),$today->format('Y-m-d')));
Log::debug(sprintf('Start is %s, end is %s, today is %s', $start->format('Y-m-d'), $end->format('Y-m-d'), $today->format('Y-m-d')));
if ($today->gte($start) && $today->lte($end)) {
$days = $end->diffInDays($today);
$daysInMonth = $start->diffInDays($today);

View File

@ -111,10 +111,12 @@ class DebugController extends Controller
return view(
'debug', compact(
'phpVersion', 'extensions', 'localeAttempts', 'appEnv', 'appDebug', 'appLog', 'appLogLevel', 'now', 'packages', 'drivers', 'currentDriver',
'userAgent', 'displayErrors', 'errorReporting', 'phpOs', 'interface', 'logContent', 'cacheDriver', 'isDocker', 'isSandstorm', 'trustedProxies',
'toSandbox'
)
'phpVersion', 'extensions', 'localeAttempts', 'appEnv', 'appDebug', 'appLog', 'appLogLevel', 'now', 'packages', 'drivers',
'currentDriver',
'userAgent', 'displayErrors', 'errorReporting', 'phpOs', 'interface', 'logContent', 'cacheDriver', 'isDocker', 'isSandstorm',
'trustedProxies',
'toSandbox'
)
);
}

View File

@ -23,13 +23,11 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use ExpandedForm;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Requests\RuleFormRequest;
use FireflyIII\Http\Requests\SelectTransactionsRequest;
use FireflyIII\Http\Requests\TestRuleFormRequest;
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleAction;
@ -331,11 +329,11 @@ class RuleController extends Controller
public function selectTransactions(Rule $rule)
{
// does the user have shared accounts?
$first = session('first')->format('Y-m-d');
$today = Carbon::create()->format('Y-m-d');
$subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);
$first = session('first')->format('Y-m-d');
$today = Carbon::create()->format('Y-m-d');
$subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);
return view('rules.rule.select-transactions', compact( 'first', 'today', 'rule', 'subTitle'));
return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));
}
/**
@ -429,6 +427,7 @@ class RuleController extends Controller
Log::error(sprintf('Could not render view in testTriggers(): %s', $exception->getMessage()));
Log::error($exception->getTraceAsString());
}
// @codeCoverageIgnoreEnd
return response()->json(['html' => $view, 'warning' => $warning]);
@ -490,6 +489,7 @@ class RuleController extends Controller
Log::error(sprintf('Could not render view in testTriggersByRule(): %s', $exception->getMessage()));
Log::error($exception->getTraceAsString());
}
// @codeCoverageIgnoreEnd
return response()->json(['html' => $view, 'warning' => $warning]);
@ -600,6 +600,7 @@ class RuleController extends Controller
Log::error(sprintf('Throwable was thrown in getActionsForBill(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
}
// @codeCoverageIgnoreEnd
return $actions;
@ -809,6 +810,7 @@ class RuleController extends Controller
Log::debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage()));
Log::debug($e->getTraceAsString());
}
// @codeCoverageIgnoreEnd
return $triggers;

View File

@ -87,7 +87,7 @@ class BulkController extends Controller
/**
* @param BulkEditJournalRequest $request
* @param BulkEditJournalRequest $request
*
* @return mixed
*/

View File

@ -98,8 +98,9 @@ class ConvertController extends Controller
return view(
'transactions.convert', compact(
'sourceType', 'destinationType', 'journal', 'positiveAmount', 'sourceAccount', 'destinationAccount', 'sourceType', 'subTitle', 'subTitleIcon'
)
'sourceType', 'destinationType', 'journal', 'positiveAmount', 'sourceAccount', 'destinationAccount', 'sourceType',
'subTitle', 'subTitleIcon'
)
);
}

View File

@ -24,7 +24,6 @@ namespace FireflyIII\Http\Controllers\Transaction;
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Filter\NegativeAmountFilter;
use FireflyIII\Helpers\Filter\TransactionViewFilter;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\MassDeleteJournalRequest;
@ -37,10 +36,9 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Transformers\TransactionTransformer;
use Illuminate\Support\Collection;
use Illuminate\View\View as IlluminateView;
use Preferences;
use Symfony\Component\HttpFoundation\ParameterBag;
use View;
use Illuminate\View\View as IlluminateView;
/**
* Class MassController.
@ -155,10 +153,11 @@ class MassController extends Controller
// transform to array
$transactions = $collection->map(
function (Transaction $transaction) use ($transformer) {
$transaction= $transformer->transform($transaction);
$transaction = $transformer->transform($transaction);
// make sure amount is positive:
$transaction['amount'] = app('steam')->positive((string)$transaction['amount']);
$transaction['amount'] = app('steam')->positive((string)$transaction['amount']);
$transaction['foreign_amount'] = app('steam')->positive((string)$transaction['foreign_amount']);
return $transaction;
}
);

View File

@ -62,12 +62,12 @@ class PiggyBankFormRequest extends Request
}
$rules = [
'name' => $nameRule,
'account_id' => 'required|belongsToUser:accounts',
'targetamount' => 'required|numeric|more:0',
'startdate' => 'date',
'targetdate' => 'date|nullable',
'order' => 'integer|min:1',
'name' => $nameRule,
'account_id' => 'required|belongsToUser:accounts',
'targetamount' => 'required|numeric|more:0',
'startdate' => 'date',
'targetdate' => 'date|nullable',
'order' => 'integer|min:1',
];
return $rules;

View File

@ -109,23 +109,23 @@ class SplitJournalFormRequest extends Request
public function rules(): array
{
return [
'what' => 'required|in:withdrawal,deposit,transfer',
'journal_description' => 'required|between:1,255',
'id' => 'numeric|belongsToUser:transaction_journals,id',
'journal_source_account_id' => 'numeric|belongsToUser:accounts,id',
'journal_source_account_name.*' => 'between:1,255',
'journal_currency_id' => 'required|exists:transaction_currencies,id',
'date' => 'required|date',
'interest_date' => 'date|nullable',
'book_date' => 'date|nullable',
'process_date' => 'date|nullable',
'transactions.*.transaction_description' => 'required|between:1,255',
'transactions.*.destination_account_id' => 'numeric|belongsToUser:accounts,id',
'transactions.*.destination_name' => 'between:1,255|nullable',
'transactions.*.amount' => 'required|numeric',
'transactions.*.budget_id' => 'belongsToUser:budgets,id',
'transactions.*.category_name' => 'between:1,255|nullable',
'transactions.*.piggy_bank_id' => 'between:1,255|nullable',
'what' => 'required|in:withdrawal,deposit,transfer',
'journal_description' => 'required|between:1,255',
'id' => 'numeric|belongsToUser:transaction_journals,id',
'journal_source_account_id' => 'numeric|belongsToUser:accounts,id',
'journal_source_account_name.*' => 'between:1,255',
'journal_currency_id' => 'required|exists:transaction_currencies,id',
'date' => 'required|date',
'interest_date' => 'date|nullable',
'book_date' => 'date|nullable',
'process_date' => 'date|nullable',
'transactions.*.transaction_description' => 'required|between:1,255',
'transactions.*.destination_account_id' => 'numeric|belongsToUser:accounts,id',
'transactions.*.destination_name' => 'between:1,255|nullable',
'transactions.*.amount' => 'required|numeric',
'transactions.*.budget_id' => 'belongsToUser:budgets,id',
'transactions.*.category_name' => 'between:1,255|nullable',
'transactions.*.piggy_bank_id' => 'between:1,255|nullable',
];
}

View File

@ -44,7 +44,7 @@ class RabobankDebitCredit implements ConverterInterface
return -1;
}
// old format:
if('A' === $value) {
if ('A' === $value) {
Log::debug('Return -1');
return -1;

View File

@ -106,6 +106,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
/**
* Return the data required for the next step in the job configuration.
*
* @codeCoverageIgnore
* @return array
*/
@ -144,6 +145,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
if (strtolower($album) !== 'station to station' && $this->importJob->stage !== 'new') {
return 'import.fake.enter-album';
}
return 'impossible-view'; // @codeCoverageIgnore
}
@ -152,7 +154,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
*/
public function setImportJob(ImportJob $importJob): void
{
$this->importJob = $importJob;
$this->importJob = $importJob;
$this->repository = app(ImportJobRepositoryInterface::class);
$this->repository->setUser($importJob->user);
}

View File

@ -28,10 +28,10 @@ namespace FireflyIII\Import\JobConfiguration;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Support\Import\JobConfiguration\File\FileConfigurationInterface;
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureMappingHandler;
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureRolesHandler;
use FireflyIII\Support\Import\JobConfiguration\File\ConfigureUploadHandler;
use FireflyIII\Support\Import\JobConfiguration\File\FileConfigurationInterface;
use FireflyIII\Support\Import\JobConfiguration\File\NewFileJobHandler;
use Illuminate\Support\MessageBag;
@ -120,7 +120,7 @@ class FileJobConfiguration implements JobConfigurationInterface
*/
public function setImportJob(ImportJob $importJob): void
{
$this->importJob = $importJob;
$this->importJob = $importJob;
$this->repository = app(ImportJobRepositoryInterface::class);
$this->repository->setUser($importJob->user);
}

View File

@ -119,7 +119,7 @@ class BunqPrerequisites implements PrerequisitesInterface
try {
/** @var ApiContext $object */
$object = app(ApiContext::class);
$object = app(ApiContext::class);
$apiContext = $object->create($environment, $apiKey, $deviceDescription, $permittedIps);
} catch (FireflyException $e) {
$messages = new MessageBag();

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Import\Prerequisites;
use FireflyIII\User;
use Illuminate\Http\Request;
use Illuminate\Support\MessageBag;
/**

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Import\Prerequisites;
use FireflyIII\User;
use Illuminate\Http\Request;
use Illuminate\Support\MessageBag;
/**

View File

@ -25,8 +25,8 @@ namespace FireflyIII\Import\Routine;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler;
use FireflyIII\Support\Import\Routine\Spectre\StageAuthenticatedHandler;
use FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler;
use FireflyIII\Support\Import\Routine\Spectre\StageNewHandler;
use Log;

View File

@ -215,7 +215,7 @@ class ImportArrayStorage
$collector = app(JournalCollectorInterface::class);
$collector->setUser($this->importJob->user);
$collector->setAllAssetAccounts()
->ignoreCache()
->ignoreCache()
->setTypes([TransactionType::TRANSFER])
->withOpposingAccount();
$collector->removeFilter(InternalTransferFilter::class);

View File

@ -38,9 +38,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Account.
*
* @property int $id
* @property string $name
* @property string $iban
* @property int $id
* @property string $name
* @property string $iban
* @property AccountType $accountType
*/
class Account extends Model

View File

@ -24,7 +24,6 @@ namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use FireflyIII\Models\Account;
/**
* Class AccountMeta.

View File

@ -24,10 +24,10 @@ namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use FireflyIII\Models\Account;
/**
* Class AccountType.
*
* @property string $type
*
*/

View File

@ -23,12 +23,12 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\User;
/**
* Class Attachment.

View File

@ -22,11 +22,10 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use FireflyIII\User;
use FireflyIII\Models\TransactionCurrency;
/**
* Class AvailableBudget.

View File

@ -23,14 +23,11 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\User;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\BudgetLimit;
/**
* Class Budget.

View File

@ -24,7 +24,6 @@ namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Models\Budget;
/**
* Class BudgetLimit.

View File

@ -23,13 +23,11 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\User;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
/**
* Class Category.

View File

@ -29,10 +29,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Steam;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Models\PiggyBankRepetition;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\Note;
use FireflyIII\Models\Account;
/**
* Class PiggyBank.

View File

@ -23,8 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\PiggyBank;
/**
* Class PiggyBankEvent.

View File

@ -25,10 +25,10 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use FireflyIII\Models\PiggyBank;
/**
* Class PiggyBankRepetition.
*
* @property string $currentamount
*/
class PiggyBankRepetition extends Model

View File

@ -25,15 +25,15 @@ namespace FireflyIII\Models;
use Crypt;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Model;
use Log;
use FireflyIII\User;
/**
* Class Preference.
*
* @property mixed $data
* @property mixed $data
* @property string $name
*/
class Preference extends Model

View File

@ -22,9 +22,9 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use FireflyIII\User;
/**
* Class Role.

View File

@ -22,18 +22,16 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\User;
use FireflyIII\Models\RuleTrigger;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\RuleAction;
/**
* Class Rule.
* @property bool $stop_processing
* @property int $id
*
* @property bool $stop_processing
* @property int $id
* @property \Illuminate\Support\Collection $ruleTriggers
*/
class Rule extends Model
@ -56,7 +54,7 @@ class Rule extends Model
'strict' => 'boolean',
];
/** @var array */
protected $fillable = ['rule_group_id', 'order', 'active', 'title', 'description', 'user_id','strict'];
protected $fillable = ['rule_group_id', 'order', 'active', 'title', 'description', 'user_id', 'strict'];
/**
* @param string $value

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use FireflyIII\Models\Rule;
/**
* Class RuleAction.

View File

@ -22,14 +22,14 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\User;
use FireflyIII\Models\Rule;
/**
* Class RuleGroup.
*
* @property bool $active
*/
class RuleGroup extends Model

View File

@ -23,19 +23,18 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\User;
use FireflyIII\Models\TransactionJournal;
/**
* Class Tag.
*
* @property Collection $transactionJournals
* @property string $tag
* @property int $id
* @property Collection $transactionJournals
* @property string $tag
* @property int $id
* @property \Carbon\Carbon $date
*/
class Tag extends Model

View File

@ -71,7 +71,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $description
* @property bool $is_split
* @property int $attachmentCount
* @property int $transaction_currency_id
* @property int $transaction_currency_id
*/
class Transaction extends Model
{

View File

@ -25,13 +25,12 @@ namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Models\TransactionJournal;
/**
* Class TransactionCurrency.
*
* @property string $code
* @property int $decimal_places
* @property int $decimal_places
*
*/
class TransactionCurrency extends Model

View File

@ -35,23 +35,12 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Log;
use Preferences;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\Models\TransactionJournalMeta;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\Tag;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\Note;
use FireflyIII\Models\Category;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Attachment;
/**
* Class TransactionJournal.
*
* @property User $user
* @property int $bill_id
* @property int $bill_id
*/
class TransactionJournal extends Model
{

View File

@ -25,12 +25,12 @@ namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use FireflyIII\Models\TransactionJournal;
/**
* Class TransactionJournalMeta.
*
* @property string $name
* @property int $transaction_journal_id
* @property int $transaction_journal_id
*/
class TransactionJournalMeta extends Model
{

View File

@ -25,10 +25,10 @@ namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Models\TransactionJournal;
/**
* Class TransactionType.
*
* @property string $type
*/
class TransactionType extends Model

View File

@ -58,6 +58,7 @@ trait FindAccountsTrait
/**
* @param string $number
* @param array $types
*
* @return Account|null
*/
public function findByAccountNumber(string $number, array $types): ?Account

View File

@ -35,15 +35,6 @@ use Illuminate\Support\Collection;
interface BudgetRepositoryInterface
{
/**
* Get all budgets with these ID's.
*
* @param array $budgetIds
*
* @return Collection
*/
public function getByIds(array $budgetIds): Collection;
/**
* A method that returns the amount of money budgeted per day for this budget,
* on average.
@ -174,6 +165,15 @@ interface BudgetRepositoryInterface
*/
public function getBudgets(): Collection;
/**
* Get all budgets with these ID's.
*
* @param array $budgetIds
*
* @return Collection
*/
public function getByIds(array $budgetIds): Collection;
/**
* @return Collection
*/

View File

@ -360,6 +360,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
$newConfig = array_merge($currentConfig, $configuration);
$job->configuration = $newConfig;
$job->save();
//Log::debug(sprintf('Set config of job "%s" to: ', $job->key), $newConfig);
return $job;

View File

@ -36,52 +36,13 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
interface ImportJobRepositoryInterface
{
/**
* Return all attachments for job.
*
* @param ImportJob $job
*
* @return Collection
*/
public function getAttachments(ImportJob $job): Collection;
/**
* Handle upload for job.
*
* @param ImportJob $job
* @param string $name
* @param UploadedFile $file
*
* @return MessageBag
* @throws FireflyException
*/
public function storeFileUpload(ImportJob $job, string $name, UploadedFile $file): MessageBag;
/**
* Store file.
*
* @param ImportJob $job
* @param string $name
* @param string $fileName
*
* @return MessageBag
*/
public function storeCLIUpload(ImportJob $job, string $name, string $fileName): MessageBag;
/**
* @param ImportJob $job
* @param array $transactions
* @param int $index
* @param string $error
*
* @return ImportJob
*/
public function setTransactions(ImportJob $job, array $transactions): ImportJob;
/**
* @param ImportJob $job
* @param Tag $tag
*
* @return ImportJob
*/
public function setTag(ImportJob $job, Tag $tag): ImportJob;
public function addError(ImportJob $job, int $index, string $error): ImportJob;
/**
* Add message to job.
@ -93,15 +54,6 @@ interface ImportJobRepositoryInterface
*/
public function addErrorMessage(ImportJob $job, string $error): ImportJob;
/**
* @param ImportJob $job
* @param int $index
* @param string $error
*
* @return ImportJob
*/
public function addError(ImportJob $job, int $index, string $error): ImportJob;
/**
* @param ImportJob $job
* @param int $steps
@ -141,6 +93,15 @@ interface ImportJobRepositoryInterface
*/
public function findByKey(string $key): ImportJob;
/**
* Return all attachments for job.
*
* @param ImportJob $job
*
* @return Collection
*/
public function getAttachments(ImportJob $job): Collection;
/**
* Return configuration of job.
*
@ -198,14 +159,6 @@ interface ImportJobRepositoryInterface
*/
public function setExtendedStatus(ImportJob $job, array $array): ImportJob;
/**
* @param ImportJob $job
* @param string $status
*
* @return ImportJob
*/
public function setStatus(ImportJob $job, string $status): ImportJob;
/**
* @param ImportJob $job
* @param string $stage
@ -214,6 +167,14 @@ interface ImportJobRepositoryInterface
*/
public function setStage(ImportJob $job, string $stage): ImportJob;
/**
* @param ImportJob $job
* @param string $status
*
* @return ImportJob
*/
public function setStatus(ImportJob $job, string $status): ImportJob;
/**
* @param ImportJob $job
* @param int $steps
@ -222,6 +183,14 @@ interface ImportJobRepositoryInterface
*/
public function setStepsDone(ImportJob $job, int $steps): ImportJob;
/**
* @param ImportJob $job
* @param Tag $tag
*
* @return ImportJob
*/
public function setTag(ImportJob $job, Tag $tag): ImportJob;
/**
* @param ImportJob $job
* @param int $count
@ -230,11 +199,42 @@ interface ImportJobRepositoryInterface
*/
public function setTotalSteps(ImportJob $job, int $count): ImportJob;
/**
* @param ImportJob $job
* @param array $transactions
*
* @return ImportJob
*/
public function setTransactions(ImportJob $job, array $transactions): ImportJob;
/**
* @param User $user
*/
public function setUser(User $user);
/**
* Store file.
*
* @param ImportJob $job
* @param string $name
* @param string $fileName
*
* @return MessageBag
*/
public function storeCLIUpload(ImportJob $job, string $name, string $fileName): MessageBag;
/**
* Handle upload for job.
*
* @param ImportJob $job
* @param string $name
* @param UploadedFile $file
*
* @return MessageBag
* @throws FireflyException
*/
public function storeFileUpload(ImportJob $job, string $name, UploadedFile $file): MessageBag;
/**
* @param ImportJob $job
* @param string $status

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
use Carbon\Carbon;
use DB;
use Exception;
use FireflyIII\Factory\TransactionJournalFactory;
use FireflyIII\Factory\TransactionJournalMetaFactory;

View File

@ -38,15 +38,6 @@ use Illuminate\Support\MessageBag;
*/
interface JournalRepositoryInterface
{
/**
* Find a journal by its hash.
*
* @param string $hash
*
* @return TransactionJournalMeta|null
*/
public function findByHash(string $hash): ?TransactionJournalMeta;
/**
* @param TransactionJournal $journal
* @param TransactionType $type
@ -77,12 +68,22 @@ interface JournalRepositoryInterface
* Find a specific journal.
*
* @param int $journalId
*
* @deprecated
*
* @return TransactionJournal
*/
public function find(int $journalId): TransactionJournal;
/**
* Find a journal by its hash.
*
* @param string $hash
*
* @return TransactionJournalMeta|null
*/
public function findByHash(string $hash): ?TransactionJournalMeta;
/**
* Find a specific journal.
*

View File

@ -334,8 +334,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
public function getSuggestedMonthlyAmount(PiggyBank $piggyBank): string
{
$savePerMonth = '0';
$repetition = $this->getRepetition($piggyBank);
if(null === $repetition) {
$repetition = $this->getRepetition($piggyBank);
if (null === $repetition) {
return $savePerMonth;
}
if (null !== $piggyBank->targetdate && $repetition->currentamount < $piggyBank->targetamount) {

View File

@ -136,6 +136,16 @@ class TagRepository implements TagRepositoryInterface
return new Tag;
}
/**
* @param int $tagId
*
* @return Tag|null
*/
public function findNull(int $tagId): ?Tag
{
return $this->user->tags()->find($tagId);
}
/**
* @param Tag $tag
*
@ -192,6 +202,16 @@ class TagRepository implements TagRepositoryInterface
return new Carbon;
}
/**
* Will return the newest tag (if known) or NULL.
*
* @return Tag|null
*/
public function newestTag(): ?Tag
{
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'DESC')->first();
}
/**
* @return Tag
*/
@ -453,23 +473,4 @@ class TagRepository implements TagRepositoryInterface
return (int)($range[0] + $extra);
}
/**
* @param int $tagId
*
* @return Tag|null
*/
public function findNull(int $tagId): ?Tag
{
return $this->user->tags()->find($tagId);
}
/**
* Will return the newest tag (if known) or NULL.
*
* @return Tag|null
*/
public function newestTag(): ?Tag
{
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'DESC')->first();
}}
}

View File

@ -69,12 +69,6 @@ interface TagRepositoryInterface
/**
* @param int $tagId
*
* @return Tag|null
*/
public function findNull(int $tagId): ?Tag;
/**
* @param int $tagId
* @deprecated
* @return Tag
*/
@ -87,6 +81,13 @@ interface TagRepositoryInterface
*/
public function findByTag(string $tag): Tag;
/**
* @param int $tagId
*
* @return Tag|null
*/
public function findNull(int $tagId): ?Tag;
/**
* @param Tag $tag
*
@ -117,15 +118,18 @@ interface TagRepositoryInterface
/**
* Will return the newest tag (if known) or NULL.
*
* @return Tag|null
*/
public function newestTag(): ?Tag;
/**
* Will return the newest tag (if known) or NULL.
*
* @return Tag|null
*/
public function oldestTag(): ?Tag;
/**
* Will return the newest tag (if known) or NULL.
* @return Tag|null
*/
public function newestTag(): ?Tag;
/**
* @param User $user
*/

View File

@ -87,9 +87,9 @@ class Attempt extends SpectreObject
private $successAt;
/** @var Carbon */
private $toDate;
/** @var Carbon */
/** @var Carbon */
private $updatedAt; // undocumented
/** @var string */
/** @var string */
private $userAgent;
/**

View File

@ -28,7 +28,6 @@ use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Routing\Route;
use Illuminate\Support\Collection;
use Session;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
@ -58,7 +57,7 @@ class SimpleJournalList implements BinderInterface
// prep some vars
$messages = [];
$final = new Collection;
$final = new Collection;
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);

View File

@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Support\Import\JobConfiguration\Bunq;
use FireflyIII\Models\ImportJob;
use Illuminate\Support\MessageBag;

View File

@ -35,61 +35,12 @@ use Log;
*/
class ConfigureUploadHandler implements FileConfigurationInterface
{
/** @var ImportJob */
private $importJob;
/** @var ImportJobRepositoryInterface */
private $repository;
/** @var AccountRepositoryInterface */
private $accountRepos;
/**
* Get the data necessary to show the configuration screen.
*
* @return array
*/
public function getNextData(): array
{
$delimiters = [
',' => trans('form.csv_comma'),
';' => trans('form.csv_semicolon'),
'tab' => trans('form.csv_tab'),
];
$config = $this->importJob->configuration;
$config['date-format'] = $config['date-format'] ?? 'Ymd';
$specifics = [];
$this->repository->setConfiguration($this->importJob, $config);
// collect specifics.
foreach (config('csv.import_specifics') as $name => $className) {
$specifics[$name] = [
'name' => trans($className::getName()),
'description' => trans($className::getDescription()),
];
}
$data = [
'accounts' => [],
'delimiters' => $delimiters,
'specifics' => $specifics,
];
return $data;
}
/**
* @param ImportJob $importJob
*/
public function setImportJob(ImportJob $importJob): void
{
$this->importJob = $importJob;
$this->repository = app(ImportJobRepositoryInterface::class);
$this->repository->setUser($importJob->user);
$this->accountRepos = app(AccountRepositoryInterface::class);
$this->accountRepos->setUser($importJob->user);
}
/** @var ImportJob */
private $importJob;
/** @var ImportJobRepositoryInterface */
private $repository;
/**
* Store data associated with current stage.
@ -137,6 +88,40 @@ class ConfigureUploadHandler implements FileConfigurationInterface
return new MessageBag;
}
/**
* Get the data necessary to show the configuration screen.
*
* @return array
*/
public function getNextData(): array
{
$delimiters = [
',' => trans('form.csv_comma'),
';' => trans('form.csv_semicolon'),
'tab' => trans('form.csv_tab'),
];
$config = $this->importJob->configuration;
$config['date-format'] = $config['date-format'] ?? 'Ymd';
$specifics = [];
$this->repository->setConfiguration($this->importJob, $config);
// collect specifics.
foreach (config('csv.import_specifics') as $name => $className) {
$specifics[$name] = [
'name' => trans($className::getName()),
'description' => trans($className::getDescription()),
];
}
$data = [
'accounts' => [],
'delimiters' => $delimiters,
'specifics' => $specifics,
];
return $data;
}
/**
* @param array $data
*
@ -159,4 +144,17 @@ class ConfigureUploadHandler implements FileConfigurationInterface
return $return;
}
/**
* @param ImportJob $importJob
*/
public function setImportJob(ImportJob $importJob): void
{
$this->importJob = $importJob;
$this->repository = app(ImportJobRepositoryInterface::class);
$this->repository->setUser($importJob->user);
$this->accountRepos = app(AccountRepositoryInterface::class);
$this->accountRepos->setUser($importJob->user);
}
}

View File

@ -80,6 +80,7 @@ class NewFileJobHandler implements FileConfigurationInterface
/**
*
* Get the data necessary to show the configuration screen.
*
* @codeCoverageIgnore
* @return array
*/

View File

@ -26,12 +26,7 @@ namespace FireflyIII\Support\Import\JobConfiguration\Spectre;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Services\Spectre\Object\Customer;
use FireflyIII\Services\Spectre\Object\Login;
use FireflyIII\Services\Spectre\Object\Token;
use FireflyIII\Services\Spectre\Request\CreateTokenRequest;
use FireflyIII\Services\Spectre\Request\ListCustomersRequest;
use FireflyIII\Services\Spectre\Request\NewCustomerRequest;
use FireflyIII\Support\Import\Information\GetSpectreCustomerTrait;
use FireflyIII\Support\Import\Information\GetSpectreTokenTrait;
use Illuminate\Support\MessageBag;

View File

@ -25,6 +25,7 @@ namespace FireflyIII\Support\Import\Placeholder;
/**
* Class ColumnValue
*
* @codeCoverageIgnore
*/
class ColumnValue

View File

@ -62,7 +62,7 @@ class CSVProcessor implements FileProcessorInterface
// validate mapped values:
/** @var MappedValuesValidator $validator */
$validator = app(MappedValuesValidator::class);
$validator = app(MappedValuesValidator::class);
$validator->setImportJob($this->importJob);
$mappedValues = $validator->validate($mappingConverger->getMappedValues());

View File

@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Support\Import\Routine\File;
use FireflyIII\Models\ImportJob;

View File

@ -164,6 +164,7 @@ class LineReader
} catch (\League\Csv\Exception $e) {
throw new FireflyException(sprintf('Cannot set delimiter: %s', $e->getMessage()));
}
// @codeCoverageIgnoreEnd
return $reader;

View File

@ -208,7 +208,7 @@ class Preferences
/**
* @param \FireflyIII\User $user
* @param $name
* @param mixed $value
* @param mixed $value
*
* @return Preference
*/

View File

@ -55,7 +55,7 @@ class Steam
//
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$currencyId = (int)$repository->getMetaValue($account, 'currency_id');
$currencyId = (int)$repository->getMetaValue($account, 'currency_id');
// use system default currency:
if (0 === $currencyId) {
@ -77,9 +77,9 @@ class Steam
->where('transactions.transaction_currency_id', '!=', $currencyId)
->sum('transactions.foreign_amount');
$balance = bcadd($nativeBalance, $foreignBalance);
$virtual = null === $account->virtual_balance ? '0' : (string)$account->virtual_balance;
$balance = bcadd($balance, $virtual);
$balance = bcadd($nativeBalance, $foreignBalance);
$virtual = null === $account->virtual_balance ? '0' : (string)$account->virtual_balance;
$balance = bcadd($balance, $virtual);
$cache->store($balance);
return $balance;

View File

@ -26,11 +26,11 @@ use FireflyIII\Models\AccountType;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\Transaction as TransactionModel;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use Lang;
use Log;
use Twig_Extension;
use FireflyIII\Models\TransactionJournal;
/**
* Class Transaction.

View File

@ -24,12 +24,12 @@ namespace FireflyIII\Support\Twig;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Support\Twig\Extension\Account as AccountExtension;
use League\CommonMark\CommonMarkConverter;
use Route;
use Twig_Extension;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
use FireflyIII\Support\Twig\Extension\Account as AccountExtension;
/**
* Class TwigSupport.

View File

@ -58,8 +58,8 @@ class LinkToBill implements ActionInterface
/** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class);
$repository->setUser($this->action->rule->user);
$billName = (string)$this->action->action_value;
$bill = $repository->findByName($billName);
$billName = (string)$this->action->action_value;
$bill = $repository->findByName($billName);
if (null !== $bill && $journal->transactionType->type === TransactionType::WITHDRAWAL) {
$journal->bill()->associate($bill);

View File

@ -101,8 +101,8 @@ class SetDestinationAccount implements ActionInterface
// update destination transaction with new destination account:
// get destination transaction:
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
if(null === $transaction) {
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
if (null === $transaction) {
return true;
}
$transaction->account_id = $this->newDestinationAccount->id;

View File

@ -25,7 +25,23 @@ declare(strict_types=1);
namespace FireflyIII;
use FireflyIII\Events\RequestedNewPassword;
use FireflyIII\Models\Account;
use FireflyIII\Models\Attachment;
use FireflyIII\Models\AvailableBudget;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\CurrencyExchangeRate;
use FireflyIII\Models\ExportJob;
use FireflyIII\Models\ImportJob;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Role;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
@ -36,26 +52,11 @@ use Laravel\Passport\HasApiTokens;
use Log;
use Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\Tag;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\Role;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Account;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\ImportJob;
use FireflyIII\Models\ExportJob;
use FireflyIII\Models\Category;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Bill;
use FireflyIII\Models\AvailableBudget;
use FireflyIII\Models\Attachment;
/**
* Class User.
* @property int $id
*
* @property int $id
* @property string $email
*/
class User extends Authenticatable