Code cleanup.

This commit is contained in:
James Cole 2016-08-12 15:10:03 +02:00
parent 955306d877
commit 5c4d010bde
94 changed files with 106 additions and 363 deletions

View File

@ -51,7 +51,7 @@ class EncryptFile extends Command
*/
public function handle()
{
$file = $this->argument('file');
$file = e($this->argument('file'));
if (!file_exists($file)) {
$this->error(sprintf('File "%s" does not seem to exist.', $file));

View File

@ -19,7 +19,6 @@ use FireflyIII\Import\Logging\CommandHandler;
use FireflyIII\Models\ImportJob;
use Illuminate\Console\Command;
use Log;
use Monolog\Handler\StreamHandler;
/**
* Class Import
@ -73,7 +72,11 @@ class Import extends Command
}
$this->line('Going to import job with key "' . $job->key . '" of type ' . $job->file_type);
$class = config('firefly.import_formats.' . $job->file_type);
$valid = array_keys(config('firefly.import_formats'));
$class = 'INVALID';
if (in_array($job->file_type, $valid)) {
$class = config('firefly.import_formats.' . $job->file_type);
}
/** @var ImporterInterface $importer */
$importer = app($class);
@ -98,7 +101,7 @@ class Import extends Command
$cleaned = $validator->clean();
// then import collection:
$storage = new ImportStorage($collection);
$storage = new ImportStorage($cleaned);
$storage->setUser($job->user);
// and run store routine:

View File

@ -119,7 +119,7 @@ class AccountCrud implements AccountCrudInterface
*/
public function findByIban(string $iban, array $types): Account
{
$query = $this->user->accounts()->where('iban', '!=', "");
$query = $this->user->accounts()->where('iban', '!=', '');
if (count($types) > 0) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
@ -538,4 +538,4 @@ class AccountCrud implements AccountCrudInterface
return true;
}
}
}

View File

@ -106,4 +106,4 @@ interface AccountCrudInterface
* @return Account
*/
public function updateAccountType(Account $account, string $type): Account;
}
}

View File

@ -213,4 +213,4 @@ class Journal implements JournalInterface
}
}
}

View File

@ -44,4 +44,4 @@ interface JournalInterface
* @return TransactionJournal
*/
public function updateJournal(TransactionJournal $journal, array $data): TransactionJournal;
}
}

View File

@ -83,10 +83,10 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
/** @var TransactionJournal $journal */
$journal = $attachment->attachable;
$args = [
'attachment_name' => $attachment->filename,
'attachment_name' => e($attachment->filename),
'attachment_id' => $attachment->id,
'type' => strtolower($journal->transactionType->type),
'description' => $journal->description,
'description' => e($journal->description),
'journal_id' => $journal->id,
'date' => $journal->date->formatLocalized(strval(trans('config.month_and_day'))),
'amount' => Amount::formatJournal($journal, false),

View File

@ -45,8 +45,6 @@ class UploadCollector extends BasicCollector implements CollectorInterface
// make storage:
$this->uploadDisk = Storage::disk('upload');
$this->exportDisk = Storage::disk('export');
// todo needs work for new importer (potentially collect other types as well)
$this->expected = 'csv-upload-' . Auth::user()->id . '-';
}

View File

@ -44,4 +44,4 @@ class EntryAccount
$this->type = $account->accountType->type;
$this->number = $account->getMeta('accountNumber');
}
}
}

View File

@ -38,4 +38,4 @@ class EntryBill
}
}
}
}

View File

@ -38,4 +38,4 @@ class EntryBudget
}
}
}
}

View File

@ -37,4 +37,4 @@ class EntryCategory
$this->name = $category->name;
}
}
}
}

View File

@ -104,4 +104,4 @@ class BudgetLimitEventHandler
}
}
}
}

View File

@ -59,4 +59,4 @@ class UserSaveIpAddress
return true;
}
}
}

View File

@ -133,4 +133,4 @@ class DomainController extends Controller
return $filtered;
}
}
}

View File

@ -28,10 +28,12 @@ class UserController extends Controller
/**
* @param User $user
*
* @return int
*/
public function edit(User $user)
{
return $user->id;
}

View File

@ -45,8 +45,7 @@ class ImportController extends Controller
*
* @param ImportJob $job
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws FireflyException
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
*/
public function complete(ImportJob $job)
{
@ -54,7 +53,6 @@ class ImportController extends Controller
if (!$this->jobInCorrectStep($job, 'complete')) {
return $this->redirectToCorrectStep($job);
}
$importer = $this->makeImporter($job);
$subTitle = trans('firefy.import_complete');
$subTitleIcon = 'fa-star';
@ -305,14 +303,11 @@ class ImportController extends Controller
case 'configure':
case 'process':
return $job->status === 'import_status_never_started';
break;
case 'settings':
case 'store-settings':
return $job->status === 'import_configuration_saved';
break;
case 'complete':
return $job->status === 'settings_complete';
break;
}
return false;

View File

@ -230,4 +230,4 @@ class MassController extends Controller
return redirect(session('transactions.mass-edit.url'));
}
}
}

View File

@ -358,4 +358,4 @@ class SplitController extends Controller
return $return;
}
}
}

View File

@ -107,6 +107,8 @@ class Range
$ranges['next'] = [$nextStart->format('Y-m-d'), $nextEnd->format('Y-m-d')];
switch ($viewRange) {
default:
throw new FireflyException('The date picker does not yet support "' . $viewRange . '".');
case '1D':
$format = (string)trans('config.month_and_day');
break;
@ -122,8 +124,6 @@ class Range
case '1M':
$format = (string)trans('config.month');
break;
default:
throw new FireflyException('The date picker does not yet support "' . $viewRange . '".');
case '1W':
$format = (string)trans('config.week_in_year');
break;

View File

@ -97,4 +97,4 @@ class SplitJournalFormRequest extends Request
'piggy_bank_id.*' => 'between:1,255',
];
}
}
}

View File

@ -599,4 +599,4 @@ Breadcrumbs::register(
$breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('split.journal.create', [$what]));
}
);
);

View File

@ -62,4 +62,4 @@ class AccountId extends BasicConverter implements ConverterInterface
return new Account;
}
}
}

View File

@ -62,4 +62,4 @@ class Amount extends BasicConverter implements ConverterInterface
return round(floatval($value), 4);
}
}
}

View File

@ -81,4 +81,4 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
return $account;
}
}
}

View File

@ -84,4 +84,4 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
}
}
}

View File

@ -90,4 +90,4 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
return $account;
}
}
}

View File

@ -80,4 +80,4 @@ class BasicConverter
{
$this->user = $user;
}
}
}

View File

@ -70,4 +70,4 @@ class BillId extends BasicConverter implements ConverterInterface
return new Bill;
}
}
}

View File

@ -89,4 +89,4 @@ class BillName extends BasicConverter implements ConverterInterface
}
}
}

View File

@ -69,4 +69,4 @@ class BudgetId extends BasicConverter implements ConverterInterface
return new Budget;
}
}
}

View File

@ -72,4 +72,4 @@ class BudgetName extends BasicConverter implements ConverterInterface
return $budget;
}
}
}

View File

@ -68,4 +68,4 @@ class CategoryId extends BasicConverter implements ConverterInterface
return new Category;
}
}
}

View File

@ -72,4 +72,4 @@ class CategoryName extends BasicConverter implements ConverterInterface
return $category;
}
}
}

View File

@ -51,4 +51,4 @@ interface ConverterInterface
* @param User $user
*/
public function setUser(User $user);
}
}

View File

@ -63,4 +63,4 @@ class CurrencyCode extends BasicConverter implements ConverterInterface
return $currency;
}
}
}

View File

@ -67,4 +67,4 @@ class CurrencyId extends BasicConverter implements ConverterInterface
return new TransactionCurrency;
}
}
}

View File

@ -72,4 +72,4 @@ class CurrencyName extends BasicConverter implements ConverterInterface
return $currency;
}
}
}

View File

@ -72,4 +72,4 @@ class CurrencySymbol extends BasicConverter implements ConverterInterface
return $currency;
}
}
}

View File

@ -46,4 +46,4 @@ class Date extends BasicConverter implements ConverterInterface
$this->setCertainty(100);
return $date;
}
}
}

View File

@ -34,4 +34,4 @@ class Description extends BasicConverter implements ConverterInterface
return strval($value);
}
}
}

View File

@ -34,4 +34,4 @@ class ExternalId extends BasicConverter implements ConverterInterface
return strval(trim($value));
}
}
}

View File

@ -42,4 +42,4 @@ class INGDebetCredit extends BasicConverter implements ConverterInterface
return 1;
}
}
}

View File

@ -29,4 +29,4 @@ class Ignore extends BasicConverter implements ConverterInterface
return null;
}
}
}

View File

@ -73,4 +73,4 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
return $account;
}
}
}

View File

@ -82,4 +82,4 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
return $account;
}
}
}

View File

@ -82,4 +82,4 @@ class OpposingAccountNumber extends BasicConverter implements ConverterInterface
return $account;
}
}
}

View File

@ -42,4 +42,4 @@ class RabobankDebetCredit extends BasicConverter implements ConverterInterface
return 1;
}
}
}

View File

@ -1,31 +0,0 @@
<?php
/**
* SomeConverter.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace FireflyIII\Import\Converter;
/**
* Class SomeConverter
*
* @package FireflyIII\Import\Converter
*/
class SomeConverter extends BasicConverter implements ConverterInterface
{
/**
* @param $value
*
*/
public function convert($value)
{
// // TODO: Implement convert() method.
// throw new NotImplementedException;
}
}

View File

@ -86,4 +86,4 @@ class TagsComma extends BasicConverter implements ConverterInterface
return $set;
}
}
}

View File

@ -87,4 +87,4 @@ class TagsSpace extends BasicConverter implements ConverterInterface
return $set;
}
}
}

View File

@ -55,7 +55,6 @@ class ImportEntry
*/
public function __construct()
{
$this->defaultImportAccount = new Account;
/** @var string $value */
foreach ($this->validFields as $value) {
$this->fields[$value] = null;
@ -63,21 +62,6 @@ class ImportEntry
}
}
/**
* @return ImportResult
*/
public function import(): ImportResult
{
$validation = $this->validate();
if ($validation->valid()) {
return $this->doImport();
}
return $validation;
}
/**
* @param string $role
* @param int $certainty
@ -91,14 +75,11 @@ class ImportEntry
default:
Log::error('Import entry cannot handle object.', ['role' => $role]);
throw new FireflyException('Import entry cannot handle object of type "' . $role . '".');
break;
case 'amount':
/*
* Easy enough.
*/
$this->setFloat('amount', $convertedValue, $certainty);
$this->applyMultiplier('amount'); // if present.
return;
@ -147,7 +128,7 @@ class ImportEntry
case 'sepa-ct-id':
case 'sepa-db':
case 'sepa-ct-op':
case'description':
case 'description':
$this->setAppendableString('description', $convertedValue);
break;
case '_ignore':
@ -160,6 +141,7 @@ class ImportEntry
case 'tags-comma':
case 'tags-space':
$this->appendCollection('tags', $convertedValue);
break;
case 'external-id':
$this->externalID = $convertedValue;
break;

View File

@ -165,4 +165,4 @@ class ImportResult
}
}
}

View File

@ -187,4 +187,4 @@ class ImportStorage
}
}
}

View File

@ -386,4 +386,4 @@ class ImportValidator
}
}
}

View File

@ -86,6 +86,8 @@ class CsvImporter implements ImporterInterface
// create import object. This is where each entry ends up.
$object = new ImportEntry;
Log::debug(sprintf('Now at row %d', $index));
// set some vars:
$object->setUser($this->job->user);
$config = $this->job->configuration;
@ -129,4 +131,4 @@ class CsvImporter implements ImporterInterface
return $object;
}
}
}

View File

@ -32,4 +32,4 @@ interface ImporterInterface
*
*/
public function setJob(ImportJob $job);
}
}

View File

@ -82,4 +82,4 @@ class CommandHandler extends AbstractProcessingHandler
break;
}
}
}
}

View File

@ -53,4 +53,4 @@ class AssetAccountIbans implements MapperInterface
return $list;
}
}
}

View File

@ -50,4 +50,4 @@ class AssetAccounts implements MapperInterface
return $list;
}
}
}

View File

@ -43,4 +43,4 @@ class Bills implements MapperInterface
return $list;
}
}
}

View File

@ -44,4 +44,4 @@ class Budgets implements MapperInterface
return $list;
}
}
}

View File

@ -44,4 +44,4 @@ class Categories implements MapperInterface
return $list;
}
}
}

View File

@ -58,4 +58,4 @@ class OpposingAccountIbans implements MapperInterface
return $list;
}
}
}

View File

@ -54,4 +54,4 @@ class OpposingAccounts implements MapperInterface
return $list;
}
}
}

View File

@ -43,4 +43,4 @@ class Tags implements MapperInterface
return $list;
}
}
}

View File

@ -39,4 +39,4 @@ class TransactionCurrencies implements MapperInterface
return $list;
}
}
}

View File

@ -25,4 +25,4 @@ interface PreProcessorInterface
*/
public function run(string $value): array;
}
}

View File

@ -28,4 +28,4 @@ class TagsComma implements PreProcessorInterface
{
return explode(',', $value);
}
}
}

View File

@ -27,4 +27,4 @@ class TagsSpace implements PreProcessorInterface
{
return explode(' ', $value);
}
}
}

View File

@ -15,4 +15,4 @@ namespace FireflyIII\Import\Role;
class Map
{
}
}

View File

@ -15,4 +15,4 @@ namespace FireflyIII\Import\Role;
class Role
{
}
}

View File

@ -469,4 +469,4 @@ class CsvSetup implements SetupInterface
}
}
}

View File

@ -82,4 +82,4 @@ interface SetupInterface
*
*/
public function setJob(ImportJob $job);
}
}

View File

@ -29,7 +29,7 @@ class AbnAmroDescription implements SpecificInterface
/**
* @return string
*/
static public function getDescription(): string
public static function getDescription(): string
{
return 'Fixes possible problems with ABN Amro descriptions.';
}
@ -37,7 +37,7 @@ class AbnAmroDescription implements SpecificInterface
/**
* @return string
*/
static public function getName(): string
public static function getName(): string
{
return 'ABN Amro description';
}
@ -218,4 +218,4 @@ class AbnAmroDescription implements SpecificInterface
}
}
}

View File

@ -23,7 +23,7 @@ class RabobankDescription implements SpecificInterface
/**
* @return string
*/
static public function getDescription(): string
public static function getDescription(): string
{
return 'Fixes possible problems with Rabobank descriptions.';
}
@ -31,7 +31,7 @@ class RabobankDescription implements SpecificInterface
/**
* @return string
*/
static public function getName(): string
public static function getName(): string
{
return 'Rabobank description';
}
@ -61,4 +61,4 @@ class RabobankDescription implements SpecificInterface
return $row;
}
}
}

View File

@ -21,12 +21,12 @@ interface SpecificInterface
/**
* @return string
*/
static public function getName(): string;
public static function getName(): string;
/**
* @return string
*/
static public function getDescription(): string;
public static function getDescription(): string;
/**
* @param array $row
@ -35,4 +35,4 @@ interface SpecificInterface
*/
public function run(array $row): array;
}
}

View File

@ -28,7 +28,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $key
* @property string $file_type
* @property string $status
* @property string $configuration
* @property array $configuration
* @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\ImportJob whereId($value)
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\ImportJob whereCreatedAt($value)

View File

@ -58,8 +58,6 @@ class CrudServiceProvider extends ServiceProvider
if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.');
}
// Log::debug('AccountCrud constructor, run with default arguments.', $arguments);
return app('FireflyIII\Crud\Account\AccountCrud', $arguments);
}
);

View File

@ -444,12 +444,6 @@ class CategoryRepository implements CategoryRepositoryInterface
*/
public function store(array $data): Category
{
// TODO use validation, not this.
if (strlen($data['name']) > 200 || strlen($data['name']) === 0) {
}
$newCategory = Category::firstOrCreateEncrypted(
[
'user_id' => $data['user'],

View File

@ -78,4 +78,4 @@ class ImportJobRepository implements ImportJobRepositoryInterface
return $result;
}
}
}

View File

@ -33,4 +33,4 @@ interface ImportJobRepositoryInterface
* @return ImportJob
*/
public function findByKey(string $key): ImportJob;
}
}

View File

@ -88,4 +88,4 @@ class TagSupport extends Model
}
}
}

View File

@ -276,203 +276,4 @@ return [
'field' => 'description',
],
],
/*
'specifix' => [
'RabobankDescription',
'AbnAmroDescription',
'Dummy'
],
'post_processors' => [
'Description',
'Amount',
'Currency',
'Bill',
'OpposingAccount', // must be after Amount!
'AssetAccount',
],
'roles' => [
'_ignore' => [
'mappable' => false,
'converter' => 'Ignore',
'field' => 'ignored',
],
'bill-id' => [
'mappable' => false,
'field' => 'bill',
'converter' => 'BillId',
'mapper' => 'Bill',
],
'bill-name' => [
'mappable' => true,
'converter' => 'BillName',
'field' => 'bill',
'mapper' => 'Bill',
],
'currency-id' => [
'mappable' => true,
'converter' => 'CurrencyId',
'field' => 'currency',
'mapper' => 'TransactionCurrency'
],
'currency-name' => [
'mappable' => true,
'converter' => 'CurrencyName',
'field' => 'currency',
'mapper' => 'TransactionCurrency'
],
'currency-code' => [
'mappable' => true,
'converter' => 'CurrencyCode',
'field' => 'currency',
'mapper' => 'TransactionCurrency'
],
'currency-symbol' => [
'mappable' => true,
'converter' => 'CurrencySymbol',
'field' => 'currency',
'mapper' => 'TransactionCurrency'
],
'description' => [
'mappable' => false,
'converter' => 'Description',
'field' => 'description',
],
'date-transaction' => [
'mappable' => false,
'converter' => 'Date',
'field' => 'date',
],
'date-rent' => [
'mappable' => false,
'converter' => 'Date',
'field' => 'date-rent',
],
'budget-id' => [
'mappable' => true,
'converter' => 'BudgetId',
'field' => 'budget',
'mapper' => 'Budget',
],
'budget-name' => [
'mappable' => true,
'converter' => 'BudgetName',
'field' => 'budget',
'mapper' => 'Budget',
],
'rabo-debet-credit' => [
'mappable' => false,
'converter' => 'RabobankDebetCredit',
'field' => 'amount-modifier',
],
'ing-debet-credit' => [
'mappable' => false,
'converter' => 'INGDebetCredit',
'field' => 'amount-modifier',
],
'category-id' => [
'mappable' => true,
'converter' => 'CategoryId',
'field' => 'category',
'mapper' => 'Category',
],
'category-name' => [
'mappable' => true,
'converter' => 'CategoryName',
'field' => 'category',
'mapper' => 'Category',
],
'tags-comma' => [
'mappable' => true,
'field' => 'tags',
'converter' => 'TagsComma',
'mapper' => 'Tag',
],
'tags-space' => [
'mappable' => true,
'field' => 'tags',
'converter' => 'TagsSpace',
'mapper' => 'Tag',
],
'account-id' => [
'mappable' => true,
'mapper' => 'AssetAccount',
'field' => 'asset-account-id',
'converter' => 'AccountId'
],
'account-name' => [
'mappable' => true,
'mapper' => 'AssetAccount',
'field' => 'asset-account-name',
'converter' => 'AssetAccountName'
],
'account-iban' => [
'mappable' => true,
'converter' => 'AssetAccountIban',
'field' => 'asset-account-iban',
'mapper' => 'AssetAccount'
],
'account-number' => [
'mappable' => true,
'converter' => 'AssetAccountNumber',
'field' => 'asset-account-number',
'mapper' => 'AssetAccount'
],
'opposing-id' => [
'mappable' => true,
'field' => 'opposing-account-id',
'converter' => 'OpposingAccountId',
'mapper' => 'AnyAccount',
],
'opposing-name' => [
'mappable' => true,
'field' => 'opposing-account-name',
'converter' => 'OpposingAccountName',
'mapper' => 'AnyAccount',
],
'opposing-iban' => [
'mappable' => true,
'field' => 'opposing-account-iban',
'converter' => 'OpposingAccountIban',
'mapper' => 'AnyAccount',
],
'opposing-number' => [
'mappable' => true,
'field' => 'opposing-account-number',
'converter' => 'OpposingAccountNumber',
'mapper' => 'AnyAccount',
],
'amount' => [
'mappable' => false,
'converter' => 'Amount',
'field' => 'amount',
],
'amount-comma-separated' => [
'mappable' => false,
'converter' => 'AmountComma',
'field' => 'amount',
],
'sepa-ct-id' => [
'mappable' => false,
'converter' => 'Description',
'field' => 'description',
],
'sepa-ct-op' => [
'mappable' => false,
'converter' => 'Description',
'field' => 'description',
],
'sepa-db' => [
'mappable' => false,
'converter' => 'Description',
'field' => 'description',
],
]
*/
];

View File

@ -56,7 +56,6 @@ class CreateMainTables extends Migration
$this->createBudgetTables();
$this->createCategoriesTable();
$this->createExportJobsTable();
// $this->createImportJobsTable();
$this->createPreferencesTable();
$this->createRoleTable();
$this->createRuleTables();

0
phpunit.xml Executable file → Normal file
View File

View File

@ -77,4 +77,4 @@ return [
'column_tags-space' => 'Tags (space separated)',
'column_account-number' => 'Asset account (account number)',
'column_opposing-number' => 'Opposing account (account number)',
];
];

View File

@ -77,4 +77,4 @@ return [
'column_tags-space' => 'Tags (space separated)',
'column_account-number' => 'Asset account (account number)',
'column_opposing-number' => 'Opposing account (account number)',
];
];

View File

@ -77,4 +77,4 @@ return [
'column_tags-space' => 'Tags (spatiegescheiden)',
'column_account-number' => 'Betaalrekening (rekeningnummer)',
'column_opposing-number' => 'Tegenrekening (rekeningnummer)',
];
];

View File

@ -77,4 +77,4 @@ return [
'column_tags-space' => 'Tags (space separated)',
'column_account-number' => 'Asset account (account number)',
'column_opposing-number' => 'Opposing account (account number)',
];
];

View File

@ -77,4 +77,4 @@ return [
'column_tags-space' => 'Tags (space separated)',
'column_account-number' => 'Asset account (account number)',
'column_opposing-number' => 'Opposing account (account number)',
];
];

View File

@ -77,4 +77,4 @@ return [
'column_tags-space' => 'Tags (space separated)',
'column_account-number' => 'Asset account (account number)',
'column_opposing-number' => 'Opposing account (account number)',
];
];

View File

@ -45,4 +45,4 @@
</div>
</div>
</div>
{% endif %}
{% endif %}

View File

@ -36,4 +36,4 @@
</div>
{{ Form.close|raw }}
{% endblock %}
{% endblock %}