diff --git a/app/breadcrumbs.php b/app/breadcrumbs.php deleted file mode 100644 index 126c478c30..0000000000 --- a/app/breadcrumbs.php +++ /dev/null @@ -1,369 +0,0 @@ -push('Home', route('index')); - } -); - -// accounts -Breadcrumbs::register( - 'accounts.index', function (Generator $breadcrumbs, $what) { - $breadcrumbs->parent('home'); - $breadcrumbs->push(ucfirst(e($what)) . ' accounts', route('accounts.index', $what)); -} -); -Breadcrumbs::register( - 'accounts.show', function (Generator $breadcrumbs, \Account $account) { - switch ($account->accountType->type) { - default: - throw new FireflyException('Cannot handle account type "' . e($account->accountType->type) . '"'); - break; - case 'Default account': - case 'Asset account': - $what = 'asset'; - break; - case 'Cash account': - $what = 'cash'; - break; - case 'Expense account': - case 'Beneficiary account': - $what = 'expense'; - break; - case 'Revenue account': - $what = 'revenue'; - break; - } - $breadcrumbs->parent('accounts.index', $what); - $breadcrumbs->push(e($account->name), route('accounts.show', $account->id)); -} -); -Breadcrumbs::register( - 'accounts.delete', function (Generator $breadcrumbs, \Account $account) { - $breadcrumbs->parent('accounts.show', $account); - $breadcrumbs->push('Delete ' . e($account->name), route('accounts.delete', $account->id)); -} -); - -Breadcrumbs::register( - 'accounts.edit', function (Generator $breadcrumbs, \Account $account) { - $breadcrumbs->parent('accounts.show', $account); - $breadcrumbs->push('Edit ' . e($account->name), route('accounts.edit', $account->id)); -} -); - -// budgets. -Breadcrumbs::register( - 'budgets.index', function (Generator $breadcrumbs) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Budgets', route('budgets.index')); -} -); -Breadcrumbs::register( - 'budgets.create', function (Generator $breadcrumbs) { - $breadcrumbs->parent('budgets.index'); - $breadcrumbs->push('Create new budget', route('budgets.create')); -} -); - -Breadcrumbs::register( - 'budgets.edit', function (Generator $breadcrumbs, Budget $budget) { - $breadcrumbs->parent('budgets.show', $budget); - $breadcrumbs->push('Edit ' . e($budget->name), route('budgets.edit', $budget->id)); -} -); -Breadcrumbs::register( - 'budgets.delete', function (Generator $breadcrumbs, Budget $budget) { - $breadcrumbs->parent('budgets.show', $budget); - $breadcrumbs->push('Delete ' . e($budget->name), route('budgets.delete', $budget->id)); -} -); - -Breadcrumbs::register( - 'budgets.show', function (Generator $breadcrumbs, Budget $budget, LimitRepetition $repetition = null) { - $breadcrumbs->parent('budgets.index'); - $breadcrumbs->push(e($budget->name), route('budgets.show', $budget->id)); - if (!is_null($repetition)) { - $breadcrumbs->push( - DateKit::periodShow($repetition->startdate, $repetition->budgetlimit->repeat_freq), route('budgets.show', $budget->id, $repetition->id) - ); - } -} -); - -// categories -Breadcrumbs::register( - 'categories.index', function (Generator $breadcrumbs) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Categories', route('categories.index')); -} -); -Breadcrumbs::register( - 'categories.create', function (Generator $breadcrumbs) { - $breadcrumbs->parent('categories.index'); - $breadcrumbs->push('Create new category', route('categories.create')); -} -); - -Breadcrumbs::register( - 'categories.edit', function (Generator $breadcrumbs, Category $category) { - $breadcrumbs->parent('categories.show', $category); - $breadcrumbs->push('Edit ' . e($category->name), route('categories.edit', $category->id)); -} -); -Breadcrumbs::register( - 'categories.delete', function (Generator $breadcrumbs, Category $category) { - $breadcrumbs->parent('categories.show', $category); - $breadcrumbs->push('Delete ' . e($category->name), route('categories.delete', $category->id)); -} -); - -Breadcrumbs::register( - 'categories.show', function (Generator $breadcrumbs, Category $category) { - $breadcrumbs->parent('categories.index'); - $breadcrumbs->push(e($category->name), route('categories.show', $category->id)); - -} -); - - -// piggy banks -Breadcrumbs::register( - 'piggyBanks.index', function (Generator $breadcrumbs) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Piggy banks', route('piggyBanks.index')); -} -); -Breadcrumbs::register( - 'piggyBanks.create', function (Generator $breadcrumbs) { - $breadcrumbs->parent('piggyBanks.index'); - $breadcrumbs->push('Create new piggy bank', route('piggyBanks.create')); -} -); - -Breadcrumbs::register( - 'piggyBanks.edit', function (Generator $breadcrumbs, PiggyBank $piggyBank) { - $breadcrumbs->parent('piggyBanks.show', $piggyBank); - $breadcrumbs->push('Edit ' . e($piggyBank->name), route('piggyBanks.edit', $piggyBank->id)); -} -); -Breadcrumbs::register( - 'piggyBanks.delete', function (Generator $breadcrumbs, PiggyBank $piggyBank) { - $breadcrumbs->parent('piggyBanks.show', $piggyBank); - $breadcrumbs->push('Delete ' . e($piggyBank->name), route('piggyBanks.delete', $piggyBank->id)); -} -); - -Breadcrumbs::register( - 'piggyBanks.show', function (Generator $breadcrumbs, PiggyBank $piggyBank) { - $breadcrumbs->parent('piggyBanks.index'); - $breadcrumbs->push(e($piggyBank->name), route('piggyBanks.show', $piggyBank->id)); - -} -); - -// preferences -Breadcrumbs::register( - 'preferences', function (Generator $breadcrumbs) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Preferences', route('preferences')); - -} -); - -// profile -Breadcrumbs::register( - 'profile', function (Generator $breadcrumbs) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Profile', route('profile')); - -} -); -Breadcrumbs::register( - 'change-password', function (Generator $breadcrumbs) { - $breadcrumbs->parent('profile'); - $breadcrumbs->push('Change your password', route('change-password')); - -} -); - -// bills -Breadcrumbs::register( - 'bills.index', function (Generator $breadcrumbs) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Bills', route('bills.index')); -} -); -Breadcrumbs::register( - 'bills.create', function (Generator $breadcrumbs) { - $breadcrumbs->parent('bills.index'); - $breadcrumbs->push('Create new bill', route('bills.create')); -} -); - -Breadcrumbs::register( - 'bills.edit', function (Generator $breadcrumbs, Bill $bill) { - $breadcrumbs->parent('bills.show', $bill); - $breadcrumbs->push('Edit ' . e($bill->name), route('bills.edit', $bill->id)); -} -); -Breadcrumbs::register( - 'bills.delete', function (Generator $breadcrumbs, Bill $bill) { - $breadcrumbs->parent('bills.show', $bill); - $breadcrumbs->push('Delete ' . e($bill->name), route('bills.delete', $bill->id)); -} -); - -Breadcrumbs::register( - 'bills.show', function (Generator $breadcrumbs, Bill $bill) { - $breadcrumbs->parent('bills.index'); - $breadcrumbs->push(e($bill->name), route('bills.show', $bill->id)); - -} -); - -// reminders -Breadcrumbs::register( - 'reminders.show', function (Generator $breadcrumbs, Reminder $reminder) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Reminder #' . $reminder->id, route('reminders.show', $reminder->id)); - -} -); - -// repeated expenses -Breadcrumbs::register( - 'repeated.index', function (Generator $breadcrumbs) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Repeated expenses', route('repeated.index')); -} -); -Breadcrumbs::register( - 'repeated.create', function (Generator $breadcrumbs) { - $breadcrumbs->parent('repeated.index'); - $breadcrumbs->push('Create new repeated expense', route('repeated.create')); -} -); - -Breadcrumbs::register( - 'repeated.edit', function (Generator $breadcrumbs, PiggyBank $piggyBank) { - $breadcrumbs->parent('repeated.show', $piggyBank); - $breadcrumbs->push('Edit ' . e($piggyBank->name), route('repeated.edit', $piggyBank->id)); -} -); -Breadcrumbs::register( - 'repeated.delete', function (Generator $breadcrumbs, PiggyBank $piggyBank) { - $breadcrumbs->parent('repeated.show', $piggyBank); - $breadcrumbs->push('Delete ' . e($piggyBank->name), route('repeated.delete', $piggyBank->id)); -} -); - -Breadcrumbs::register( - 'repeated.show', function (Generator $breadcrumbs, PiggyBank $piggyBank) { - $breadcrumbs->parent('repeated.index'); - $breadcrumbs->push(e($piggyBank->name), route('repeated.show', $piggyBank->id)); - -} -); - -// reports -Breadcrumbs::register( - 'reports.index', function (Generator $breadcrumbs) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Reports', route('reports.index')); -} -); - -Breadcrumbs::register( - 'reports.year', function (Generator $breadcrumbs, Carbon $date) { - $breadcrumbs->parent('reports.index'); - $breadcrumbs->push($date->format('Y'), route('reports.year', $date->format('Y'))); -} -); - -Breadcrumbs::register( - 'reports.month', function (Generator $breadcrumbs, Carbon $date) { - $breadcrumbs->parent('reports.index'); - $breadcrumbs->push('Monthly report for ' . $date->format('F Y'), route('reports.month', $date)); -} -); - -Breadcrumbs::register( - 'reports.budget', function (Generator $breadcrumbs, Carbon $date) { - $breadcrumbs->parent('reports.index'); - $breadcrumbs->push('Budget report for ' . $date->format('F Y'), route('reports.budget', $date)); -} -); - -// search -Breadcrumbs::register( - 'search', function (Generator $breadcrumbs, $query) { - $breadcrumbs->parent('home'); - $breadcrumbs->push('Search for "' . e($query) . '"', route('search')); -} -); - -// transactions -Breadcrumbs::register( - 'transactions.index', function (Generator $breadcrumbs, $what) { - $breadcrumbs->parent('home'); - - switch ($what) { - case 'expenses': - case 'withdrawal': - $subTitle = 'Expenses'; - break; - case 'revenue': - case 'deposit': - $subTitle = 'Revenue, income and deposits'; - break; - case 'transfer': - case 'transfers': - $subTitle = 'Transfers'; - break; - case 'opening balance': - $subTitle = 'Opening balances'; - break; - default: - throw new FireflyException('Cannot handle $what "' . e($what) . '" in bread crumbs'); - } - - $breadcrumbs->push($subTitle, route('transactions.index', $what)); -} -); -Breadcrumbs::register( - 'transactions.create', function (Generator $breadcrumbs, $what) { - $breadcrumbs->parent('transactions.index', $what); - $breadcrumbs->push('Create new ' .e($what), route('transactions.create', $what)); -} -); - -Breadcrumbs::register( - 'transactions.edit', function (Generator $breadcrumbs, TransactionJournal $journal) { - $breadcrumbs->parent('transactions.show', $journal); - $breadcrumbs->push('Edit ' . e($journal->description), route('transactions.edit', $journal->id)); -} -); -Breadcrumbs::register( - 'transactions.delete', function (Generator $breadcrumbs, TransactionJournal $journal) { - $breadcrumbs->parent('transactions.show', $journal); - $breadcrumbs->push('Delete ' . e($journal->description), route('transactions.delete', $journal->id)); -} -); - -Breadcrumbs::register( - 'transactions.show', function (Generator $breadcrumbs, TransactionJournal $journal) { - - $breadcrumbs->parent('transactions.index', strtolower($journal->transactionType->type)); - $breadcrumbs->push(e($journal->description), route('transactions.show', $journal->id)); - -} -); diff --git a/app/commands/.gitkeep b/app/commands/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/app/commands/Cleanup.php b/app/commands/Cleanup.php deleted file mode 100644 index db76195588..0000000000 --- a/app/commands/Cleanup.php +++ /dev/null @@ -1,76 +0,0 @@ -info('Start!'); - Artisan::call('clear-compiled'); - $this->info('Cleared compiled...'); - Artisan::call('ide-helper:generate'); - $this->info('IDE helper, done...'); - Artisan::call('ide-helper:models'); - $this->info('IDE models, done...'); - Artisan::call('optimize'); - $this->info('Optimized...'); - Artisan::call('dump-autoload'); - $this->info('Done!'); - } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - // ['example', InputArgument::REQUIRED, 'An example argument.'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - // ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], - ]; - } - -} diff --git a/app/config/.gitignore b/app/config/.gitignore deleted file mode 100644 index 10601ce198..0000000000 --- a/app/config/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -local/ -laptop/ -vagrant/ -production/ diff --git a/app/config/app.php b/app/config/app.php deleted file mode 100644 index 4771579bbb..0000000000 --- a/app/config/app.php +++ /dev/null @@ -1,91 +0,0 @@ - false, - 'url' => 'http://localhost', - 'timezone' => 'UTC', - 'locale' => 'en', - 'fallback_locale' => 'en', - 'log_level' => 'notice', - 'key' => 'D93oqmVsIARg23FC3cbsHuBGk0uXQc3r', - 'cipher' => MCRYPT_RIJNDAEL_128, - 'providers' => [ - - 'Illuminate\Foundation\Providers\ArtisanServiceProvider', - 'Illuminate\Auth\AuthServiceProvider', - 'Illuminate\Cache\CacheServiceProvider', - 'Illuminate\Session\CommandsServiceProvider', - 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', - 'Illuminate\Routing\ControllerServiceProvider', - 'Illuminate\Cookie\CookieServiceProvider', - 'Illuminate\Database\DatabaseServiceProvider', - 'Illuminate\Encryption\EncryptionServiceProvider', - 'Illuminate\Filesystem\FilesystemServiceProvider', - 'Illuminate\Hashing\HashServiceProvider', - 'Illuminate\Html\HtmlServiceProvider', - 'Illuminate\Log\LogServiceProvider', - 'Illuminate\Mail\MailServiceProvider', - 'Illuminate\Database\MigrationServiceProvider', - 'Illuminate\Pagination\PaginationServiceProvider', - 'Illuminate\Queue\QueueServiceProvider', - 'Illuminate\Redis\RedisServiceProvider', - 'Illuminate\Remote\RemoteServiceProvider', - 'Illuminate\Auth\Reminders\ReminderServiceProvider', - 'Illuminate\Database\SeedServiceProvider', - 'Illuminate\Session\SessionServiceProvider', - 'Illuminate\Translation\TranslationServiceProvider', - 'Illuminate\Validation\ValidationServiceProvider', - 'Illuminate\View\ViewServiceProvider', - 'Illuminate\Workbench\WorkbenchServiceProvider', - //'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', - //'Barryvdh\Debugbar\ServiceProvider', - 'FireflyIII\FF3ServiceProvider', - 'DaveJamesMiller\Breadcrumbs\ServiceProvider', - 'Grumpydictator\Gchart\GchartServiceProvider', - ], - 'manifest' => storage_path() . '/meta', - 'aliases' => [ - - 'App' => 'Illuminate\Support\Facades\App', - 'Artisan' => 'Illuminate\Support\Facades\Artisan', - 'Auth' => 'Illuminate\Support\Facades\Auth', - 'Blade' => 'Illuminate\Support\Facades\Blade', - 'Cache' => 'Illuminate\Support\Facades\Cache', - 'ClassLoader' => 'Illuminate\Support\ClassLoader', - 'Config' => 'Illuminate\Support\Facades\Config', - 'Controller' => 'Illuminate\Routing\Controller', - 'Cookie' => 'Illuminate\Support\Facades\Cookie', - 'Crypt' => 'Illuminate\Support\Facades\Crypt', - 'DB' => 'Illuminate\Support\Facades\DB', - 'Eloquent' => 'Illuminate\Database\Eloquent\Model', - 'Event' => 'Illuminate\Support\Facades\Event', - 'File' => 'Illuminate\Support\Facades\File', - 'Form' => 'Illuminate\Support\Facades\Form', - 'Hash' => 'Illuminate\Support\Facades\Hash', - 'HTML' => 'Illuminate\Support\Facades\HTML', - 'Input' => 'Illuminate\Support\Facades\Input', - 'Lang' => 'Illuminate\Support\Facades\Lang', - 'Log' => 'Illuminate\Support\Facades\Log', - 'Mail' => 'Illuminate\Support\Facades\Mail', - 'Paginator' => 'Illuminate\Support\Facades\Paginator', - 'Password' => 'Illuminate\Support\Facades\Password', - 'Queue' => 'Illuminate\Support\Facades\Queue', - 'Redirect' => 'Illuminate\Support\Facades\Redirect', - 'Redis' => 'Illuminate\Support\Facades\Redis', - 'Request' => 'Illuminate\Support\Facades\Request', - 'Response' => 'Illuminate\Support\Facades\Response', - 'Route' => 'Illuminate\Support\Facades\Route', - 'Schema' => 'Illuminate\Support\Facades\Schema', - 'Seeder' => 'Illuminate\Database\Seeder', - 'Session' => 'Illuminate\Support\Facades\Session', - 'SoftDeletingTrait' => 'Illuminate\Database\Eloquent\SoftDeletingTrait', - 'SSH' => 'Illuminate\Support\Facades\SSH', - 'Str' => 'Illuminate\Support\Str', - 'URL' => 'Illuminate\Support\Facades\URL', - 'Validator' => 'Illuminate\Support\Facades\Validator', - 'View' => 'Illuminate\Support\Facades\View', - 'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade' - - ], - -]; diff --git a/app/config/auth.php b/app/config/auth.php deleted file mode 100644 index 6e606f0ebe..0000000000 --- a/app/config/auth.php +++ /dev/null @@ -1,16 +0,0 @@ - 'eloquent', - 'model' => 'User', - 'table' => 'users', - 'reminder' => [ - 'email' => 'emails.auth.reminder', - 'table' => 'password_reminders', - 'expire' => 60, - ], - 'verify_mail' => true, - 'verify_reset' => true, - 'allow_register' => true - -]; diff --git a/app/config/cache.php b/app/config/cache.php deleted file mode 100644 index 8fa089055b..0000000000 --- a/app/config/cache.php +++ /dev/null @@ -1,12 +0,0 @@ - 'file', - 'path' => storage_path() . '/cache', - 'connection' => null, - 'table' => 'cache', - 'memcached' => [ - ['host' => '127.0.0.1', 'port' => 11211, 'weight' => 100], - ], - 'prefix' => 'laravel', -]; diff --git a/app/config/compile.php b/app/config/compile.php deleted file mode 100644 index 0b67a5fe47..0000000000 --- a/app/config/compile.php +++ /dev/null @@ -1,3 +0,0 @@ - PDO::FETCH_CLASS, - 'default' => 'mysql', - 'connections' => [ - 'mysql' => [ - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'forge', - 'username' => 'forge', - 'password' => '', - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - ], - ], - 'migrations' => 'migrations', - 'redis' => [ - - 'cluster' => false, - - 'default' => [ - 'host' => '127.0.0.1', - 'port' => 6379, - 'database' => 0, - ], - - ], - -]; diff --git a/app/config/dev.php b/app/config/dev.php deleted file mode 100644 index a5f5e8f277..0000000000 --- a/app/config/dev.php +++ /dev/null @@ -1,4 +0,0 @@ - '' -]; diff --git a/app/config/firefly.php b/app/config/firefly.php deleted file mode 100644 index c17ca873e3..0000000000 --- a/app/config/firefly.php +++ /dev/null @@ -1,49 +0,0 @@ - ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'], - 'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'], - 'piggy_bank_periods' => [ - 'week' => 'Week', - 'month' => 'Month', - 'quarter' => 'Quarter', - 'year' => 'Year' - ], - 'periods_to_text' => [ - 'weekly' => 'A week', - 'monthly' => 'A month', - 'quarterly' => 'A quarter', - 'half-year' => 'Six months', - 'yearly' => 'A year', - ], - - 'accountRoles' => [ - 'defaultExpense' => 'Default expense account', - 'sharedExpense' => 'Shared expense account' - ], - - 'range_to_text' => [ - '1D' => 'day', - '1W' => 'week', - '1M' => 'month', - '3M' => 'three months', - '6M' => 'half year', - 'custom' => '(custom)' - ], - 'range_to_name' => [ - '1D' => 'one day', - '1W' => 'one week', - '1M' => 'one month', - '3M' => 'three months', - '6M' => 'six months', - '1Y' => 'one year', - ], - 'range_to_repeat_freq' => [ - '1D' => 'weekly', - '1W' => 'weekly', - '1M' => 'monthly', - '3M' => 'quarterly', - '6M' => 'half-year', - 'custom' => 'monthly' - ], -]; diff --git a/app/config/homestead/app.php b/app/config/homestead/app.php deleted file mode 100644 index 0f1dd6a103..0000000000 --- a/app/config/homestead/app.php +++ /dev/null @@ -1,15 +0,0 @@ - true, - 'log_level' => 'debug', -]; diff --git a/app/config/homestead/cache.php b/app/config/homestead/cache.php deleted file mode 100644 index 8fa089055b..0000000000 --- a/app/config/homestead/cache.php +++ /dev/null @@ -1,12 +0,0 @@ - 'file', - 'path' => storage_path() . '/cache', - 'connection' => null, - 'table' => 'cache', - 'memcached' => [ - ['host' => '127.0.0.1', 'port' => 11211, 'weight' => 100], - ], - 'prefix' => 'laravel', -]; diff --git a/app/config/homestead/database.php b/app/config/homestead/database.php deleted file mode 100644 index d585027ae3..0000000000 --- a/app/config/homestead/database.php +++ /dev/null @@ -1,37 +0,0 @@ - 'mysql', - 'connections' => [ - - 'mysql' => [ - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'homestead', - 'username' => 'homestead', - 'password' => 'secret', - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - ], - 'sqlite' => [ - 'driver' => 'sqlite', - 'database' => realpath(__DIR__.'/../../../tests/_data/testing.sqlite'), - 'prefix' => '' - ], - - 'pgsql' => [ - 'driver' => 'pgsql', - 'host' => 'localhost', - 'database' => 'homestead', - 'username' => 'homestead', - 'password' => 'secret', - 'charset' => 'utf8', - 'prefix' => '', - 'schema' => 'public', - ], - - ], - -]; diff --git a/app/config/homestead/mail.php b/app/config/homestead/mail.php deleted file mode 100644 index 28ee90f10c..0000000000 --- a/app/config/homestead/mail.php +++ /dev/null @@ -1,13 +0,0 @@ - 'smtp', - 'host' => 'smtp.gmail.com', - 'port' => 587, - 'from' => ['address' => 'empty@example.com', 'name' => 'Firefly III'], - 'encryption' => 'tls', - 'username' => 'empty@example.com', - 'password' => '', - 'sendmail' => '/usr/sbin/sendmail -bs', - 'pretend' => false, -]; diff --git a/app/config/mail.php b/app/config/mail.php deleted file mode 100644 index 9fe35072ad..0000000000 --- a/app/config/mail.php +++ /dev/null @@ -1,13 +0,0 @@ - 'smtp', - 'host' => '', - 'port' => 587, - 'from' => ['address' => '', 'name' => 'Firefly III'], - 'encryption' => 'tls', - 'username' => '', - 'password' => '', - 'sendmail' => '/usr/sbin/sendmail -bs', - 'pretend' => false, -]; diff --git a/app/config/packages/.gitkeep b/app/config/packages/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/app/config/packages/barryvdh/laravel-debugbar/config.php b/app/config/packages/barryvdh/laravel-debugbar/config.php deleted file mode 100644 index 3baf4b799a..0000000000 --- a/app/config/packages/barryvdh/laravel-debugbar/config.php +++ /dev/null @@ -1,127 +0,0 @@ - Config::get('app.debug'), - - 'storage' => [ - 'enabled' => true, - 'path' => storage_path() . '/debugbar', - ], - - /* - |-------------------------------------------------------------------------- - | Vendors - |-------------------------------------------------------------------------- - | - | Vendor files are included by default, but can be set to false. - | This can also be set to 'js' or 'css', to only include javascript or css vendor files. - | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files) - | and for js: jquery and and highlight.js - | So if you want syntax highlighting, set it to true. - | jQuery is set to not conflict with existing jQuery scripts. - | - */ - - 'include_vendors' => true, - - /* - |-------------------------------------------------------------------------- - | Capture Ajax Requests - |-------------------------------------------------------------------------- - | - | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors), - | you can use this option to disable sending the data through the headers. - | - */ - - 'capture_ajax' => true, - - /* - |-------------------------------------------------------------------------- - | Capture Console Commands - |-------------------------------------------------------------------------- - | - | The Debugbar can listen to Artisan commands. You can view them with the browse button in the Debugbar. - | - */ - - 'capture_console' => false, - - /* - |-------------------------------------------------------------------------- - | DataCollectors - |-------------------------------------------------------------------------- - | - | Enable/disable DataCollectors - | - */ - - 'collectors' => [ - 'phpinfo' => true, // Php version - 'messages' => true, // Messages - 'time' => true, // Time Datalogger - 'memory' => true, // Memory usage - 'exceptions' => true, // Exception displayer - 'log' => true, // Logs from Monolog (merged in messages if enabled) - 'db' => true, // Show database (PDO) queries and bindings - 'views' => true, // Views with their data - 'route' => true, // Current route information - 'laravel' => false, // Laravel version and environment - 'events' => false, // All events fired - 'default_request' => false, // Regular or special Symfony request logger - 'symfony_request' => true, // Only one can be enabled.. - 'mail' => true, // Catch mail messages - 'logs' => false, // Add the latest log messages - 'files' => false, // Show the included files - 'config' => false, // Display config settings - 'auth' => false, // Display Laravel authentication status - ], - - /* - |-------------------------------------------------------------------------- - | Extra options - |-------------------------------------------------------------------------- - | - | Configure some DataCollectors - | - */ - - 'options' => [ - 'auth' => [ - 'show_name' => false, // Also show the users name/email in the debugbar - ], - 'db' => [ - 'with_params' => true, // Render SQL with the parameters substituted - 'timeline' => false, // Add the queries to the timeline - ], - 'mail' => [ - 'full_log' => false - ], - 'views' => [ - 'data' => false, //Note: Can slow down the application, because the data can be quite large.. - ], - 'route' => [ - 'label' => true // show complete route on bar - ], - 'logs' => [ - 'file' => null - ], - ], - - /* - |-------------------------------------------------------------------------- - | Inject Debugbar in Response - |-------------------------------------------------------------------------- - | - | Usually, the debugbar is added just before
, by listening to the - | Response after the App is done. If you disable this, you have to add them - | in your template yourself. See http://phpdebugbar.com/docs/rendering.html - | - */ - - 'inject' => true, - -]; diff --git a/app/config/packages/barryvdh/laravel-ide-helper/config.php b/app/config/packages/barryvdh/laravel-ide-helper/config.php deleted file mode 100644 index a49a469e62..0000000000 --- a/app/config/packages/barryvdh/laravel-ide-helper/config.php +++ /dev/null @@ -1,76 +0,0 @@ - '_ide_helper.php', - - /* - |-------------------------------------------------------------------------- - | Helper files to include - |-------------------------------------------------------------------------- - | - | Include helper files. By default not included, but can be toggled with the - | -- helpers (-H) option. Extra helper files can be included. - | - */ - - 'include_helpers' => false, - - 'helper_files' => [ - base_path() . '/vendor/laravel/framework/src/Illuminate/Support/helpers.php', - ], - - /* - |-------------------------------------------------------------------------- - | Model locations to include - |-------------------------------------------------------------------------- - | - | Define in which directories the ide-helper:models command should look - | for models. - | - */ - - 'model_locations' => [ - 'app/models', - ], - - - /* - |-------------------------------------------------------------------------- - | Extra classes - |-------------------------------------------------------------------------- - | - | These implementations are not really extended, but called with magic functions - | - */ - - 'extra' => [ - 'Artisan' => ['Illuminate\Foundation\Artisan'], - 'Eloquent' => ['Illuminate\Database\Eloquent\Builder', 'Illuminate\Database\Query\Builder'], - 'Session' => ['Illuminate\Session\Store'], - ], - - 'magic' => [ - 'Log' => [ - 'debug' => 'Monolog\Logger::addDebug', - 'info' => 'Monolog\Logger::addInfo', - 'notice' => 'Monolog\Logger::addNotice', - 'warning' => 'Monolog\Logger::addWarning', - 'error' => 'Monolog\Logger::addError', - 'critical' => 'Monolog\Logger::addCritical', - 'alert' => 'Monolog\Logger::addAlert', - 'emergency' => 'Monolog\Logger::addEmergency', - ] - ] - - -]; diff --git a/app/config/packages/davejamesmiller/laravel-breadcrumbs/config.php b/app/config/packages/davejamesmiller/laravel-breadcrumbs/config.php deleted file mode 100644 index e58b40faa9..0000000000 --- a/app/config/packages/davejamesmiller/laravel-breadcrumbs/config.php +++ /dev/null @@ -1,5 +0,0 @@ - 'laravel-breadcrumbs::bootstrap3', -]; diff --git a/app/config/queue.php b/app/config/queue.php deleted file mode 100644 index 79da1ff9c7..0000000000 --- a/app/config/queue.php +++ /dev/null @@ -1,45 +0,0 @@ - 'sync', - 'connections' => [ - - 'sync' => [ - 'driver' => 'sync', - ], - - 'beanstalkd' => [ - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'ttr' => 60, - ], - - 'sqs' => [ - 'driver' => 'sqs', - 'key' => 'your-public-key', - 'secret' => 'your-secret-key', - 'queue' => 'your-queue-url', - 'region' => 'us-east-1', - ], - - 'iron' => [ - 'driver' => 'iron', - 'host' => 'mq-aws-us-east-1.iron.io', - 'token' => 'your-token', - 'project' => 'your-project-id', - 'queue' => 'your-queue-name', - 'encrypt' => true, - ], - - 'redis' => [ - 'driver' => 'redis', - 'queue' => 'default', - ], - - ], - 'failed' => [ - 'database' => 'mysql', 'table' => 'failed_jobs', - ], - -]; diff --git a/app/config/remote.php b/app/config/remote.php deleted file mode 100644 index 3104bf7e34..0000000000 --- a/app/config/remote.php +++ /dev/null @@ -1,21 +0,0 @@ - 'production', - 'connections' => [ - - 'production' => [ - 'host' => '', - 'username' => '', - 'password' => '', - 'key' => '', - 'keyphrase' => '', - 'root' => '/var/www', - ], - ], - 'groups' => [ - 'web' => ['production'] - - ], - -]; diff --git a/app/config/services.php b/app/config/services.php deleted file mode 100644 index c252b2be65..0000000000 --- a/app/config/services.php +++ /dev/null @@ -1,19 +0,0 @@ - [ - 'domain' => '', - 'secret' => '', - ], - - 'mandrill' => [ - 'secret' => '', - ], - - 'stripe' => [ - 'model' => 'User', - 'secret' => '', - ], - -]; diff --git a/app/config/session.php b/app/config/session.php deleted file mode 100644 index a41728b267..0000000000 --- a/app/config/session.php +++ /dev/null @@ -1,16 +0,0 @@ - 'file', - 'lifetime' => 120, - 'expire_on_close' => false, - 'files' => storage_path() . '/sessions', - 'connection' => null, - 'table' => 'sessions', - 'lottery' => [2, 100], - 'cookie' => 'firefly_session', - 'path' => '/', - 'domain' => null, - 'secure' => false, - -]; diff --git a/app/config/testing/app.php b/app/config/testing/app.php deleted file mode 100644 index 7f9d13d6fb..0000000000 --- a/app/config/testing/app.php +++ /dev/null @@ -1,2 +0,0 @@ - 'debug',]; diff --git a/app/config/testing/auth.php b/app/config/testing/auth.php deleted file mode 100644 index 0fe9e0172d..0000000000 --- a/app/config/testing/auth.php +++ /dev/null @@ -1,8 +0,0 @@ - false, - 'verify_reset' => true, - 'allow_register' => true - -]; diff --git a/app/config/testing/cache.php b/app/config/testing/cache.php deleted file mode 100644 index fef1e78b52..0000000000 --- a/app/config/testing/cache.php +++ /dev/null @@ -1,3 +0,0 @@ - 'array',]; diff --git a/app/config/testing/database.php b/app/config/testing/database.php deleted file mode 100644 index e0be6a4063..0000000000 --- a/app/config/testing/database.php +++ /dev/null @@ -1,12 +0,0 @@ - 'sqlite', - 'connections' => [ - 'sqlite' => [ - 'driver' => 'sqlite', - 'database' => realpath(__DIR__.'/../../../tests/_data/db.sqlite'), - 'prefix' => '' - ] - - ] -]; diff --git a/app/config/testing/mail.php b/app/config/testing/mail.php deleted file mode 100644 index d2df78f4cd..0000000000 --- a/app/config/testing/mail.php +++ /dev/null @@ -1,13 +0,0 @@ - 'smtp', - 'host' => '', - 'port' => 587, - 'from' => ['address' => '', 'name' => 'Firefly III'], - 'encryption' => 'tls', - 'username' => '', - 'password' => '', - 'sendmail' => '/usr/sbin/sendmail -bs', - 'pretend' => true, -]; diff --git a/app/config/testing/session.php b/app/config/testing/session.php deleted file mode 100644 index fef1e78b52..0000000000 --- a/app/config/testing/session.php +++ /dev/null @@ -1,3 +0,0 @@ - 'array',]; diff --git a/app/config/testingInMemory/app.php b/app/config/testingInMemory/app.php deleted file mode 100644 index 7f9d13d6fb..0000000000 --- a/app/config/testingInMemory/app.php +++ /dev/null @@ -1,2 +0,0 @@ - 'debug',]; diff --git a/app/config/testingInMemory/auth.php b/app/config/testingInMemory/auth.php deleted file mode 100644 index 0fe9e0172d..0000000000 --- a/app/config/testingInMemory/auth.php +++ /dev/null @@ -1,8 +0,0 @@ - false, - 'verify_reset' => true, - 'allow_register' => true - -]; diff --git a/app/config/testingInMemory/cache.php b/app/config/testingInMemory/cache.php deleted file mode 100644 index fef1e78b52..0000000000 --- a/app/config/testingInMemory/cache.php +++ /dev/null @@ -1,3 +0,0 @@ - 'array',]; diff --git a/app/config/testingInMemory/database.php b/app/config/testingInMemory/database.php deleted file mode 100644 index 06b50aa143..0000000000 --- a/app/config/testingInMemory/database.php +++ /dev/null @@ -1,12 +0,0 @@ - 'sqlite', - 'connections' => [ - 'sqlite' => [ - 'driver' => 'sqlite', - 'database' => ':memory:', - 'prefix' => '' - ] - - ] -]; diff --git a/app/config/testingInMemory/mail.php b/app/config/testingInMemory/mail.php deleted file mode 100644 index d2df78f4cd..0000000000 --- a/app/config/testingInMemory/mail.php +++ /dev/null @@ -1,13 +0,0 @@ - 'smtp', - 'host' => '', - 'port' => 587, - 'from' => ['address' => '', 'name' => 'Firefly III'], - 'encryption' => 'tls', - 'username' => '', - 'password' => '', - 'sendmail' => '/usr/sbin/sendmail -bs', - 'pretend' => true, -]; diff --git a/app/config/testingInMemory/session.php b/app/config/testingInMemory/session.php deleted file mode 100644 index fef1e78b52..0000000000 --- a/app/config/testingInMemory/session.php +++ /dev/null @@ -1,3 +0,0 @@ - 'array',]; diff --git a/app/config/view.php b/app/config/view.php deleted file mode 100644 index f3b156d455..0000000000 --- a/app/config/view.php +++ /dev/null @@ -1,6 +0,0 @@ - [__DIR__ . '/../views'], - 'pagination' => 'pagination::slider-3', -]; diff --git a/app/config/workbench.php b/app/config/workbench.php deleted file mode 100644 index 62c843d71d..0000000000 --- a/app/config/workbench.php +++ /dev/null @@ -1,6 +0,0 @@ - '', - 'email' => '', -]; diff --git a/app/controllers/.gitkeep b/app/controllers/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php deleted file mode 100644 index fb38a501c0..0000000000 --- a/app/controllers/AccountController.php +++ /dev/null @@ -1,233 +0,0 @@ - ['Default account', 'Asset account'], - 'expense' => ['Expense account', 'Beneficiary account'], - 'revenue' => ['Revenue account'], - ]; - - /** @var AccountRepository */ - protected $_repository; - - /** @var array */ - protected $_shortNamesByFullName - = [ - 'Default account' => 'asset', - 'Asset account' => 'asset', - 'Expense account' => 'expense', - 'Beneficiary account' => 'expense', - 'Revenue account' => 'revenue', - 'Cash account' => 'cash', - ]; - - /** @var array */ - protected $_subIconsByIdentifier - = [ - 'asset' => 'fa-money', - 'Asset account' => 'fa-money', - 'Default account' => 'fa-money', - 'Cash account' => 'fa-money', - 'expense' => 'fa-shopping-cart', - 'Expense account' => 'fa-shopping-cart', - 'Beneficiary account' => 'fa-shopping-cart', - 'revenue' => 'fa-download', - 'Revenue account' => 'fa-download', - ]; - /** @var array */ - protected $_subTitlesByIdentifier - = [ - 'asset' => 'Asset accounts', - 'expense' => 'Expense accounts', - 'revenue' => 'Revenue accounts', - ]; - - /** - * @param AccountRepository $repository - */ - public function __construct(AccountRepository $repository) - { - $this->_repository = $repository; - View::share('mainTitleIcon', 'fa-credit-card'); - View::share('title', 'Accounts'); - } - - /** - * @param $what - * - * @return \Illuminate\View\View - */ - public function create($what) - { - $subTitleIcon = $this->_subIconsByIdentifier[$what]; - $subTitle = 'Create a new ' . e($what) . ' account'; - - return View::make('accounts.create', compact('subTitleIcon', 'what', 'subTitle')); - } - - /** - * @param Account $account - * - * @return $this - */ - public function delete(Account $account) - { - $subTitle = 'Delete ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"'; - - return View::make('accounts.delete', compact('account', 'subTitle')); - } - - /** - * @param Account $account - * - * @return $this|\Illuminate\Http\RedirectResponse - */ - public function destroy(Account $account) - { - - $type = $account->accountType->type; - $typeName = $this->_shortNamesByFullName[$type]; - $name = $account->name; - - $this->_repository->destroy($account); - - Session::flash('success', 'The ' . e($typeName) . ' account "' . e($name) . '" was deleted.'); - - return Redirect::route('accounts.index', $typeName); - } - - /** - * @param Account $account - * - * @return $this - */ - public function edit(Account $account) - { - - $openingBalance = $this->_repository->openingBalanceTransaction($account); - $subTitleIcon = $this->_subIconsByIdentifier[$account->accountType->type]; - $subTitle = 'Edit ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"'; - $what = $this->_shortNamesByFullName[$account->accountType->type]; - - // pre fill some useful values. - $preFilled = [ - 'account_role' => $account->getMeta('accountRole'), - 'openingBalanceDate' => $openingBalance ? $openingBalance->date->format('Y-m-d') : null, - 'openingBalance' => $openingBalance ? $openingBalance->getAmount($account) : null - ]; - Session::flash('preFilled', $preFilled); - - return View::make('accounts.edit', compact('account', 'what', 'subTitle', 'openingBalance', 'subTitleIcon')); - } - - /** - * - * @param string $what - * - * @return View - * @throws FireflyException - */ - public function index($what = 'default') - { - $subTitle = $this->_subTitlesByIdentifier[$what]; - $subTitleIcon = $this->_subIconsByIdentifier[$what]; - - $accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]); - - return View::make('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts')); - } - - /** - * @param Account $account - * @param string $range - * - * @return $this - */ - public function show(Account $account, $range = 'session') - { - $subTitleIcon = $this->_subIconsByIdentifier[$account->accountType->type]; - $what = $this->_shortNamesByFullName[$account->accountType->type]; - $journals = $this->_repository->getTransactionJournals($account, 50, $range); - $subTitle = 'Details for ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"'; - - return View::make('accounts.show', compact('account', 'what', 'range', 'subTitleIcon', 'journals', 'subTitle')); - } - - /** - * @return $this|\Illuminate\Http\RedirectResponse - * @throws FireflyException - */ - public function store() - { - $data = Input::except('_token'); - $messages = $this->_repository->validate($data); - - - // flash messages: - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not store account: ' . $messages['errors']->first()); - } - - // return to create screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { - return Redirect::route('accounts.create', e($data['what']))->withInput(); - } - - // store - $this->_repository->store($data); - Session::flash('success', 'Account "' . e($data['name']) . '" stored.'); - if ($data['post_submit_action'] == 'store') { - return Redirect::route('accounts.index', e($data['what'])); - } - - return Redirect::route('accounts.create', e($data['what']))->withInput(); - } - - /** - * @param Account $account - * - * @return $this - * @throws FireflyException - */ - public function update(Account $account) - { - $data = Input::except('_token'); - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update account: ' . $messages['errors']->first()); - } - - // return to update screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { - return Redirect::route('accounts.edit', $account->id)->withInput(); - } - - // update - $this->_repository->update($account, $data); - Session::flash('success', 'Account "' . e($data['name']) . '" updated.'); - - // go back to list - if ($data['post_submit_action'] == 'update') { - return Redirect::route('accounts.index', e($data['what'])); - } - - // go back to update screen. - return Redirect::route('accounts.edit', $account->id)->withInput(['post_submit_action' => 'return_to_edit']); - } -} diff --git a/app/controllers/BaseController.php b/app/controllers/BaseController.php deleted file mode 100644 index df09e3091d..0000000000 --- a/app/controllers/BaseController.php +++ /dev/null @@ -1,30 +0,0 @@ -layout)) { - $this->layout = View::make($this->layout); - } - } - -} diff --git a/app/controllers/BillController.php b/app/controllers/BillController.php deleted file mode 100644 index 0fdd0f7309..0000000000 --- a/app/controllers/BillController.php +++ /dev/null @@ -1,215 +0,0 @@ -_repository = $repository; - - View::share('title', 'Bills'); - View::share('mainTitleIcon', 'fa-calendar-o'); - } - - /** - * @return $this - */ - public function create() - { - $periods = \Config::get('firefly.periods_to_text'); - - return View::make('bills.create')->with('periods', $periods)->with('subTitle', 'Create new'); - } - - /** - * @param Bill $bill - * - * @return $this - */ - public function delete(Bill $bill) - { - return View::make('bills.delete')->with('bill', $bill)->with( - 'subTitle', 'Delete "' . e($bill->name) . '"' - ); - } - - /** - * @param Bill $bill - * - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(Bill $bill) - { - $this->_repository->destroy($bill); - Session::flash('success', 'The bill was deleted.'); - - return Redirect::route('bills.index'); - - } - - /** - * @param Bill $bill - * - * @return $this - */ - public function edit(Bill $bill) - { - $periods = \Config::get('firefly.periods_to_text'); - - return View::make('bills.edit')->with('periods', $periods)->with('bill', $bill)->with( - 'subTitle', 'Edit "' . e($bill->name) . '"' - ); - } - - /** - * @return $this - */ - public function index() - { - $bills = $this->_repository->get(); - $bills->each( - function (Bill $bill) { - $bill->nextExpectedMatch = $this->_repository->nextExpectedMatch($bill); - $bill->lastFoundMatch = $this->_repository->lastFoundMatch($bill); - } - ); - - return View::make('bills.index', compact('bills')); - } - - /** - * @param Bill $bill - * - * @return mixed - */ - public function rescan(Bill $bill) - { - if (intval($bill->active) == 0) { - Session::flash('warning', 'Inactive bills cannot be scanned.'); - - return Redirect::intended('/'); - } - - $this->_repository->scanEverything($bill); - - Session::flash('success', 'Rescanned everything.'); - - return Redirect::intended('/'); - } - - /** - * @param Bill $bill - * - * @return mixed - */ - public function show(Bill $bill) - { - $journals = $bill->transactionjournals()->withRelevantData()->orderBy('date', 'DESC')->get(); - $bill->nextExpectedMatch = $this->_repository->nextExpectedMatch($bill); - $hideBill = true; - - - return View::make('bills.show', compact('journals', 'hideBill', 'bill'))->with( - 'subTitle', e($bill->name) - ); - } - - /** - * @return $this - * @throws FireflyException - */ - public function store() - { - $data = Input::except(['_token', 'post_submit_action']); - $data['user_id'] = Auth::user()->id; - - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not store bill: ' . $messages['errors']->first()); - - return Redirect::route('bills.create')->withInput(); - } - - // return to create screen: - if (Input::get('post_submit_action') == 'validate_only') { - return Redirect::route('bills.create')->withInput(); - } - - // store - $this->_repository->store($data); - Session::flash('success', 'Bill "' . e($data['name']) . '" stored.'); - if (Input::get('post_submit_action') == 'store') { - return Redirect::route('bills.index'); - } - - return Redirect::route('bills.create')->withInput(); - - } - - /** - * @param Bill $bill - * - * @return $this - * @throws FireflyException - */ - public function update(Bill $bill) - { - $data = Input::except('_token'); - $data['active'] = intval(Input::get('active')); - $data['automatch'] = intval(Input::get('automatch')); - $data['user_id'] = Auth::user()->id; - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update bill: ' . $messages['errors']->first()); - - return Redirect::route('bills.edit', $bill->id)->withInput(); - } - - // return to update screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('bills.edit', $bill->id)->withInput(); - } - - // update - $this->_repository->update($bill, $data); - Session::flash('success', 'Bill "' . e($data['name']) . '" updated.'); - - // go back to list - if ($data['post_submit_action'] == 'update') { - return Redirect::route('bills.index'); - } - - // go back to update screen. - return Redirect::route('bills.edit', $bill->id)->withInput(['post_submit_action' => 'return_to_edit']); - - } -} diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.php deleted file mode 100644 index 5a42967adc..0000000000 --- a/app/controllers/BudgetController.php +++ /dev/null @@ -1,254 +0,0 @@ -_repository = $repository; - $this->_preferences = $preferences; - View::share('title', 'Budgets'); - View::share('mainTitleIcon', 'fa-tasks'); - } - - /** - * @param Budget $budget - * - * @return \Illuminate\Http\JsonResponse - * @throws Exception - */ - public function amount(Budget $budget) - { - $amount = intval(Input::get('amount')); - $date = Session::get('start', Carbon::now()->startOfMonth()); - $limitRepetition = $this->_repository->updateLimitAmount($budget, $date, $amount); - - return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition ? $limitRepetition->id : 0]); - - } - - /** - * @return $this - */ - public function create() - { - return View::make('budgets.create')->with('subTitle', 'Create a new budget'); - } - - /** - * @param Budget $budget - * - * @return $this - */ - public function delete(Budget $budget) - { - $subTitle = 'Delete budget "' . e($budget->name) . '"'; - - return View::make('budgets.delete', compact('budget', 'subTitle')); - } - - /** - * @param Budget $budget - * - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(Budget $budget) - { - Session::flash('success', 'Budget "' . e($budget->name) . '" was deleted.'); - $this->_repository->destroy($budget); - - - return Redirect::route('budgets.index'); - - } - - /** - * @param Budget $budget - * - * @return $this - */ - public function edit(Budget $budget) - { - $subTitle = 'Edit budget "' . e($budget->name) . '"'; - - return View::make('budgets.edit', compact('budget', 'subTitle')); - - } - - /** - * The index of the budget controller contains all budgets and the current relevant limit repetition. - * - * @return $this - */ - public function index() - { - $budgets = $this->_repository->get(); - - // loop the budgets: - $budgets->each( - function (Budget $budget) { - $budget->spent = $this->_repository->spentInMonth($budget, \Session::get('start', Carbon::now()->startOfMonth())); - $budget->currentRep = $this->_repository->getRepetitionByDate($budget, \Session::get('start', Carbon::now()->startOfMonth())); - } - ); - - $spent = $budgets->sum('spent'); - $amount = $this->_preferences->get('budgetIncomeTotal' . \Session::get('start', Carbon::now()->startOfMonth())->format('FY'), 1000)->data; - $overspent = $spent > $amount; - $spentPCT = $overspent ? ceil($amount / $spent * 100) : ceil($spent / $amount * 100); - $budgetMax = $this->_preferences->get('budgetMaximum', 1000); - $budgetMaximum = $budgetMax->data; - - return View::make('budgets.index', compact('budgetMaximum', 'budgets', 'spent', 'spentPCT', 'overspent', 'amount')); - } - - /** - * @return \Illuminate\View\View - */ - public function noBudget() - { - $start = \Session::get('start', Carbon::now()->startOfMonth()); - $end = \Session::get('end', Carbon::now()->startOfMonth()); - $list = $this->_repository->journalsNoBudget($start, $end); - $subTitle = 'Transactions without a budget in ' . $start->format('F Y'); - - return View::make('budgets.noBudget', compact('list', 'subTitle')); - } - - /** - * @return \Illuminate\Http\RedirectResponse - */ - public function postUpdateIncome() - { - $this->_preferences->set('budgetIncomeTotal' . Session::get('start', Carbon::now()->startOfMonth())->format('FY'), intval(Input::get('amount'))); - - return Redirect::route('budgets.index'); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @param Budget $budget - * @param LimitRepetition $repetition - * - * @return \Illuminate\View\View - */ - public function show(Budget $budget, LimitRepetition $repetition = null) - { - if (!is_null($repetition) && $repetition->budgetLimit->budget->id != $budget->id) { - return View::make('error')->with('message', 'Invalid selection.'); - } - - $hideBudget = true; // used in transaction list. - $journals = $this->_repository->getJournals($budget, $repetition); - $limits = $repetition ? [$repetition->budgetLimit] : $budget->budgetLimits()->orderBy('startdate', 'DESC')->get(); - $subTitle = $repetition ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name); - - return View::make('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle', 'hideBudget')); - } - - /** - * @return $this|\Illuminate\Http\RedirectResponse - */ - public function store() - { - $data = Input::except('_token'); - $data['user_id'] = Auth::user()->id; - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not validate budget: ' . $messages['errors']->first()); - return Redirect::route('budgets.create')->withInput(); - } - - // return to create screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('budgets.create')->withInput(); - } - - // store - $this->_repository->store($data); - Session::flash('success', 'Budget "' . e($data['name']) . '" stored.'); - if ($data['post_submit_action'] == 'store') { - return Redirect::route('budgets.index'); - } - - // create another. - return Redirect::route('budgets.create')->withInput(); - } - - /** - * @param Budget $budget - * - * @return $this|\Illuminate\Http\RedirectResponse - */ - public function update(Budget $budget) - { - - $data = Input::except('_token'); - $data['user_id'] = Auth::user()->id; - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update budget: ' . $messages['errors']->first()); - return Redirect::route('budgets.edit', $budget->id)->withInput(); - } - - // return to update screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('budgets.edit', $budget->id)->withInput(); - } - - // update - $this->_repository->update($budget, $data); - Session::flash('success', 'Budget "' . e($data['name']) . '" updated.'); - - // go back to list - if ($data['post_submit_action'] == 'update') { - return Redirect::route('budgets.index'); - } - - return Redirect::route('budgets.edit', $budget->id)->withInput(['post_submit_action' => 'return_to_edit']); - } - - /** - * @return $this - */ - public function updateIncome() - { - $budgetAmount = $this->_preferences->get('budgetIncomeTotal' . Session::get('start', Carbon::now()->startOfMonth())->format('FY'), 1000); - - return View::make('budgets.income')->with('amount', $budgetAmount); - } -} diff --git a/app/controllers/CategoryController.php b/app/controllers/CategoryController.php deleted file mode 100644 index bc5d0846f1..0000000000 --- a/app/controllers/CategoryController.php +++ /dev/null @@ -1,189 +0,0 @@ -_repository = $repository; - } - - /** - * @return \Illuminate\View\View - */ - public function create() - { - return View::make('categories.create')->with('subTitle', 'Create a new category'); - } - - /** - * @return \Illuminate\View\View - */ - public function noCategory() - { - $start = \Session::get('start', Carbon::now()->startOfMonth()); - $end = \Session::get('end', Carbon::now()->startOfMonth()); - $list = $this->_repository->journalsNoCategory($start, $end); - $subTitle = 'Transactions without a category in ' . $start->format('F Y'); - - return View::make('categories.noCategory', compact('list', 'subTitle')); - } - - /** - * @param Category $category - * - * @return $this - */ - public function delete(Category $category) - { - return View::make('categories.delete')->with('category', $category)->with('subTitle', 'Delete category "' . e($category->name) . '"'); - } - - /** - * @param Category $category - * - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(Category $category) - { - Session::flash('success', 'Category "' . e($category->name) . '" was deleted.'); - $this->_repository->destroy($category); - - - return Redirect::route('categories.index'); - } - - /** - * @param Category $category - * - * @return $this - */ - public function edit(Category $category) - { - return View::make('categories.edit')->with('category', $category)->with('subTitle', 'Edit category "' . e($category->name) . '"'); - } - - /** - * @return $this - */ - public function index() - { - $categories = $this->_repository->get(); - - return View::make('categories.index', compact('categories')); - } - - /** - * @param Category $category - * - * @return $this - */ - public function show(Category $category) - { - $hideCategory = true; // used in list. - $journals = $this->_repository->getTransactionJournals($category, 50); - - return View::make('categories.show', compact('category', 'journals', 'hideCategory')); - } - - /** - * - * @return $this - * @throws FireflyException - */ - public function store() - { - $data = Input::except('_token'); - $data['user_id'] = Auth::user()->id; - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not store category: ' . $messages['errors']->first()); - return Redirect::route('categories.create')->withInput(); - } - - // return to create screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('categories.create')->withInput(); - } - - // store - $this->_repository->store($data); - Session::flash('success', 'Category "' . e($data['name']) . '" stored.'); - if ($data['post_submit_action'] == 'store') { - return Redirect::route('categories.index'); - } - - return Redirect::route('categories.create')->withInput(); - } - - /** - * - * @param Category $category - * - * @return $this - * @throws FireflyException - */ - public function update(Category $category) - { - $data = Input::except('_token'); - $data['user_id'] = Auth::user()->id; - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update category: ' . $messages['errors']->first()); - return Redirect::route('categories.edit', $category->id)->withInput(); - } - - // return to update screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('categories.edit', $category->id)->withInput(); - } - - // update - $this->_repository->update($category, $data); - Session::flash('success', 'Category "' . e($data['name']) . '" updated.'); - - // go back to list - if ($data['post_submit_action'] == 'update') { - return Redirect::route('categories.index'); - } - - // go back to update screen. - return Redirect::route('categories.edit', $category->id)->withInput(['post_submit_action' => 'return_to_edit']); - - - } - - -} diff --git a/app/controllers/CurrencyController.php b/app/controllers/CurrencyController.php deleted file mode 100644 index 9b55132333..0000000000 --- a/app/controllers/CurrencyController.php +++ /dev/null @@ -1,199 +0,0 @@ -_repository = $repository; - - - View::share('title', 'Currencies'); - View::share('mainTitleIcon', 'fa-usd'); - } - - /** - * @return \Illuminate\View\View - */ - public function create() - { - $subTitleIcon = 'fa-plus'; - $subTitle = 'Create a new currency'; - - return View::make('currency.create', compact('subTitleIcon', 'subTitle')); - } - - /** - * @param TransactionCurrency $currency - * - * @return \Illuminate\Http\RedirectResponse - */ - public function defaultCurrency(TransactionCurrency $currency) - { - /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */ - $preferences = App::make('FireflyIII\Shared\Preferences\Preferences'); - - $currencyPreference = $preferences->get('currencyPreference', 'EUR'); - $currencyPreference->data = $currency->code; - $currencyPreference->save(); - - Session::flash('success', $currency->name.' is now the default currency.'); - Cache::forget('FFCURRENCYSYMBOL'); - Cache::forget('FFCURRENCYCODE'); - - return Redirect::route('currency.index'); - - } - - /** - * @param TransactionCurrency $currency - * - * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View - */ - public function delete(TransactionCurrency $currency) - { - if ($currency->transactionJournals()->count() > 0) { - Session::flash('error', 'Cannot delete ' . e($currency->name) . ' because there are still transactions attached to it.'); - - return Redirect::route('currency.index'); - } - - - return View::make('currency.delete', compact('currency')); - } - - /** - * @param TransactionCurrency $currency - * - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(TransactionCurrency $currency) - { - Session::flash('success', 'Currency "' . e($currency->name) . '" deleted'); - - $this->_repository->destroy($currency); - - return Redirect::route('currency.index'); - } - - /** - * @param TransactionCurrency $currency - * - * @return \Illuminate\View\View - */ - public function edit(TransactionCurrency $currency) - { - $subTitleIcon = 'fa-pencil'; - $subTitle = 'Edit currency "' . e($currency->name) . '"'; - $currency->symbol = htmlentities($currency->symbol); - - return View::make('currency.edit', compact('currency', 'subTitle', 'subTitleIcon')); - - } - - /** - * @return \Illuminate\View\View - */ - public function index() - { - $currencies = $this->_repository->get(); - - /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */ - $preferences = App::make('FireflyIII\Shared\Preferences\Preferences'); - - $currencyPreference = $preferences->get('currencyPreference', 'EUR'); - $defaultCurrency = $this->_repository->findByCode($currencyPreference->data); - - - return View::make('currency.index', compact('currencies', 'defaultCurrency')); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @return $this|\Illuminate\Http\RedirectResponse - */ - public function store() - { - $data = Input::except('_token'); - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not store currency: ' . $messages['errors']->first()); - } - - // return to create screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { - return Redirect::route('currency.create')->withInput(); - } - - // store - $this->_repository->store($data); - Session::flash('success', 'Currency "' . e($data['name']) . '" stored.'); - if ($data['post_submit_action'] == 'store') { - return Redirect::route('currency.index'); - } - - return Redirect::route('currency.create')->withInput(); - - } - - /** - * @param TransactionCurrency $currency - * - * @return $this|\Illuminate\Http\RedirectResponse - */ - public function update(TransactionCurrency $currency) - { - $data = Input::except('_token'); - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update currency: ' . $messages['errors']->first()); - return Redirect::route('currency.edit', $currency->id)->withInput(); - } - - // return to update screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('currency.edit', $currency->id)->withInput(); - } - - // update - $this->_repository->update($currency, $data); - Session::flash('success', 'Currency "' . e($data['name']) . '" updated.'); - - // go back to list - if ($data['post_submit_action'] == 'update') { - return Redirect::route('currency.index'); - } - - return Redirect::route('currency.edit', $currency->id)->withInput(['post_submit_action' => 'return_to_edit']); - - } - -} diff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.php deleted file mode 100644 index 4e882653b1..0000000000 --- a/app/controllers/GoogleChartController.php +++ /dev/null @@ -1,537 +0,0 @@ -_chart = $chart; - $this->_repository = $repository; - $this->_start = Session::get('start', Carbon::now()->startOfMonth()); - $this->_end = Session::get('end', Carbon::now()->endOfMonth()); - - } - - /** - * @param Account $account - * @param string $view - * - * @return \Illuminate\Http\JsonResponse - */ - public function accountBalanceChart(Account $account, $view = 'session') - { - $this->_chart->addColumn('Day of month', 'date'); - $this->_chart->addColumn('Balance for ' . $account->name, 'number'); - $this->_chart->addCertainty(1); - - $start = $this->_start; - $end = $this->_end; - $count = $account->transactions()->count(); - - if ($view == 'all' && $count > 0) { - $first = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy( - 'date', 'ASC' - )->first(['transaction_journals.date']); - $last = $account->transactions()->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->orderBy( - 'date', 'DESC' - )->first(['transaction_journals.date']); - $start = new Carbon($first->date); - $end = new Carbon($last->date); - } - - $current = clone $start; - - while ($end >= $current) { - $this->_chart->addRow(clone $current, Steam::balance($account, $current), false); - $current->addDay(); - } - - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - */ - public function allAccountsBalanceChart() - { - $this->_chart->addColumn('Day of the month', 'date'); - - /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */ - $preferences = App::make('FireflyIII\Shared\Preferences\Preferences'); - $pref = $preferences->get('frontPageAccounts', []); - - /** @var \FireflyIII\Database\Account\Account $acct */ - $acct = App::make('FireflyIII\Database\Account\Account'); - $accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAccountsByType(['Default account', 'Asset account']); - - $index = 1; - /** @var Account $account */ - foreach ($accounts as $account) { - $this->_chart->addColumn('Balance for ' . $account->name, 'number'); - $this->_chart->addCertainty($index); - $index++; - } - $current = clone $this->_start; - $current->subDay(); - $today = Carbon::now(); - while ($this->_end >= $current) { - $row = [clone $current]; - $certain = $current < $today; - foreach ($accounts as $account) { - - $row[] = Steam::balance($account, $current); - $row[] = $certain; - } - $this->_chart->addRowArray($row); - $current->addDay(); - } - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - } - - /** - * @param int $year - * - * @return $this|\Illuminate\Http\JsonResponse - */ - public function allBudgetsAndSpending($year) - { - try { - new Carbon('01-01-' . $year); - } catch (Exception $e) { - return View::make('error')->with('message', 'Invalid year.'); - } - /** @var \FireflyIII\Database\Budget\Budget $budgetRepository */ - $budgetRepository = App::make('FireflyIII\Database\Budget\Budget'); - $budgets = $budgetRepository->get(); - $budgets->sortBy('name'); - $this->_chart->addColumn('Month', 'date'); - foreach ($budgets as $budget) { - $this->_chart->addColumn($budget->name, 'number'); - } - $start = Carbon::createFromDate(intval($year), 1, 1); - $end = clone $start; - $end->endOfYear(); - - - while ($start <= $end) { - $row = [clone $start]; - foreach ($budgets as $budget) { - $spent = $budgetRepository->spentInMonth($budget, $start); - //$repetition = $budgetRepository->repetitionOnStartingOnDate($budget, $start); - $row[] = $spent; - } - $this->_chart->addRowArray($row); - $start->addMonth(); - } - - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - } - - /** - * @return \Illuminate\Http\JsonResponse - */ - public function allBudgetsHomeChart() - { - $this->_chart->addColumn('Budget', 'string'); - $this->_chart->addColumn('Budgeted', 'number'); - $this->_chart->addColumn('Spent', 'number'); - - /** @var \FireflyIII\Database\Budget\Budget $bdt */ - $bdt = App::make('FireflyIII\Database\Budget\Budget'); - $budgets = $bdt->get(); - - /** @var Budget $budget */ - foreach ($budgets as $budget) { - - /** @var \LimitRepetition $repetition */ - $repetition = $bdt->repetitionOnStartingOnDate($budget, $this->_start); - if (is_null($repetition)) { // use the session start and end for our search query - $searchStart = $this->_start; - $searchEnd = $this->_end; - $limit = 0; // the limit is zero: - } else { - // use the limit's start and end for our search query - $searchStart = $repetition->startdate; - $searchEnd = $repetition->enddate; - $limit = floatval($repetition->amount); // the limit is the repetitions limit: - } - - $expenses = floatval($budget->transactionjournals()->before($searchEnd)->after($searchStart)->lessThan(0)->sum('amount')) * -1; - if ($expenses > 0) { - $this->_chart->addRow($budget->name, $limit, $expenses); - } - } - - $noBudgetSet = $bdt->expenseNoBudget($this->_start, $this->_end); - $sum = $noBudgetSet->sum('amount') * -1; - $this->_chart->addRow('No budget', 0, $sum); - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - } - - /** - * @return \Illuminate\Http\JsonResponse - */ - public function allCategoriesHomeChart() - { - $this->_chart->addColumn('Category', 'string'); - $this->_chart->addColumn('Spent', 'number'); - - // query! - $set = $this->_repository->getCategorySummary($this->_start, $this->_end); - - foreach ($set as $entry) { - $entry->name = strlen($entry->name) == 0 ? '(no category)' : $entry->name; - $this->_chart->addRow($entry->name, floatval($entry->sum)); - } - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - } - - /** - * @param Bill $bill - * - * @return \Illuminate\Http\JsonResponse - */ - public function billOverview(Bill $bill) - { - - $this->_chart->addColumn('Date', 'date'); - $this->_chart->addColumn('Max amount', 'number'); - $this->_chart->addColumn('Min amount', 'number'); - $this->_chart->addColumn('Current entry', 'number'); - - // get first transaction or today for start: - $first = $bill->transactionjournals()->orderBy('date', 'ASC')->first(); - if ($first) { - $start = $first->date; - } else { - $start = new Carbon; - } - $end = new Carbon; - while ($start <= $end) { - $result = $bill->transactionjournals()->before($end)->after($start)->first(); - if ($result) { - $amount = $result->getAmount(); - } else { - $amount = 0; - } - unset($result); - $this->_chart->addRow(clone $start, $bill->amount_max, $bill->amount_min, $amount); - $start = DateKit::addPeriod($start, $bill->repeat_freq, 0); - } - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - } - - /** - * - * @return \Illuminate\Http\JsonResponse - * @throws \FireflyIII\Exception\FireflyException - */ - public function billsOverview() - { - $paid = ['items' => [], 'amount' => 0]; - $unpaid = ['items' => [], 'amount' => 0]; - $this->_chart->addColumn('Name', 'string'); - $this->_chart->addColumn('Amount', 'number'); - - $set = $this->_repository->getBillsSummary($this->_start, $this->_end); - - foreach ($set as $entry) { - if (intval($entry->journalId) == 0) { - $unpaid['items'][] = $entry->name; - $unpaid['amount'] += floatval($entry->averageAmount); - } else { - $description = intval($entry->encrypted) == 1 ? Crypt::decrypt($entry->description) : $entry->description; - $paid['items'][] = $description; - $paid['amount'] += floatval($entry->actualAmount); - } - } - $this->_chart->addRow('Unpaid: ' . join(', ', $unpaid['items']), $unpaid['amount']); - $this->_chart->addRow('Paid: ' . join(', ', $paid['items']), $paid['amount']); - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - } - - /** - * - * @param Budget $budget - * @param LimitRepetition $repetition - * - * @return \Illuminate\Http\JsonResponse - */ - public function budgetLimitSpending(\Budget $budget, \LimitRepetition $repetition) - { - $start = clone $repetition->startdate; - $end = $repetition->enddate; - - $this->_chart->addColumn('Day', 'date'); - $this->_chart->addColumn('Left', 'number'); - - - $amount = $repetition->amount; - - while ($start <= $end) { - /* - * Sum of expenses on this day: - */ - $sum = floatval($budget->transactionjournals()->lessThan(0)->transactionTypes(['Withdrawal'])->onDate($start)->sum('amount')); - $amount += $sum; - $this->_chart->addRow(clone $start, $amount); - $start->addDay(); - } - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - } - - /** - * - * @param Budget $budget - * - * @param int $year - * - * @return \Illuminate\Http\JsonResponse - */ - public function budgetsAndSpending(Budget $budget, $year = 0) - { - /** @var \FireflyIII\Database\Budget\Budget $budgetRepository */ - $budgetRepository = App::make('FireflyIII\Database\Budget\Budget'); - - $this->_chart->addColumn('Month', 'date'); - $this->_chart->addColumn('Budgeted', 'number'); - $this->_chart->addColumn('Spent', 'number'); - if ($year == 0) { - // grab the first budgetlimit ever: - $firstLimit = $budget->budgetlimits()->orderBy('startdate', 'ASC')->first(); - if ($firstLimit) { - $start = new Carbon($firstLimit->startdate); - } else { - $start = Carbon::now()->startOfYear(); - } - - // grab the last budget limit ever: - $lastLimit = $budget->budgetlimits()->orderBy('startdate', 'DESC')->first(); - if ($lastLimit) { - $end = new Carbon($lastLimit->startdate); - } else { - $end = Carbon::now()->endOfYear(); - } - } else { - $start = Carbon::createFromDate(intval($year), 1, 1); - $end = clone $start; - $end->endOfYear(); - } - - while ($start <= $end) { - $spent = $budgetRepository->spentInMonth($budget, $start); - $repetition = $budgetRepository->repetitionOnStartingOnDate($budget, $start); - - if ($repetition) { - $budgeted = floatval($repetition->amount); - \Log::debug('Found a repetition on ' . $start->format('Y-m-d') . ' for budget ' . $budget->name . '!'); - } else { - \Log::debug('No repetition on ' . $start->format('Y-m-d') . ' for budget ' . $budget->name); - $budgeted = null; - } - $this->_chart->addRow(clone $start, $budgeted, $spent); - $start->addMonth(); - } - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - - } - - /** - * - * @param Category $component - * @param $year - * - * @return \Illuminate\Http\JsonResponse - */ - public function categoriesAndSpending(Category $component, $year) - { - try { - new Carbon('01-01-' . $year); - } catch (Exception $e) { - return View::make('error')->with('message', 'Invalid year.'); - } - - /** @var \FireflyIII\Database\Category\Category $categoryRepository */ - $categoryRepository = App::make('FireflyIII\Database\Category\Category'); - - $this->_chart->addColumn('Month', 'date'); - $this->_chart->addColumn('Budgeted', 'number'); - $this->_chart->addColumn('Spent', 'number'); - - $start = new Carbon('01-01-' . $year); - $end = clone $start; - $end->endOfYear(); - while ($start <= $end) { - - $spent = $categoryRepository->spentInMonth($component, $start); - $budgeted = null; - - $this->_chart->addRow(clone $start, $budgeted, $spent); - - $start->addMonth(); - } - - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - - } - - /** - * @param PiggyBank $piggyBank - * - * @return \Illuminate\Http\JsonResponse - */ - public function piggyBankHistory(\PiggyBank $piggyBank) - { - $this->_chart->addColumn('Date', 'date'); - $this->_chart->addColumn('Balance', 'number'); - - $set = \DB::table('piggy_bank_events')->where('piggy_bank_id', $piggyBank->id)->groupBy('date')->get(['date', DB::Raw('SUM(`amount`) AS `sum`')]); - - foreach ($set as $entry) { - $this->_chart->addRow(new Carbon($entry->date), floatval($entry->sum)); - } - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - } - - /** - * - * @param $year - * - * @return \Illuminate\Http\JsonResponse - */ - public function yearInExp($year) - { - try { - $start = new Carbon('01-01-' . $year); - } catch (Exception $e) { - return View::make('error')->with('message', 'Invalid year.'); - } - $this->_chart->addColumn('Month', 'date'); - $this->_chart->addColumn('Income', 'number'); - $this->_chart->addColumn('Expenses', 'number'); - - /** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $repository */ - $repository = App::make('FireflyIII\Database\TransactionJournal\TransactionJournal'); - - $end = clone $start; - $end->endOfYear(); - while ($start < $end) { - - // total income: - $income = $repository->getSumOfIncomesByMonth($start); - $expense = $repository->getSumOfExpensesByMonth($start); - - $this->_chart->addRow(clone $start, $income, $expense); - $start->addMonth(); - } - - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - } - - /** - * - * @param $year - * - * @return \Illuminate\Http\JsonResponse - */ - public function yearInExpSum($year) - { - try { - $start = new Carbon('01-01-' . $year); - } catch (Exception $e) { - return View::make('error')->with('message', 'Invalid year.'); - } - $this->_chart->addColumn('Summary', 'string'); - $this->_chart->addColumn('Income', 'number'); - $this->_chart->addColumn('Expenses', 'number'); - - /** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $repository */ - $repository = App::make('FireflyIII\Database\TransactionJournal\TransactionJournal'); - - $end = clone $start; - $end->endOfYear(); - $income = 0; - $expense = 0; - $count = 0; - while ($start < $end) { - - // total income: - $income += $repository->getSumOfIncomesByMonth($start); - $expense += $repository->getSumOfExpensesByMonth($start); - $count++; - - $start->addMonth(); - } - $this->_chart->addRow('Sum', $income, $expense); - $count = $count > 0 ? $count : 1; - $this->_chart->addRow('Average', ($income / $count), ($expense / $count)); - - - $this->_chart->generate(); - - return Response::json($this->_chart->getData()); - - } -} diff --git a/app/controllers/HelpController.php b/app/controllers/HelpController.php deleted file mode 100644 index dbb9f7a2aa..0000000000 --- a/app/controllers/HelpController.php +++ /dev/null @@ -1,84 +0,0 @@ - 'There is no help for this route!
', - 'title' => 'Help', - ]; - - if (!Route::has($route)) { - \Log::error('No such route: ' . $route); - - return Response::json($content); - } - - if ($this->_inCache($route)) { - $content = [ - 'text' => Cache::get('help.' . $route . '.text'), - 'title' => Cache::get('help.' . $route . '.title'), - ]; - - return Response::json($content); - } - $content = $this->_getFromGithub($route); - - - Cache::put('help.' . $route . '.text', $content['text'], 10080); // a week. - Cache::put('help.' . $route . '.title', $content['title'], 10080); - - return Response::json($content); - - } - - /** - * @param $route - * - * @return bool - */ - protected function _inCache($route) - { - return Cache::has('help.' . $route . '.title') && Cache::has('help.' . $route . '.text'); - } - - /** - * @param $route - * - * @return array - */ - protected function _getFromGithub($route) - { - $uri = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md'; - $content = [ - 'text' => 'There is no help for this route!
', - 'title' => $route, - ]; - try { - $content['text'] = file_get_contents($uri); - } catch (ErrorException $e) { - \Log::error(trim($e->getMessage())); - } - if (strlen(trim($content['text'])) == 0) { - $content['text'] = 'There is no help for this route.
'; - } - $content['text'] = \Michelf\Markdown::defaultTransform($content['text']); - - return $content; - - - } -} - diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php deleted file mode 100644 index b9e15a285a..0000000000 --- a/app/controllers/HomeController.php +++ /dev/null @@ -1,101 +0,0 @@ -countAccountsByType(['Default account', 'Asset account']); - - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); - - - // get the preference for the home accounts to show: - $frontPage = $preferences->get('frontPageAccounts', []); - if ($frontPage->data == []) { - $accounts = $acct->getAccountsByType(['Default account', 'Asset account']); - } else { - $accounts = $acct->getByIds($frontPage->data); - } - - $transactions = []; - foreach ($accounts as $account) { - $set = $journalRepository->getInDateRangeAccount($account, $start, $end, 10); - if (count($set) > 0) { - $transactions[] = [$set, $account]; - } - } - - // build the home screen: - return View::make('index')->with('count', $count)->with('transactions', $transactions)->with('title', 'Firefly')->with('subTitle', 'What\'s playing?') - ->with('mainTitleIcon', 'fa-fire'); - } - - /** - * @param $range - * - * @return \Illuminate\Http\RedirectResponse - */ - public function rangeJump($range) - { - - $valid = ['1D', '1W', '1M', '3M', '6M', '1Y',]; - - /** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */ - $preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface'); - - if (in_array($range, $valid)) { - $preferences->set('viewRange', $range); - Session::forget('range'); - } - return Redirect::to(URL::previous()); - } - - /** - * @return \Illuminate\Http\RedirectResponse - */ - public function sessionNext() - { - Navigation::next(); - return Redirect::to(URL::previous()); - - } - - /** - * @return \Illuminate\Http\RedirectResponse - */ - public function sessionPrev() - { - Navigation::prev(); - return Redirect::to(URL::previous()); - } -} diff --git a/app/controllers/JsonController.php b/app/controllers/JsonController.php deleted file mode 100644 index a0e6f08262..0000000000 --- a/app/controllers/JsonController.php +++ /dev/null @@ -1,65 +0,0 @@ -get(); - $return = []; - foreach ($list as $entry) { - $return[] = $entry->name; - } - - return Response::json($return); - - - } - - /** - * Returns a JSON list of all beneficiaries. - * - * @return \Illuminate\Http\JsonResponse - */ - public function expenseAccounts() - { - /** @var \FireflyIII\Database\Account\Account $accounts */ - $accounts = App::make('FireflyIII\Database\Account\Account'); - $list = $accounts->getAccountsByType(['Expense account', 'Beneficiary account']); - $return = []; - foreach ($list as $entry) { - $return[] = $entry->name; - } - - return Response::json($return); - - } - - /** - * @return \Illuminate\Http\JsonResponse - */ - public function revenueAccounts() - { - /** @var \FireflyIII\Database\Account\Account $accounts */ - $accounts = App::make('FireflyIII\Database\Account\Account'); - $list = $accounts->getAccountsByType(['Revenue account']); - $return = []; - foreach ($list as $entry) { - $return[] = $entry->name; - } - - return Response::json($return); - - } -} diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php deleted file mode 100644 index 5b9851eb84..0000000000 --- a/app/controllers/PiggybankController.php +++ /dev/null @@ -1,360 +0,0 @@ -_repository = $repository; - View::share('title', 'Piggy banks'); - View::share('mainTitleIcon', 'fa-sort-amount-asc'); - } - - /** - * Add money to piggy bank - * - * @param PiggyBank $piggyBank - * - * @return $this - */ - public function add(PiggyBank $piggyBank) - { - $leftOnAccount = $this->_repository->leftOnAccount($piggyBank->account); - $savedSoFar = $piggyBank->currentRelevantRep()->currentamount; - $leftToSave = $piggyBank->targetamount - $savedSoFar; - $maxAmount = min($leftOnAccount, $leftToSave); - - - \Log::debug('Now going to view for piggy bank #' . $piggyBank->id . ' (' . $piggyBank->name . ')'); - - return View::make('piggy_banks.add', compact('piggyBank', 'maxAmount')); - } - - /** - * @return mixed - */ - public function create() - { - - /** @var \FireflyIII\Database\Account\Account $acct */ - $acct = App::make('FireflyIII\Database\Account\Account'); - - $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); - $subTitle = 'Create new piggy bank'; - $subTitleIcon = 'fa-plus'; - - return View::make('piggy_banks.create', compact('accounts', 'periods', 'subTitle', 'subTitleIcon')); - } - - /** - * @param PiggyBank $piggyBank - * - * @return $this - */ - public function delete(PiggyBank $piggyBank) - { - $subTitle = 'Delete "' . e($piggyBank->name) . '"'; - - return View::make('piggy_banks.delete', compact('piggyBank', 'subTitle')); - } - - /** - * @param PiggyBank $piggyBank - * - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(PiggyBank $piggyBank) - { - - Session::flash('success', 'Piggy bank "' . e($piggyBank->name) . '" deleted.'); - $this->_repository->destroy($piggyBank); - - return Redirect::route('piggy_banks.index'); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @param PiggyBank $piggyBank - * - * @return $this - */ - public function edit(PiggyBank $piggyBank) - { - - /** @var \FireflyIII\Database\Account\Account $acct */ - $acct = App::make('FireflyIII\Database\Account\Account'); - - $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); - $subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"'; - $subTitleIcon = 'fa-pencil'; - - /* - * Flash some data to fill the form. - */ - if (is_null($piggyBank->targetdate) || $piggyBank->targetdate == '') { - $targetDate = null; - } else { - $targetDate = new Carbon($piggyBank->targetdate); - $targetDate = $targetDate->format('Y-m-d'); - } - $preFilled = ['name' => $piggyBank->name, - 'account_id' => $piggyBank->account_id, - 'targetamount' => $piggyBank->targetamount, - 'targetdate' => $targetDate, - 'reminder' => $piggyBank->reminder, - 'remind_me' => intval($piggyBank->remind_me) == 1 || !is_null($piggyBank->reminder) ? true : false - ]; - Session::flash('preFilled', $preFilled); - - return View::make('piggy_banks.edit', compact('subTitle', 'subTitleIcon', 'piggyBank', 'accounts', 'periods', 'preFilled')); - } - - /** - * @return $this - */ - public function index() - { - /** @var Collection $piggyBanks */ - $piggyBanks = $this->_repository->get(); - - $accounts = []; - /** @var PiggyBank $piggyBank */ - foreach ($piggyBanks as $piggyBank) { - $piggyBank->savedSoFar = floatval($piggyBank->currentRelevantRep()->currentamount); - $piggyBank->percentage = intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100); - $piggyBank->leftToSave = $piggyBank->targetamount - $piggyBank->savedSoFar; - - /* - * Fill account information: - */ - $account = $piggyBank->account; - if (!isset($accounts[$account->id])) { - $accounts[$account->id] = [ - 'name' => $account->name, - 'balance' => Steam::balance($account), - 'leftForPiggyBanks' => $this->_repository->leftOnAccount($account), - 'sumOfSaved' => $piggyBank->savedSoFar, - 'sumOfTargets' => floatval($piggyBank->targetamount), - 'leftToSave' => $piggyBank->leftToSave - ]; - } else { - $accounts[$account->id]['sumOfSaved'] += $piggyBank->savedSoFar; - $accounts[$account->id]['sumOfTargets'] += floatval($piggyBank->targetamount); - $accounts[$account->id]['leftToSave'] += $piggyBank->leftToSave; - } - } - - return View::make('piggy_banks.index', compact('piggyBanks', 'accounts')); - } - - /** - * POST add money to piggy bank - * - * @param PiggyBank $piggyBank - * - * @return \Illuminate\Http\RedirectResponse - */ - public function postAdd(PiggyBank $piggyBank) - { - $amount = round(floatval(Input::get('amount')), 2); - - /** @var \FireflyIII\Database\PiggyBank\PiggyBank $acct */ - $piggyRepository = App::make('FireflyIII\Database\PiggyBank\PiggyBank'); - - $leftOnAccount = $piggyRepository->leftOnAccount($piggyBank->account); - $savedSoFar = $piggyBank->currentRelevantRep()->currentamount; - $leftToSave = $piggyBank->targetamount - $savedSoFar; - $maxAmount = round(min($leftOnAccount, $leftToSave), 2); - - if ($amount <= $maxAmount) { - $repetition = $piggyBank->currentRelevantRep(); - $repetition->currentamount += $amount; - $repetition->save(); - - /* - * Create event! - */ - Event::fire('piggy_bank.addMoney', [$piggyBank, $amount]); // new and used. - - Session::flash('success', 'Added ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".'); - } else { - Session::flash('error', 'Could not add ' . Amount::format($amount, false) . ' to "' . e($piggyBank->name) . '".'); - } - - return Redirect::route('piggy_banks.index'); - } - - /** - * @param PiggyBank $piggyBank - * - * @return \Illuminate\Http\RedirectResponse - */ - public function postRemove(PiggyBank $piggyBank) - { - $amount = floatval(Input::get('amount')); - - $savedSoFar = $piggyBank->currentRelevantRep()->currentamount; - - if ($amount <= $savedSoFar) { - $repetition = $piggyBank->currentRelevantRep(); - $repetition->currentamount -= $amount; - $repetition->save(); - - /* - * Create event! - */ - Event::fire('piggy_bank.removeMoney', [$piggyBank, $amount]); // new and used. - - Session::flash('success', 'Removed ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".'); - } else { - Session::flash('error', 'Could not remove ' . Amount::format($amount, false) . ' from "' . e($piggyBank->name) . '".'); - } - - return Redirect::route('piggy_banks.index'); - } - - /** - * @param PiggyBank $piggyBank - * - * @SuppressWarnings("Unused") - * - * @return \Illuminate\View\View - */ - public function remove(PiggyBank $piggyBank) - { - return View::make('piggy_banks.remove', compact('piggyBank')); - } - - /** - * @param PiggyBank $piggyBank - * - * @return $this - */ - public function show(PiggyBank $piggyBank) - { - - $events = $piggyBank->piggyBankEvents()->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get(); - - /* - * Number of reminders: - */ - - $subTitle = e($piggyBank->name); - - return View::make('piggy_banks.show', compact('piggyBank', 'events', 'subTitle')); - - } - - /** - * - */ - public function store() - { - $data = Input::all(); - $data['repeats'] = 0; - $data['user_id'] = Auth::user()->id; - $data['rep_every'] = 0; - $data['reminder_skip'] = 0; - $data['remind_me'] = intval(Input::get('remind_me')); - $data['order'] = 0; - - - // always validate: - $messages = $this->_repository->validate($data); - - // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not store piggy bank: ' . $messages['errors']->first()); - return Redirect::route('piggy_banks.create')->withInput(); - } - - - // return to create screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('piggy_banks.create')->withInput(); - } - - // store - $piggyBank = $this->_repository->store($data); - Event::fire('piggy_bank.store', [$piggyBank]); // new and used. - Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.'); - if ($data['post_submit_action'] == 'store') { - return Redirect::route('piggy_banks.index'); - } - - return Redirect::route('piggy_banks.create')->withInput(); - } - - /** - * @param PiggyBank $piggyBank - * - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @return $this - * @throws FireflyException - */ - public function update(PiggyBank $piggyBank) - { - - $data = Input::except('_token'); - $data['rep_every'] = 0; - $data['reminder_skip'] = 0; - $data['order'] = 0; - $data['remind_me'] = isset($data['remind_me']) ? 1 : 0; - $data['user_id'] = Auth::user()->id; - $data['repeats'] = 0; - - $messages = $this->_repository->validate($data); - - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update piggy bank: ' . $messages['errors']->first()); - return Redirect::route('piggy_banks.edit', $piggyBank->id)->withInput(); - } - - // return to update screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('piggy_banks.edit', $piggyBank->id)->withInput(); - } - - // update - $this->_repository->update($piggyBank, $data); - Session::flash('success', 'Piggy bank "' . e($data['name']) . '" updated.'); - - // go back to list - if ($data['post_submit_action'] == 'update') { - return Redirect::route('piggy_banks.index'); - } - - // go back to update screen. - return Redirect::route('piggy_banks.edit', $piggyBank->id)->withInput(['post_submit_action' => 'return_to_edit']); - - } -} diff --git a/app/controllers/PreferencesController.php b/app/controllers/PreferencesController.php deleted file mode 100644 index d0d62d797d..0000000000 --- a/app/controllers/PreferencesController.php +++ /dev/null @@ -1,75 +0,0 @@ -getAccountsByType(['Default account', 'Asset account']); - $viewRange = $preferences->get('viewRange', '1M'); - $viewRangeValue = $viewRange->data; - $frontPage = $preferences->get('frontPageAccounts', []); - $budgetMax = $preferences->get('budgetMaximum', 1000); - $budgetMaximum = $budgetMax->data; - - return View::make('preferences.index', compact('budgetMaximum'))->with('accounts', $accounts)->with('frontPageAccounts', $frontPage)->with( - 'viewRange', $viewRangeValue - ); - } - - /** - * @return \Illuminate\Http\RedirectResponse - */ - public function postIndex() - { - /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */ - $preferences = App::make('FireflyIII\Shared\Preferences\Preferences'); - - // front page accounts - $frontPageAccounts = []; - foreach (Input::get('frontPageAccounts') as $id) { - $frontPageAccounts[] = intval($id); - } - $preferences->set('frontPageAccounts', $frontPageAccounts); - - // view range: - $preferences->set('viewRange', Input::get('viewRange')); - // forget session values: - Session::forget('start'); - Session::forget('end'); - Session::forget('range'); - - // budget maximum: - $budgetMaximum = intval(Input::get('budgetMaximum')); - $preferences->set('budgetMaximum', $budgetMaximum); - - - Session::flash('success', 'Preferences saved!'); - - return Redirect::route('preferences'); - } - -} diff --git a/app/controllers/ProfileController.php b/app/controllers/ProfileController.php deleted file mode 100644 index 8ac759f571..0000000000 --- a/app/controllers/ProfileController.php +++ /dev/null @@ -1,85 +0,0 @@ -with('title', Auth::user()->email)->with('subTitle', 'Change your password')->with( - 'mainTitleIcon', 'fa-user' - ); - } - - /** - * @return \Illuminate\View\View - * - */ - public function index() - { - return View::make('profile.index')->with('title', 'Profile')->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user'); - } - - /** - * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View - */ - public function postChangePassword() - { - - // old, new1, new2 - if (!Hash::check(Input::get('old'), Auth::user()->password)) { - Session::flash('error', 'Invalid current password!'); - - return View::make('profile.change-password'); - } - $result = $this->_validatePassword(Input::get('old'), Input::get('new1'), Input::get('new2')); - if (!($result === true)) { - Session::flash('error', $result); - - return View::make('profile.change-password'); - } - - // update the user with the new password. - /** @var \FireflyIII\Database\User\User $repository */ - $repository = \App::make('FireflyIII\Database\User\User'); - $repository->updatePassword(Auth::user(), Input::get('new1')); - - Session::flash('success', 'Password changed!'); - - return Redirect::route('profile'); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @param string $old - * @param string $new1 - * @param string $new2 - * - * @return string|bool - */ - protected function _validatePassword($old, $new1, $new2) - { - if (strlen($new1) == 0 || strlen($new2) == 0) { - return 'Do fill in a password!'; - - } - if ($new1 == $old) { - return 'The idea is to change your password.'; - } - - if ($new1 !== $new2) { - return 'New passwords do not match!'; - } - - return true; - - } - -} diff --git a/app/controllers/RelatedController.php b/app/controllers/RelatedController.php deleted file mode 100644 index fb77ee320c..0000000000 --- a/app/controllers/RelatedController.php +++ /dev/null @@ -1,148 +0,0 @@ -_repository = $repository; - - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @param TransactionJournal $journal - * - * @return \Illuminate\Http\JsonResponse - */ - public function alreadyRelated(TransactionJournal $journal) - { - $ids = []; - /** @var TransactionGroup $group */ - foreach ($journal->transactiongroups()->get() as $group) { - /** @var TransactionJournal $loopJournal */ - foreach ($group->transactionjournals()->get() as $loopJournal) { - if ($loopJournal->id != $journal->id) { - $ids[] = $loopJournal->id; - } - } - } - $unique = array_unique($ids); - if (count($unique) > 0) { - - $set = $this->_repository->getJournalsByIds($unique); - $set->each( - function (TransactionJournal $journal) { - $journal->amount = Amount::format($journal->getAmount()); - } - ); - - return Response::json($set->toArray()); - } else { - return Response::json((new Collection)->toArray()); - } - } - - /** - * @param TransactionJournal $parentJournal - * @param TransactionJournal $childJournal - * - * @return \Illuminate\Http\JsonResponse - */ - public function relate(TransactionJournal $parentJournal, TransactionJournal $childJournal) - { - $group = new TransactionGroup; - $group->relation = 'balance'; - $group->user_id = $this->_repository->getUser()->id; - $group->save(); - $group->transactionjournals()->save($parentJournal); - $group->transactionjournals()->save($childJournal); - - return Response::json(true); - - } - - /** - * @param TransactionJournal $journal - * - * @return \Illuminate\View\View - */ - public function related(TransactionJournal $journal) - { - $groups = $journal->transactiongroups()->get(); - $members = new Collection; - /** @var TransactionGroup $group */ - foreach ($groups as $group) { - /** @var TransactionJournal $loopJournal */ - foreach ($group->transactionjournals()->get() as $loopJournal) { - if ($loopJournal->id != $journal->id) { - $members->push($loopJournal); - } - } - } - - return View::make('related.relate', compact('journal', 'members')); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @param TransactionJournal $parentJournal - * @param TransactionJournal $childJournal - * - * @return \Illuminate\Http\JsonResponse - * @throws Exception - */ - public function removeRelation(TransactionJournal $parentJournal, TransactionJournal $childJournal) - { - $groups = $parentJournal->transactiongroups()->get(); - /** @var TransactionGroup $group */ - foreach ($groups as $group) { - foreach ($group->transactionjournals()->get() as $loopJournal) { - if ($loopJournal->id == $childJournal->id) { - // remove from group: - $group->transactionjournals()->detach($childJournal); - } - } - if ($group->transactionjournals()->count() == 1) { - $group->delete(); - } - } - - return Response::json(true); - } - - /** - * @param TransactionJournal $journal - * - * @return \Illuminate\Http\JsonResponse - */ - public function search(TransactionJournal $journal) - { - - $search = e(trim(Input::get('searchValue'))); - - $result = $this->_repository->search($search, $journal); - $result->each( - function (TransactionJournal $j) { - $j->amount = Amount::format($j->getAmount()); - } - ); - - return Response::json($result->toArray()); - } - -} diff --git a/app/controllers/ReminderController.php b/app/controllers/ReminderController.php deleted file mode 100644 index 7b34fadb04..0000000000 --- a/app/controllers/ReminderController.php +++ /dev/null @@ -1,93 +0,0 @@ -remindersable); - - if ($class == 'PiggyBank') { - $amount = Reminders::amountForReminder($reminder); - $preFilled = [ - 'amount' => round($amount, 2), - 'description' => 'Money for ' . $reminder->remindersable->name, - 'piggy_bank_id' => $reminder->remindersable_id, - 'account_to_id' => $reminder->remindersable->account_id - ]; - Session::flash('preFilled', $preFilled); - - return Redirect::route('transactions.create', 'transfer'); - } - - return View::make('error')->with('message', 'This reminder has an invalid class connected to it.'); - } - - /** - * @param Reminder $reminder - * - * @return \Illuminate\Http\RedirectResponse - */ - public function dismiss(Reminder $reminder) - { - $reminder->active = 0; - $reminder->save(); - Session::flash('success', 'Reminder dismissed'); - - return Redirect::route('index'); - } - - /** - * @param Reminder $reminder - * - * @return \Illuminate\Http\RedirectResponse - */ - public function notNow(Reminder $reminder) - { - $reminder->active = 0; - $reminder->notnow = 1; - $reminder->save(); - Session::flash('success', 'Reminder dismissed'); - - return Redirect::route('index'); - } - - /** - * @param Reminder $reminder - * - * @return \Illuminate\View\View - */ - public function show(Reminder $reminder) - { - - $amount = null; - if (get_class($reminder->remindersable) == 'PiggyBank') { - - $amount = Reminders::amountForReminder($reminder); - } - - return View::make('reminders.show', compact('reminder', 'amount')); - } - -} diff --git a/app/controllers/RepeatedExpenseController.php b/app/controllers/RepeatedExpenseController.php deleted file mode 100644 index 73494b0377..0000000000 --- a/app/controllers/RepeatedExpenseController.php +++ /dev/null @@ -1,227 +0,0 @@ -_repository = $repository; - } - - /** - * @return $this - */ - public function create() - { - /** @var \FireflyIII\Database\Account\Account $acct */ - $acct = App::make('FireflyIII\Database\Account\Account'); - $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); - - return View::make('repeatedExpense.create', compact('accounts', 'periods'))->with('subTitle', 'Create new repeated expense')->with( - 'subTitleIcon', 'fa-plus' - ); - } - - /** - * @param PiggyBank $repeatedExpense - * - * @return $this - */ - public function delete(PiggyBank $repeatedExpense) - { - $subTitle = 'Delete "' . e($repeatedExpense->name) . '"'; - - return View::make('repeatedExpense.delete', compact('repeatedExpense', 'subTitle')); - } - - /** - * @param PiggyBank $repeatedExpense - * - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(PiggyBank $repeatedExpense) - { - - Session::flash('success', 'Repeated expense "' . e($repeatedExpense->name) . '" deleted.'); - $this->_repository->destroy($repeatedExpense); - - return Redirect::route('repeated.index'); - } - - /** - * @param PiggyBank $repeatedExpense - * - * @return $this - */ - public function edit(PiggyBank $repeatedExpense) - { - - /** @var \FireflyIII\Database\Account\Account $acct */ - $acct = App::make('FireflyIII\Database\Account\Account'); - - $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); - $subTitle = 'Edit repeated expense "' . e($repeatedExpense->name) . '"'; - $subTitleIcon = 'fa-pencil'; - - /* - * Flash some data to fill the form. - */ - $preFilled = ['name' => $repeatedExpense->name, - 'account_id' => $repeatedExpense->account_id, - 'targetamount' => $repeatedExpense->targetamount, - 'targetdate' => $repeatedExpense->targetdate->format('Y-m-d'), - 'reminder' => $repeatedExpense->reminder, - 'remind_me' => intval($repeatedExpense->remind_me) == 1 || !is_null($repeatedExpense->reminder) ? true : false - ]; - Session::flash('preFilled', $preFilled); - - return View::make('repeatedExpense.edit', compact('subTitle', 'subTitleIcon', 'repeatedExpense', 'accounts', 'periods', 'preFilled')); - } - - /** - * @return \Illuminate\View\View - */ - public function index() - { - - $subTitle = 'Overview'; - - $expenses = $this->_repository->get(); - $expenses->each( - function (PiggyBank $piggyBank) { - $piggyBank->currentRelevantRep(); - } - ); - - return View::make('repeatedExpense.index', compact('expenses', 'subTitle')); - } - - /** - * @param PiggyBank $repeatedExpense - * - * @return \Illuminate\View\View - */ - public function show(PiggyBank $repeatedExpense) - { - $subTitle = $repeatedExpense->name; - $today = Carbon::now(); - $repetitions = $repeatedExpense->piggyBankRepetitions()->get(); - - $repetitions->each( - function (PiggyBankRepetition $repetition) { - $repetition->bars = $this->_repository->calculateParts($repetition); - } - ); - - return View::make('repeatedExpense.show', compact('repetitions', 'repeatedExpense', 'today', 'subTitle')); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - */ - public function store() - { - $data = Input::all(); - $data['repeats'] = 1; - $data['user_id'] = Auth::user()->id; - $targetDate = new Carbon($data['targetdate']); - $startDate = \DateKit::subtractPeriod($targetDate, $data['rep_length']); - $data['startdate'] = $startDate->format('Y-m-d'); - $data['targetdate'] = $targetDate->format('Y-m-d'); - $data['reminder_skip'] = 0; - $data['remind_me'] = isset($data['remind_me']) ? 1 : 0; - $data['order'] = 0; - - $messages = $this->_repository->validate($data); - - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not store repeated expense: ' . $messages['errors']->first()); - return Redirect::route('repeated.create')->withInput(); - } - - - // return to create screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('repeated.create')->withInput(); - } - - // store - $piggyBank = $this->_repository->store($data); - Event::fire('piggy_bank.store', [$piggyBank]); // new and used. - Session::flash('success', 'Piggy bank "' . e($data['name']) . '" stored.'); - if ($data['post_submit_action'] == 'store') { - return Redirect::route('repeated.index'); - } - - return Redirect::route('repeated.create')->withInput(); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @param PiggyBank $repeatedExpense - * - * @return $this - * @throws FireflyException - */ - public function update(PiggyBank $repeatedExpense) - { - - $data = Input::except('_token'); - $data['rep_every'] = 0; - $data['reminder_skip'] = 0; - $data['order'] = 0; - $data['repeats'] = 1; - $data['remind_me'] = isset($data['remind_me']) ? 1 : 0; - $data['user_id'] = Auth::user()->id; - - $messages = $this->_repository->validate($data); - - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update repeated expense: ' . $messages['errors']->first()); - return Redirect::route('repeated.edit', $repeatedExpense->id)->withInput(); - } - - // return to update screen: - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('repeated.edit', $repeatedExpense->id)->withInput(); - } - - // update - $this->_repository->update($repeatedExpense, $data); - Session::flash('success', 'Repeated expense "' . e($data['name']) . '" updated.'); - - // go back to list - if ($data['post_submit_action'] == 'update') { - return Redirect::route('repeated.index'); - } - - // go back to update screen. - return Redirect::route('repeated.edit', $repeatedExpense->id)->withInput(['post_submit_action' => 'return_to_edit']); - - } -} diff --git a/app/controllers/ReportController.php b/app/controllers/ReportController.php deleted file mode 100644 index 6577ca5271..0000000000 --- a/app/controllers/ReportController.php +++ /dev/null @@ -1,136 +0,0 @@ -_journals = $journals; - $this->_repository = $repository; - /** @var \FireflyIII\Database\Budget\Budget _budgets */ - $this->_budgets = App::make('FireflyIII\Database\Budget\Budget'); - - - View::share('title', 'Reports'); - View::share('mainTitleIcon', 'fa-line-chart'); - - } - - /** - * @param string $year - * @param string $month - * - * @return \Illuminate\View\View - */ - public function budget($year = '2014', $month = '1') - { - try { - new Carbon($year . '-' . $month . '-01'); - } catch (Exception $e) { - return View::make('error')->with('message', 'Invalid date'); - } - $date = new Carbon($year . '-' . $month . '-01'); - $dayEarly = clone $date; - $subTitle = 'Budget report for ' . $date->format('F Y'); - $subTitleIcon = 'fa-calendar'; - $dayEarly = $dayEarly->subDay(); - $accounts = $this->_repository->getAccountListBudgetOverview($date); - $budgets = $this->_repository->getBudgetsForMonth($date); - - return View::make('reports.budget', compact('subTitle', 'subTitleIcon', 'date', 'accounts', 'budgets', 'dayEarly')); - - } - - /** - * - */ - public function index() - { - $start = $this->_journals->firstDate(); - $months = $this->_repository->listOfMonths(clone $start); - $years = $this->_repository->listOfYears(clone $start); - $title = 'Reports'; - $mainTitleIcon = 'fa-line-chart'; - - return View::make('reports.index', compact('years', 'months', 'title', 'mainTitleIcon')); - } - - /** - * @param string $year - * @param string $month - * - * @return \Illuminate\View\View - */ - public function month($year = '2014', $month = '1') - { - try { - new Carbon($year . '-' . $month . '-01'); - } catch (Exception $e) { - return View::make('error')->with('message', 'Invalid date.'); - } - $date = new Carbon($year . '-' . $month . '-01'); - $subTitle = 'Report for ' . $date->format('F Y'); - $subTitleIcon = 'fa-calendar'; - $displaySum = true; // to show sums in report. - $income = $this->_repository->getIncomeForMonth($date); - $expenses = $this->_repository->getExpenseGroupedForMonth($date, 10); - $budgets = $this->_repository->getBudgetsForMonth($date); - $categories = $this->_repository->getCategoriesForMonth($date, 10); - $accounts = $this->_repository->getAccountsForMonth($date); - - return View::make( - 'reports.month', - compact('date', 'accounts', 'categories', 'budgets', 'expenses', 'subTitle', 'displaySum', 'subTitleIcon', 'income') - ); - } - - /** - * @param $year - * - * @return $this - */ - public function year($year) - { - try { - new Carbon('01-01-' . $year); - } catch (Exception $e) { - return View::make('error')->with('message', 'Invalid date.'); - } - $date = new Carbon('01-01-' . $year); - $end = clone $date; - $end->endOfYear(); - $title = 'Reports'; - $subTitle = $year; - $subTitleIcon = 'fa-bar-chart'; - $mainTitleIcon = 'fa-line-chart'; - - $balances = $this->_repository->yearBalanceReport($date); - $groupedIncomes = $this->_repository->revenueGroupedByAccount($date, $end); - $groupedExpenses = $this->_repository->expensesGroupedByAccount($date, $end, 15); - - return View::make( - 'reports.year', - compact('date', 'groupedIncomes', 'groupedExpenses', 'year', 'balances', 'title', 'subTitle', 'subTitleIcon', 'mainTitleIcon') - ); - } - -} diff --git a/app/controllers/SearchController.php b/app/controllers/SearchController.php deleted file mode 100644 index 6bcbb73d35..0000000000 --- a/app/controllers/SearchController.php +++ /dev/null @@ -1,38 +0,0 @@ - 0) { - $rawQuery = trim(Input::get('q')); - $words = explode(' ', $rawQuery); - $subTitle = 'Results for "' . e($rawQuery) . '"'; - - $transactions = $searcher->searchTransactions($words); - $accounts = $searcher->searchAccounts($words); - $categories = $searcher->searchCategories($words); - $budgets = $searcher->searchBudgets($words); - $tags = $searcher->searchTags($words); - $result = ['transactions' => $transactions, 'accounts' => $accounts, 'categories' => $categories, 'budgets' => $budgets, 'tags' => $tags]; - - } - - return View::make('search.index')->with('title', 'Search')->with('subTitle', $subTitle)->with( - 'mainTitleIcon', 'fa-search' - )->with('query', $rawQuery)->with('result', $result); - } -} diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php deleted file mode 100644 index f1e6184fc1..0000000000 --- a/app/controllers/TransactionController.php +++ /dev/null @@ -1,328 +0,0 @@ -_repository = $repository; - $this->_helper = $helper; - View::share('title', 'Transactions'); - View::share('mainTitleIcon', 'fa-repeat'); - } - - - /** - * Shows the view helping the user to create a new transaction journal. - * - * @param string $what - * - * @return \Illuminate\View\View - */ - public function create($what = 'deposit') - { - $accounts = FFForm::makeSelectList($this->_helper->getAssetAccounts()); - $budgets = FFForm::makeSelectList($this->_helper->getBudgets()); - $budgets[0] = '(no budget)'; - $piggyBanks = $this->_helper->getPiggyBanks(); - $repeatedExpenses = $this->_helper->getRepeatedExpenses(); - $list = $piggyBanks->merge($repeatedExpenses); - $piggies = FFForm::makeSelectList($list); - $piggies[0] = '(no piggy bank)'; - $preFilled = Session::has('preFilled') ? Session::get('preFilled') : []; - $respondTo = ['account_id', 'account_from_id']; - $subTitle = 'Add a new ' . e($what); - - foreach ($respondTo as $r) { - if (!is_null(Input::get($r))) { - $preFilled[$r] = Input::get($r); - } - } - Session::put('preFilled', $preFilled); - - asort($piggies); - - - return View::make('transactions.create', compact('accounts', 'budgets', 'what', 'piggies', 'subTitle')); - } - - /** - * Shows the form that allows a user to delete a transaction journal. - * - * @param TransactionJournal $journal - * - * @return $this - */ - public function delete(TransactionJournal $journal) - { - $type = strtolower($journal->transactionType->type); - $subTitle = 'Delete ' . e($type) . ' "' . e($journal->description) . '"'; - - return View::make('transactions.delete', compact('journal', 'subTitle')); - - - } - - /** - * @param TransactionJournal $transactionJournal - * - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(TransactionJournal $transactionJournal) - { - $type = $transactionJournal->transactionType->type; - $return = 'withdrawal'; - - Session::flash('success', 'Transaction "' . e($transactionJournal->description) . '" destroyed.'); - - $this->_repository->destroy($transactionJournal); - - switch ($type) { - case 'Deposit': - $return = 'deposit'; - break; - case 'Transfer': - $return = 'transfers'; - break; - } - - return Redirect::route('transactions.index', $return); - } - - /** - * Shows the view to edit a transaction. - * - * @param TransactionJournal $journal - * - * @return $this - */ - public function edit(TransactionJournal $journal) - { - $what = strtolower($journal->transactiontype->type); - $subTitle = 'Edit ' . e($what) . ' "' . e($journal->description) . '"'; - $budgets = FFForm::makeSelectList($this->_helper->getBudgets(), true); - $accounts = FFForm::makeSelectList($this->_helper->getAssetAccounts()); - $piggies = FFForm::makeSelectList($this->_helper->getPiggyBanks(), true); - $transactions = $journal->transactions()->orderBy('amount', 'DESC')->get(); - $preFilled = [ - 'date' => $journal->date->format('Y-m-d'), - 'category' => '', - 'budget_id' => 0, - 'piggy_bank_id' => 0 - ]; - - $category = $journal->categories()->first(); - if (!is_null($category)) { - $preFilled['category'] = $category->name; - } - - $budget = $journal->budgets()->first(); - if (!is_null($budget)) { - $preFilled['budget_id'] = $budget->id; - } - - if ($journal->piggyBankEvents()->count() > 0) { - $preFilled['piggy_bank_id'] = $journal->piggyBankEvents()->first()->piggy_bank_id; - } - - $preFilled['amount'] = $journal->getAmount(); - $preFilled['account_id'] = $this->_helper->getAssetAccount($what, $transactions); - $preFilled['expense_account'] = $transactions[0]->account->name; - $preFilled['revenue_account'] = $transactions[1]->account->name; - $preFilled['account_from_id'] = $transactions[1]->account->id; - $preFilled['account_to_id'] = $transactions[0]->account->id; - - - return View::make('transactions.edit', compact('journal', 'accounts', 'what', 'budgets', 'piggies', 'subTitle'))->with('data', $preFilled); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's 7. More than 5 but alright. - * - * @param $what - * - * @return $this - */ - public function index($what) - { - switch ($what) { - case 'expenses': - case 'withdrawal': - $subTitleIcon = 'fa-long-arrow-left'; - $subTitle = 'Expenses'; - $journals = $this->_repository->getWithdrawalsPaginated(50); - break; - case 'revenue': - case 'deposit': - $subTitleIcon = 'fa-long-arrow-right'; - $subTitle = 'Revenue, income and deposits'; - $journals = $this->_repository->getDepositsPaginated(50); - break; - case 'transfer': - case 'transfers': - $subTitleIcon = 'fa-arrows-h'; - $subTitle = 'Transfers'; - $journals = $this->_repository->getTransfersPaginated(50); - break; - } - - return View::make('transactions.index', compact('subTitle', 'what', 'subTitleIcon', 'journals')); - - } - - - /** - * @param TransactionJournal $journal - * - * @return $this - */ - public function show(TransactionJournal $journal) - { - $journal->transactions->each( - function (\Transaction $t) use ($journal) { - $t->before = floatval( - $t->account->transactions()->leftJoin( - 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id' - )->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))->where( - 'transaction_journals.created_at', '<=', $journal->created_at->format('Y-m-d H:i:s') - )->where('transaction_journals.id', '!=', $journal->id)->sum('transactions.amount') - ); - $t->after = $t->before + $t->amount; - } - ); - $members = new Collection; - /** @var TransactionGroup $group */ - foreach ($journal->transactiongroups()->get() as $group) { - /** @var TransactionJournal $loopJournal */ - foreach ($group->transactionjournals()->get() as $loopJournal) { - if ($loopJournal->id != $journal->id) { - $members->push($loopJournal); - } - } - } - - return View::make('transactions.show', compact('journal', 'members'))->with( - 'subTitle', e($journal->transactionType->type) . ' "' . e($journal->description) . '"' - ); - } - - /** - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @param $what - * - * @return $this|\Illuminate\Http\RedirectResponse - * @throws FireflyException - */ - public function store($what) - { - $data = Input::except('_token'); - $transactionType = $this->_repository->getJournalType($what); - $transactionCurrency = $this->_repository->getJournalCurrencyById(intval($data['amount_currency_id'])); - $data['transaction_type_id'] = $transactionType->id; - $data['transaction_currency_id'] = $transactionCurrency->id; - $data['completed'] = 0; - $data['what'] = $what; - $messages = $this->_repository->validate($data); - - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not store transaction: ' . $messages['errors']->first()); - - return Redirect::route('transactions.create', $data['what'])->withInput(); - } - - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('transactions.create', $data['what'])->withInput(); - } - - $journal = $this->_repository->store($data); - Event::fire('transactionJournal.store', [$journal, Input::get('piggy_bank_id')]); // new and used. - - /** @var Transaction $transaction */ - foreach ($journal->transactions as $transaction) { - Event::fire('transaction.store', [$transaction]); - } - - Session::flash('success', 'Transaction "' . e($data['description']) . '" stored.'); - if ($data['post_submit_action'] == 'store') { - return Redirect::route('transactions.index', $data['what']); - } - - return Redirect::route('transactions.create', $data['what'])->withInput(); - } - - - /** - * @param TransactionJournal $journal - * - * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind. - * - * @return $this - * @throws FireflyException - */ - public function update(TransactionJournal $journal) - { - $data = Input::except('_token'); - $data['what'] = strtolower($journal->transactionType->type); - $data['transaction_type_id'] = $journal->transaction_type_id; - $data['transaction_currency_id'] = intval($data['amount_currency_id']); - $data['completed'] = 1; - $messages = $this->_repository->validate($data); - - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update transaction: ' . $messages['errors']->first()); - - return Redirect::route('transactions.edit', $journal->id)->withInput(); - } - if ($data['post_submit_action'] == 'validate_only') { - return Redirect::route('transactions.edit', $journal->id)->withInput(); - } - $this->_repository->update($journal, $data); - Session::flash('success', 'Transaction "' . e($data['description']) . '" updated.'); - Event::fire('transactionJournal.update', [$journal]); // new and used. - /** @var Transaction $transaction */ - foreach ($journal->transactions()->get() as $transaction) { - Event::fire('transaction.update', [$transaction]); - } - if ($data['post_submit_action'] == 'update') { - return Redirect::route('transactions.index', $data['what']); - } - - // go back to update screen. - return Redirect::route('transactions.edit', $journal->id)->withInput(['post_submit_action' => 'return_to_edit']); - - - } - -} diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php deleted file mode 100644 index e4c96900f2..0000000000 --- a/app/controllers/UserController.php +++ /dev/null @@ -1,176 +0,0 @@ - Input::get('email'), 'password' => Input::get('password')]; - $result = Auth::attempt($data, $rememberMe); - if ($result) { - return Redirect::route('index'); - } - - Session::flash('error', 'No good!'); - - return View::make('user.login'); - } - - /** - * If allowed, register the user. - * - * Then: - * - * - Send password OR - * - Send reset code. - * - * @return $this|\Illuminate\View\View - */ - public function postRegister() - { - - /** @var \FireflyIII\Database\User\User $repository */ - $repository = App::make('FireflyIII\Database\User\User'); - - /** @var \FireflyIII\Shared\Mail\RegistrationInterface $email */ - $email = App::make('FireflyIII\Shared\Mail\RegistrationInterface'); - - $user = $repository->register(Input::all()); - - if ($user) { - $result = $email->sendVerificationMail($user); - if ($result === false && Config::get('mail.pretend') === false) { - // @codeCoverageIgnoreStart - $user->delete(); - - return View::make('error')->with('message', 'The email message could not be send. See the log files.'); - // @codeCoverageIgnoreEnd - } - - return View::make('user.verification-pending'); - } - - - return View::make('user.register'); - } - - /** - * If need to verify, send new reset code. - * Otherwise, send new password. - * - * @return \Illuminate\View\View - */ - public function postRemindMe() - { - - /** @var \FireflyIII\Database\User\User $repository */ - $repository = App::make('FireflyIII\Database\User\User'); - - /** @var \FireflyIII\Shared\Mail\RegistrationInterface $email */ - $email = App::make('FireflyIII\Shared\Mail\RegistrationInterface'); - - - $user = $repository->findByEmail(Input::get('email')); - if (!$user) { - Session::flash('error', 'No good!'); - - return View::make('user.remindMe'); - } - $email->sendResetVerification($user); - - return View::make('user.verification-pending'); - - } - - /** - * If allowed, show the register form. - * - * @return $this|\Illuminate\View\View - */ - public function register() - { - if ((Config::get('mail.from.address') == '@gmail.com' || Config::get('mail.from.address') == '') - && Config::get('mail.pretend') === false - ) { - return View::make('error')->with('message', 'Configuration error inapp/config/' . App::environment() . '/mail.php
');
- }
-
- return View::make('user.register');
- }
-
- /**
- * Show form to help user get a new password.
- *
- * @return \Illuminate\View\View
- */
- public function remindMe()
- {
- return View::make('user.remindMe');
- }
-
- /**
- * Send a user a password based on his reset code.
- *
- * @param $reset
- *
- * @return $this|\Illuminate\View\View
- */
- public function reset($reset)
- {
-
- /** @var \FireflyIII\Database\User\User $repository */
- $repository = App::make('FireflyIII\Database\User\User');
-
- /** @var \FireflyIII\Shared\Mail\RegistrationInterface $email */
- $email = App::make('FireflyIII\Shared\Mail\RegistrationInterface');
-
- $user = $repository->findByReset($reset);
- if ($user) {
- $email->sendPasswordMail($user);
-
- return View::make('user.registered');
- }
-
- return View::make('error')->with('message', 'No reset code found!');
- }
-
-}
diff --git a/app/database/migrations/.gitkeep b/app/database/migrations/.gitkeep
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/app/database/migrations/2014_06_27_163032_create_users_table.php b/app/database/migrations/2014_06_27_163032_create_users_table.php
deleted file mode 100644
index cd554148db..0000000000
--- a/app/database/migrations/2014_06_27_163032_create_users_table.php
+++ /dev/null
@@ -1,44 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->string('email', 100);
- $table->string('password', 60);
- $table->string('reset', 32)->nullable();
- $table->string('remember_token', 255)->nullable();
- $table->unique('email');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_163145_create_account_types_table.php b/app/database/migrations/2014_06_27_163145_create_account_types_table.php
deleted file mode 100644
index 783ec4d15d..0000000000
--- a/app/database/migrations/2014_06_27_163145_create_account_types_table.php
+++ /dev/null
@@ -1,44 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->string('type', 30);
- $table->boolean('editable');
-
- $table->unique('type');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_163259_create_accounts_table.php b/app/database/migrations/2014_06_27_163259_create_accounts_table.php
deleted file mode 100644
index 3fb5541655..0000000000
--- a/app/database/migrations/2014_06_27_163259_create_accounts_table.php
+++ /dev/null
@@ -1,54 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->softDeletes();
- $table->integer('user_id')->unsigned();
- $table->integer('account_type_id')->unsigned();
- $table->string('name', 100);
- $table->boolean('active');
-
- // connect accounts to users
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
-
- // connect accounts to account_types
- $table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade');
-
- // for a user, the account name must be unique.
- $table->unique(['user_id', 'account_type_id', 'name']);
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_163817_create_components_table.php b/app/database/migrations/2014_06_27_163817_create_components_table.php
deleted file mode 100644
index 465b1ecaff..0000000000
--- a/app/database/migrations/2014_06_27_163817_create_components_table.php
+++ /dev/null
@@ -1,51 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->softDeletes();
- $table->string('name', 50);
- $table->integer('user_id')->unsigned();
- $table->string('class', 20);
-
- // connect components to users
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
-
- // for a user, the component type & name must be unique.
- $table->unique(['user_id', 'class', 'name']);
- }
- );
-
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php b/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php
deleted file mode 100644
index 67d527a66d..0000000000
--- a/app/database/migrations/2014_06_27_163818_create_piggybanks_table.php
+++ /dev/null
@@ -1,60 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->integer('account_id')->unsigned();
- $table->string('name', 100);
- $table->decimal('targetamount', 10, 2);
- $table->date('startdate')->nullable();
- $table->date('targetdate')->nullable();
- $table->boolean('repeats');
- $table->enum('rep_length', ['day', 'week', 'quarter', 'month', 'year'])->nullable();
- $table->smallInteger('rep_every')->unsigned();
- $table->smallInteger('rep_times')->unsigned()->nullable();
- $table->enum('reminder', ['day', 'week', 'quarter', 'month', 'year'])->nullable();
- $table->smallInteger('reminder_skip')->unsigned();
- $table->boolean('remind_me');
- $table->integer('order')->unsigned();
-
- // connect account to piggy bank.
- $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
-
- // for an account, the name must be unique.
- $table->unique(['account_id', 'name']);
-
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_164042_create_transaction_currencies_table.php b/app/database/migrations/2014_06_27_164042_create_transaction_currencies_table.php
deleted file mode 100644
index 809a837bc9..0000000000
--- a/app/database/migrations/2014_06_27_164042_create_transaction_currencies_table.php
+++ /dev/null
@@ -1,45 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->softDeletes();
- $table->string('code', 3);
-
- // code must be unique.
- $table->unique(['code']);
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_164512_create_transaction_types_table.php b/app/database/migrations/2014_06_27_164512_create_transaction_types_table.php
deleted file mode 100644
index 746f037a84..0000000000
--- a/app/database/migrations/2014_06_27_164512_create_transaction_types_table.php
+++ /dev/null
@@ -1,45 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->softDeletes();
- $table->string('type', 50);
-
- // type must be unique.
- $table->unique(['type']);
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_164619_create_recurring_transactions_table.php b/app/database/migrations/2014_06_27_164619_create_recurring_transactions_table.php
deleted file mode 100644
index 724059c859..0000000000
--- a/app/database/migrations/2014_06_27_164619_create_recurring_transactions_table.php
+++ /dev/null
@@ -1,59 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->integer('user_id')->unsigned();
- $table->string('name', 50);
- $table->string('match', 255);
- $table->decimal('amount_min', 10, 2);
- $table->decimal('amount_max', 10, 2);
- $table->date('date');
- $table->boolean('active');
-
- $table->boolean('automatch');
- $table->enum('repeat_freq', ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly']);
- $table->smallInteger('skip')->unsigned();
-
- // connect user id to users
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
-
- // for a user, the name must be unique
- $table->unique(['user_id', 'name']);
-
-
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_164620_create_transaction_journals_table.php b/app/database/migrations/2014_06_27_164620_create_transaction_journals_table.php
deleted file mode 100644
index 44ede35eb0..0000000000
--- a/app/database/migrations/2014_06_27_164620_create_transaction_journals_table.php
+++ /dev/null
@@ -1,62 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->softDeletes();
- $table->integer('user_id')->unsigned();
- $table->integer('transaction_type_id')->unsigned();
- $table->integer('recurring_transaction_id')->unsigned()->nullable();
- $table->integer('transaction_currency_id')->unsigned();
- $table->string('description', 255)->nullable();
- $table->boolean('completed');
- $table->date('date');
-
- // connect users
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
-
- // connect transaction journals to transaction types
- $table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
-
- // connect transaction journals to recurring transactions
- $table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('set null');
-
- // connect transaction journals to transaction currencies
- $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
-
-
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_164836_create_transactions_table.php b/app/database/migrations/2014_06_27_164836_create_transactions_table.php
deleted file mode 100644
index 66b2772534..0000000000
--- a/app/database/migrations/2014_06_27_164836_create_transactions_table.php
+++ /dev/null
@@ -1,60 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->softDeletes();
- $table->integer('account_id')->unsigned();
- $table->integer('piggybank_id')->nullable()->unsigned();
- $table->integer('transaction_journal_id')->unsigned();
- $table->string('description', 255)->nullable();
- $table->decimal('amount', 10, 2);
-
- // connect account id:
- $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
-
- // connect piggy banks
- $table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('set null');
-
- // connect transactions to transaction journals
- $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
-
-
-
-
-
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_06_27_165344_create_component_transaction_table.php b/app/database/migrations/2014_06_27_165344_create_component_transaction_table.php
deleted file mode 100644
index 6eee751926..0000000000
--- a/app/database/migrations/2014_06_27_165344_create_component_transaction_table.php
+++ /dev/null
@@ -1,50 +0,0 @@
-increments('id');
- $table->integer('component_id')->unsigned();
- $table->integer('transaction_id')->unsigned();
-
- // connect to components
- $table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
-
- // connect to transactions
- $table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
-
- // combo must be unique:
- $table->unique(['component_id', 'transaction_id']);
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_07_05_171326_create_component_transaction_journal_table.php b/app/database/migrations/2014_07_05_171326_create_component_transaction_journal_table.php
deleted file mode 100644
index e6de376c42..0000000000
--- a/app/database/migrations/2014_07_05_171326_create_component_transaction_journal_table.php
+++ /dev/null
@@ -1,50 +0,0 @@
-increments('id');
- $table->integer('component_id')->unsigned();
- $table->integer('transaction_journal_id')->unsigned();
-
- // link components with component_id
- $table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
-
- // link transaction journals with transaction_journal_id
- $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
-
- // combo must be unique:
- $table->unique(['component_id', 'transaction_journal_id'], 'cid_tjid_unique');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_07_06_123842_create_preferences_table.php b/app/database/migrations/2014_07_06_123842_create_preferences_table.php
deleted file mode 100644
index 7cd7069c8e..0000000000
--- a/app/database/migrations/2014_07_06_123842_create_preferences_table.php
+++ /dev/null
@@ -1,49 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->integer('user_id')->unsigned();
- $table->string('name');
- $table->text('data');
-
- // connect preferences to users
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
-
- // only one preference per name per user
- $table->unique(['user_id', 'name']);
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_07_09_204843_create_session_table.php b/app/database/migrations/2014_07_09_204843_create_session_table.php
deleted file mode 100644
index 240f66ba88..0000000000
--- a/app/database/migrations/2014_07_09_204843_create_session_table.php
+++ /dev/null
@@ -1,41 +0,0 @@
-string('id')->unique();
- $table->text('payload');
- $table->integer('last_activity');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_07_17_183717_create_limits_table.php b/app/database/migrations/2014_07_17_183717_create_limits_table.php
deleted file mode 100644
index f6c507216a..0000000000
--- a/app/database/migrations/2014_07_17_183717_create_limits_table.php
+++ /dev/null
@@ -1,51 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->integer('component_id')->unsigned();
- $table->date('startdate');
- $table->decimal('amount', 10, 2);
- $table->boolean('repeats');
- $table->enum('repeat_freq', ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly']);
-
- $table->unique(['component_id', 'startdate', 'repeat_freq'], 'unique_ci_combi');
-
- // connect component
- $table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_07_19_055011_create_limit_repeat_table.php b/app/database/migrations/2014_07_19_055011_create_limit_repeat_table.php
deleted file mode 100644
index 46edc87ac9..0000000000
--- a/app/database/migrations/2014_07_19_055011_create_limit_repeat_table.php
+++ /dev/null
@@ -1,49 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->integer('limit_id')->unsigned();
- $table->date('startdate');
- $table->date('enddate');
- $table->decimal('amount', 10, 2);
-
- $table->unique(['limit_id', 'startdate', 'enddate']);
-
- // connect limit
- $table->foreign('limit_id')->references('id')->on('limits')->onDelete('cascade');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_08_06_044416_create_component_recurring_transaction_table.php b/app/database/migrations/2014_08_06_044416_create_component_recurring_transaction_table.php
deleted file mode 100644
index 6105817f64..0000000000
--- a/app/database/migrations/2014_08_06_044416_create_component_recurring_transaction_table.php
+++ /dev/null
@@ -1,52 +0,0 @@
-increments('id');
- $table->integer('component_id')->unsigned();
- $table->integer('recurring_transaction_id')->unsigned();
- $table->boolean('optional');
-
- // link components with component_id
- $table->foreign('component_id')->references('id')->on('components')->onDelete('cascade');
-
- // link transaction journals with transaction_journal_id
- $table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('cascade');
-
- // component and recurring transaction must be unique.
- $table->unique(['component_id', 'recurring_transaction_id'], 'cid_rtid_unique');
-
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_08_12_173919_create_piggybank_repetitions_table.php b/app/database/migrations/2014_08_12_173919_create_piggybank_repetitions_table.php
deleted file mode 100644
index 341d36a9d8..0000000000
--- a/app/database/migrations/2014_08_12_173919_create_piggybank_repetitions_table.php
+++ /dev/null
@@ -1,49 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->integer('piggybank_id')->unsigned();
- $table->date('startdate')->nullable();
- $table->date('targetdate')->nullable();
- $table->decimal('currentamount', 10, 2);
-
- $table->unique(['piggybank_id', 'startdate', 'targetdate']);
-
- // connect instance to piggybank.
- $table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('cascade');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_08_18_100330_create_piggybank_events_table.php b/app/database/migrations/2014_08_18_100330_create_piggybank_events_table.php
deleted file mode 100644
index 8eebf01388..0000000000
--- a/app/database/migrations/2014_08_18_100330_create_piggybank_events_table.php
+++ /dev/null
@@ -1,51 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->integer('piggybank_id')->unsigned();
- $table->integer('transaction_journal_id')->unsigned()->nullable();
-
- $table->date('date');
- $table->decimal('amount', 10, 2);
-
- // connect instance to piggybank.
- $table->foreign('piggybank_id')->references('id')->on('piggybanks')->onDelete('cascade');
-
- // connect to journal:
- $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_08_23_113221_create_reminders_table.php b/app/database/migrations/2014_08_23_113221_create_reminders_table.php
deleted file mode 100644
index 1aaa49fb0a..0000000000
--- a/app/database/migrations/2014_08_23_113221_create_reminders_table.php
+++ /dev/null
@@ -1,50 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->integer('user_id')->unsigned();
- $table->date('startdate');
- $table->date('enddate')->nullable();
- $table->boolean('active');
- $table->boolean('notnow')->default(0);
- $table->integer('remindersable_id')->unsigned()->nullable();
- $table->string('remindersable_type')->nullable();
-
- // connect reminders to users
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_11_10_172053_create_account_meta_table.php b/app/database/migrations/2014_11_10_172053_create_account_meta_table.php
deleted file mode 100644
index 1febb05a1b..0000000000
--- a/app/database/migrations/2014_11_10_172053_create_account_meta_table.php
+++ /dev/null
@@ -1,49 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->integer('account_id')->unsigned();
- $table->string('name');
- $table->text('data');
-
- $table->unique(['account_id', 'name']);
-
-
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_11_29_135749_create_transaction_groups_table.php b/app/database/migrations/2014_11_29_135749_create_transaction_groups_table.php
deleted file mode 100644
index c3d2e3af49..0000000000
--- a/app/database/migrations/2014_11_29_135749_create_transaction_groups_table.php
+++ /dev/null
@@ -1,48 +0,0 @@
-increments('id');
- $table->timestamps();
- $table->softDeletes();
- $table->integer('user_id')->unsigned();
- $table->enum('relation', ['balance']);
-
- // connect reminders to users
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
- }
- );
-
-
- }
-
-}
diff --git a/app/database/migrations/2014_11_29_140217_create_transaction_group_transaction_journal_table.php b/app/database/migrations/2014_11_29_140217_create_transaction_group_transaction_journal_table.php
deleted file mode 100644
index 7a275b68d6..0000000000
--- a/app/database/migrations/2014_11_29_140217_create_transaction_group_transaction_journal_table.php
+++ /dev/null
@@ -1,49 +0,0 @@
-increments('id');
- $table->integer('transaction_group_id')->unsigned();
- $table->integer('transaction_journal_id')->unsigned();
-
- // link to foreign tables.
- $table->foreign('transaction_group_id', 'tr_grp_id')->references('id')->on('transaction_groups')->onDelete('cascade');
- $table->foreign('transaction_journal_id', 'tr_trj_id')->references('id')->on('transaction_journals')->onDelete('cascade');
-
- // add unique.
- $table->unique(['transaction_group_id', 'transaction_journal_id'], 'tt_joined');
- }
- );
- }
-
-}
diff --git a/app/database/migrations/2014_12_13_190730_changes_for_v321.php b/app/database/migrations/2014_12_13_190730_changes_for_v321.php
deleted file mode 100644
index 9d5242189d..0000000000
--- a/app/database/migrations/2014_12_13_190730_changes_for_v321.php
+++ /dev/null
@@ -1,497 +0,0 @@
-moveBudgetsBack(); // 1.
- $this->moveCategoriesBack(); // 2.
- $this->createComponentId(); // 3.
- $this->updateComponentInBudgetLimits(); // 4.
- $this->createComponentIdForeignKey(); // 5.
- $this->dropBudgetIdColumnInBudgetLimits(); // 6.
- $createComponents = new CreateComponentTransactionJournalTable; // 7.
- $createComponents->up();
- $this->moveBackEntriesForBudgetsInJoinedTable(); // 8.
- $this->moveBackEntriesForCategoriesInJoinedTable(); // 9.
- $this->dropBudgetJournalTable(); // 10.
- $this->dropCategoryJournalTable(); // 11.
- $this->dropBudgetTable(); // 12.
- $this->dropCategoryTable(); // 13.
- $this->renameBudgetLimits(); // 14.
- $this->renamePiggyBankEvents(); // 15.
- $this->renameBudgetLimitToBudgetInRepetitions(); // 16.
- // 17, 18, 19
- $this->dropFieldsFromCurrencyTable(); // 20.
-
-
- }
-
- public function moveBudgetsBack()
- {
- Budget::get()->each(
- function (Budget $budget) {
- Component::firstOrCreate(
- [
- 'name' => $budget->name,
- 'user_id' => $budget->user_id,
- 'class' => 'Budget'
- ]
- );
- }
- );
- }
-
- public function moveCategoriesBack()
- {
- Category::get()->each(
- function (Category $category) {
- Component::firstOrCreate(
- [
- 'name' => $category->name,
- 'user_id' => $category->user_id,
- 'class' => 'Category'
- ]
- );
- }
- );
- }
-
- public function createComponentId()
- {
- Schema::table(
- 'budget_limits', function (Blueprint $table) {
- $table->integer('component_id')->unsigned();
- }
- );
- }
-
- public function updateComponentInBudgetLimits()
- {
- BudgetLimit::get()->each(
- function (BudgetLimit $bl) {
- $budgetId = $bl->budget_id;
- $budget = Budget::find($budgetId);
- if ($budget) {
- $component = Component::where('class', 'Budget')->where('user_id', $budget->user_id)->where('name', $budget->name)->first();
- if ($component) {
- $bl->component_id = $component->id;
- $bl->save();
- }
- }
- }
- );
- }
-
- public function createComponentIdForeignKey()
- {
- Schema::table(
- 'budget_limits', function (Blueprint $table) {
- $table->foreign('component_id', 'limits_component_id_foreign')->references('id')->on('components')->onDelete('cascade');
- }
- );
- }
-
- public function dropBudgetIdColumnInBudgetLimits()
- {
- Schema::table(
- 'budget_limits', function (Blueprint $table) {
- $table->dropForeign('bid_foreign');
- $table->dropColumn('budget_id'); // also drop foreign key!
- }
- );
- }
-
- public function moveBackEntriesForBudgetsInJoinedTable()
- {
- $set = DB::table('budget_transaction_journal')->get();
- foreach ($set as $entry) {
- $budget = Budget::find($entry->budget_id);
- if ($budget) {
- $component = Component::where('class', 'Budget')->where('name', $budget->name)->where('user_id', $budget->user_id)->first();
- if ($component) {
- DB::table('component_transaction_journal')->insert(
- [
- 'component_id' => $component->id,
- 'transaction_journal_id' => $entry->transaction_journal_id
- ]
- );
- }
-
- }
- }
-
- }
-
- public function moveBackEntriesForCategoriesInJoinedTable()
- {
- $set = DB::table('category_transaction_journal')->get();
- foreach ($set as $entry) {
- $category = Category::find($entry->category_id);
- if ($category) {
- $component = Component::where('class', 'Category')->where('name', $category->name)->where('user_id', $category->user_id)->first();
- if ($component) {
- DB::table('component_transaction_journal')->insert(
- [
- 'component_id' => $component->id,
- 'transaction_journal_id' => $entry->transaction_journal_id
- ]
- );
- }
-
- }
- }
-
- }
-
- public function dropBudgetJournalTable()
- {
- Schema::dropIfExists('budget_transaction_journal');
- }
-
- public function dropCategoryJournalTable()
- {
- Schema::dropIfExists('category_transaction_journal');
- }
-
- public function dropBudgetTable()
- {
- Schema::dropIfExists('budgets');
- }
-
- public function dropCategoryTable()
- {
- Schema::dropIfExists('categories');
- }
-
- public function renameBudgetLimits()
- {
- Schema::rename('budget_limits', 'limits');
- }
-
- public function renamePiggyBankEvents()
- {
- Schema::rename('piggy_bank_events', 'piggybank_events');
-
- }
-
- public function renameBudgetLimitToBudgetInRepetitions()
- {
- Schema::table(
- 'limit_repetitions', function (Blueprint $table) {
- $table->renameColumn('budget_limit_id', 'limit_id');
- }
- );
- }
-
- public function dropFieldsFromCurrencyTable()
- {
-
- Schema::table(
- 'transaction_currencies', function (Blueprint $table) {
- $table->dropColumn('symbol');
- $table->dropColumn('name');
- }
- );
- }
-
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- $this->createBudgetTable(); // 1.
- $this->createCategoryTable(); // 2.
- $this->createBudgetJournalTable(); // 3
- $this->createCategoryJournalTable(); // 4.
- $this->moveBudgets(); // 5.
- $this->moveCategories(); // 6.
- $this->correctNameForBudgetLimits(); // 7.
- $this->correctNameForPiggyBankEvents(); // 8.
- $this->renameBudgetToBudgetLimitInRepetitions(); // 9.
- $this->addBudgetIdFieldToBudgetLimits(); // 10.
- $this->moveComponentIdToBudgetId(); // 11.
- $this->dropComponentJournalTable(); // 12.
- $this->dropComponentRecurringTransactionTable(); // 13.
- $this->dropComponentTransactionTable(); // 14.
- $this->dropPiggyBankIdFromTransactions(); // 15.
- $this->dropComponentIdFromBudgetLimits(); // 16.
- $this->expandCurrencyTable(); // 17.
-
- }
-
- public function createBudgetTable()
- {
- Schema::create(
- 'budgets', function (Blueprint $table) {
- $table->increments('id');
- $table->timestamps();
- $table->softDeletes();
- $table->string('name', 50);
- $table->integer('user_id')->unsigned();
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
- $table->unique(['user_id', 'name']);
- }
- );
-
-
- }
-
- public function createCategoryTable()
- {
- Schema::create(
- 'categories', function (Blueprint $table) {
- $table->increments('id');
- $table->timestamps();
- $table->softDeletes();
- $table->string('name', 50);
- $table->integer('user_id')->unsigned();
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
- $table->unique(['user_id', 'name']);
- }
- );
- }
-
- public function createBudgetJournalTable()
- {
- Schema::create(
- 'budget_transaction_journal', function (Blueprint $table) {
- $table->increments('id');
- $table->integer('budget_id')->unsigned();
- $table->integer('transaction_journal_id')->unsigned();
- $table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
- $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
- $table->unique(['budget_id', 'transaction_journal_id'], 'budid_tjid_unique');
- }
- );
- }
-
- public function createCategoryJournalTable()
- {
- Schema::create(
- 'category_transaction_journal', function (Blueprint $table) {
- $table->increments('id');
- $table->integer('category_id')->unsigned();
- $table->integer('transaction_journal_id')->unsigned();
- $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
- $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
- $table->unique(['category_id', 'transaction_journal_id'], 'catid_tjid_unique');
- }
- );
- }
-
- public function moveBudgets()
- {
- Component::where('class', 'Budget')->get()->each(
- function (Component $c) {
- $entry = [
- 'user_id' => $c->user_id,
- 'name' => $c->name
-
- ];
- $budget = Budget::firstOrCreate($entry);
- Log::debug('Migrated budget #' . $budget->id . ': ' . $budget->name);
- // create entry in budget_transaction_journal
- $connections = DB::table('component_transaction_journal')->where('component_id', $c->id)->get();
- foreach ($connections as $connection) {
- DB::table('budget_transaction_journal')->insert(
- [
- 'budget_id' => $budget->id,
- 'transaction_journal_id' => $connection->transaction_journal_id
- ]
- );
- }
- }
- );
- }
-
- public function moveCategories()
- {
- Component::where('class', 'Category')->get()->each(
- function (Component $c) {
- $entry = [
- 'user_id' => $c->user_id,
- 'name' => $c->name
-
- ];
- $category = Category::firstOrCreate($entry);
- Log::debug('Migrated category #' . $category->id . ': ' . $category->name);
- // create entry in category_transaction_journal
- $connections = DB::table('component_transaction_journal')->where('component_id', $c->id)->get();
- foreach ($connections as $connection) {
- DB::table('category_transaction_journal')->insert(
- [
- 'category_id' => $category->id,
- 'transaction_journal_id' => $connection->transaction_journal_id
- ]
- );
- }
- }
- );
- }
-
- public function correctNameForBudgetLimits()
- {
- Schema::rename('limits', 'budget_limits');
- }
-
- public function correctNameForPiggyBankEvents()
- {
- Schema::rename('piggybank_events', 'piggy_bank_events');
-
- }
-
- public function renameBudgetToBudgetLimitInRepetitions()
- {
- Schema::table(
- 'limit_repetitions', function (Blueprint $table) {
- $table->renameColumn('limit_id', 'budget_limit_id');
- }
- );
- }
-
- public function addBudgetIdFieldToBudgetLimits()
- {
- Schema::table(
- 'budget_limits', function (Blueprint $table) {
- $table->integer('budget_id', false, true)->nullable()->after('updated_at');
- $table->foreign('budget_id', 'bid_foreign')->references('id')->on('budgets')->onDelete('cascade');
- }
- );
- }
-
- public function moveComponentIdToBudgetId()
- {
- \Log::debug('Now in moveComponentIdToBudgetId()');
- BudgetLimit::get()->each(
- function (BudgetLimit $bl) {
- \Log::debug('Now at budgetLimit #' . $bl->id . ' with component_id: ' . $bl->component_id);
- $component = Component::find($bl->component_id);
- if ($component) {
- \Log::debug('Found component with id #' . $component->id . ' and name ' . $component->name);
- $budget = Budget::whereName($component->name)->whereUserId($component->user_id)->first();
- if ($budget) {
- \Log::debug('Found a budget with ID #' . $budget->id . ' and name ' . $budget->name);
- $bl->budget_id = $budget->id;
- $bl->save();
- \Log::debug('Connected budgetLimit #' . $bl->id . ' to budget_id' . $budget->id);
- } else {
- \Log::debug('Could not find a matching budget with name ' . $component->name);
- }
- } else {
- \Log::debug('Could not find a component with id ' . $bl->component_id);
- }
- }
- );
- \Log::debug('Done with moveComponentIdToBudgetId()');
-
- }
-
- public function dropComponentJournalTable()
- {
- Schema::dropIfExists('component_transaction_journal');
- }
-
- public function dropComponentRecurringTransactionTable()
- {
- Schema::dropIfExists('component_recurring_transaction');
- }
-
- public function dropComponentTransactionTable()
- {
- Schema::dropIfExists('component_transaction');
- }
-
- public function dropPiggyBankIdFromTransactions()
- {
-
- Schema::table(
- 'transactions', function (Blueprint $table) {
- if (Schema::hasColumn('transactions', 'piggybank_id')) {
- $table->dropForeign('transactions_piggybank_id_foreign');
- $table->dropColumn('piggybank_id');
- }
- }
- );
- }
-
- public function dropComponentIdFromBudgetLimits()
- {
- Schema::table(
- 'budget_limits', function (Blueprint $table) {
- $table->dropForeign('limits_component_id_foreign');
- $table->dropColumn('component_id');
- }
- );
- }
-
- public function expandCurrencyTable()
- {
- Schema::table(
- 'transaction_currencies', function (Blueprint $table) {
- $table->string('name', 48)->nullable();
- $table->string('symbol', 8)->nullable();
- }
- );
- \DB::update('UPDATE `transaction_currencies` SET `symbol` = "€", `name` = "Euro" WHERE `code` = "EUR";');
- }
-
-
-}
diff --git a/app/database/migrations/2014_12_24_191544_changes_for_v322.php b/app/database/migrations/2014_12_24_191544_changes_for_v322.php
deleted file mode 100644
index 5b5e7abff2..0000000000
--- a/app/database/migrations/2014_12_24_191544_changes_for_v322.php
+++ /dev/null
@@ -1,172 +0,0 @@
-renameColumn('piggy_bank_id', 'piggybank_id');
- }
- );
-
- Schema::table(
- 'piggybank_repetitions', function (Blueprint $table) {
- $table->renameColumn('piggy_bank_id', 'piggybank_id');
- }
- );
-
- // remove soft delete to piggy banks
- Schema::table(
- 'piggybanks', function (Blueprint $table) {
- $table->dropSoftDeletes();
- }
- );
-
- // drop keys from bills (foreign bills_uid_for and unique uid_name_unique)
- Schema::table(
- 'bills', function (Blueprint $table) {
- $table->dropForeign('bills_uid_for');
- $table->dropUnique('uid_name_unique');
- }
- );
- // drop foreign key from transaction_journals (bill_id_foreign)
- Schema::table(
- 'transaction_journals', function (Blueprint $table) {
- $table->dropForeign('bill_id_foreign');
-
- }
- );
-
- // drop foreign key from budget_limits:
- Schema::table(
- 'budget_limits', function (Blueprint $table) {
- $table->dropForeign('bid_foreign');
- $table->dropUnique('unique_bl_combi');
- }
- );
-
- // rename bills to recurring_transactions
- Schema::rename('bills', 'recurring_transactions');
- // recreate foreign key recurring_transactions_user_id_foreign in recurring_transactions
- // recreate unique recurring_transactions_user_id_name_unique in recurring_transactions
- Schema::table(
- 'recurring_transactions', function (Blueprint $table) {
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
- $table->unique(['user_id', 'name']);
- }
- );
-
- // rename bill_id to recurring_transaction_id
- // recreate foreign transaction_journals_recurring_transaction_id_foreign in transaction_journals
- Schema::table(
- 'transaction_journals', function (Blueprint $table) {
- $table->renameColumn('bill_id', 'recurring_transaction_id');
- $table->foreign('recurring_transaction_id')->references('id')->on('recurring_transactions')->onDelete('set null');
- }
- );
-
-
- }
-
-
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- // rename tables:
- Schema::rename('piggybank_repetitions', 'piggy_bank_repetitions');
- Schema::rename('piggybanks', 'piggy_banks');
-
- // recreate it the correct way:
- Schema::table(
- 'budget_limits', function (Blueprint $table) {
- $table->unique(['budget_id', 'startdate', 'repeat_freq'], 'unique_bl_combi');
- }
- );
-
- // rename fields
- Schema::table(
- 'piggy_bank_events', function (Blueprint $table) {
- $table->renameColumn('piggybank_id', 'piggy_bank_id');
- }
- );
-
- Schema::table(
- 'piggy_bank_repetitions', function (Blueprint $table) {
- $table->renameColumn('piggybank_id', 'piggy_bank_id');
- }
- );
-
- // add soft delete to piggy banks
- Schema::table(
- 'piggy_banks', function (Blueprint $table) {
- $table->softDeletes();
- }
- );
-
- // rename everything related to recurring transactions, aka bills:
- Schema::table(
- 'transaction_journals', function (Blueprint $table) {
-
-
- // drop relation
- $table->dropForeign('transaction_journals_recurring_transaction_id_foreign');
- // rename column
- $table->renameColumn('recurring_transaction_id', 'bill_id');
-
- }
- );
-
- Schema::table(
- 'recurring_transactions', function (Blueprint $table) {
- $table->dropForeign('recurring_transactions_user_id_foreign');
- $table->dropUnique('recurring_transactions_user_id_name_unique');
- }
- );
- // rename table:
- Schema::rename('recurring_transactions', 'bills');
-
- // recreate foreign relation:
- Schema::table(
- 'transaction_journals', function (Blueprint $table) {
- $table->foreign('bill_id', 'bill_id_foreign')->references('id')->on('bills')->onDelete('set null');
- }
- );
-
- // recreate more foreign relations.
- Schema::table(
- 'bills', function (Blueprint $table) {
- // connect user id to users
- $table->foreign('user_id', 'bills_uid_for')->references('id')->on('users')->onDelete('cascade');
-
- // for a user, the name must be unique
- $table->unique(['user_id', 'name'], 'uid_name_unique');
- }
- );
-
-
- }
-
-}
diff --git a/app/database/migrations/2015_01_18_082406_changes_for_v325.php b/app/database/migrations/2015_01_18_082406_changes_for_v325.php
deleted file mode 100644
index 32a4d2e769..0000000000
--- a/app/database/migrations/2015_01_18_082406_changes_for_v325.php
+++ /dev/null
@@ -1,62 +0,0 @@
-dropUnique('unique_ci_combi');
-
- }
- );
- } catch (PDOException $e) {
- // don't care.
- }
-
- // allow journal descriptions to be encrypted.
- Schema::table(
- 'transaction_journals', function (Blueprint $table) {
- $table->boolean('encrypted')->default(0);
-
- }
- );
- try {
- DB::update('ALTER TABLE `transaction_journals` MODIFY `description` VARCHAR(1024)');
- } catch (PDOException $e) {
- // don't care.
- }
-
- }
-
-}
diff --git a/app/database/seeds/.gitkeep b/app/database/seeds/.gitkeep
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/app/database/seeds/AccountTypeSeeder.php b/app/database/seeds/AccountTypeSeeder.php
deleted file mode 100644
index 93523755ac..0000000000
--- a/app/database/seeds/AccountTypeSeeder.php
+++ /dev/null
@@ -1,24 +0,0 @@
-delete();
-
- AccountType::create(['type' => 'Default account', 'editable' => true]);
- AccountType::create(['type' => 'Cash account', 'editable' => false]);
- AccountType::create(['type' => 'Asset account', 'editable' => true]);
- AccountType::create(['type' => 'Expense account', 'editable' => true]);
- AccountType::create(['type' => 'Revenue account', 'editable' => true]);
- AccountType::create(['type' => 'Initial balance account', 'editable' => false]);
- AccountType::create(['type' => 'Beneficiary account', 'editable' => true]);
- AccountType::create(['type' => 'Import account', 'editable' => false]);
- }
-
-
-}
diff --git a/app/database/seeds/DatabaseSeeder.php b/app/database/seeds/DatabaseSeeder.php
deleted file mode 100644
index 9912f3c281..0000000000
--- a/app/database/seeds/DatabaseSeeder.php
+++ /dev/null
@@ -1,27 +0,0 @@
-call('AccountTypeSeeder');
- $this->call('TransactionCurrencySeeder');
- $this->call('TransactionTypeSeeder');
-
- if (App::environment() == 'testing' || App::environment() == 'homestead') {
- $this->call('TestDataSeeder');
- }
- }
-
-}
diff --git a/app/database/seeds/TestDataSeeder.php b/app/database/seeds/TestDataSeeder.php
deleted file mode 100644
index 0c3de6f0af..0000000000
--- a/app/database/seeds/TestDataSeeder.php
+++ /dev/null
@@ -1,609 +0,0 @@
-_startOfMonth = Carbon::now()->startOfMonth();
- $this->som = $this->_startOfMonth->format('Y-m-d');
- $this->_endOfMonth = Carbon::now()->endOfMonth();
- $this->eom = $this->_endOfMonth->format('Y-m-d');
- $this->_nextStartOfMonth = Carbon::now()->addMonth()->startOfMonth();
- $this->nsom = $this->_nextStartOfMonth->format('Y-m-d');
- $this->_nextEndOfMonth = Carbon::now()->addMonth()->endOfMonth();
- $this->neom = $this->_nextEndOfMonth->format('Y-m-d');
- $this->_yearAgoStartOfMonth = Carbon::now()->subYear()->startOfMonth();
- $this->yasom = $this->_yearAgoStartOfMonth->format('Y-m-d');
- $this->_yearAgoEndOfMonth = Carbon::now()->subYear()->startOfMonth();
- $this->yaeom = $this->_yearAgoEndOfMonth->format('Y-m-d');
- $this->_today = Carbon::now();
- $this->today = $this->_today->format('Y-m-d');
- }
-
- /**
- * Dates are always this month, the start of this month or earlier.
- */
- public function run()
- {
- $this->createUsers();
- $this->createAssetAccounts();
- $this->createBudgets();
- $this->createCategories();
- $this->createPiggyBanks();
- $this->createReminders();
- $this->createRecurringTransactions();
- $this->createBills();
- $this->createExpenseAccounts();
- $this->createRevenueAccounts();
-
- $current = clone $this->_yearAgoStartOfMonth;
- while ($current <= $this->_startOfMonth) {
-
- // create expenses for rent, utilities, TV, phone on the 1st of the month.
- $this->createMonthlyExpenses(clone $current);
- $this->createGroceries(clone $current);
- $this->createBigExpense(clone $current);
-
- echo 'Created test-content for ' . $current->format('F Y') . "\n";
- $current->addMonth();
- }
- $this->createPiggyBankEvent();
-
-
- }
-
- /**
- *
- */
- public function createUsers()
- {
- User::create(['email' => 'reset@example.com', 'password' => 'functional', 'reset' => 'okokokokokokokokokokokokokokokok', 'remember_token' => null]);
- User::create(['email' => 'functional@example.com', 'password' => 'functional', 'reset' => null, 'remember_token' => null]);
- User::create(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james', 'reset' => null, 'remember_token' => null]);
- }
-
- /**
- *
- */
- public function createAssetAccounts()
- {
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
- $assetType = AccountType::whereType('Asset account')->first();
- $ibType = AccountType::whereType('Initial balance account')->first();
- $obType = TransactionType::whereType('Opening balance')->first();
- $euro = TransactionCurrency::whereCode('EUR')->first();
-
-
- $acc_a = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Checking account', 'active' => 1]);
- $acc_b = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Savings account', 'active' => 1]);
- $acc_c = Account::create(['user_id' => $user->id, 'account_type_id' => $assetType->id, 'name' => 'Delete me', 'active' => 1]);
-
- $acc_d = Account::create(['user_id' => $user->id, 'account_type_id' => $ibType->id, 'name' => 'Checking account initial balance', 'active' => 0]);
- $acc_e = Account::create(['user_id' => $user->id, 'account_type_id' => $ibType->id, 'name' => 'Savings account initial balance', 'active' => 0]);
- $acc_f = Account::create(['user_id' => $user->id, 'account_type_id' => $ibType->id, 'name' => 'Delete me initial balance', 'active' => 0]);
-
- $this->createJournal(
- ['from' => $acc_d, 'to' => $acc_a, 'amount' => 4000, 'transactionType' => $obType, 'description' => 'Initial Balance for Checking account',
- 'date' => $this->yasom, 'transactionCurrency' => $euro]
- );
- $this->createJournal(
- ['from' => $acc_e, 'to' => $acc_b, 'amount' => 10000, 'transactionType' => $obType, 'description' => 'Initial Balance for Savings account',
- 'date' => $this->yasom, 'transactionCurrency' => $euro]
- );
- $this->createJournal(
- ['from' => $acc_f, 'to' => $acc_c, 'amount' => 100, 'transactionType' => $obType, 'description' => 'Initial Balance for Delete me',
- 'date' => $this->yasom, 'transactionCurrency' => $euro]
- );
-
-
- }
-
- /**
- * @param array $data
- *
- * @return TransactionJournal
- */
- public function createJournal(array $data)
- {
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
- $billID = isset($data['bill']) ? $data['bill']->id : null;
-
- /** @var TransactionJournal $journal */
- $journal = TransactionJournal::create(
- [
- 'user_id' => $user->id,
- 'transaction_type_id' => $data['transactionType']->id,
- 'transaction_currency_id' => $data['transactionCurrency']->id,
- 'bill_id' => $billID,
- 'description' => $data['description'],
- 'completed' => 1,
- 'date' => $data['date']
- ]
- );
-
- Transaction::create(['account_id' => $data['from']->id, 'transaction_journal_id' => $journal->id, 'amount' => $data['amount'] * -1]);
- Transaction::create(['account_id' => $data['to']->id, 'transaction_journal_id' => $journal->id, 'amount' => $data['amount']]);
-
- if (isset($data['budget'])) {
- $journal->budgets()->save($data['budget']);
- }
- if (isset($data['category'])) {
- $journal->categories()->save($data['category']);
- }
-
- return $journal;
- }
-
- /**
- *
- */
- public function createBudgets()
- {
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
-
- $groceries = Budget::create(['user_id' => $user->id, 'name' => 'Groceries']);
- $bills = Budget::create(['user_id' => $user->id, 'name' => 'Bills']);
- $deleteMe = Budget::create(['user_id' => $user->id, 'name' => 'Delete me']);
- Budget::create(['user_id' => $user->id, 'name' => 'Budget without repetition']);
- $groceriesLimit = BudgetLimit::create(
- ['startdate' => $this->som, 'amount' => 201, 'repeats' => 0, 'repeat_freq' => 'monthly', 'budget_id' => $groceries->id]
- );
- $billsLimit = BudgetLimit::create(
- ['startdate' => $this->som, 'amount' => 202, 'repeats' => 0, 'repeat_freq' => 'monthly', 'budget_id' => $bills->id]
- );
- $deleteMeLimit = BudgetLimit::create(
- ['startdate' => $this->som, 'amount' => 203, 'repeats' => 0, 'repeat_freq' => 'monthly', 'budget_id' => $deleteMe->id]
- );
-
- // and because we have no filters, some repetitions:
- LimitRepetition::create(['budget_limit_id' => $groceriesLimit->id, 'startdate' => $this->som, 'enddate' => $this->eom, 'amount' => 201]);
- LimitRepetition::create(['budget_limit_id' => $billsLimit->id, 'startdate' => $this->som, 'enddate' => $this->eom, 'amount' => 202]);
- LimitRepetition::create(['budget_limit_id' => $deleteMeLimit->id, 'startdate' => $this->som, 'enddate' => $this->eom, 'amount' => 203]);
- }
-
- /**
- *
- */
- public function createCategories()
- {
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
- Category::create(['user_id' => $user->id, 'name' => 'DailyGroceries']);
- Category::create(['user_id' => $user->id, 'name' => 'Lunch']);
- Category::create(['user_id' => $user->id, 'name' => 'House']);
- Category::create(['user_id' => $user->id, 'name' => 'Delete me']);
-
- }
-
- /**
- *
- */
- public function createPiggyBanks()
- {
- // account
- $savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
-
- // some dates
- $endDate = clone $this->_startOfMonth;
- $nextYear = clone $this->_startOfMonth;
-
- $endDate->addMonths(4);
- $nextYear->addYear()->subDay();
-
- $next = $nextYear->format('Y-m-d');
- $end = $endDate->format('Y-m-d');
-
- // piggy bank
- $newCamera = PiggyBank::create(
- [
- 'account_id' => $savings->id,
- 'name' => 'New camera',
- 'targetamount' => 2000,
- 'startdate' => $this->som,
- 'targetdate' => null,
- 'repeats' => 0,
- 'rep_length' => null,
- 'rep_every' => 0,
- 'rep_times' => null,
- 'reminder' => null,
- 'reminder_skip' => 0,
- 'remind_me' => 0,
- 'order' => 0,
- ]
- );
- // and some events!
- PiggyBankEvent::create(['piggy_bank_id' => $newCamera->id, 'date' => $this->som, 'amount' => 100]);
- PiggyBankRepetition::create(['piggy_bank_id' => $newCamera->id, 'startdate' => $this->som, 'targetdate' => null, 'currentamount' => 100]);
-
-
- $newClothes = PiggyBank::create(
- [
- 'account_id' => $savings->id,
- 'name' => 'New clothes',
- 'targetamount' => 2000,
- 'startdate' => $this->som,
- 'targetdate' => $end,
- 'repeats' => 0,
- 'rep_length' => null,
- 'rep_every' => 0,
- 'rep_times' => null,
- 'reminder' => null,
- 'reminder_skip' => 0,
- 'remind_me' => 0,
- 'order' => 0,
- ]
- );
-
- PiggyBankEvent::create(['piggy_bank_id' => $newClothes->id, 'date' => $this->som, 'amount' => 100]);
- PiggyBankRepetition::create(['piggy_bank_id' => $newClothes->id, 'startdate' => $this->som, 'targetdate' => $end, 'currentamount' => 100]);
-
- // weekly reminder piggy bank
- $weekly = PiggyBank::create(
- [
- 'account_id' => $savings->id,
- 'name' => 'Weekly reminder for clothes',
- 'targetamount' => 2000,
- 'startdate' => $this->som,
- 'targetdate' => $next,
- 'repeats' => 0,
- 'rep_length' => null,
- 'rep_every' => 0,
- 'rep_times' => null,
- 'reminder' => 'week',
- 'reminder_skip' => 0,
- 'remind_me' => 1,
- 'order' => 0,
- ]
- );
- PiggyBankRepetition::create(['piggy_bank_id' => $weekly->id, 'startdate' => $this->som, 'targetdate' => $next, 'currentamount' => 0]);
- }
-
- /**
- *
- */
- public function createReminders()
- {
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
- // for weekly piggy bank (clothes)
- $nextWeek = clone $this->_startOfMonth;
- $piggyBank = PiggyBank::whereName('New clothes')->orderBy('id', 'DESC')->first();
- $nextWeek->addWeek();
- $week = $nextWeek->format('Y-m-d');
-
- Reminder::create(
- ['user_id' => $user->id, 'startdate' => $this->som, 'enddate' => $week, 'active' => 1, 'notnow' => 0,
- 'remindersable_id' => $piggyBank->id, 'remindersable_type' => 'PiggyBank']
- );
-
- // a fake reminder::
- Reminder::create(
- ['user_id' => $user->id, 'startdate' => $this->som, 'enddate' => $week, 'active' => 0, 'notnow' => 0, 'remindersable_id' => 40,
- 'remindersable_type' => 'Transaction']
- );
- }
-
- /**
- *
- */
- public function createRecurringTransactions()
- {
- // account
- $savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
-
- $recurring = PiggyBank::create(
- [
- 'account_id' => $savings->id,
- 'name' => 'Nieuwe spullen',
- 'targetamount' => 1000,
- 'startdate' => $this->som,
- 'targetdate' => $this->eom,
- 'repeats' => 1,
- 'rep_length' => 'month',
- 'rep_every' => 0,
- 'rep_times' => 0,
- 'reminder' => 'month',
- 'reminder_skip' => 0,
- 'remind_me' => 1,
- 'order' => 0,
- ]
- );
- PiggyBankRepetition::create(['piggy_bank_id' => $recurring->id, 'startdate' => $this->som, 'targetdate' => $this->eom, 'currentamount' => 0]);
- PiggyBankRepetition::create(
- ['piggy_bank_id' => $recurring->id, 'startdate' => $this->nsom, 'targetdate' => $this->neom, 'currentamount' => 0]
- );
- Reminder::create(
- ['user_id' => $user->id, 'startdate' => $this->som, 'enddate' => $this->neom, 'active' => 1, 'notnow' => 0,
- 'remindersable_id' => $recurring->id, 'remindersable_type' => 'PiggyBank']
- );
- }
-
- /**
- *
- */
- public function createBills()
- {
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
- // bill
- Bill::create(
- ['user_id' => $user->id, 'name' => 'Rent', 'match' => 'rent,landlord', 'amount_min' => 700, 'amount_max' => 900, 'date' => $this->som,
- 'active' => 1, 'automatch' => 1, 'repeat_freq' => 'monthly', 'skip' => 0,]
- );
-
- // bill
- Bill::create(
- [
- 'user_id' => $user->id,
- 'name' => 'Gas licht',
- 'match' => 'no,match',
- 'amount_min' => 500, 'amount_max' => 700,
- 'date' => $this->som,
- 'active' => 1, 'automatch' => 1,
- 'repeat_freq' => 'monthly', 'skip' => 0,
- ]
- );
-
- // bill
- Bill::create(
- [
- 'user_id' => $user->id,
- 'name' => 'Something something',
- 'match' => 'mumble,mumble',
- 'amount_min' => 500,
- 'amount_max' => 700,
- 'date' => $this->som,
- 'active' => 0,
- 'automatch' => 1,
- 'repeat_freq' => 'monthly',
- 'skip' => 0,
- ]
- );
-
- }
-
- /**
- *
- */
- public function createExpenseAccounts()
- {
- //// create expenses for rent, utilities, water, TV, phone on the 1st of the month.
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
- $expenseType = AccountType::whereType('Expense account')->first();
-
- Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'Land lord', 'active' => 1]);
- Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'Utilities company', 'active' => 1]);
- Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'Water company', 'active' => 1]);
- Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'TV company', 'active' => 1]);
- Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'Phone agency', 'active' => 1]);
- Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'Super savers', 'active' => 1]);
- Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'Groceries House', 'active' => 1]);
- Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'Lunch House', 'active' => 1]);
-
-
- Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'Buy More', 'active' => 1]);
-
- }
-
- /**
- *
- */
- public function createRevenueAccounts()
- {
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
- $revenueType = AccountType::whereType('Revenue account')->first();
-
- Account::create(['user_id' => $user->id, 'account_type_id' => $revenueType->id, 'name' => 'Employer', 'active' => 1]);
- Account::create(['user_id' => $user->id, 'account_type_id' => $revenueType->id, 'name' => 'IRS', 'active' => 1]);
- Account::create(['user_id' => $user->id, 'account_type_id' => $revenueType->id, 'name' => 'Second job employer', 'active' => 1]);
-
- }
-
- /**
- * @param Carbon $date
- */
- public function createMonthlyExpenses(Carbon $date)
- {
- // get some objects from the database:
- $checking = Account::whereName('Checking account')->orderBy('id', 'DESC')->first();
- $savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
- $landLord = Account::whereName('Land lord')->orderBy('id', 'DESC')->first();
- $utilities = Account::whereName('Utilities company')->orderBy('id', 'DESC')->first();
- $television = Account::whereName('TV company')->orderBy('id', 'DESC')->first();
- $phone = Account::whereName('Phone agency')->orderBy('id', 'DESC')->first();
- $employer = Account::whereName('Employer')->orderBy('id', 'DESC')->first();
- $bills = Budget::whereName('Bills')->orderBy('id', 'DESC')->first();
- $house = Category::whereName('House')->orderBy('id', 'DESC')->first();
- $withdrawal = TransactionType::whereType('Withdrawal')->first();
- $deposit = TransactionType::whereType('Deposit')->first();
- $transfer = TransactionType::whereType('Transfer')->first();
- $euro = TransactionCurrency::whereCode('EUR')->first();
- $rentBill = Bill::where('name', 'Rent')->first();
- $cur = $date->format('Y-m-d');
- $formatted = $date->format('F Y');
-
- $this->createJournal(
- ['from' => $checking, 'to' => $landLord, 'amount' => 800, 'transactionType' => $withdrawal, 'description' => 'Rent for ' . $formatted,
- 'date' => $cur, 'transactionCurrency' => $euro, 'budget' => $bills, 'category' => $house, 'bill' => $rentBill]
- );
- $this->createJournal(
- ['from' => $checking, 'to' => $utilities, 'amount' => 150, 'transactionType' => $withdrawal, 'description' => 'Utilities for ' . $formatted,
- 'date' => $cur, 'transactionCurrency' => $euro, 'budget' => $bills, 'category' => $house,]
- );
- $this->createJournal(
- ['from' => $checking, 'to' => $television, 'amount' => 50, 'transactionType' => $withdrawal, 'description' => 'TV for ' . $formatted,
- 'date' => $cur, 'transactionCurrency' => $euro, 'budget' => $bills, 'category' => $house,]
- );
- $this->createJournal(
- ['from' => $checking, 'to' => $phone, 'amount' => 50, 'transactionType' => $withdrawal, 'description' => 'Phone bill for ' . $formatted,
- 'date' => $cur, 'transactionCurrency' => $euro, 'budget' => $bills, 'category' => $house,]
- );
-
- // two transactions. One without a budget, one without a category.
- $this->createJournal(
- ['from' => $checking, 'to' => $phone, 'amount' => 10, 'transactionType' => $withdrawal,
- 'description' => 'Extra charges on phone bill for ' . $formatted, 'date' => $cur, 'transactionCurrency' => $euro, 'category' => $house]
- );
- $this->createJournal(
- ['from' => $checking, 'to' => $television, 'amount' => 5, 'transactionType' => $withdrawal,
- 'description' => 'Extra charges on TV bill for ' . $formatted, 'date' => $cur, 'transactionCurrency' => $euro, 'budget' => $bills]
- );
-
- // income from job:
- $this->createJournal(
- ['from' => $employer, 'to' => $checking, 'amount' => rand(3500, 4000), 'transactionType' => $deposit, 'description' => 'Salary for ' . $formatted,
- 'date' => $cur, 'transactionCurrency' => $euro]
- );
- $this->createJournal(
- ['from' => $checking, 'to' => $savings, 'amount' => 2000, 'transactionType' => $transfer,
- 'description' => 'Salary to savings account in ' . $formatted, 'date' => $cur, 'transactionCurrency' => $euro]
- );
-
- }
-
- /**
- * @param Carbon $date
- */
- public function createGroceries(Carbon $date)
- {
- // variables we need:
- $checking = Account::whereName('Checking account')->orderBy('id', 'DESC')->first();
- $shopOne = Account::whereName('Groceries House')->orderBy('id', 'DESC')->first();
- $shopTwo = Account::whereName('Super savers')->orderBy('id', 'DESC')->first();
- $lunchHouse = Account::whereName('Lunch House')->orderBy('id', 'DESC')->first();
- $lunch = Category::whereName('Lunch')->orderBy('id', 'DESC')->first();
- $daily = Category::whereName('DailyGroceries')->orderBy('id', 'DESC')->first();
- $euro = TransactionCurrency::whereCode('EUR')->first();
- $withdrawal = TransactionType::whereType('Withdrawal')->first();
- $groceries = Budget::whereName('Groceries')->orderBy('id', 'DESC')->first();
-
-
- $shops = [$shopOne, $shopTwo];
-
- // create groceries and lunch (daily, between 5 and 10 euro).
- $mStart = clone $date;
- $mEnd = clone $date;
- $mEnd->endOfMonth();
- while ($mStart <= $mEnd) {
- $mFormat = $mStart->format('Y-m-d');
- $shop = $shops[rand(0, 1)];
-
- $this->createJournal(
- ['from' => $checking, 'to' => $shop, 'amount' => (rand(500, 1000) / 100), 'transactionType' => $withdrawal, 'description' => 'Groceries',
- 'date' => $mFormat, 'transactionCurrency' => $euro, 'category' => $daily, 'budget' => $groceries]
- );
- $this->createJournal(
- ['from' => $checking, 'to' => $lunchHouse, 'amount' => (rand(200, 600) / 100), 'transactionType' => $withdrawal, 'description' => 'Lunch',
- 'date' => $mFormat, 'transactionCurrency' => $euro, 'category' => $lunch, 'budget' => $groceries]
- );
-
- $mStart->addDay();
- }
- }
-
- /**
- * @param $date
- */
- public function createBigExpense($date)
- {
- $date->addDays(12);
- $dollar = TransactionCurrency::whereCode('USD')->first();
- $checking = Account::whereName('Checking account')->orderBy('id', 'DESC')->first();
- $savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
- $buyMore = Account::whereName('Buy More')->orderBy('id', 'DESC')->first();
- $withdrawal = TransactionType::whereType('Withdrawal')->first();
- $user = User::whereEmail('thegrumpydictator@gmail.com')->first();
-
-
- // create some big expenses, move some money around.
- $amount = rand(500, 2000);
-
- $one = $this->createJournal(
- ['from' => $savings, 'to' => $checking, 'amount' => $amount, 'transactionType' => $withdrawal,
- 'description' => 'Money for big expense in ' . $date->format('F Y'), 'date' => $date->format('Y-m-d'), 'transactionCurrency' => $dollar]
- );
- $two = $this->createJournal(
- ['from' => $checking, 'to' => $buyMore, 'amount' => $amount, 'transactionType' => $withdrawal,
- 'description' => 'Big expense in ' . $date->format('F Y'), 'date' => $date->format('Y-m-d'), 'transactionCurrency' => $dollar]
- );
- $group = TransactionGroup::create(
- [
- 'user_id' => $user->id,
- 'relation' => 'balance'
- ]
- );
- $group->transactionjournals()->save($one);
- $group->transactionjournals()->save($two);
- $group->save();
- }
-
- /**
- *
- */
- protected function createPiggyBankEvent()
- {
- // piggy bank event
- // add money to this piggy bank
- // create a piggy bank event to match:
- $checking = Account::whereName('Checking account')->orderBy('id', 'DESC')->first();
- $savings = Account::whereName('Savings account')->orderBy('id', 'DESC')->first();
- $transfer = TransactionType::whereType('Transfer')->first();
- $euro = TransactionCurrency::whereCode('EUR')->first();
- $groceries = Budget::whereName('Groceries')->orderBy('id', 'DESC')->first();
- $house = Category::whereName('House')->orderBy('id', 'DESC')->first();
- $piggyBank = PiggyBank::whereName('New camera')->orderBy('id', 'DESC')->first();
- $intoPiggy = $this->createJournal(
- ['from' => $checking, 'to' => $savings, 'amount' => 100, 'transactionType' => $transfer, 'description' => 'Money for piggy',
- 'date' => $this->yaeom, 'transactionCurrency' => $euro, 'category' => $house, 'budget' => $groceries]
- );
- PiggyBankEvent::create(
- [
- 'piggy_bank_id' => $piggyBank->id,
- 'transaction_journal_id' => $intoPiggy->id,
- 'date' => $this->yaeom,
- 'amount' => 100
- ]
- );
- }
-
-
-}
\ No newline at end of file
diff --git a/app/database/seeds/TransactionCurrencySeeder.php b/app/database/seeds/TransactionCurrencySeeder.php
deleted file mode 100644
index 6bf2eb7010..0000000000
--- a/app/database/seeds/TransactionCurrencySeeder.php
+++ /dev/null
@@ -1,18 +0,0 @@
-delete();
-
- TransactionCurrency::create(['code' => 'EUR','name' => 'Euro','symbol' => '€']);
- TransactionCurrency::create(['code' => 'USD','name' => 'US Dollar','symbol' => '$']);
- TransactionCurrency::create(['code' => 'HUF','name' => 'Hungarian forint','symbol' => 'Ft']);
- }
-
-}
diff --git a/app/database/seeds/TransactionTypeSeeder.php b/app/database/seeds/TransactionTypeSeeder.php
deleted file mode 100644
index cf0e6a5e12..0000000000
--- a/app/database/seeds/TransactionTypeSeeder.php
+++ /dev/null
@@ -1,20 +0,0 @@
-delete();
-
- TransactionType::create(['type' => 'Withdrawal']);
- TransactionType::create(['type' => 'Deposit']);
- TransactionType::create(['type' => 'Transfer']);
- TransactionType::create(['type' => 'Opening balance']);
- }
-
-}
diff --git a/app/filters.php b/app/filters.php
deleted file mode 100644
index 27e9264440..0000000000
--- a/app/filters.php
+++ /dev/null
@@ -1,104 +0,0 @@
-with('message', 'Not possible');
- }
-}
-);
diff --git a/app/lang/en/pagination.php b/app/lang/en/pagination.php
deleted file mode 100644
index 88e22db661..0000000000
--- a/app/lang/en/pagination.php
+++ /dev/null
@@ -1,20 +0,0 @@
- '« Previous',
-
- 'next' => 'Next »',
-
-];
diff --git a/app/lang/en/reminders.php b/app/lang/en/reminders.php
deleted file mode 100644
index a416c65cb5..0000000000
--- a/app/lang/en/reminders.php
+++ /dev/null
@@ -1,24 +0,0 @@
- "Passwords must be at least six characters and match the confirmation.",
-
- "user" => "We can't find a user with that e-mail address.",
-
- "token" => "This password reset token is invalid.",
-
- "sent" => "Password reminder sent!",
-
-];
diff --git a/app/lang/en/validation.php b/app/lang/en/validation.php
deleted file mode 100644
index e6ee8b9253..0000000000
--- a/app/lang/en/validation.php
+++ /dev/null
@@ -1,105 +0,0 @@
- "The :attribute must be accepted.",
- "active_url" => "The :attribute is not a valid URL.",
- "after" => "The :attribute must be a date after :date.",
- "alpha" => "The :attribute may only contain letters.",
- "alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.",
- "alpha_num" => "The :attribute may only contain letters and numbers.",
- "array" => "The :attribute must be an array.",
- "before" => "The :attribute must be a date before :date.",
- "between" => [
- "numeric" => "The :attribute must be between :min and :max.",
- "file" => "The :attribute must be between :min and :max kilobytes.",
- "string" => "The :attribute must be between :min and :max characters.",
- "array" => "The :attribute must have between :min and :max items.",
- ],
- "confirmed" => "The :attribute confirmation does not match.",
- "date" => "The :attribute is not a valid date.",
- "date_format" => "The :attribute does not match the format :format.",
- "different" => "The :attribute and :other must be different.",
- "digits" => "The :attribute must be :digits digits.",
- "digits_between" => "The :attribute must be between :min and :max digits.",
- "email" => "The :attribute must be a valid email address.",
- "exists" => "The selected :attribute is invalid.",
- "image" => "The :attribute must be an image.",
- "in" => "The selected :attribute is invalid.",
- "integer" => "The :attribute must be an integer.",
- "ip" => "The :attribute must be a valid IP address.",
- "max" => [
- "numeric" => "The :attribute may not be greater than :max.",
- "file" => "The :attribute may not be greater than :max kilobytes.",
- "string" => "The :attribute may not be greater than :max characters.",
- "array" => "The :attribute may not have more than :max items.",
- ],
- "mimes" => "The :attribute must be a file of type: :values.",
- "min" => [
- "numeric" => "The :attribute must be at least :min.",
- "file" => "The :attribute must be at least :min kilobytes.",
- "string" => "The :attribute must be at least :min characters.",
- "array" => "The :attribute must have at least :min items.",
- ],
- "not_in" => "The selected :attribute is invalid.",
- "numeric" => "The :attribute must be a number.",
- "regex" => "The :attribute format is invalid.",
- "required" => "The :attribute field is required.",
- "required_if" => "The :attribute field is required when :other is :value.",
- "required_with" => "The :attribute field is required when :values is present.",
- "required_with_all" => "The :attribute field is required when :values is present.",
- "required_without" => "The :attribute field is required when :values is not present.",
- "required_without_all" => "The :attribute field is required when none of :values are present.",
- "same" => "The :attribute and :other must match.",
- "size" => [
- "numeric" => "The :attribute must be :size.",
- "file" => "The :attribute must be :size kilobytes.",
- "string" => "The :attribute must be :size characters.",
- "array" => "The :attribute must contain :size items.",
- ],
- "unique" => "The :attribute has already been taken.",
- "url" => "The :attribute format is invalid.",
-
- /*
- |--------------------------------------------------------------------------
- | Custom Validation Language Lines
- |--------------------------------------------------------------------------
- |
- | Here you may specify custom validation messages for attributes using the
- | convention "attribute.rule" to name the lines. This makes it quick to
- | specify a specific custom language line for a given attribute rule.
- |
- */
-
- 'custom' => [
- 'attribute-name' => [
- 'rule-name' => 'custom-message',
- ],
- ],
- 'alphabasic' => 'The :attribute field must consist of basic alphanumeric characters.',
-
- /*
- |--------------------------------------------------------------------------
- | Custom Validation Attributes
- |--------------------------------------------------------------------------
- |
- | The following language lines are used to swap attribute place-holders
- | with something more reader friendly such as E-Mail Address instead
- | of "email". This simply helps us make messages a little cleaner.
- |
- */
-
- 'attributes' => [],
-
-];
diff --git a/app/lib/FireflyIII/Chart/Chart.php b/app/lib/FireflyIII/Chart/Chart.php
deleted file mode 100644
index 6d01ddaecd..0000000000
--- a/app/lib/FireflyIII/Chart/Chart.php
+++ /dev/null
@@ -1,76 +0,0 @@
-on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('amount', '>', 0);
- }
- )
- ->leftJoin(
- 'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
- )
- ->leftJoin('categories', 'categories.id', '=', 'category_transaction_journal.category_id')
- ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- ->before($end)
- ->after($start)
- ->where('transaction_types.type', 'Withdrawal')
- ->groupBy('categories.id')
- ->orderBy('sum', 'DESC')
- ->get(['categories.id', 'categories.name', \DB::Raw('SUM(`transactions`.`amount`) AS `sum`')]);
- }
-
- /**
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function getBillsSummary(Carbon $start, Carbon $end)
- {
- return \Bill::
- leftJoin(
- 'transaction_journals', function (JoinClause $join) use ($start, $end) {
- $join->on('bills.id', '=', 'transaction_journals.bill_id')
- ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
- ->where('transaction_journals.date', '<=', $end->format('Y-m-d'));
- }
- )
- ->leftJoin(
- 'transactions', function (JoinClause $join) {
- $join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '>', 0);
- }
- )
- ->where('active', 1)
- ->groupBy('bills.id')
- ->get(
- ['bills.id', 'bills.name', 'transaction_journals.description',
- 'transaction_journals.encrypted',
- 'transaction_journals.id as journalId',
- \DB::Raw('SUM(`bills`.`amount_min` + `bills`.`amount_max`) / 2 as `averageAmount`'),
- 'transactions.amount AS actualAmount']
- );
- }
-}
diff --git a/app/lib/FireflyIII/Chart/ChartInterface.php b/app/lib/FireflyIII/Chart/ChartInterface.php
deleted file mode 100644
index 62a2efa868..0000000000
--- a/app/lib/FireflyIII/Chart/ChartInterface.php
+++ /dev/null
@@ -1,31 +0,0 @@
-reminder)) {
- $this->reminder = $this->repetition->piggyBank->reminders()->where('startdate', $this->getStartdate()->format('Y-m-d'))->where(
- 'enddate', $this->getTargetdate()->format('Y-m-d')
- )->first();
- }
-
- return $this->reminder;
- }
-
- /**
- * @param \Reminder $reminder
- */
- public function setReminder($reminder)
- {
- $this->reminder = $reminder;
- }
-
- /**
- * @return Carbon
- */
- public function getStartdate()
- {
- return $this->startdate;
- }
-
- /**
- * @param Carbon $startdate
- */
- public function setStartdate($startdate)
- {
- $this->startdate = $startdate;
- }
-
- /**
- * @return Carbon
- */
- public function getTargetdate()
- {
- return $this->targetdate;
- }
-
- /**
- * @param Carbon $targetdate
- */
- public function setTargetdate($targetdate)
- {
- $this->targetdate = $targetdate;
- }
-
- /**
- * @return \PiggyBankRepetition
- */
- public function getRepetition()
- {
- return $this->repetition;
- }
-
- /**
- * @param \PiggyBankRepetition $repetition
- */
- public function setRepetition($repetition)
- {
- $this->repetition = $repetition;
- }
-
- /**
- * @return bool
- */
- public function hasReminder()
- {
- return !is_null($this->reminder);
- }
-
- /**
- * @return float|int
- */
- public function percentage()
- {
- if ($this->getCurrentamount() < $this->getCumulativeAmount()) {
- $pct = 0;
- // calculate halfway point?
- if ($this->getCumulativeAmount() - $this->getCurrentamount() < $this->getAmountPerBar()) {
- $left = $this->getCurrentamount() % $this->getAmountPerBar();
- $pct = round($left / $this->getAmountPerBar() * 100);
- }
-
- return $pct;
- } else {
- return 100;
- }
- }
-
- /**
- * @return float
- */
- public function getCurrentamount()
- {
- return $this->currentamount;
- }
-
- /**
- * @param float $currentamount
- */
- public function setCurrentamount($currentamount)
- {
- $this->currentamount = $currentamount;
- }
-
- /**
- * @return float
- */
- public function getCumulativeAmount()
- {
- return $this->cumulativeAmount;
- }
-
- /**
- * @param float $cumulativeAmount
- */
- public function setCumulativeAmount($cumulativeAmount)
- {
- $this->cumulativeAmount = $cumulativeAmount;
- }
-
- /**
- * @return float
- */
- public function getAmountPerBar()
- {
- return $this->amountPerBar;
- }
-
- /**
- * @param float $amountPerBar
- */
- public function setAmountPerBar($amountPerBar)
- {
- $this->amountPerBar = $amountPerBar;
- }
-
-
-}
diff --git a/app/lib/FireflyIII/Database/Account/Account.php b/app/lib/FireflyIII/Database/Account/Account.php
deleted file mode 100644
index 816274cc49..0000000000
--- a/app/lib/FireflyIII/Database/Account/Account.php
+++ /dev/null
@@ -1,534 +0,0 @@
-setUser(\Auth::user());
- }
-
- /**
- * @param array $types
- *
- * @return int
- */
- public function countAccountsByType(array $types)
- {
- return $this->getUser()->accounts()->accountTypeIn($types)->count();
- }
-
- /**
- * @param array $types
- *
- * @return Collection
- */
- public function getAccountsByType(array $types)
- {
- /*
- * Basic query:
- */
- $query = $this->getUser()->accounts()->accountTypeIn($types)->withMeta()->orderBy('name', 'ASC');;
- $set = $query->get(['accounts.*', 'account_meta.data as accountRole']);
-
- $set->each(
- function (\Account $account) {
- /*
- * Get last activity date.
- */
- $account->lastActivityDate = $this->getLastActivity($account);
- $account->accountRole = \Config::get('firefly.accountRoles.' . json_decode($account->accountRole));
- }
- );
-
- return $set;
- }
-
- /**
- * @param \Account $account
- *
- * @return \TransactionJournal|null
- */
- public function openingBalanceTransaction(\Account $account)
- {
-
- $first = \TransactionJournal::withRelevantData()->accountIs($account)
- ->orderBy('transaction_journals.date', 'ASC')
- ->orderBy('created_at', 'ASC')
- ->first(['transaction_journals.*']);
- $initial = strpos(strtolower($first->description), 'initial');
- $opening = strpos(strtolower($first->description), 'opening');
- if ($initial === false && $opening === false) {
- return null;
- }
-
- return $first;
-
- }
-
- /**
- * @param \Account $account
- * @param array $data
- *
- * @return bool
- */
- public function storeInitialBalance(\Account $account, array $data)
- {
- /** @var \FireflyIII\Database\TransactionType\TransactionType $typeRepository */
- $typeRepository = \App::make('FireflyIII\Database\TransactionType\TransactionType');
-
- /** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $journals */
- $journals = \App::make('FireflyIII\Database\TransactionJournal\TransactionJournal');
-
- // some initial variables:
- $balance = floatval($data['openingBalance']);
- $date = new Carbon($data['openingBalanceDate']);
-
- // some dynamic variables:
- if ($balance < 0) {
- $opposingType = 'expense';
- $transactionType = $typeRepository->findByWhat('withdrawal');
- $toAccount = $this->store(['name' => $account->name . ' Initial Balance Account', 'active' => 1, 'what' => $opposingType]);
- $fromAccount = $account;
- } else {
- $opposingType = 'revenue';
- $transactionType = $typeRepository->findByWhat('deposit');
- $fromAccount = $this->store(['name' => $account->name . ' Initial Balance Account', 'active' => 1, 'what' => $opposingType]);
- $toAccount = $account;
- }
-
- // data for transaction journal:
- $balance = $balance < 0 ? $balance * -1 : $balance;
- $currency = $journals->getJournalCurrencyById(intval($data['balance_currency_id']));
- $opening = [
- 'transaction_type_id' => $transactionType->id,
- 'transaction_currency_id' => $currency->id,
- 'amount' => $balance,
- 'what' => 'opening',
- 'from' => $fromAccount,
- 'completed' => 0,
- 'to' => $toAccount,
- 'date' => $date,
- 'description' => 'Opening balance for new account ' . $account->name
- ];
-
- $validation = $journals->validate($opening);
- if ($validation['errors']->count() == 0) {
- $journals->store($opening);
-
- return true;
- } else {
- \Log::error('Initial balance created is not valid (Database/Account)');
- \Log::error($validation['errors']->all());
- \App::abort(500);
- }
-
- return false;
- }
-
- /**
- * @param \Account $account
- *
- * @return int
- */
- public function getLastActivity(\Account $account)
- {
- $lastActivityKey = 'account.' . $account->id . '.lastActivityDate';
- if (\Cache::has($lastActivityKey)) {
- return \Cache::get($lastActivityKey);
- }
-
- $transaction = $account->transactions()
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->orderBy('transaction_journals.date', 'DESC')->first();
- if ($transaction) {
- $date = $transaction->transactionJournal->date;
- } else {
- $date = 0;
- }
- \Cache::forever($lastActivityKey, $date);
-
- return $date;
- }
-
- /**
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot make it shorter because of query.
- * @param Eloquent $model
- *
- * @return bool
- */
- public function destroy(Eloquent $model)
- {
- $journals = \TransactionJournal::whereIn(
- 'id', function (QueryBuilder $query) use ($model) {
- $query->select('transaction_journal_id')
- ->from('transactions')
- ->whereIn(
- 'account_id', function (QueryBuilder $query) use ($model) {
- $query
- ->select('accounts.id')
- ->from('accounts')
- ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
- ->where(
- function (QueryBuilder $q) use ($model) {
- $q->where('accounts.id', $model->id);
- $q->orWhere(
- function (QueryBuilder $q) use ($model) {
- $q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
- $q->where('account_types.type', 'Initial balance account');
- $q->where('accounts.active', 0);
- }
- );
- }
- )->where('accounts.user_id', $this->getUser()->id);
- }
- )->get();
- }
- )->get();
- $transactions = [];
- /** @var \TransactionJournal $journal */
- foreach ($journals as $journal) {
- /** @var \Transaction $t */
- foreach ($journal->transactions as $t) {
- $transactions[] = intval($t->id);
- }
- $journal->delete();
- }
- if (count($transactions) > 0) {
- \Transaction::whereIn('id', $transactions)->delete();
- }
- \Event::fire('account.destroy', [$model]);
-
- // get account type:
- /** @var \FireflyIII\Database\AccountType\AccountType $acctType */
- $acctType = \App::make('FireflyIII\Database\AccountType\AccountType');
-
- $accountType = $acctType->findByWhat('initial');
-
- //$q->where('account_types.type', '');
-
- \Account::where(
- function (EloquentBuilder $q) use ($model, $accountType) {
- $q->where('id', $model->id);
- $q->orWhere(
- function (EloquentBuilder $q) use ($model, $accountType) {
- $q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
- $q->where('accounts.account_type_id', $accountType->id);
- $q->where('accounts.active', 0);
- }
- );
- }
- )->delete();
-
- return true;
-
- }
-
- /**
- * @param array $data
- *
- * @return \Eloquent
- */
- public function store(array $data)
- {
-
- /** @var \FireflyIII\Database\AccountType\AccountType $acctType */
- $acctType = \App::make('FireflyIII\Database\AccountType\AccountType');
-
- $accountType = $acctType->findByWhat($data['what']);
-
- $data['user_id'] = $this->getUser()->id;
- $data['account_type_id'] = $accountType->id;
- $data['active'] = isset($data['active']) && intval($data['active']) === 1 ? 1 : 0;
-
- $data = array_except($data, ['_token', 'what']);
- $account = new \Account($data);
- if (!$account->isValid()) {
- \Log::error('Account created is not valid (Database/Account)');
- \Log::error($account->getErrors()->all());
- \App::abort(500);
- }
- $account->save();
- if (isset($data['openingBalance']) && floatval($data['openingBalance']) != 0) {
- $this->storeInitialBalance($account, $data);
- }
-
- switch ($account->accountType->type) {
- case 'Asset account':
- case 'Default account':
- $account->updateMeta('accountRole', $data['account_role']);
- break;
- }
-
-
- /* Tell transaction journal to store a new one.*/
- \Event::fire('account.store', [$account]);
-
-
- return $account;
-
- }
-
- /**
- * @param Eloquent $model
- * @param array $data
- *
- * @return bool
- */
- public function update(Eloquent $model, array $data)
- {
- $model->name = $data['name'];
- $model->active = isset($data['active']) ? intval($data['active']) : 0;
-
- switch ($model->accountType->type) {
- case 'Asset account':
- case 'Default account':
- $model->updateMeta('accountRole', $data['account_role']);
- break;
- }
-
- $model->save();
-
- if (isset($data['openingBalance']) && isset($data['openingBalanceDate']) && strlen($data['openingBalanceDate']) > 0) {
- $this->updateInitialBalance($model, $data);
-
- }
- \Event::fire('account.update', [$model]);
-
- return true;
- }
-
- /**
- * Validates a model. Returns an array containing MessageBags
- * errors/warnings/successes.
- *
- * @param array $model
- *
- * @return array
- */
- public function validate(array $model)
- {
- $model['active'] = !isset($model['active']) ? false : $model['active'];
- $successes = new MessageBag;
- $account = new \Account($model);
- $account->isValid('form_input', false);
- $errors = $account->getErrors();
-
- if (isset($model['account_role']) && !in_array($model['account_role'], array_keys(\Config::get('firefly.accountRoles')))) {
- $errors->add('account_role', 'Invalid account role');
- }
- /*
- * Opening balance and opening balance date.
- */
- if (isset($model['what']) && $model['what'] == 'asset') {
- if (isset($model['openingBalance']) && strlen($model['openingBalance']) > 0 && !is_numeric($model['openingBalance'])) {
- $errors->add('openingBalance', 'This is not a number.');
- }
- if (isset($model['openingBalanceDate']) && strlen($model['openingBalanceDate']) > 0) {
- try {
- new Carbon($model['openingBalanceDate']);
- } catch (\Exception $e) {
- $errors->add('openingBalanceDate', 'This date is invalid.');
- }
- }
- }
- $fields = ['name', 'openingBalance', 'openingBalanceDate', 'active', 'account_role'];
- foreach ($fields as $field) {
- if (!$errors->has($field)) {
- $successes->add($field, 'OK');
- }
- }
-
- return ['errors' => $errors, 'successes' => $successes];
- }
-
- /**
- * @param Eloquent $model
- * @param array $data
- */
- public function updateInitialBalance(Eloquent $model, array $data)
- {
- /** @noinspection PhpParamsInspection */
- $openingBalance = $this->openingBalanceTransaction($model);
- if (is_null($openingBalance)) {
- $this->storeInitialBalance($model, $data);
- } else {
- $openingBalance->date = new Carbon($data['openingBalanceDate']);
- $openingBalance->save();
- $amount = floatval($data['openingBalance']);
- /** @var \Transaction $transaction */
- foreach ($openingBalance->transactions as $transaction) {
- if ($transaction->account_id == $model->id) {
- $transaction->amount = $amount;
- } else {
- $transaction->amount = $amount * -1;
- }
- $transaction->save();
- }
- }
- }
-
- /**
- * Returns an object with id $id.
- *
- * @param int $objectId
- *
- * @return \Eloquent
- */
- public function find($objectId)
- {
- return $this->getUser()->accounts()->find($objectId);
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- * @codeCoverageIgnore
- *
- * @param $what
- *
- * @throws NotImplementedException
- * @return \AccountType|null
- */
- public function findByWhat($what)
- {
- throw new NotImplementedException;
- }
-
- /**
- * Returns all objects.
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function get()
- {
- throw new NotImplementedException;
- }
-
- /**
- * @param array $ids
- *
- * @return Collection
- */
- public function getByIds(array $ids)
- {
- return $this->getUser()->accounts()->whereIn('id', $ids)->get();
- }
-
- /**
- * @param $name
- *
- * @return static
- * @throws \FireflyIII\Exception\FireflyException
- */
- public function firstExpenseAccountOrCreate($name)
- {
- /** @var \FireflyIII\Database\AccountType\AccountType $typeRepository */
- $typeRepository = \App::make('FireflyIII\Database\AccountType\AccountType');
-
- $accountType = $typeRepository->findByWhat('expense');
-
- // if name is "", find cash account:
- if (strlen($name) == 0) {
- $cashAccountType = $typeRepository->findByWhat('cash');
-
- // find or create cash account:
- return \Account::firstOrCreate(
- ['name' => 'Cash account', 'account_type_id' => $cashAccountType->id, 'active' => 0, 'user_id' => $this->getUser()->id,]
- );
- }
-
- $data = ['user_id' => $this->getUser()->id, 'account_type_id' => $accountType->id, 'name' => $name, 'active' => 1];
-
- return \Account::firstOrCreate($data);
-
- }
-
- /**
- * @param $name
- *
- * @return static
- * @throws \FireflyIII\Exception\FireflyException
- */
- public function firstRevenueAccountOrCreate($name)
- {
- /** @var \FireflyIII\Database\AccountType\AccountType $typeRepository */
- $typeRepository = \App::make('FireflyIII\Database\AccountType\AccountType');
-
- $accountType = $typeRepository->findByWhat('revenue');
-
- // if name is "", find cash account:
- if (strlen($name) == 0) {
- $cashAccountType = $typeRepository->findByWhat('cash');
-
- // find or create cash account:
- return \Account::firstOrCreate(
- ['name' => 'Cash account', 'account_type_id' => $cashAccountType->id, 'active' => 0, 'user_id' => $this->getUser()->id,]
- );
- }
-
- $data = ['user_id' => $this->getUser()->id, 'account_type_id' => $accountType->id, 'name' => $name, 'active' => 1];
-
- return \Account::firstOrCreate($data);
-
- }
-
- /**
- * @param \Account $account
- * @param int $limit
- * @param string $range
- *
- * @return \Illuminate\Pagination\Paginator
- */
- public function getTransactionJournals(\Account $account, $limit = 50, $range = 'session')
- {
- $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
- $items = [];
- $query = $this->getUser()
- ->transactionJournals()
- ->withRelevantData()
- ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transactions.account_id', $account->id)
- ->orderBy('date', 'DESC');
-
- if ($range == 'session') {
- $query->before(\Session::get('end', Carbon::now()->startOfMonth()));
- $query->after(\Session::get('start', Carbon::now()->startOfMonth()));
- }
- $count = $query->count();
- $set = $query->take($limit)->offset($offset)->get(['transaction_journals.*']);
-
- foreach ($set as $entry) {
- $items[] = $entry;
- }
-
- return \Paginator::make($items, $count, $limit);
-
-
- }
-
-}
diff --git a/app/lib/FireflyIII/Database/Account/AccountInterface.php b/app/lib/FireflyIII/Database/Account/AccountInterface.php
deleted file mode 100644
index c9d21ba229..0000000000
--- a/app/lib/FireflyIII/Database/Account/AccountInterface.php
+++ /dev/null
@@ -1,48 +0,0 @@
- 'Expense account',
- 'asset' => 'Asset account',
- 'revenue' => 'Revenue account',
- 'cash' => 'Cash account',
- 'initial' => 'Initial balance account',
- ];
- if (isset($typeMap[$what])) {
- return \AccountType::whereType($typeMap[$what])->first();
- }
- throw new FireflyException('Cannot find account type described as "' . e($what) . '".');
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Returns all objects.
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function get()
- {
- throw new NotImplementedException;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @param array $ids
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function getByIds(array $ids)
- {
- throw new NotImplementedException;
- }
-}
diff --git a/app/lib/FireflyIII/Database/Bill/Bill.php b/app/lib/FireflyIII/Database/Bill/Bill.php
deleted file mode 100644
index 642f5163a4..0000000000
--- a/app/lib/FireflyIII/Database/Bill/Bill.php
+++ /dev/null
@@ -1,356 +0,0 @@
-setUser(\Auth::user());
- }
-
- /**
- * @param Eloquent $model
- *
- * @return bool
- */
- public function destroy(Eloquent $model)
- {
- $model->delete();
-
- return true;
- }
-
- /**
- * @param array $data
- *
- * @return \Eloquent
- */
- public function store(array $data)
- {
- $bill = new \Bill;
- $bill->user()->associate($this->getUser());
- $bill->name = $data['name'];
- $bill->match = $data['match'];
- $bill->amount_max = floatval($data['amount_max']);
- $bill->amount_min = floatval($data['amount_min']);
-
- $date = new Carbon($data['date']);
-
-
- $bill->active = intval($data['active']);
- $bill->automatch = intval($data['automatch']);
- $bill->repeat_freq = $data['repeat_freq'];
-
- /*
- * Jump to the start of the period.
- */
- $date = \DateKit::startOfPeriod($date, $data['repeat_freq']);
- $bill->date = $date;
- $bill->skip = intval($data['skip']);
-
- $bill->save();
-
- return $bill;
- }
-
- /**
- * @param Eloquent $model
- * @param array $data
- *
- * @return bool
- */
- public function update(Eloquent $model, array $data)
- {
- $model->name = $data['name'];
- $model->match = $data['match'];
- $model->amount_max = floatval($data['amount_max']);
- $model->amount_min = floatval($data['amount_min']);
-
- $date = new Carbon($data['date']);
-
- $model->date = $date;
- $model->active = intval($data['active']);
- $model->automatch = intval($data['automatch']);
- $model->repeat_freq = $data['repeat_freq'];
- $model->skip = intval($data['skip']);
- $model->save();
-
- return true;
- }
-
- /**
- * Validates an array. Returns an array containing MessageBags
- * errors/warnings/successes.
- *
- * ignored because this method will be gone soon.
- *
- * @param array $model
- *
- * @return array
- */
- public function validate(array $model)
- {
- $warnings = new MessageBag;
- $successes = new MessageBag;
- $errors = new MessageBag;
- if (floatval($model['amount_min']) > floatval($model['amount_max'])) {
- $errors->add('amount_max', 'Maximum amount can not be less than minimum amount.');
- $errors->add('amount_min', 'Minimum amount can not be more than maximum amount.');
- }
- $object = new \Bill($model);
- $object->isValid();
- $errors->merge($object->getErrors());
-
- $set = ['name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active'];
- foreach ($set as $entry) {
- if (!$errors->has($entry)) {
- $successes->add($entry, 'OK');
- }
- }
-
- return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Returns an object with id $id.
- *
- * @param int $objectId
- *
- * @return \Eloquent
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function find($objectId)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
- *
- * @param $what
- *
- * @return \AccountType|null
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function findByWhat($what)
- {
- throw new NotImplementedException;
- }
-
- /**
- * Returns all objects.
- *
- * @return Collection
- */
- public function get()
- {
- return $this->getUser()->bills()->orderBy('name')->get();
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- * @param array $ids
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function getByIds(array $ids)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @param \Bill $bill
- *
- * @return Carbon|null
- */
- public function lastFoundMatch(\Bill $bill)
- {
- $last = $bill->transactionjournals()->orderBy('date', 'DESC')->first();
- if ($last) {
- return $last->date;
- }
-
- return null;
- }
-
- /**
- * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
- *
- * @param \Bill $bill
- *
- * @return Carbon|null
- */
- public function nextExpectedMatch(\Bill $bill)
- {
- $finalDate = null;
- if ($bill->active == 0) {
- return $finalDate;
- }
-
- /*
- * $today is the start of the next period, to make sure FF3 won't miss anything
- * when the current period has a transaction journal.
- */
- $today = \DateKit::addPeriod(new Carbon, $bill->repeat_freq, 0);
-
- $skip = $bill->skip + 1;
- $start = \DateKit::startOfPeriod(new Carbon, $bill->repeat_freq);
- /*
- * go back exactly one month/week/etc because FF3 does not care about 'next'
- * bills if they're too far into the past.
- */
-
- $counter = 0;
- while ($start <= $today) {
- if (($counter % $skip) == 0) {
- // do something.
- $end = \DateKit::endOfPeriod(clone $start, $bill->repeat_freq);
- $journalCount = $bill->transactionjournals()->before($end)->after($start)->count();
- if ($journalCount == 0) {
- $finalDate = clone $start;
- break;
- }
- }
-
- // add period for next round!
- $start = \DateKit::addPeriod($start, $bill->repeat_freq, 0);
- $counter++;
- }
-
- return $finalDate;
- }
-
- /**
- * @param \Bill $bill
- * @param \TransactionJournal $journal
- *
- * @return bool
- */
- public function scan(\Bill $bill, \TransactionJournal $journal)
- {
- /*
- * Match words.
- */
- $wordMatch = false;
- $matches = explode(',', $bill->match);
- $description = strtolower($journal->description);
-
- /*
- * Attach expense account to description for more narrow matching.
- */
- if (count($journal->transactions) < 2) {
- $transactions = $journal->transactions()->get();
- } else {
- $transactions = $journal->transactions;
- }
- /** @var \Transaction $transaction */
- foreach ($transactions as $transaction) {
- /** @var \Account $account */
- $account = $transaction->account()->first();
- /** @var \AccountType $type */
- $type = $account->accountType()->first();
- if ($type->type == 'Expense account' || $type->type == 'Beneficiary account') {
- $description .= ' ' . strtolower($account->name);
- }
- }
- \Log::debug('Final description: ' . $description);
- \Log::debug('Matches searched: ' . join(':', $matches));
-
- $count = 0;
- foreach ($matches as $word) {
- if (!(strpos($description, strtolower($word)) === false)) {
- $count++;
- }
- }
- if ($count >= count($matches)) {
- $wordMatch = true;
- \Log::debug('word match is true');
- }
-
-
- /*
- * Match amount.
- */
-
- $amountMatch = false;
- if (count($transactions) > 1) {
-
- $amount = max(floatval($transactions[0]->amount), floatval($transactions[1]->amount));
- $min = floatval($bill->amount_min);
- $max = floatval($bill->amount_max);
- if ($amount >= $min && $amount <= $max) {
- $amountMatch = true;
- \Log::debug('Amount match is true!');
- }
- }
-
- /*
- * If both, update!
- */
- if ($wordMatch && $amountMatch) {
- $journal->bill()->associate($bill);
- $journal->save();
- }
- }
-
- /**
- * @param \Bill $bill
- *
- * @return bool
- */
- public function scanEverything(\Bill $bill)
- {
- // get all journals that (may) be relevant.
- // this is usually almost all of them.
-
- /** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $journalRepository */
- $journalRepository = \App::make('FireflyIII\Database\TransactionJournal\TransactionJournal');
-
- $set = \DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $bill->amount_min)->where('amount', '<=', $bill->amount_max)
- ->get(['transaction_journal_id']);
- $ids = [];
-
- /** @var \Transaction $entry */
- foreach ($set as $entry) {
- $ids[] = intval($entry->transaction_journal_id);
- }
- if (count($ids) > 0) {
- $journals = $journalRepository->getByIds($ids);
- /** @var \TransactionJournal $journal */
- foreach ($journals as $journal) {
- $this->scan($bill, $journal);
- }
- }
-
- return true;
- }
-}
diff --git a/app/lib/FireflyIII/Database/Bill/BillInterface.php b/app/lib/FireflyIII/Database/Bill/BillInterface.php
deleted file mode 100644
index ec75dd1167..0000000000
--- a/app/lib/FireflyIII/Database/Bill/BillInterface.php
+++ /dev/null
@@ -1,43 +0,0 @@
-setUser(\Auth::user());
- }
-
- /**
- * @param Eloquent $model
- *
- * @return bool
- */
- public function destroy(Eloquent $model)
- {
- $model->delete();
-
- return true;
- }
-
- /**
- * @param array $data
- *
- * @return \Eloquent
- * @throws FireflyException
- */
- public function store(array $data)
- {
- $budget = new \Budget($data);
-
- if (!$budget->isValid()) {
- \Log::error('Could not store budget: ' . $budget->getErrors()->toJson());
- throw new FireflyException($budget->getErrors()->first());
- }
- $budget->save();
-
- return $budget;
- }
-
- /**
- * @param Eloquent $model
- * @param array $data
- *
- * @return bool
- */
- public function update(Eloquent $model, array $data)
- {
- $model->name = $data['name'];
- $model->save();
-
- return true;
- }
-
- /**
- * Validates an array. Returns an array containing MessageBags
- * errors/warnings/successes.
- *
- * @param array $model
- *
- * @return array
- */
- public function validate(array $model)
- {
- $warnings = new MessageBag;
- $successes = new MessageBag;
- $budget = new \Budget($model);
- $budget->isValid();
- $errors = $budget->getErrors();
-
- if (!$errors->has('name')) {
- $successes->add('name', 'OK');
- }
-
- return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
- }
-
- /**
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function expenseNoBudget(Carbon $start, Carbon $end)
- {
- // Add expenses that have no budget:
- return $this->getUser()
- ->transactionjournals()
- ->whereNotIn(
- 'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) {
- $query
- ->select('transaction_journals.id')
- ->from('transaction_journals')
- ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
- ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
- ->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'));
- }
- )
- ->before($end)
- ->after($start)
- ->lessThan(0)
- ->transactionTypes(['Withdrawal'])
- ->get();
- }
-
- /**
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function journalsNoBudget(Carbon $start, Carbon $end)
- {
- $set = $this->getUser()
- ->transactionjournals()
- ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
- ->whereNull('budget_transaction_journal.id')
- ->before($end)
- ->after($start)
- ->orderBy('transaction_journals.date')
- ->get(['transaction_journals.*']);
-
- return $set;
- }
-
- /**
- * This method includes the time because otherwise, SQLite does not understand it.
- *
- * @param \Budget $budget
- * @param Carbon $date
- *
- * @return \LimitRepetition|null
- */
- public function repetitionOnStartingOnDate(\Budget $budget, Carbon $date)
- {
- return \LimitRepetition::
- leftJoin('budget_limits', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
- ->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00'))
- ->where('budget_limits.budget_id', $budget->id)
- ->first(['limit_repetitions.*']);
- }
-
- /**
- * Returns an object with id $id.
- *
- * @param int $objectId
- *
- * @return \Eloquent
- */
- public function find($objectId)
- {
- return $this->getUser()->budgets()->find($objectId);
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
- *
- * @param $what
- *
- * @return \AccountType|null
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function findByWhat($what)
- {
- throw new NotImplementedException;
- }
-
- /**
- * Returns all objects.
- *
- * @return Collection
- */
- public function get()
- {
- $budgets = $this->getUser()->budgets()->get();
-
- return $budgets;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @param array $ids
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function getByIds(array $ids)
- {
- throw new NotImplementedException;
- }
-
- /**
- * Returns all the transaction journals for a limit, possibly limited by a limit repetition.
- *
- * @param \Budget $budget
- * @param \LimitRepetition $repetition
- * @param int $take
- *
- * @return \Illuminate\Pagination\Paginator
- */
- public function getJournals(\Budget $budget, \LimitRepetition $repetition = null, $take = 50)
- {
- $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $take : 0;
-
-
- $setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset)->orderBy('date', 'DESC');
- $countQuery = $budget->transactionJournals();
-
-
- if (!is_null($repetition)) {
- $setQuery->after($repetition->startdate)->before($repetition->enddate);
- $countQuery->after($repetition->startdate)->before($repetition->enddate);
- }
-
-
- $set = $setQuery->get(['transaction_journals.*']);
- $count = $countQuery->count();
- $items = [];
- foreach ($set as $entry) {
- $items[] = $entry;
- }
-
- return \Paginator::make($items, $count, $take);
- }
-
- /**
- * @param \Budget $budget
- * @param Carbon $date
- *
- * @return \LimitRepetition
- */
- public function getRepetitionByDate(\Budget $budget, Carbon $date)
- {
- return $budget->limitrepetitions()->where('limit_repetitions.startdate', $date)->first(['limit_repetitions.*']);
- }
-
- /**
- * @param \Budget $budget
- * @param Carbon $date
- *
- * @return float
- */
- public function spentInMonth(\Budget $budget, Carbon $date)
- {
- $end = clone $date;
- $date->startOfMonth();
- $end->endOfMonth();
- $sum = floatval($budget->transactionjournals()->before($end)->after($date)->lessThan(0)->sum('amount')) * -1;
-
- return $sum;
- }
-
- /**
- * This method updates the amount (envelope) for the given date and budget. This results in a (new) limit (aka an envelope)
- * for that budget. Returned to the user is the new limit repetition.
- *
- * @param \Budget $budget
- * @param Carbon $date
- * @param $amount
- *
- * @return \LimitRepetition
- * @throws \Exception
- */
- public function updateLimitAmount(\Budget $budget, Carbon $date, $amount)
- {
- /** @var \BudgetLimit $limit */
- $limit = $this->limitOnStartingOnDate($budget, $date);
- if (!$limit) {
- // create one!
- $limit = new \BudgetLimit;
- $limit->budget()->associate($budget);
- $limit->startdate = $date;
- $limit->amount = $amount;
- $limit->repeat_freq = 'monthly';
- $limit->repeats = 0;
- $limit->save();
- \Log::info('ID: ' . $limit->id);
- /*
- * A newly stored limit also created a limit repetition.
- */
- \Event::fire('limits.store', [$limit]);
- } else {
- if ($amount > 0) {
- $limit->amount = $amount;
- $limit->save();
- /*
- * An updated limit also updates the associated limit repetitions.
- */
- \Event::fire('limits.update', [$limit]);
- } else {
- $limit->delete();
- }
- }
-
- return $limit->limitrepetitions()->first();
-
-
- }
-
- /**
- * @param \Budget $budget
- * @param Carbon $date
- *
- * @return \BudgetLimit
- */
- public function limitOnStartingOnDate(\Budget $budget, Carbon $date)
- {
- return $budget->budgetLimits()->where('startdate', $date->format('Y-m-d 00:00:00'))->first();
-
-
- }
-}
diff --git a/app/lib/FireflyIII/Database/Budget/BudgetInterface.php b/app/lib/FireflyIII/Database/Budget/BudgetInterface.php
deleted file mode 100644
index b81b786c85..0000000000
--- a/app/lib/FireflyIII/Database/Budget/BudgetInterface.php
+++ /dev/null
@@ -1,40 +0,0 @@
-setUser(\Auth::user());
- }
-
- /**
- * @param Eloquent $model
- *
- * @return bool
- */
- public function destroy(Eloquent $model)
- {
- $model->delete();
-
- return true;
- }
-
- /**
- * @param array $data
- *
- * @return \Eloquent
- * @throws FireflyException
- */
- public function store(array $data)
- {
- $category = new \Category;
- $category->name = $data['name'];
- $category->user()->associate($this->getUser());
- if (!$category->isValid()) {
- \Log::error('Could not store category: ' . $category->getErrors()->toJson());
- throw new FireflyException($category->getErrors()->first());
- }
- $category->save();
-
- return $category;
- }
-
- /**
- * @param Eloquent $model
- * @param array $data
- *
- * @return bool
- * @throws FireflyException
- */
- public function update(Eloquent $model, array $data)
- {
- $model->name = $data['name'];
- $model->save();
-
- return true;
- }
-
- /**
- * Validates an array. Returns an array containing MessageBags
- * errors/warnings/successes.
- *
- * @param array $model
- *
- * @return array
- */
- public function validate(array $model)
- {
- $warnings = new MessageBag;
- $successes = new MessageBag;
- $category = new \Category($model);
- $category->isValid();
- $errors = $category->getErrors();
-
- if (!$errors->has('name')) {
- $successes->add('name', 'OK');
- }
-
- return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Returns an object with id $id.
- *
- * @param int $objectId
- *
- * @return \Eloquent
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function find($objectId)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
- *
- * @param $what
- *
- * @return \AccountType|null
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function findByWhat($what)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Returns all objects.
- *
- * @return Collection
- */
- public function get()
- {
- return $this->getUser()->categories()->orderBy('name', 'ASC')->get();
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @param array $ids
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function getByIds(array $ids)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @param $name
- *
- * @return \Category
- */
- public function firstOrCreate($name)
- {
- return \Category::firstOrCreate(['user_id' => $this->getUser()->id, 'name' => $name]);
- }
-
- /**
- * @param \Category $category
- * @param int $limit
- *
- * @return \Illuminate\Pagination\Paginator
- */
- public function getTransactionJournals(\Category $category, $limit = 50)
- {
- $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
- $set = $category->transactionJournals()->withRelevantData()->take($limit)->offset($offset)->orderBy('date', 'DESC')->get(['transaction_journals.*']);
- $count = $category->transactionJournals()->count();
- $items = [];
- foreach ($set as $entry) {
- $items[] = $entry;
- }
-
- return \Paginator::make($items, $count, $limit);
-
- }
-
- /**
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function journalsNoCategory(Carbon $start, Carbon $end)
- {
- $set = $this->getUser()
- ->transactionjournals()
- ->leftJoin('category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
- ->whereNull('category_transaction_journal.id')
- ->before($end)
- ->after($start)
- ->orderBy('transaction_journals.date')
- ->get(['transaction_journals.*']);
-
- return $set;
- }
-
- /**
- * @param \Category $category
- * @param Carbon $date
- *
- * @return float
- */
- public function spentInMonth(\Category $category, Carbon $date)
- {
- $end = clone $date;
- $date->startOfMonth();
- $end->endOfMonth();
- $sum = floatval($category->transactionjournals()->before($end)->after($date)->lessThan(0)->sum('amount')) * -1;
-
- return $sum;
- }
-}
diff --git a/app/lib/FireflyIII/Database/CommonDatabaseCallsInterface.php b/app/lib/FireflyIII/Database/CommonDatabaseCallsInterface.php
deleted file mode 100644
index 6fbf57c68b..0000000000
--- a/app/lib/FireflyIII/Database/CommonDatabaseCallsInterface.php
+++ /dev/null
@@ -1,47 +0,0 @@
-piggyBankRepetitions()->get();
- if ($reps->count() == 1) {
- return $reps->first();
- }
- // should filter the one we need:
- $repetitions = $reps->filter(
- function (\PiggyBankRepetition $rep) use ($date) {
- if ($date->between($rep->startdate, $rep->targetdate)) {
- return $rep;
- }
-
- return null;
- }
- );
- if ($repetitions->count() == 0) {
- return null;
- }
-
- return $repetitions->first();
- }
-
- /**
- * Returns all objects.
- *
- * @return Collection
- */
- public function get()
- {
- return $this->getUser()->piggyBanks()->where('repeats', 0)->orderBy('name')->get();
- }
-}
diff --git a/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php b/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php
deleted file mode 100644
index be969c4259..0000000000
--- a/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php
+++ /dev/null
@@ -1,186 +0,0 @@
-setUser(\Auth::user());
- }
-
- /**
- * @param Eloquent $model
- *
- * @return bool
- */
- public function destroy(Eloquent $model)
- {
- $reminders = \Reminder::where('remindersable_id', $model->id)->get();
- /** @var \Reminder $reminder */
- foreach ($reminders as $reminder) {
- $reminder->delete();
- }
- $model->delete();
-
- }
-
- /**
- * Returns an object with id $id.
- *
- * @param int $objectId
- *
- * @return \Eloquent
- */
- public function find($objectId)
- {
- return \PiggyBank::
- leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('piggy_banks.id', '=', $objectId)->where(
- 'accounts.user_id', $this->getUser()->id
- )
- ->first(['piggy_banks.*']);
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
- *
- * @param $what
- *
- * @return \AccountType|null
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function findByWhat($what)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @param array $ids
- *
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function getByIds(array $ids)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @param \Account $account
- *
- * @return float
- */
- public function leftOnAccount(\Account $account)
- {
- \Log::debug('Now in leftOnAccount() for account #' . $account->id . ' (' . $account->name . ')');
- $balance = \Steam::balance($account);
- \Log::debug('Steam says: ' . $balance);
- /** @var \PiggyBank $p */
- foreach ($account->piggyBanks()->get() as $p) {
- $balance -= $p->currentRelevantRep()->currentamount;
- }
-
- return $balance;
-
- }
-
- /**
- * @param array $data
- *
- * @return \Eloquent
- */
- public function store(array $data)
- {
- if (!isset($data['remind_me']) || (isset($data['remind_me']) && $data['remind_me'] == 0)) {
- $data['reminder'] = null;
- }
- $piggyBank = new \PiggyBank($data);
- $piggyBank->save();
-
- return $piggyBank;
- }
-
-
- /**
- * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
- *
- * @param Eloquent $model
- * @param array $data
- *
- * @return bool
- */
- public function update(Eloquent $model, array $data)
- {
- /** @var \PiggyBank $model */
- $model->name = $data['name'];
- $model->account_id = intval($data['account_id']);
- $model->targetamount = floatval($data['targetamount']);
- $model->targetdate = isset($data['targetdate']) && $data['targetdate'] != '' ? $data['targetdate'] : null;
- $model->rep_every = intval($data['rep_every']);
- $model->reminder_skip = intval($data['reminder_skip']);
- $model->order = intval($data['order']);
- $model->remind_me = intval($data['remind_me']);
- $model->reminder = isset($data['reminder']) ? $data['reminder'] : 'month';
-
- if ($model->remind_me == 0) {
- $model->reminder = null;
- }
-
- $model->save();
-
- return true;
- }
-
- /**
- * Validates an array. Returns an array containing MessageBags
- * errors/warnings/successes.
- *
- * Ignore PHPMD rules because Laravel 5.0 will make this method superfluous anyway.
- *
- * @param array $model
- *
- * @return array
- */
- public function validate(array $model)
- {
- $warnings = new MessageBag;
- $successes = new MessageBag;
- $model = new \PiggyBank($model);
- $model->isValid();
- $errors = $model->getErrors();
-
- // add ok messages.
- $list = ['name', 'account_id', 'targetamount', 'targetdate', 'remind_me', 'reminder'];
- foreach ($list as $entry) {
- if (!$errors->has($entry) && !$warnings->has($entry)) {
- $successes->add($entry, 'OK');
- }
- }
-
-
- return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
- }
-
-}
diff --git a/app/lib/FireflyIII/Database/PiggyBank/PiggybankInterface.php b/app/lib/FireflyIII/Database/PiggyBank/PiggybankInterface.php
deleted file mode 100644
index 3c26f1c969..0000000000
--- a/app/lib/FireflyIII/Database/PiggyBank/PiggybankInterface.php
+++ /dev/null
@@ -1,19 +0,0 @@
-piggyBank()->first();
- $bars = new Collection;
- $currentStart = clone $repetition->startdate;
-
- if (is_null($piggyBank->reminder)) {
- $entry = ['repetition' => $repetition, 'amountPerBar' => floatval($piggyBank->targetamount),
- 'currentAmount' => floatval($repetition->currentamount), 'cumulativeAmount' => floatval($piggyBank->targetamount),
- 'startDate' => clone $repetition->startdate, 'targetDate' => clone $repetition->targetdate];
- $bars->push($this->createPiggyBankPart($entry));
-
- return $bars;
- }
-
- while ($currentStart < $repetition->targetdate) {
- $currentTarget = \DateKit::endOfX($currentStart, $piggyBank->reminder, $repetition->targetdate);
- $entry = ['repetition' => $repetition, 'amountPerBar' => null, 'currentAmount' => floatval($repetition->currentamount),
- 'cumulativeAmount' => null, 'startDate' => $currentStart, 'targetDate' => $currentTarget];
- $bars->push($this->createPiggyBankPart($entry));
- $currentStart = clone $currentTarget;
- $currentStart->addDay();
-
- }
- $amountPerBar = floatval($piggyBank->targetamount) / $bars->count();
- $cumulative = $amountPerBar;
- /** @var PiggyBankPart $bar */
- foreach ($bars as $index => $bar) {
- $bar->setAmountPerBar($amountPerBar);
- $bar->setCumulativeAmount($cumulative);
- if ($bars->count() - 1 == $index) {
- $bar->setCumulativeAmount($piggyBank->targetamount);
- }
- $cumulative += $amountPerBar;
- }
-
- return $bars;
- }
-
- /**
- * @param array $data
- *
- * @return PiggyBankPart
- */
- public function createPiggyBankPart(array $data)
- {
- $part = new PiggyBankPart;
- $part->setRepetition($data['repetition']);
- $part->setAmountPerBar($data['amountPerBar']);
- $part->setCurrentamount($data['currentAmount']);
- $part->setCumulativeAmount($data['cumulativeAmount']);
- $part->setStartdate($data['startDate']);
- $part->setTargetdate($data['targetDate']);
-
- return $part;
- }
-
-
- /**
- * @param array $data
- *
- * @return \Eloquent
- */
- public function store(array $data)
- {
-
- $data['rep_every'] = intval($data['rep_every']);
- $data['reminder_skip'] = intval($data['reminder_skip']);
- $data['order'] = intval($data['order']);
- $data['remind_me'] = intval($data['remind_me']);
- $data['account_id'] = intval($data['account_id']);
-
-
- if ($data['remind_me'] == 0) {
- $data['reminder'] = null;
- }
-
- $repeated = new \PiggyBank($data);
- $repeated->save();
-
- return $repeated;
- }
-
- /**
- * Returns all objects.
- *
- * @return Collection
- */
- public function get()
- {
- return $this->getUser()->piggyBanks()->where('repeats', 1)->get();
- }
-
-}
diff --git a/app/lib/FireflyIII/Database/SwitchUser.php b/app/lib/FireflyIII/Database/SwitchUser.php
deleted file mode 100644
index d8c0946274..0000000000
--- a/app/lib/FireflyIII/Database/SwitchUser.php
+++ /dev/null
@@ -1,27 +0,0 @@
-_user;
- }
-
- /**
- * @param $user
- */
- public function setUser($user)
- {
- $this->_user = $user;
- }
-}
diff --git a/app/lib/FireflyIII/Database/Transaction/Transaction.php b/app/lib/FireflyIII/Database/Transaction/Transaction.php
deleted file mode 100644
index d8c2ea909d..0000000000
--- a/app/lib/FireflyIII/Database/Transaction/Transaction.php
+++ /dev/null
@@ -1,156 +0,0 @@
-account()->associate($data['account']);
- $transaction->transactionJournal()->associate($data['transaction_journal']);
- $transaction->amount = floatval($data['amount']);
- if (isset($data['piggyBank'])) {
- $transaction->piggyBank()->associate($data['piggyBank']);
- }
- if (isset($data['description'])) {
- $transaction->description = $data['description'];
- }
- if ($transaction->isValid()) {
- $transaction->save();
- } else {
- throw new FireflyException($transaction->getErrors()->first());
- }
-
- return $transaction;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @param Eloquent $model
- * @param array $data
- *
- * @return bool
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function update(Eloquent $model, array $data)
- {
- throw new NotImplementedException;
- }
-
- /**
- * Validates an array. Returns an array containing MessageBags
- * errors/warnings/successes.
- *
- * @param array $model
- *
- * @return MessageBag
- */
- public function validate(array $model)
- {
- $errors = new MessageBag;
- if (is_null($model['account'])) {
- $errors->add('account', 'No account present');
- }
- if (is_null($model['transaction_journal'])) {
- $errors->add('transaction_journal', 'No valid transaction journal present');
- }
-
- return $errors;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Returns an object with id $id.
- *
- * @param int $objectId
- *
- * @return \Eloquent
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function find($objectId)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
- *
- * @param $what
- *
- * @return \AccountType|null
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function findByWhat($what)
- {
- throw new NotImplementedException;
- }
-
- /**
- * Returns all objects.
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function get()
- {
- throw new NotImplementedException;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @param array $ids
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function getByIds(array $ids)
- {
- throw new NotImplementedException;
- }
-}
diff --git a/app/lib/FireflyIII/Database/TransactionCurrency/TransactionCurrency.php b/app/lib/FireflyIII/Database/TransactionCurrency/TransactionCurrency.php
deleted file mode 100644
index 3eeb6eb5f9..0000000000
--- a/app/lib/FireflyIII/Database/TransactionCurrency/TransactionCurrency.php
+++ /dev/null
@@ -1,154 +0,0 @@
-delete();
- }
-
- /**
- * @param array $data
- *
- * @return Eloquent
- */
- public function store(array $data)
- {
- $currency = new \TransactionCurrency($data);
- $currency->save();
-
- return $currency;
- }
-
- /**
- * @param Eloquent $model
- * @param array $data
- *
- * @return bool
- */
- public function update(Eloquent $model, array $data)
- {
- $model->symbol = $data['symbol'];
- $model->code = $data['code'];
- $model->name = $data['name'];
- $model->save();
-
- return true;
- }
-
- /**
- * Validates an array. Returns an array containing MessageBags
- * errors/warnings/successes.
- *
- * @param array $model
- *
- * @return array
- */
- public function validate(array $model)
- {
- $warnings = new MessageBag;
- $successes = new MessageBag;
- \Log::debug('Now in TransactionCurrency::validate()');
-
- $currency = new \TransactionCurrency($model);
- $currency->isValid();
- $errors = $currency->getErrors();
-
- \Log::debug('Data: ' . json_encode($model));
- \Log::debug('Error-content: ' . json_encode($errors->all()));
- \Log::debug('Error count is: ' . $errors->count());
-
- $fields = ['name', 'code', 'symbol'];
- foreach ($fields as $field) {
- if (!$errors->has($field)) {
- $successes->add($field, 'OK');
- }
- }
-
- return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Returns an object with id $id.
- *
- * @param int $objectId
- *
- * @return \Eloquent
- */
- public function find($objectId)
- {
- return \TransactionCurrency::find($objectId);
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
- *
- * @param $what
- * @throws NotImplementedException
- * @codeCoverageIgnore
- *
- * @return \AccountType|null
- */
- public function findByWhat($what)
- {
- throw new NotImplementedException;
- }
-
- /**
- * Returns all objects.
- *
- * @return Collection
- */
- public function get()
- {
- return \TransactionCurrency::orderBy('code', 'ASC')->get();
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @param array $objectIds
- * @throws NotImplementedException
- * @codeCoverageIgnore
- *
- * @return Collection
- */
- public function getByIds(array $objectIds)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @param string $code
- *
- * @return \TransactionCurrency|null
- */
- public function findByCode($code)
- {
- return \TransactionCurrency::whereCode($code)->first();
- }
-}
diff --git a/app/lib/FireflyIII/Database/TransactionCurrency/TransactionCurrencyInterface.php b/app/lib/FireflyIII/Database/TransactionCurrency/TransactionCurrencyInterface.php
deleted file mode 100644
index bd2c0a159d..0000000000
--- a/app/lib/FireflyIII/Database/TransactionCurrency/TransactionCurrencyInterface.php
+++ /dev/null
@@ -1,20 +0,0 @@
-setUser(\Auth::user());
- }
-
- /**
- * @param Eloquent $model
- *
- * @return bool
- */
- public function destroy(Eloquent $model)
- {
- /*
- * Trigger deletion.
- */
- \Event::fire('transactionJournal.destroy', [$model]); // new and used.
- /*
- * Since this event will also destroy both transactions, trigger on those as
- * well because we might want to update some caches and what-not.
- */
- /** @var Transaction $transaction */
- foreach ($model->transactions as $transaction) {
- \Event::fire('transaction.destroy', [$transaction]);
- }
-
- $model->delete();
-
- return true;
- }
-
- /**
- * @param array $data
- *
- * @return \Eloquent
- * @throws FireflyException
- */
- public function store(array $data)
- {
- $journal = new \TransactionJournal(
- [
- 'transaction_type_id' => $data['transaction_type_id'],
- 'transaction_currency_id' => $data['transaction_currency_id'],
- 'user_id' => $this->getUser()->id,
- 'description' => $data['description'],
- 'date' => $data['date'], 'completed' => 0]
- );
- $journal->save();
-
- list($fromAccount, $toAccount) = $this->storeAccounts($data);
-
-
- $this->storeTransaction(
- ['account_id' => $fromAccount->id, 'account' => $fromAccount, 'transaction_journal' => $journal, 'transaction_journal_id' => $journal->id,
- 'amount' => floatval($data['amount'] * -1)]
- );
- $this->storeTransaction(
- ['account_id' => $toAccount->id, 'account' => $toAccount, 'transaction_journal' => $journal, 'transaction_journal_id' => $journal->id,
- 'amount' => floatval($data['amount'])]
- );
- $this->storeBudget($data, $journal);
- $this->storeCategory($data, $journal);
-
- $journal->completed = 1;
- $journal->save();
-
- return $journal;
- }
-
- /**
- * @param Eloquent $model
- * @param array $data
- *
- * @return bool
- * @throws FireflyException
- */
- public function update(Eloquent $model, array $data)
- {
- $journalType = $this->getJournalType($data['what']);
- $currency = $this->getJournalCurrencyById($data['transaction_currency_id']);
- $model->description = $data['description'];
- $model->date = $data['date'];
-
- $model->transactionType()->associate($journalType);
- $model->transactionCurrency()->associate($currency);
- $model->user()->associate($this->getUser());
- $model->save();
-
- list($fromAccount, $toAccount) = $this->storeAccounts($data);
-
- /** @noinspection PhpParamsInspection */
- $this->storeBudget($data, $model);
- $this->storeCategory($data, $model);
-
- $amount = floatval($data['amount']);
- /** @var \Transaction $transaction */
- foreach ($model->transactions()->get() as $transaction) {
- if (floatval($transaction->amount) > 0) {
- // the TO transaction.
- $transaction->account()->associate($toAccount);
- $transaction->amount = $amount;
- } else {
- $transaction->account()->associate($fromAccount);
- $transaction->amount = $amount * -1;
- }
- if (!$transaction->isValid()) {
- throw new FireflyException('Could not validate transaction while saving.');
- }
- $transaction->save();
- }
-
- return true;
- }
-
- /**
- * Validates an array. Returns an array containing MessageBags
- * errors/warnings/successes.
- *
- * ignored because this method will be gone soon.
- *
- * @param array $model
- *
- * @return array
- * @throws FireflyException
- */
- public function validate(array $model)
- {
-
- $warnings = new MessageBag;
- $successes = new MessageBag;
-
- $journal = new \TransactionJournal($model);
- $journal->isValid();
- $errors = $journal->getErrors();
-
- if (!isset($model['what']) && !isset($model['transaction_type_id'])) {
- $errors->add('description', 'Internal error: need to know type of transaction!');
- }
- if (strlen($model['description']) == 0) {
- $errors->add('description', 'The description field is required.');
- }
- $errors = $errors->merge($this->_validateAmount($model));
- $errors = $errors->merge($this->_validateBudget($model));
- $errors = $errors->merge($this->_validateAccount($model));
-
- $list = ['date', 'description', 'amount', 'budget_id', 'from', 'to', 'account_from_id', 'account_to_id', 'category', 'account_id', 'expense_account',
- 'revenue_account'];
- foreach ($list as $entry) {
- if (!$errors->has($entry)) {
- $successes->add($entry, 'OK');
- }
- }
-
- return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];
-
-
- }
-
- /**
- * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
- *
- * @param array $data
- *
- * @return array
- * @throws FireflyException
- */
- public function storeAccounts(array $data)
- {
- /** @var \FireflyIII\Database\Account\Account $accountRepository */
- $accountRepository = \App::make('FireflyIII\Database\Account\Account');
- $fromAccount = null;
- $toAccount = null;
-
- switch ($data['what']) {
- case 'withdrawal':
- $fromAccount = $accountRepository->find($data['account_id']);
- $toAccount = $accountRepository->firstExpenseAccountOrCreate($data['expense_account']);
- break;
- case 'opening':
- $fromAccount = $data['from'];
- $toAccount = $data['to'];
- break;
- case 'deposit':
- $fromAccount = $accountRepository->firstRevenueAccountOrCreate($data['revenue_account']);
- $toAccount = $accountRepository->find($data['account_id']);
- break;
- case 'transfer':
- $fromAccount = $accountRepository->find($data['account_from_id']);
- $toAccount = $accountRepository->find($data['account_to_id']);
- break;
-
- default:
- throw new FireflyException('Cannot save transaction journal with accounts based on $what "' . $data['what'] . '".');
- break;
- }
-
- return [$fromAccount, $toAccount];
- }
-
- /**
- * @param array $data
- *
- * @return \Eloquent
- * @throws FireflyException
- */
- public function storeTransaction($data)
- {
-
- /** @var \FireflyIII\Database\Transaction\Transaction $repository */
- $repository = \App::make('FireflyIII\Database\Transaction\Transaction');
-
- $errors = $repository->validate($data);
- if ($errors->count() > 0) {
- \Log::error('Could not store transaction: ' . $errors->toJson());
- throw new FireflyException('store() transaction failed, but it should not!');
- }
-
- return $repository->store($data);
- }
-
- /**
- * @param array $data
- * @param \TransactionJournal|\Eloquent $journal
- */
- public function storeBudget($data, \TransactionJournal $journal)
- {
- if (isset($data['budget_id']) && intval($data['budget_id']) > 0) {
- /** @var \FireflyIII\Database\Budget\Budget $budgetRepository */
- $budgetRepository = \App::make('FireflyIII\Database\Budget\Budget');
- $budget = $budgetRepository->find(intval($data['budget_id']));
- if ($budget) {
- $journal->budgets()->sync([$budget->id]);
- }
- }
- }
-
- /**
- * @param array $data
- * @param \TransactionJournal|\Eloquent $journal
- */
- public function storeCategory(array $data, \TransactionJournal $journal)
- {
- if (isset($data['category']) && strlen($data['category']) > 0) {
- /** @var \FireflyIII\Database\Category\Category $categoryRepository */
- $categoryRepository = \App::make('FireflyIII\Database\Category\Category');
- $category = $categoryRepository->firstOrCreate($data['category']);
- if ($category) {
- $journal->categories()->sync([$category->id]);
- }
-
- return;
- }
- $journal->categories()->sync([]);
-
- return;
- }
-
- /**
- * @param $type
- *
- * @return \TransactionType|null
- * @throws FireflyException
- */
- public function getJournalType($type)
- {
- /** @var \FireflyIII\Database\TransactionType\TransactionType $typeRepository */
- $typeRepository = \App::make('FireflyIII\Database\TransactionType\TransactionType');
-
- return $typeRepository->findByWhat($type);
- }
-
- /**
- * @param int $currencyId
- *
- * @return null|\TransactionCurrency
- */
- public function getJournalCurrencyById($currencyId)
- {
- /** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencyRepository */
- $currencyRepository = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
-
- return $currencyRepository->find($currencyId);
- }
-
- /**
- * @SuppressWarnings("CamelCase") // I'm fine with this.
- *
- * @param array $model
- *
- * @return MessageBag
- */
- protected function _validateAmount(array $model)
- {
- $errors = new MessageBag;
- if (isset($model['amount']) && floatval($model['amount']) < 0.01) {
- $errors->add('amount', 'Amount must be > 0.01');
- } else {
- if (!isset($model['amount'])) {
- $errors->add('amount', 'Amount must be set!');
- }
- }
-
- return $errors;
- }
-
- /**
- * @SuppressWarnings("CamelCase") // I'm fine with this.
- *
- * @param array $model
- *
- * @return MessageBag
- */
- protected function _validateBudget(array $model)
- {
- /*
- * Budget (is not in rules)
- */
- $errors = new MessageBag;
- if (isset($model['budget_id']) && !ctype_digit($model['budget_id'])) {
- $errors->add('budget_id', 'Invalid budget');
- }
-
- return $errors;
- }
-
- /**
- * @SuppressWarnings("CamelCase") // I'm fine with this.
- *
- * @param array $model
- *
- * @return MessageBag
- * @throws FireflyException
- */
- protected function _validateAccount(array $model)
- {
- $errors = new MessageBag;
- switch (true) {
- // this combination is often seen in withdrawals.
- case (isset($model['account_id']) && isset($model['expense_account'])):
- if (intval($model['account_id']) < 1) {
- $errors->add('account_id', 'Invalid account.');
- }
- break;
- // often seen in deposits
- case (isset($model['account_id']) && isset($model['revenue_account'])):
- if (intval($model['account_id']) < 1) {
- $errors->add('account_id', 'Invalid account.');
- }
- break;
- // often seen in transfers
- case (isset($model['account_from_id']) && isset($model['account_to_id'])):
- if (intval($model['account_from_id']) < 1 || intval($model['account_from_id']) < 1) {
- $errors->add('account_from_id', 'Invalid account selected.');
- $errors->add('account_to_id', 'Invalid account selected.');
-
- } else {
- if (intval($model['account_from_id']) == intval($model['account_to_id'])) {
- $errors->add('account_to_id', 'Cannot be the same as "from" account.');
- $errors->add('account_from_id', 'Cannot be the same as "to" account.');
- }
- }
- break;
- case (isset($model['from']) && isset($model['to'])):
- break;
- default:
- throw new FireflyException('Cannot validate accounts for transaction journal.');
- break;
- }
-
- return $errors;
- }
-
- /**
- * Returns an object with id $id.
- *
- * @param int $objectId
- *
- * @codeCoverageIgnore
- * @throws NotImplementedException
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @return \Eloquent
- */
- public function find($objectId)
- {
- throw new NotImplementedException;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
- *
- * @param $what
- *
- * @return \AccountType|null
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function findByWhat($what)
- {
- throw new NotImplementedException;
- }
-
- /**
- * Returns all objects.
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function get()
- {
- throw new NotImplementedException;
- }
-
- /**
- * @param array $ids
- *
- * @return Collection
- */
- public function getByIds(array $ids)
- {
- return $this->getUser()->transactionjournals()->with('transactions')->whereIn('id', $ids)->orderBy('date', 'ASC')->get();
- }
-
- /**
- * @return Carbon
- */
- public function firstDate()
- {
- $journal = $this->first();
- if ($journal) {
- return $journal->date;
- }
-
- return Carbon::now();
- }
-
- /**
- * @return TransactionJournal
- */
- public function first()
- {
- return $this->getUser()->transactionjournals()->orderBy('date', 'ASC')->first();
- }
-
- /**
- * @param Carbon $date
- *
- * @return float
- */
- public function getSumOfExpensesByMonth(Carbon $date)
- {
- /** @var \FireflyIII\Report\ReportInterface $reportRepository */
- $reportRepository = \App::make('FireflyIII\Report\ReportInterface');
-
- $set = $reportRepository->getExpenseGroupedForMonth($date, 200);
- $sum = 0;
- foreach ($set as $entry) {
- $sum += $entry['amount'];
- }
-
-
- return $sum;
- }
-
- /**
- * @param Carbon $date
- *
- * @return float
- */
- public function getSumOfIncomesByMonth(Carbon $date)
- {
- /** @var \FireflyIII\Report\ReportInterface $reportRepository */
- $reportRepository = \App::make('FireflyIII\Report\ReportInterface');
-
- $incomes = $reportRepository->getIncomeForMonth($date);
- $totalIn = 0;
- /** @var \TransactionJournal $entry */
- foreach ($incomes as $entry) {
- $totalIn += $entry->getAmount();
- }
-
- return $totalIn;
- }
-
- /**
- * @param int $limit
- *
- * @return \Illuminate\Pagination\Paginator
- */
- public function getDepositsPaginated($limit = 50)
- {
- $offset = intval(\Input::get('page')) > 0 ? (intval(\Input::get('page')) - 1) * $limit : 0;
-
- $set = $this->getUser()->transactionJournals()->transactionTypes(['Deposit'])->withRelevantData()->take($limit)->offset($offset)->orderBy(
- 'date', 'DESC'
- )->get(['transaction_journals.*']);
- $count = $this->getUser()->transactionJournals()->transactionTypes(['Deposit'])->count();
- $items = [];
- foreach ($set as $entry) {
- $items[] = $entry;
- }
-
- return \Paginator::make($items, $count, $limit);
- }
-
- /**
- * @param \Account $account
- * @param Carbon $start
- * @param Carbon $end
- * @param int $count
- *
- * @return Collection
- */
- public function getInDateRangeAccount(\Account $account, Carbon $start, Carbon $end, $count = 20)
- {
-
- $accountID = $account->id;
- $query = $this->_user->transactionjournals()->with(['transactions', 'transactioncurrency', 'transactiontype'])->leftJoin(
- 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
- )->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')->where('accounts.id', $accountID)->where(
- 'date', '>=', $start->format('Y-m-d')
- )->where('date', '<=', $end->format('Y-m-d'))->orderBy('transaction_journals.date', 'DESC')->orderBy('transaction_journals.id', 'DESC')->take(
- $count
- )->get(['transaction_journals.*']);
-
- return $query;
- }
-
- /**
- * @param $currency
- *
- * @return null|\TransactionCurrency
- */
- public function getJournalCurrency($currency)
- {
- /** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencyRepository */
- $currencyRepository = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
-
- return $currencyRepository->findByCode($currency);
- }
-
- /**
- * @param int $limit
- *
- * @return \Illuminate\Pagination\Paginator
- */
- public function getTransfersPaginated($limit = 50)
- {
- $offset = intval(\Input::get('page')) > 0 ? (intval(\Input::get('page')) - 1) * $limit : 0;
-
- $set = $this->getUser()->transactionJournals()->transactionTypes(['Transfer'])->withRelevantData()->take($limit)->offset($offset)->orderBy(
- 'date', 'DESC'
- )->get(['transaction_journals.*']);
- $count = $this->getUser()->transactionJournals()->transactionTypes(['Transfer'])->count();
- $items = [];
- foreach ($set as $entry) {
- $items[] = $entry;
- }
-
- return \Paginator::make($items, $count, $limit);
- }
-
- /**
- * @param int $limit
- *
- * @return \Illuminate\Pagination\Paginator
- */
- public function getWithdrawalsPaginated($limit = 50)
- {
- $offset = intval(\Input::get('page')) > 0 ? (intval(\Input::get('page')) - 1) * $limit : 0;
-
- $set = $this->getUser()->transactionJournals()->transactionTypes(['Withdrawal'])->withRelevantData()->take($limit)->offset($offset)->orderBy(
- 'date', 'DESC'
- )->get(['transaction_journals.*']);
- $count = $this->getUser()->transactionJournals()->transactionTypes(['Withdrawal'])->count();
- $items = [];
- foreach ($set as $entry) {
- $items[] = $entry;
- }
-
- return \Paginator::make($items, $count, $limit);
- }
-}
diff --git a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournalInterface.php b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournalInterface.php
deleted file mode 100644
index 264aeb5200..0000000000
--- a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournalInterface.php
+++ /dev/null
@@ -1,36 +0,0 @@
- 'Opening balance',
- 'transfer' => 'Transfer',
- 'withdrawal' => 'Withdrawal',
- 'deposit' => 'Deposit',
- ];
- if (!isset($translation[$what])) {
- throw new FireflyException('Cannot find transaction type described as "' . e($what) . '".');
- }
-
- return \TransactionType::whereType($translation[$what])->first();
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * Returns all objects.
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function get()
- {
- throw new NotImplementedException;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @param array $ids
- *
- * @return Collection
- * @throws NotImplementedException
- * @codeCoverageIgnore
- */
- public function getByIds(array $ids)
- {
- throw new NotImplementedException;
- }
-}
diff --git a/app/lib/FireflyIII/Database/User/User.php b/app/lib/FireflyIII/Database/User/User.php
deleted file mode 100644
index f60bfc3037..0000000000
--- a/app/lib/FireflyIII/Database/User/User.php
+++ /dev/null
@@ -1,73 +0,0 @@
-first();
- }
-
- /**
- * @param $reset
- *
- * @return null|User
- */
- public function findByReset($reset)
- {
- return \User::where('reset', $reset)->first();
- }
-
- /**
- * @param array $data
- *
- * @return bool|\User
- */
- public function register(array $data)
- {
- $user = new \User;
- $user->email = isset($data['email']) ? $data['email'] : null;
- $user->reset = \Str::random(32);
- $user->password = \Hash::make(\Str::random(12));
-
- // validate user:
- if (!$user->isValid()) {
- \Log::error('Invalid user with data: ' . isset($data['email']) ? $data['email'] : '(no email!)');
- \Session::flash('error', 'Input invalid, please try again: ' . $user->getErrors()->first());
-
- return false;
- }
- $user->save();
-
- return $user;
-
- }
-
- /**
- * @param \User $user
- * @param $password
- *
- * @return bool
- */
- public function updatePassword(\User $user, $password)
- {
- $user->password = $password;
- $user->forceSave();
-
- return true;
- }
-
-}
diff --git a/app/lib/FireflyIII/Event/Account.php b/app/lib/FireflyIII/Event/Account.php
deleted file mode 100644
index 6890d5b1e1..0000000000
--- a/app/lib/FireflyIII/Event/Account.php
+++ /dev/null
@@ -1,53 +0,0 @@
-id . '.latestBalance');
- \Cache::forget('account.' . $account->id . '.lastActivityDate');
- }
-
- /**
- * @param \Account $account
- */
- public function store(\Account $account)
- {
-
- \Cache::forget('account.' . $account->id . '.latestBalance');
- \Cache::forget('account.' . $account->id . '.lastActivityDate');
- }
-
- /**
- * @param Dispatcher $events
- */
- public function subscribe(Dispatcher $events)
- {
- // triggers when others are updated.
- $events->listen('account.store', 'FireflyIII\Event\Account@store');
- $events->listen('account.update', 'FireflyIII\Event\Account@update');
- $events->listen('account.destroy', 'FireflyIII\Event\Account@destroy');
- }
-
- /**
- * @param \Account $account
- */
- public function update(\Account $account)
- {
- \Cache::forget('account.' . $account->id . '.latestBalance');
- \Cache::forget('account.' . $account->id . '.lastActivityDate');
- }
-}
diff --git a/app/lib/FireflyIII/Event/Budget.php b/app/lib/FireflyIII/Event/Budget.php
deleted file mode 100644
index 940f87d887..0000000000
--- a/app/lib/FireflyIII/Event/Budget.php
+++ /dev/null
@@ -1,67 +0,0 @@
-startdate, $budgetLimit->repeat_freq, 0);
- $end->subDay();
-
- $set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->get();
- /*
- * Create new LimitRepetition:
- */
- if ($set->count() == 0) {
-
- $repetition = new \LimitRepetition();
- $repetition->startdate = $budgetLimit->startdate;
- $repetition->enddate = $end;
- $repetition->amount = $budgetLimit->amount;
- $repetition->budgetLimit()->associate($budgetLimit);
-
- try {
- $repetition->save();
- } catch (QueryException $e) {
- \Log::error('Trying to save new LimitRepetition failed!');
- \Log::error($e->getMessage());
- }
- } else {
- if ($set->count() == 1) {
- /*
- * Update existing one.
- */
- $repetition = $set->first();
- $repetition->amount = $budgetLimit->amount;
- $repetition->save();
-
- }
- }
-
- }
-
- /**
- * @param Dispatcher $events
- */
- public function subscribe(Dispatcher $events)
- {
- $events->listen('limits.store', 'FireflyIII\Event\Budget@storeOrUpdateLimit');
- $events->listen('limits.update', 'FireflyIII\Event\Budget@storeOrUpdateLimit');
-
- }
-}
diff --git a/app/lib/FireflyIII/Event/Event.php b/app/lib/FireflyIII/Event/Event.php
deleted file mode 100644
index 34980e5a8d..0000000000
--- a/app/lib/FireflyIII/Event/Event.php
+++ /dev/null
@@ -1,45 +0,0 @@
-piggyBanks()->get();
-
- // get reminders for each
- /** @var \PiggyBank $piggyBank */
- foreach ($piggies as $piggyBank) {
- $reminders = $piggyBank->reminders()->get();
- /** @var \Reminder $reminder */
- foreach ($reminders as $reminder) {
- $reminder->delete();
- }
- }
- }
-
-
- /**
- * @param Dispatcher $events
- */
- public function subscribe(Dispatcher $events)
- {
- // triggers when others are updated.
- $events->listen('account.destroy', 'FireflyIII\Event\Event@deleteAccount');
- }
-}
diff --git a/app/lib/FireflyIII/Event/Piggybank.php b/app/lib/FireflyIII/Event/Piggybank.php
deleted file mode 100644
index 9273f5c600..0000000000
--- a/app/lib/FireflyIII/Event/Piggybank.php
+++ /dev/null
@@ -1,293 +0,0 @@
- 0) {
- $event = new \PiggyBankEvent;
- $event->piggyBank()->associate($piggyBank);
- $event->amount = floatval($amount);
- $event->date = new Carbon;
- if (!$event->isValid()) {
- \Log::error($event->getErrors());
- \App::abort(500);
- }
- $event->save();
- }
- }
-
- /**
- * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
- *
- * @param \TransactionJournal $journal
- *
- * @throws \FireflyIII\Exception\FireflyException
- * @throws \FireflyIII\Exception\NotImplementedException
- */
- public function destroyTransfer(\TransactionJournal $journal)
- {
- if ($journal->piggyBankEvents()->count() > 0) {
-
- /** @var \FireflyIII\Database\PiggyBank\PiggyBank $repository */
- $repository = \App::make('FireflyIII\Database\PiggyBank\PiggyBank');
-
- /** @var \PiggyBank $piggyBank */
- $piggyBank = $journal->piggyBankEvents()->first()->piggyBank()->first();
-
- /** @var \PiggyBankRepetition $repetition */
- $repetition = $repository->findRepetitionByDate($piggyBank, $journal->date);
-
- $relevantTransaction = null;
- /** @var \Transaction $transaction */
- foreach ($journal->transactions as $transaction) {
- if ($transaction->account_id == $piggyBank->account_id) {
- $relevantTransaction = $transaction;
- }
- }
- if (is_null($relevantTransaction)) {
- return;
- }
-
- $repetition->currentamount += floatval($relevantTransaction->amount * -1);
- $repetition->save();
-
-
- $event = new \PiggyBankEvent;
- $event->piggyBank()->associate($piggyBank);
- $event->amount = floatval($relevantTransaction->amount * -1);
- $event->date = new Carbon;
- $event->save();
- }
- }
-
- /**
- * @param \PiggyBank $piggyBank
- * @param float $amount
- */
- public function removeMoney(\PiggyBank $piggyBank, $amount = 0.0)
- {
- $amount = $amount * -1;
- if ($amount < 0) {
- $event = new \PiggyBankEvent;
- $event->piggyBank()->associate($piggyBank);
- $event->amount = floatval($amount);
- $event->date = new Carbon;
- $event->save();
- }
- }
-
- /**
- * @param \PiggyBank $piggyBank
- */
- public function storePiggyBank(\PiggyBank $piggyBank)
- {
- $repetition = new \PiggyBankRepetition;
- $repetition->piggyBank()->associate($piggyBank);
- $repetition->startdate = $piggyBank->startdate;
- $repetition->targetdate = $piggyBank->targetdate;
- $repetition->currentamount = 0;
- $repetition->save();
- }
-
- /*
- *
- */
-
- /**
- * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
- *
- * @param \TransactionJournal $journal
- * @param int $piggyBankId
- */
- public function storeTransfer(\TransactionJournal $journal, $piggyBankId = 0)
- {
- if (intval($piggyBankId) == 0) {
- return;
- }
- /** @var \FireflyIII\Database\PiggyBank\PiggyBank $repository */
- $repository = \App::make('FireflyIII\Database\PiggyBank\PiggyBank');
-
- /** @var \PiggyBank $piggyBank */
- $piggyBank = $repository->find($piggyBankId);
-
- if ($journal->transactions()->where('account_id', $piggyBank->account_id)->count() == 0) {
- return;
- }
- /** @var \PiggyBankRepetition $repetition */
- $repetition = $repository->findRepetitionByDate($piggyBank, $journal->date);
- $amount = floatval($piggyBank->targetamount);
- $leftToSave = $amount - floatval($repetition->currentamount);
- $transaction = $journal->transactions()->where('account_id', $piggyBank->account_id)->first();
- // must be in range of journal. Continue determines if we can move it.
- if (floatval($transaction->amount < 0)) {
- // amount removed from account, so removed from piggy bank.
- $continue = ($transaction->amount * -1 <= floatval($repetition->currentamount));
- } else {
- // amount added
- $continue = $transaction->amount <= $leftToSave;
- }
- if ($continue) {
- \Log::debug('Update repetition.');
- $repetition->currentamount += floatval($transaction->amount);
- $repetition->save();
- $event = new \PiggyBankEvent;
- $event->piggyBank()->associate($piggyBank);
- $event->transactionjournal()->associate($journal);
- $event->amount = floatval($transaction->amount);
- $event->date = new Carbon;
- $event->save();
- }
- }
-
- /**
- * @param Dispatcher $events
- */
- public function subscribe(Dispatcher $events)
- {
- // triggers on piggy bank events:
- $events->listen('piggy_bank.addMoney', 'FireflyIII\Event\PiggyBank@addMoney');
- $events->listen('piggy_bank.removeMoney', 'FireflyIII\Event\PiggyBank@removeMoney');
- $events->listen('piggy_bank.store', 'FireflyIII\Event\PiggyBank@storePiggyBank');
- $events->listen('piggy_bank.update', 'FireflyIII\Event\PiggyBank@updatePiggyBank');
-
- \App::before(
- function () {
- $this->validateRepeatedExpenses();
- }
- );
-
- // triggers when others are updated.
- $events->listen('transactionJournal.store', 'FireflyIII\Event\PiggyBank@storeTransfer');
- $events->listen('transactionJournal.update', 'FireflyIII\Event\PiggyBank@updateTransfer');
- $events->listen('transactionJournal.destroy', 'FireflyIII\Event\PiggyBank@destroyTransfer');
- }
-
- /**
- * @SuppressWarnings("CyclomaticComplexity") // It's 6. More than 5 but alright.
- *
- * Validates the presence of repetitions for all repeated expenses!
- */
- public function validateRepeatedExpenses()
- {
- if (!\Auth::check()) {
- return;
- }
- /** @var \FireflyIII\Database\PiggyBank\RepeatedExpense $repository */
- $repository = \App::make('FireflyIII\Database\PiggyBank\RepeatedExpense');
- $list = $repository->get();
- $today = Carbon::now();
- /** @var \PiggyBank $entry */
- foreach ($list as $entry) {
- $count = $entry->piggyBankrepetitions()->starts($entry->startdate)->targets($entry->targetdate)->count();
- if ($count == 0) {
- $repetition = new \PiggyBankRepetition;
- $repetition->piggyBank()->associate($entry);
- $repetition->startdate = $entry->startdate;
- $repetition->targetdate = $entry->targetdate;
- $repetition->currentamount = 0;
- $repetition->save();
- }
- $currentTarget = clone $entry->startdate;
- $currentStart = null;
- while ($currentTarget < $today) {
- $currentStart = \DateKit::subtractPeriod($currentTarget, $entry->rep_length, 0);
- $currentTarget = \DateKit::addPeriod($currentTarget, $entry->rep_length, 0);
- $count = $entry->piggyBankRepetitions()->starts($currentStart)->targets($currentTarget)->count();
- if ($count == 0) {
- $repetition = new \PiggyBankRepetition;
- $repetition->piggyBank()->associate($entry);
- $repetition->startdate = $currentStart;
- $repetition->targetdate = $currentTarget;
- $repetition->currentamount = 0;
- $repetition->save();
- }
-
- }
- }
- }
-
- /**
- * @param \PiggyBank $piggyBank
- */
- public function updatePiggyBank(\PiggyBank $piggyBank)
- {
- // get the repetition:
- $repetition = $piggyBank->currentRelevantRep();
- $repetition->startdate = $piggyBank->startdate;
- $repetition->targetdate = $piggyBank->targetdate;
- $repetition->save();
- }
-
- /**
- * @param \TransactionJournal $journal
- *
- * @throws \FireflyIII\Exception\FireflyException
- * @throws \FireflyIII\Exception\NotImplementedException
- */
- public function updateTransfer(\TransactionJournal $journal)
- {
-
- if ($journal->piggyBankEvents()->count() > 0) {
-
- $event = $journal->piggyBankEvents()->orderBy('date', 'DESC')->orderBy('id', 'DESC')->first();
- $eventSum = floatval($journal->piggyBankEvents()->orderBy('date', 'DESC')->orderBy('id', 'DESC')->sum('amount'));
-
- /** @var \FireflyIII\Database\PiggyBank\PiggyBank $repository */
- $repository = \App::make('FireflyIII\Database\PiggyBank\PiggyBank');
-
- /** @var \PiggyBank $piggyBank */
- $piggyBank = $journal->piggyBankEvents()->first()->piggyBank()->first();
-
- /** @var \PiggyBankRepetition $repetition */
- $repetition = $repository->findRepetitionByDate($piggyBank, $journal->date);
-
- $relevantTransaction = null;
- /** @var \Transaction $transaction */
- foreach ($journal->transactions as $transaction) {
- if ($transaction->account_id == $piggyBank->account_id) {
- $relevantTransaction = $transaction;
- }
- }
- if (is_null($relevantTransaction)) {
- return;
- }
-
- $diff = floatval($relevantTransaction->amount) - floatval($eventSum);
- /*
- * Create an event to remove /add the difference from the piggy
- */
- $repetition->currentamount += $diff;
- $repetition->save();
-
-
- $event = new \PiggyBankEvent;
- $event->piggyBank()->associate($piggyBank);
- $event->transactionJournal()->associate($journal);
- $event->amount = $diff;
- $event->date = new Carbon;
- if (!$event->isValid()) {
- \Log::error($event->getErrors());
- \App::abort(500);
- }
- $event->save();
- }
-
- }
-}
diff --git a/app/lib/FireflyIII/Event/Transaction.php b/app/lib/FireflyIII/Event/Transaction.php
deleted file mode 100644
index 9c96070cd0..0000000000
--- a/app/lib/FireflyIII/Event/Transaction.php
+++ /dev/null
@@ -1,55 +0,0 @@
-account_id . '.latestBalance');
- \Cache::forget('account.' . $transaction->account_id . '.lastActivityDate');
-
- // delete transaction:
- $transaction->delete();
- }
-
- /**
- * @param \Transaction $transaction
- */
- public function store(\Transaction $transaction)
- {
- \Cache::forget('account.' . $transaction->account_id . '.latestBalance');
- \Cache::forget('account.' . $transaction->account_id . '.lastActivityDate');
- }
-
- /**
- * @param Dispatcher $events
- */
- public function subscribe(Dispatcher $events)
- {
- // triggers when others are updated.
- $events->listen('transaction.store', 'FireflyIII\Event\Transaction@store');
- $events->listen('transaction.update', 'FireflyIII\Event\Transaction@update');
- $events->listen('transaction.destroy', 'FireflyIII\Event\Transaction@destroy');
- }
-
- /**
- * @param \Transaction $transaction
- */
- public function update(\Transaction $transaction)
- {
- \Cache::forget('account.' . $transaction->account_id . '.latestBalance');
- \Cache::forget('account.' . $transaction->account_id . '.lastActivityDate');
- }
-}
diff --git a/app/lib/FireflyIII/Event/TransactionJournal.php b/app/lib/FireflyIII/Event/TransactionJournal.php
deleted file mode 100644
index c7cabb911c..0000000000
--- a/app/lib/FireflyIII/Event/TransactionJournal.php
+++ /dev/null
@@ -1,57 +0,0 @@
-get();
-
-
- /** @var \Bill $entry */
- foreach ($set as $entry) {
- $repository->scan($entry, $journal);
- }
- }
-
- /**
- * @param Dispatcher $events
- */
- public function subscribe(Dispatcher $events)
- {
- // triggers when others are updated.
- $events->listen('transactionJournal.store', 'FireflyIII\Event\TransactionJournal@store');
- $events->listen('transactionJournal.update', 'FireflyIII\Event\TransactionJournal@update');
- }
-
- /**
- * @param \TransactionJournal $journal
- */
- public function update(\TransactionJournal $journal)
- {
- /** @var \FireflyIII\Database\Bill\Bill $repository */
- $repository = \App::make('FireflyIII\Database\Bill\Bill');
- $set = $repository->get();
- $journal->bill_id = null;
- $journal->save();
-
- /** @var \Bill $entry */
- foreach ($set as $entry) {
- $repository->scan($entry, $journal);
- }
- }
-}
diff --git a/app/lib/FireflyIII/Exception/FireflyException.php b/app/lib/FireflyIII/Exception/FireflyException.php
deleted file mode 100644
index a2d36d3b59..0000000000
--- a/app/lib/FireflyIII/Exception/FireflyException.php
+++ /dev/null
@@ -1,14 +0,0 @@
-app->validator->resolver(
- function ($translator, $data, $rules, $messages) {
- return new FireflyValidator($translator, $data, $rules, $messages);
- }
- );
- }
-
- /**
- * Return the services bla bla.
- *
- * @codeCoverageIgnore
- * @return array
- */
- public function provides()
- {
- // @codeCoverageIgnoreStart
- return ['reminders', 'filters', 'datekit', 'navigation'];
- // @codeCoverageIgnoreEnd
- }
-
- /**
- * Triggered automatically by Laravel
- */
- public function register()
- {
- $this->registerFacades();
- $this->registerInterfaces();
- $this->registerAliases();
-
-
- }
-
- public function registerFacades()
- {
- $this->app->bind(
- 'reminders', function () {
- return new Reminders;
- }
- );
- $this->app->bind(
- 'filter', function () {
- return new Filter;
- }
- );
- $this->app->bind(
- 'datekit', function () {
- return new Date;
- }
- );
- $this->app->bind(
- 'navigation', function () {
- return new Navigation;
- }
- );
- $this->app->bind(
- 'ffform', function () {
- return new Form;
- }
- );
- $this->app->bind(
- 'steam', function () {
- return new Steam;
- }
- );
- $this->app->bind(
- 'amount', function () {
- return new Amount;
- }
- );
- }
-
- public function registerInterfaces()
- {
- // preferences
- $this->app->bind('FireflyIII\Shared\Preferences\PreferencesInterface', 'FireflyIII\Shared\Preferences\Preferences');
-
- // registration and user mail
- $this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');
-
- // reports
- $this->app->bind('FireflyIII\Report\ReportInterface', 'FireflyIII\Report\Report');
- $this->app->bind('FireflyIII\Report\ReportQueryInterface', 'FireflyIII\Report\ReportQuery');
- $this->app->bind('FireflyIII\Report\ReportHelperInterface', 'FireflyIII\Report\ReportHelper');
-
- $this->app->bind('FireflyIII\Helper\Related\RelatedInterface', 'FireflyIII\Helper\Related\Related');
-
- $this->app->bind('FireflyIII\Helper\TransactionJournal\HelperInterface', 'FireflyIII\Helper\TransactionJournal\Helper');
-
- // chart
- $this->app->bind('FireflyIII\Chart\ChartInterface', 'FireflyIII\Chart\Chart');
- }
-
- public function registerAliases()
- {
- // Shortcut so developers don't need to add an Alias in app/config/app.php
- $this->app->booting(
- function () {
- $loader = AliasLoader::getInstance();
- $loader->alias('Reminders', 'FireflyIII\Shared\Facade\Reminders');
- $loader->alias('Filter', 'FireflyIII\Shared\Facade\Filter');
- $loader->alias('DateKit', 'FireflyIII\Shared\Facade\DateKit');
- $loader->alias('Navigation', 'FireflyIII\Shared\Facade\Navigation');
- $loader->alias('FFForm', 'FireflyIII\Shared\Facade\FFForm');
- $loader->alias('Steam', 'FireflyIII\Shared\Facade\Steam');
- $loader->alias('Amount', 'FireflyIII\Shared\Facade\Amount');
- }
- );
- }
-
-}
diff --git a/app/lib/FireflyIII/Form/Form.php b/app/lib/FireflyIII/Form/Form.php
deleted file mode 100644
index 0396a0a33d..0000000000
--- a/app/lib/FireflyIII/Form/Form.php
+++ /dev/null
@@ -1,290 +0,0 @@
-get();
- $html = \View::make('form.amount', compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
-
- return $html;
-
- }
-
- /**
- * @param $name
- * @param $options
- *
- * @return string
- */
- public static function label($name, $options)
- {
- if (isset($options['label'])) {
- return $options['label'];
- }
- $labels = ['amount_min' => 'Amount (min)', 'amount_max' => 'Amount (max)', 'match' => 'Matches on', 'repeat_freq' => 'Repetition',
- 'account_from_id' => 'Account from', 'account_to_id' => 'Account to', 'account_id' => 'Asset account', 'budget_id' => 'Budget'
- , 'piggy_bank_id' => 'Piggy bank'];
-
-
- return isset($labels[$name]) ? $labels[$name] : str_replace('_', ' ', ucfirst($name));
-
- }
-
- /**
- * @param $name
- * @param $label
- * @param array $options
- *
- * @return array
- */
- public static function expandOptionArray($name, $label, array $options)
- {
- $options['class'] = 'form-control';
- $options['id'] = 'ffInput_' . $name;
- $options['autocomplete'] = 'off';
- $options['placeholder'] = ucfirst($label);
-
- return $options;
- }
-
- /**
- * @param $name
- *
- * @return string
- */
- public static function getHolderClasses($name)
- {
- /*
- * Get errors, warnings and successes from session:
- */
- /** @var MessageBag $errors */
- $errors = \Session::get('errors');
-
- /** @var MessageBag $successes */
- $successes = \Session::get('successes');
-
- switch (true) {
- case (!is_null($errors) && $errors->has($name)):
- $classes = 'form-group has-error has-feedback';
- break;
- case (!is_null($successes) && $successes->has($name)):
- $classes = 'form-group has-success has-feedback';
- break;
- default:
- $classes = 'form-group';
- break;
- }
-
- return $classes;
- }
-
- /**
- * @param $name
- * @param $value
- *
- * @return mixed
- */
- public static function fillFieldValue($name, $value)
- {
- if (\Session::has('preFilled')) {
- $preFilled = \Session::get('preFilled');
- $value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
- }
- if (!is_null(\Input::old($name))) {
- $value = \Input::old($name);
- }
-
- return $value;
- }
-
- /**
- * @param $name
- * @param null $value
- * @param array $options
- *
- * @return string
- * @throws FireflyException
- */
- public static function ffBalance($name, $value = null, array $options = [])
- {
- $label = self::label($name, $options);
- $options = self::expandOptionArray($name, $label, $options);
- $classes = self::getHolderClasses($name);
- $value = self::fillFieldValue($name, $value);
- $options['step'] = 'any';
- $defaultCurrency = isset($options['currency']) ? $options['currency'] : \Amount::getDefaultCurrency();
- $currencies = \TransactionCurrency::orderBy('code', 'ASC')->get();
- $html = \View::make('form.balance', compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
-
- return $html;
- }
-
- /**
- * @param $name
- * @param int $value
- * @param null $checked
- * @param array $options
- *
- * @return string
- * @throws FireflyException
- */
- public static function ffCheckbox($name, $value = 1, $checked = null, $options = [])
- {
- $options['checked'] = $checked === true ? true : null;
- $label = self::label($name, $options);
- $options = self::expandOptionArray($name, $label, $options);
- $classes = self::getHolderClasses($name);
- $value = self::fillFieldValue($name, $value);
-
- unset($options['placeholder'], $options['autocomplete'], $options['class']);
-
- $html = \View::make('form.checkbox', compact('classes', 'name', 'label', 'value', 'options'))->render();
-
- return $html;
- }
-
- /**
- * @param $name
- * @param null $value
- * @param array $options
- *
- * @return string
- * @throws FireflyException
- */
- public static function ffDate($name, $value = null, array $options = [])
- {
- $label = self::label($name, $options);
- $options = self::expandOptionArray($name, $label, $options);
- $classes = self::getHolderClasses($name);
- $value = self::fillFieldValue($name, $value);
- $html = \View::make('form.date', compact('classes', 'name', 'label', 'value', 'options'))->render();
-
- return $html;
- }
-
- /**
- * @param $name
- * @param null $value
- * @param array $options
- *
- * @return string
- * @throws FireflyException
- */
- public static function ffInteger($name, $value = null, array $options = [])
- {
- $label = self::label($name, $options);
- $options = self::expandOptionArray($name, $label, $options);
- $classes = self::getHolderClasses($name);
- $value = self::fillFieldValue($name, $value);
- $options['step'] = '1';
- $html = \View::make('form.integer', compact('classes', 'name', 'label', 'value', 'options'))->render();
-
- return $html;
-
- }
-
- /**
- * Return buttons for update/validate/return.
- *
- * @param $type
- * @param $name
- *
- * @return string
- * @throws FireflyException
- */
- public static function ffOptionsList($type, $name)
- {
- $previousValue = \Input::old('post_submit_action');
- $previousValue = is_null($previousValue) ? 'store' : $previousValue;
- $html = \View::make('form.options', compact('type', 'name', 'previousValue'))->render();
-
- return $html;
- }
-
- /**
- * @param $name
- * @param array $list
- * @param null $selected
- * @param array $options
- *
- * @return string
- */
- public static function ffSelect($name, array $list = [], $selected = null, array $options = [])
- {
- $label = self::label($name, $options);
- $options = self::expandOptionArray($name, $label, $options);
- $classes = self::getHolderClasses($name);
- $selected = self::fillFieldValue($name, $selected);
- $html = \View::make('form.select', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render();
-
- return $html;
- }
-
- /**
- * @param $name
- * @param null $value
- * @param array $options
- *
- * @return string
- * @throws FireflyException
- */
- public static function ffTags($name, $value = null, array $options = [])
- {
- $label = self::label($name, $options);
- $options = self::expandOptionArray($name, $label, $options);
- $classes = self::getHolderClasses($name);
- $value = self::fillFieldValue($name, $value);
- $options['data-role'] = 'tagsinput';
- $html = \View::make('form.tags', compact('classes', 'name', 'label', 'value', 'options'))->render();
-
- return $html;
- }
-
- /**
- * @param $name
- * @param null $value
- * @param array $options
- *
- * @return string
- * @throws FireflyException
- */
- public static function ffText($name, $value = null, array $options = [])
- {
- $label = self::label($name, $options);
- $options = self::expandOptionArray($name, $label, $options);
- $classes = self::getHolderClasses($name);
- $value = self::fillFieldValue($name, $value);
- $html = \View::make('form.text', compact('classes', 'name', 'label', 'value', 'options'))->render();
-
- return $html;
-
- }
-}
diff --git a/app/lib/FireflyIII/Helper/Related/Related.php b/app/lib/FireflyIII/Helper/Related/Related.php
deleted file mode 100644
index 06e1047858..0000000000
--- a/app/lib/FireflyIII/Helper/Related/Related.php
+++ /dev/null
@@ -1,88 +0,0 @@
-setUser(\Auth::user());
- }
-
- /**
- * @param array $objectIds
- *
- * @return Collection
- */
- public function getJournalsByIds(array $objectIds)
- {
- /** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $repository */
- $repository = \App::make('FireflyIII\Database\TransactionJournal\TransactionJournal');
-
- return $repository->getByIds($objectIds);
- }
-
- /**
- * @param string $query
- * @param \TransactionJournal $journal
- *
- * @return Collection
- */
- public function search($query, \TransactionJournal $journal)
- {
- $start = clone $journal->date;
- $end = clone $journal->date;
- $start->startOfMonth();
- $end->endOfMonth();
-
- // get already related transactions:
- $exclude = [$journal->id];
- foreach ($journal->transactiongroups()->get() as $group) {
- foreach ($group->transactionjournals()->get() as $current) {
- $exclude[] = $current->id;
- }
- }
- $exclude = array_unique($exclude);
-
- /** @var Collection $collection */
- $collection = $this->getUser()->transactionjournals()
- ->withRelevantData()
- ->before($end)->after($start)->where('encrypted', 0)
- ->whereNotIn('id', $exclude)
- ->where('description', 'LIKE', '%' . $query . '%')
- ->get();
-
- // manually search encrypted entries:
- /** @var Collection $encryptedCollection */
- $encryptedCollection = $this->getUser()->transactionjournals()
- ->withRelevantData()
- ->before($end)->after($start)
- ->where('encrypted', 1)
- ->whereNotIn('id', $exclude)
- ->get();
- $encrypted = $encryptedCollection->filter(
- function (\TransactionJournal $journal) use ($query) {
- $strPos = strpos(strtolower($journal->description), strtolower($query));
- if ($strPos !== false) {
- return $journal;
- }
-
- return null;
- }
- );
-
- return $collection->merge($encrypted);
- }
-}
diff --git a/app/lib/FireflyIII/Helper/Related/RelatedInterface.php b/app/lib/FireflyIII/Helper/Related/RelatedInterface.php
deleted file mode 100644
index f2072cf823..0000000000
--- a/app/lib/FireflyIII/Helper/Related/RelatedInterface.php
+++ /dev/null
@@ -1,29 +0,0 @@
-account->id);
- }
-
- // otherwise (its a deposit), it's been paid into account #0.
- return intval($transactions[0]->account->id);
- }
-
- /**
- * @return Collection
- */
- public function getAssetAccounts()
- {
- /** @var \FireflyIII\Database\Account\Account $accountRepository */
- $accountRepository = \App::make('FireflyIII\Database\Account\Account');
-
- /** @var Collection $list */
- $list = $accountRepository->getAccountsByType(['Default account', 'Asset account']);
- $filtered = $list->filter(
- function (\Account $account) {
- if (intval($account->active) === 1) {
- return $account;
- }
- return null;
- }
- );
-
- return $filtered;
- }
-
- /**
- * @return Collection
- */
- public function getBudgets()
- {
- /** @var \FireflyIII\Database\Budget\Budget $budgetRepository */
- $budgetRepository = \App::make('FireflyIII\Database\Budget\Budget');
-
- return $budgetRepository->get();
-
- }
-
- /**
- * @return Collection
- */
- public function getPiggyBanks()
- {
- /** @var \FireflyIII\Database\PiggyBank\PiggyBank $piggyRepository */
- $piggyRepository = \App::make('FireflyIII\Database\PiggyBank\PiggyBank');
-
- return $piggyRepository->get();
-
-
- }
-
- /**
- * @return Collection
- */
- public function getRepeatedExpenses()
- {
- /** @var \FireflyIII\Database\PiggyBank\RepeatedExpense $repRepository */
- $repRepository = \App::make('FireflyIII\Database\PiggyBank\RepeatedExpense');
-
- return $repRepository->get();
-
-
- }
-
-
-}
diff --git a/app/lib/FireflyIII/Helper/TransactionJournal/HelperInterface.php b/app/lib/FireflyIII/Helper/TransactionJournal/HelperInterface.php
deleted file mode 100644
index 06bcac0de7..0000000000
--- a/app/lib/FireflyIII/Helper/TransactionJournal/HelperInterface.php
+++ /dev/null
@@ -1,45 +0,0 @@
-_accounts = $accounts;
- $this->_journals = $journals;
- $this->_queries = \App::make('FireflyIII\Report\ReportQueryInterface');
- $this->_helper = \App::make('FireflyIII\Report\ReportHelperInterface');
-
-
- }
-
- /**
- * This methods fails to take in account transfers FROM shared accounts.
- *
- * @param Carbon $start
- * @param Carbon $end
- * @param int $limit
- *
- * @return Collection
- */
- public function expensesGroupedByAccount(Carbon $start, Carbon $end, $limit = 15)
- {
- $result = $this->_queries->journalsByExpenseAccount($start, $end);
- $array = $this->_helper->makeArray($result);
- $limited = $this->_helper->limitArray($array, $limit);
-
- return $limited;
-
- }
-
- /**
- * Gets all the users shared and non-shared accounts combined with various meta-data
- * to display the amount of money spent that month compared to what's been spend within
- * budgets.
- *
- * @param Carbon $date
- *
- * @return Collection
- */
- public function getAccountListBudgetOverview(Carbon $date)
- {
- $start = clone $date;
- $start->startOfMonth();
- $end = clone $date;
- $end->endOfMonth();
- $start->subDay();
- $accounts = $this->_queries->getAllAccounts($start, $end);
-
- $accounts->each(
- function (\Account $account) use ($start, $end) {
- $budgets = $this->_queries->getBudgetSummary($account, $start, $end);
- $balancedAmount = $this->_queries->balancedTransactionsSum($account, $start, $end);
- $array = [];
- foreach ($budgets as $budget) {
- $id = intval($budget->id);
- $data = $budget->toArray();
- $array[$id] = $data;
- }
- $account->budgetInformation = $array;
- $account->balancedAmount = $balancedAmount;
-
- }
- );
-
- return $accounts;
-
- }
-
- /**
- * @param Carbon $date
- *
- * @return array
- */
- public function getAccountsForMonth(Carbon $date)
- {
- $start = clone $date;
- $start->startOfMonth()->subDay();
- $end = clone $date;
- $end->endOfMonth();
- \Log::debug('Monthly report account dates: start:[' . $start->format('Y-m-d') . '] and end:[' . $end->format('Y-m-d') . ']');
- $list = $this->_queries->accountList();
- $accounts = [];
- /** @var \Account $account */
- foreach ($list as $account) {
- $id = intval($account->id);
- /** @noinspection PhpParamsInspection */
- $accounts[$id] = [
- 'name' => $account->name,
- 'startBalance' => \Steam::balance($account, $start),
- 'endBalance' => \Steam::balance($account, $end)
- ];
-
- $accounts[$id]['difference'] = $accounts[$id]['endBalance'] - $accounts[$id]['startBalance'];
- }
-
- return $accounts;
- }
-
- /**
- * @param Carbon $date
- *
- * @return Collection
- */
- public function getBudgetsForMonth(Carbon $date)
- {
- $start = clone $date;
- $start->startOfMonth();
- $end = clone $date;
- $end->endOfMonth();
- // all budgets
- $set = $this->_queries->getAllBudgets($date);
- $budgets = $this->_helper->makeArray($set);
- $amountSet = $this->_queries->journalsByBudget($start, $end);
- $amounts = $this->_helper->makeArray($amountSet);
- $combined = $this->_helper->mergeArrays($budgets, $amounts);
- $combined[0]['spent'] = isset($combined[0]['spent']) ? $combined[0]['spent'] : 0.0;
- $combined[0]['amount'] = isset($combined[0]['amount']) ? $combined[0]['amount'] : 0.0;
- $combined[0]['name'] = 'No budget';
-
- // find transactions to shared expense accounts, which are without a budget by default:
- $transfers = $this->_queries->sharedExpenses($start, $end);
- foreach ($transfers as $transfer) {
- $combined[0]['spent'] += floatval($transfer->amount) * -1;
- }
-
- return $combined;
- }
-
- /**
- * @param Carbon $date
- * @param int $limit
- *
- * @return array
- */
- public function getCategoriesForMonth(Carbon $date, $limit = 15)
- {
- $start = clone $date;
- $start->startOfMonth();
- $end = clone $date;
- $end->endOfMonth();
- // all categories.
- $result = $this->_queries->journalsByCategory($start, $end);
- $categories = $this->_helper->makeArray($result);
-
- // all transfers
- $result = $this->_queries->sharedExpensesByCategory($start, $end);
- $transfers = $this->_helper->makeArray($result);
- $merged = $this->_helper->mergeArrays($categories, $transfers);
-
- // sort.
- $sorted = $this->_helper->sortNegativeArray($merged);
-
- // limit to $limit:
- $cut = $this->_helper->limitArray($sorted, $limit);
-
- return $cut;
- }
-
- /**
- * @param Carbon $date
- * @param int $limit
- *
- * @return Collection
- */
- public function getExpenseGroupedForMonth(Carbon $date, $limit = 15)
- {
- $start = clone $date;
- $start->startOfMonth();
- $end = clone $date;
- $end->endOfMonth();
-
- $set = $this->_queries->journalsByExpenseAccount($start, $end);
- $expenses = $this->_helper->makeArray($set);
-
-// $alt = $this->_queries->sharedExpenses($start, $end);
-// $transfers = $this->_helper->makeArray($alt);
-//
-// $expenses[-1] = [
-// 'amount' => 0,
-// 'name' => 'Transfers to shared',
-// 'spent' => 0
-// ];
-//
-// foreach ($transfers as $transfer) {
-// $expenses[-1]['amount'] += $transfer['amount'];
-// }
-
- $expenses = $this->_helper->sortArray($expenses);
- $limited = $this->_helper->limitArray($expenses, $limit);
-
- return $limited;
-
- }
-
- /**
- * This method gets all incomes (journals) in a list.
- *
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @param Carbon $date
- * @param bool $shared
- *
- * @return Collection
- */
- public function getIncomeForMonth(Carbon $date, $shared = false)
- {
- $start = clone $date;
- $start->startOfMonth();
- $end = clone $date;
- $end->endOfMonth();
-
- return $this->_queries->incomeByPeriod($start, $end);
-
-
- }
-
- /**
- * @param Carbon $date
- *
- * @return Collection
- */
- public function getPiggyBanksForMonth(Carbon $date)
- {
- $start = clone $date;
- $start->startOfMonth();
- $end = clone $date;
- $end->endOfMonth();
-
- \PiggyBank::
- leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
- ->where('accounts.user_id', \Auth::user()->id)
- ->where('repeats', 0)
- ->where(
- function (Builder $query) use ($start, $end) {
- $query->whereNull('piggy_banks.deleted_at');
- $query->orWhere(
- function (Builder $query) use ($start, $end) {
- $query->whereNotNull('piggy_banks.deleted_at');
- $query->where('piggy_banks.deleted_at', '>=', $start->format('Y-m-d 00:00:00'));
- $query->where('piggy_banks.deleted_at', '<=', $end->format('Y-m-d 00:00:00'));
- }
- );
- }
- )
- ->get(['piggy_banks.*']);
-
-
- }
-
- /**
- * @param Carbon $start
- *
- * @return array
- */
- public function listOfMonths(Carbon $start)
- {
- $end = Carbon::now();
- $months = [];
- while ($start <= $end) {
- $months[] = [
- 'formatted' => $start->format('F Y'),
- 'month' => intval($start->format('m')),
- 'year' => intval($start->format('Y')),
- ];
- $start->addMonth();
- }
-
- return $months;
- }
-
- /**
- * @param Carbon $start
- *
- * @return array
- */
- public function listOfYears(Carbon $start)
- {
- $end = Carbon::now();
- $years = [];
- while ($start <= $end) {
- $years[] = $start->format('Y');
- $start->addYear();
- }
-
- return $years;
- }
-
- /**
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function revenueGroupedByAccount(Carbon $start, Carbon $end)
- {
- return $this->_queries->journalsByRevenueAccount($start, $end);
-
-
- }
-
- /**
- * @param Carbon $date
- *
- * @return array
- */
- public function yearBalanceReport(Carbon $date)
- {
- $start = clone $date;
- $end = clone $date;
- $sharedAccounts = [];
- $sharedCollection = \Auth::user()->accounts()
- ->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
- ->where('account_meta.name', '=', 'accountRole')
- ->where('account_meta.data', '=', json_encode('sharedExpense'))
- ->get(['accounts.id']);
-
- foreach ($sharedCollection as $account) {
- $sharedAccounts[] = $account->id;
- }
-
- $accounts = $this->_accounts->getAccountsByType(['Default account', 'Asset account'])->filter(
- function (\Account $account) use ($sharedAccounts) {
- if (!in_array($account->id, $sharedAccounts)) {
- return $account;
- }
-
- return null;
- }
- );
- $report = [];
- $start->startOfYear()->subDay();
- $end->endOfYear();
-
- foreach ($accounts as $account) {
- $report[] = [
- 'start' => \Steam::balance($account, $start),
- 'end' => \Steam::balance($account, $end),
- 'account' => $account,
- 'shared' => $account->accountRole == 'sharedExpense'
- ];
- }
-
- return $report;
- }
-
-}
diff --git a/app/lib/FireflyIII/Report/ReportHelper.php b/app/lib/FireflyIII/Report/ReportHelper.php
deleted file mode 100644
index d2e79b6d8f..0000000000
--- a/app/lib/FireflyIII/Report/ReportHelper.php
+++ /dev/null
@@ -1,142 +0,0 @@
- 'Others',
- 'amount' => 0
- ];
- $return = [];
- $count = 0;
- foreach ($array as $id => $entry) {
- if ($count < ($limit - 1)) {
- $return[$id] = $entry;
- } else {
- $others['amount'] += $entry['amount'];
- }
-
- $count++;
- }
- $return[0] = $others;
-
- return $return;
-
- }
-
- /**
- * Turns a collection into an array. Needs the field 'id' for the key,
- * and saves only 'name' and 'amount' as a sub array.
- *
- * @param Collection $collection
- *
- * @return array
- */
- public function makeArray(Collection $collection)
- {
- $array = [];
- foreach ($collection as $entry) {
- $entry->spent = isset($entry->spent) ? floatval($entry->spent) : 0.0;
- $id = intval($entry->id);
- if (isset($array[$id])) {
- $array[$id]['amount'] += floatval($entry->amount);
- $array[$id]['spent'] += floatval($entry->spent);
- } else {
- $array[$id] = [
- 'amount' => floatval($entry->amount),
- 'spent' => floatval($entry->spent),
- 'name' => $entry->name
- ];
- }
- }
-
- return $array;
- }
-
- /**
- * Merges two of the arrays as defined above. Can't handle more (yet)
- *
- * @param array $one
- * @param array $two
- *
- * @return array
- */
- public function mergeArrays(array $one, array $two)
- {
- foreach ($two as $id => $value) {
- // $otherId also exists in $one:
- if (isset($one[$id])) {
- $one[$id]['amount'] += $value['amount'];
- $one[$id]['spent'] += $value['spent'];
- } else {
- $one[$id] = $value;
- }
- }
-
- return $one;
- }
-
- /**
- * Sort an array where all 'amount' keys are positive floats.
- *
- * @param array $array
- *
- * @return array
- */
- public function sortArray(array $array)
- {
- uasort(
- $array, function ($left, $right) {
- if ($left['amount'] == $right['amount']) {
- return 0;
- }
-
- return ($left['amount'] < $right['amount']) ? 1 : -1;
- }
- );
-
- return $array;
-
- }
-
- /**
- * Sort an array where all 'amount' keys are negative floats.
- *
- * @param array $array
- *
- * @return array
- */
- public function sortNegativeArray(array $array)
- {
- uasort(
- $array, function ($left, $right) {
- if ($left['amount'] == $right['amount']) {
- return 0;
- }
-
- return ($left['amount'] < $right['amount']) ? -1 : 1;
- }
- );
-
- return $array;
- }
-}
diff --git a/app/lib/FireflyIII/Report/ReportHelperInterface.php b/app/lib/FireflyIII/Report/ReportHelperInterface.php
deleted file mode 100644
index 828e322603..0000000000
--- a/app/lib/FireflyIII/Report/ReportHelperInterface.php
+++ /dev/null
@@ -1,64 +0,0 @@
-accounts()
- ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
- ->leftJoin(
- 'account_meta', function (JoinClause $join) {
- $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', "accountRole");
- }
- )
- ->whereIn('account_types.type', ['Default account', 'Cash account', 'Asset account'])
- ->where('active', 1)
- ->where(
- function (Builder $query) {
- $query->where('account_meta.data', '!=', '"sharedExpense"');
- $query->orWhereNull('account_meta.data');
- }
- )
- ->get(['accounts.*']);
- }
-
- /**
- * This method will get a list of all expenses in a certain time period that have no budget
- * and are balanced by a transfer to make up for it.
- *
- * @param \Account $account
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function balancedTransactionsList(\Account $account, Carbon $start, Carbon $end)
- {
-
- $set = \TransactionJournal::
- leftJoin('transaction_group_transaction_journal', 'transaction_group_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
- ->leftJoin(
- 'transaction_group_transaction_journal as otherFromGroup', function (JoinClause $join) {
- $join->on('otherFromGroup.transaction_group_id', '=', 'transaction_group_transaction_journal.transaction_group_id')
- ->on('otherFromGroup.transaction_journal_id', '!=', 'transaction_journals.id');
- }
- )
- ->leftJoin('transaction_journals as otherJournals', 'otherJournals.id', '=', 'otherFromGroup.transaction_journal_id')
- ->leftJoin('transaction_types', 'transaction_types.id', '=', 'otherJournals.transaction_type_id')
- ->leftJoin(
- 'transactions', function (JoinClause $join) {
- $join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('amount', '>', 0);
- }
- )
- ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'otherJournals.id')
- ->before($end)->after($start)
- ->where('transaction_types.type', 'Withdrawal')
- ->where('transaction_journals.user_id', \Auth::user()->id)
- ->whereNull('budget_transaction_journal.budget_id')->whereNull('transaction_journals.deleted_at')
- ->whereNull('otherJournals.deleted_at')
- ->where('transactions.account_id', $account->id)
- ->whereNotNull('transaction_group_transaction_journal.transaction_group_id')->groupBy('transaction_journals.id')
- ->get(
- [
- 'transaction_journals.id as transferId',
- 'transaction_journals.description as transferDescription',
- 'transaction_group_transaction_journal.transaction_group_id as groupId',
- 'otherFromGroup.transaction_journal_id as expenseId',
- 'otherJournals.description as expenseDescription',
- 'transactions.amount'
- ]
- );
-
- return $set;
- }
-
- /**
- * This method will sum up all expenses in a certain time period that have no budget
- * and are balanced by a transfer to make up for it.
- *
- * @param \Account $account
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return float
- */
- public function balancedTransactionsSum(\Account $account, Carbon $start, Carbon $end)
- {
- $list = $this->balancedTransactionsList($account, $start, $end);
- $sum = 0;
- foreach ($list as $entry) {
- $sum += floatval($entry->amount);
- }
-
- return $sum;
- }
-
- /**
- * Get a users accounts combined with various meta-data related to the start and end date.
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function getAllAccounts(Carbon $start, Carbon $end)
- {
- $set = \Auth::user()->accounts()
- ->accountTypeIn(['Default account', 'Asset account', 'Cash account'])
- ->leftJoin(
- 'account_meta', function (JoinClause $join) {
- $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
- }
- )
- ->where(
- function (Builder $query) {
- $query->where('account_meta.data', '!=', '"sharedExpense"');
- $query->orWhereNull('account_meta.data');
- }
- )
- ->get(['accounts.*']);
- $set->each(
- function (\Account $account) use ($start, $end) {
- /** @noinspection PhpParamsInspection */
- $account->startBalance = \Steam::balance($account, $start);
- $account->endBalance = \Steam::balance($account, $end);
- }
- );
-
- return $set;
- }
-
- /**
- * Gets a list of all budgets and if present, the amount of the current BudgetLimit
- * as well
- *
- * @param Carbon $date
- *
- * @return Collection
- */
- public function getAllBudgets(Carbon $date)
- {
- return \Auth::user()->budgets()
- ->leftJoin(
- 'budget_limits', function (JoinClause $join) use ($date) {
- $join->on('budget_limits.budget_id', '=', 'budgets.id')->where('budget_limits.startdate', '=', $date->format('Y-m-d'));
- }
- )
- ->get(['budgets.*', 'budget_limits.amount as amount']);
- }
-
- /**
- * Grabs a summary of all expenses grouped by budget, related to the account.
- *
- * @param \Account $account
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return mixed
- */
- public function getBudgetSummary(\Account $account, Carbon $start, Carbon $end)
- {
- $set = \TransactionJournal::
- leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
- ->leftJoin('budgets', 'budgets.id', '=', 'budget_transaction_journal.budget_id')
- ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- ->leftJoin(
- 'transactions', function (JoinClause $join) {
- $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0);
- }
- )
- ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
- ->before($end)
- ->after($start)
- ->where('accounts.id', $account->id)
- ->where('transaction_journals.user_id', \Auth::user()->id)
- ->where('transaction_types.type', 'Withdrawal')
- ->groupBy('budgets.id')
- ->orderBy('budgets.id')
- ->get(['budgets.id', 'budgets.name', \DB::Raw('SUM(`transactions`.`amount`) as `amount`')]);
-
- return $set;
-
-
- }
-
- /**
- * This method returns all "income" journals in a certain period, which are both transfers from a shared account
- * and "ordinary" deposits. The query used is almost equal to ReportQueryInterface::journalsByRevenueAccount but it does
- * not group and returns different fields.
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function incomeByPeriod(Carbon $start, Carbon $end)
- {
- return \TransactionJournal::
- leftJoin(
- 'transactions as t_from', function (JoinClause $join) {
- $join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
- }
- )
- ->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
- ->leftJoin(
- 'account_meta as acm_from', function (JoinClause $join) {
- $join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
- }
- )
- ->leftJoin(
- 'transactions as t_to', function (JoinClause $join) {
- $join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
- }
- )
- ->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
- ->leftJoin(
- 'account_meta as acm_to', function (JoinClause $join) {
- $join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
- }
- )
- ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- ->where(
- function ($query) {
- $query->where(
- function ($q) {
- $q->where('transaction_types.type', 'Deposit');
- $q->where('acm_to.data', '!=', '"sharedExpense"');
- }
- );
- $query->orWhere(
- function ($q) {
- $q->where('transaction_types.type', 'Transfer');
- $q->where('acm_from.data', '=', '"sharedExpense"');
- }
- );
- }
- )
- ->before($end)->after($start)
- ->where('transaction_journals.user_id', \Auth::user()->id)
- ->groupBy('t_from.account_id')->orderBy('transaction_journals.date')
- ->get(
- ['transaction_journals.id',
- 'transaction_journals.description',
- 'transaction_types.type',
- 't_to.amount', 'transaction_journals.date', 't_from.account_id as account_id',
- 'ac_from.name as name']
- );
- }
-
- /**
- * Gets a list of expenses grouped by the budget they were filed under.
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function journalsByBudget(Carbon $start, Carbon $end)
- {
- return \Auth::user()->transactionjournals()
- ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
- ->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id')
- ->leftJoin(
- 'transactions', function (JoinClause $join) {
- $join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '<', 0);
- }
- )
- ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
- ->leftJoin(
- 'account_meta', function (JoinClause $join) {
- $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
- }
- )
- ->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
- ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
- ->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
- ->where('account_meta.data', '!=', '"sharedExpense"')
- ->where('transaction_types.type', 'Withdrawal')
- ->groupBy('budgets.id')
- ->orderBy('budgets.name', 'ASC')
- ->get(['budgets.id', 'budgets.name', \DB::Raw('SUM(`transactions`.`amount`) AS `spent`')]);
- }
-
- /**
- * Gets a list of categories and the expenses therein, grouped by the relevant category.
- * This result excludes transfers to shared accounts which are expenses, technically.
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function journalsByCategory(Carbon $start, Carbon $end)
- {
- return \Auth::user()->transactionjournals()
- ->leftJoin(
- 'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
- )
- ->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id')
- ->leftJoin(
- 'transactions', function (JoinClause $join) {
- $join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '<', 0);
- }
- )
- ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
- ->leftJoin(
- 'account_meta', function (JoinClause $join) {
- $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
- }
- )
- ->leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
- ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
- ->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
- ->where('account_meta.data', '!=', '"sharedExpense"')
- ->where('transaction_types.type', 'Withdrawal')
- ->groupBy('categories.id')
- ->orderBy('amount')
- ->get(['categories.id', 'categories.name', \DB::Raw('SUM(`transactions`.`amount`) AS `amount`')]);
-
- }
-
- /**
- * Gets a list of expense accounts and the expenses therein, grouped by that expense account.
- * This result excludes transfers to shared accounts which are expenses, technically.
- *
- * So now it will include them!
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function journalsByExpenseAccount(Carbon $start, Carbon $end)
- {
- return \TransactionJournal::
- leftJoin(
- 'transactions as t_from', function (JoinClause $join) {
- $join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
- }
- )
- ->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
- ->leftJoin(
- 'account_meta as acm_from', function (JoinClause $join) {
- $join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
- }
- )
- ->leftJoin(
- 'transactions as t_to', function (JoinClause $join) {
- $join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
- }
- )
- ->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
- ->leftJoin(
- 'account_meta as acm_to', function (JoinClause $join) {
- $join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
- }
- )
- ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
-
- ->where(
- function ($query) {
- $query->where(
- function ($q) {
- $q->where('transaction_types.type', 'Withdrawal');
- $q->where('acm_from.data', '!=', '"sharedExpense"');
- }
- );
- $query->orWhere(
- function ($q) {
- $q->where('transaction_types.type', 'Transfer');
- $q->where('acm_to.data', '=', '"sharedExpense"');
- }
- );
- }
- )
-
-
- ->before($end)
- ->after($start)
- ->where('transaction_journals.user_id', \Auth::user()->id)
- ->groupBy('t_to.account_id')
- ->orderBy('amount', 'DESC')
- ->get(['t_to.account_id as id', 'ac_to.name as name', \DB::Raw('SUM(t_to.amount) as `amount`')]);
- }
-
- /**
- * This method returns all deposits into asset accounts, grouped by the revenue account,
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function journalsByRevenueAccount(Carbon $start, Carbon $end)
- {
- return \TransactionJournal::
- leftJoin(
- 'transactions as t_from', function (JoinClause $join) {
- $join->on('t_from.transaction_journal_id', '=', 'transaction_journals.id')->where('t_from.amount', '<', 0);
- }
- )
- ->leftJoin('accounts as ac_from', 't_from.account_id', '=', 'ac_from.id')
- ->leftJoin(
- 'account_meta as acm_from', function (JoinClause $join) {
- $join->on('ac_from.id', '=', 'acm_from.account_id')->where('acm_from.name', '=', 'accountRole');
- }
- )
- ->leftJoin(
- 'transactions as t_to', function (JoinClause $join) {
- $join->on('t_to.transaction_journal_id', '=', 'transaction_journals.id')->where('t_to.amount', '>', 0);
- }
- )
- ->leftJoin('accounts as ac_to', 't_to.account_id', '=', 'ac_to.id')
- ->leftJoin(
- 'account_meta as acm_to', function (JoinClause $join) {
- $join->on('ac_to.id', '=', 'acm_to.account_id')->where('acm_to.name', '=', 'accountRole');
- }
- )
- ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- ->where(
- function ($query) {
- $query->where(
- function ($q) {
- $q->where('transaction_types.type', 'Deposit');
- $q->where('acm_to.data', '!=', '"sharedExpense"');
- }
- );
- $query->orWhere(
- function ($q) {
- $q->where('transaction_types.type', 'Transfer');
- $q->where('acm_from.data', '=', '"sharedExpense"');
- }
- );
- }
- )
- ->before($end)->after($start)
- ->where('transaction_journals.user_id', \Auth::user()->id)
- ->groupBy('t_from.account_id')->orderBy('amount')
- ->get(['t_from.account_id as account_id', 'ac_from.name as name', \DB::Raw('SUM(t_from.amount) as `amount`')]);
- }
-
- /**
- * With an equally misleading name, this query returns are transfers to shared accounts. These are considered
- * expenses.
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function sharedExpenses(Carbon $start, Carbon $end)
- {
- return \TransactionJournal::
- leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- ->leftJoin(
- 'transactions', function (JoinClause $join) {
- $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where(
- 'transactions.amount', '>', 0
- );
- }
- )
- ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
- ->leftJoin(
- 'account_meta', function (JoinClause $join) {
- $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
- }
- )
- ->where('account_meta.data', '"sharedExpense"')
- ->after($start)
- ->before($end)
- ->where('transaction_types.type', 'Transfer')
- ->where('transaction_journals.user_id', \Auth::user()->id)
- ->get(
- ['transaction_journals.id', 'transaction_journals.description', 'transactions.account_id', 'accounts.name',
- 'transactions.amount']
- );
-
- }
-
- /**
- * With a slightly misleading name, this query returns all transfers to shared accounts
- * which are technically expenses, since it won't be just your money that gets spend.
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return Collection
- */
- public function sharedExpensesByCategory(Carbon $start, Carbon $end)
- {
- return \TransactionJournal::
- leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- ->leftJoin(
- 'transactions', function (JoinClause $join) {
- $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where(
- 'transactions.amount', '>', 0
- );
- }
- )
- ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
- ->leftJoin(
- 'account_meta', function (JoinClause $join) {
- $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
- }
- )
- ->leftJoin(
- 'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
- )
- ->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id')
- ->where('account_meta.data', '"sharedExpense"')
- ->after($start)
- ->before($end)
- ->where('transaction_types.type', 'Transfer')
- ->where('transaction_journals.user_id', \Auth::user()->id)
- ->groupBy('categories.name')
- ->get(
- [
- 'categories.id',
- 'categories.name as name',
- \DB::Raw('SUM(`transactions`.`amount`) * -1 AS `amount`')
- ]
- );
- }
-}
diff --git a/app/lib/FireflyIII/Report/ReportQueryInterface.php b/app/lib/FireflyIII/Report/ReportQueryInterface.php
deleted file mode 100644
index 046835b843..0000000000
--- a/app/lib/FireflyIII/Report/ReportQueryInterface.php
+++ /dev/null
@@ -1,154 +0,0 @@
-accounts()->with('accounttype')->where(
- function (EloquentBuilder $q) use ($words) {
- foreach ($words as $word) {
- $q->orWhere('name', 'LIKE', '%' . e($word) . '%');
- }
- }
- )->get();
- }
-
- /**
- * @param array $words
- *
- * @return Collection
- */
- public function searchBudgets(array $words)
- {
- /** @var Collection $set */
- $set = \Auth::user()->budgets()->get();
- $newSet = $set->filter(
- function (\Budget $b) use ($words) {
- $found = 0;
- foreach ($words as $word) {
- if (!(strpos(strtolower($b->name), strtolower($word)) === false)) {
- $found++;
- }
- }
-
- return $found > 0;
- }
- );
-
- return $newSet;
- }
-
- /**
- * @param array $words
- *
- * @return Collection
- */
- public function searchCategories(array $words)
- {
- /** @var Collection $set */
- $set = \Auth::user()->categories()->get();
- $newSet = $set->filter(
- function (\Category $c) use ($words) {
- $found = 0;
- foreach ($words as $word) {
- if (!(strpos(strtolower($c->name), strtolower($word)) === false)) {
- $found++;
- }
- }
-
- return $found > 0;
- }
- );
-
- return $newSet;
- }
-
- /**
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- *
- * @param array $words
- *
- * @return Collection
- */
- public function searchTags(array $words)
- {
- return new Collection;
- }
-
- /**
- * @param array $words
- *
- * @return Collection
- */
- public function searchTransactions(array $words)
- {
- return \Auth::user()->transactionjournals()->withRelevantData()->where(
- function (EloquentBuilder $q) use ($words) {
- foreach ($words as $word) {
- $q->orWhere('description', 'LIKE', '%' . e($word) . '%');
- }
- }
- )->get();
- }
-}
diff --git a/app/lib/FireflyIII/Shared/Facade/Amount.php b/app/lib/FireflyIII/Shared/Facade/Amount.php
deleted file mode 100644
index 4a3eb4dba4..0000000000
--- a/app/lib/FireflyIII/Shared/Facade/Amount.php
+++ /dev/null
@@ -1,24 +0,0 @@
-password = $password;
- $user->reset = \Str::random(32); // new one.
- $user->forceSave();
- $email = $user->email;
-
-
- $data = ['password' => $password];
- try {
- \Mail::send(
- ['emails.user.register-html', 'emails.user.register-text'], $data, function (Message $message) use ($email) {
-
- $message->to($email, $email)->subject('Welcome to Firefly!');
- }
- );
- } catch (Swift_RfcComplianceException $e) {
- }
- }
-
- /**
- * @param \User $user
- *
- * @return mixed|void
- */
- public function sendResetVerification(\User $user)
- {
- $reset = \Str::random(32);
- $user->reset = $reset;
- $user->forceSave();
- $email = $user->email;
-
- $data = ['reset' => $reset];
- try {
- \Mail::send(
- ['emails.user.remindMe-html', 'emails.user.remindMe-text'], $data, function (Message $message) use ($email) {
- $message->to($email, $email)->subject('Forgot your password?');
- }
- );
- } catch (Swift_RfcComplianceException $e) {
- \Log::error($e->getMessage());
- return false;
- } catch(Swift_TransportException $e) {
- \Log::error($e->getMessage());
- return false;
- } catch(\Exception $e) {
- \Log::error($e->getMessage());
- return false;
- }
- return true;
-
-
- }
-
- /**
- * @param \User $user
- *
- * @return mixed|void
- */
- public function sendVerificationMail(\User $user)
- {
-
- $reset = \Str::random(32);
- $user->reset = $reset;
- $user->forceSave();
- $email = $user->email;
- $data = ['reset' => $reset];
-
- try {
- \Mail::send(
- ['emails.user.verify-html', 'emails.user.verify-text'], $data, function (Message $message) use ($email) {
-
- $message->to($email, $email)->subject('Verify your e-mail address.');
- }
- );
- } catch (Swift_RfcComplianceException $e) {
- \Log::error($e->getMessage());
- return false;
- } catch(Swift_TransportException $e) {
- \Log::error($e->getMessage());
- return false;
- } catch(\Exception $e) {
- \Log::error($e->getMessage());
- return false;
- }
- return true;
- }
-
-}
diff --git a/app/lib/FireflyIII/Shared/Mail/RegistrationInterface.php b/app/lib/FireflyIII/Shared/Mail/RegistrationInterface.php
deleted file mode 100644
index df104cc50a..0000000000
--- a/app/lib/FireflyIII/Shared/Mail/RegistrationInterface.php
+++ /dev/null
@@ -1,34 +0,0 @@
-id)->where('name', $name)->first();
- if (is_null($pref) && is_null($default)) {
- // return NULL
- return null;
- }
- if (!is_null($pref)) {
- return $pref;
- }
-
- return $this->set($name, $default);
-
- }
-
- /**
- * @param $name
- * @param $value
- *
- * @return \Preference
- */
- public function set($name, $value)
- {
- $pref = \Preference::where('user_id', \Auth::user()->id)->where('name', $name)->first();
- if (is_null($pref)) {
- $pref = new \Preference;
- $pref->name = $name;
- $pref->user()->associate(\Auth::user());
-
- }
- $pref->data = $value;
- $pref->save();
-
-
- return $pref;
-
- }
-}
diff --git a/app/lib/FireflyIII/Shared/Preferences/PreferencesInterface.php b/app/lib/FireflyIII/Shared/Preferences/PreferencesInterface.php
deleted file mode 100644
index 3dd5606235..0000000000
--- a/app/lib/FireflyIII/Shared/Preferences/PreferencesInterface.php
+++ /dev/null
@@ -1,29 +0,0 @@
-getCurrencySymbol();
-
- return $this->formatWithSymbol($currencySymbol, $amount, $coloured);
-
-
- }
-
- /**
- * @return string
- */
- public function getCurrencySymbol()
- {
- if (defined('FFCURRENCYSYMBOL')) {
- return FFCURRENCYSYMBOL;
- }
- if (\Cache::has('FFCURRENCYSYMBOL')) {
- define('FFCURRENCYSYMBOL', \Cache::get('FFCURRENCYSYMBOL'));
-
- return FFCURRENCYSYMBOL;
- }
-
- /** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencies */
- $currencies = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
-
- /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
- $preferences = \App::make('FireflyIII\Shared\Preferences\Preferences');
-
- $currencyPreference = $preferences->get('currencyPreference', 'EUR');
- $currency = $currencies->findByCode($currencyPreference->data);
-
- \Cache::forever('FFCURRENCYSYMBOL', $currency->symbol);
-
- define('FFCURRENCYSYMBOL', $currency->symbol);
-
- return $currency->symbol;
- }
-
- /**
- * @param string $symbol
- * @param float $amount
- * @param bool $coloured
- *
- * @return string
- */
- protected function formatWithSymbol($symbol, $amount, $coloured = true)
- {
- $amount = floatval($amount);
- $amount = round($amount, 2);
- $string = number_format($amount, 2, ',', '.');
-
- if ($coloured === true) {
- if ($amount === 0.0) {
- return '' . $symbol . ' ' . $string . '';
- }
- if ($amount > 0) {
- return '' . $symbol . ' ' . $string . '';
- }
-
- return '' . $symbol . ' ' . $string . '';
- }
-
- // €
- return $symbol . ' ' . $string;
- }
-
- /**
- * @param \TransactionJournal $journal
- * @param float $amount
- * @param bool $coloured
- *
- * @return string
- */
- public function formatJournal(\TransactionJournal $journal, $amount, $coloured = true)
- {
- $symbol = $journal->transactionCurrency->symbol;
-
- return $this->formatWithSymbol($symbol, $amount, $coloured);
-
-
- }
-
- /**
- * @param \Transaction $transaction
- * @param bool $coloured
- *
- * @return string
- */
- public function formatTransaction(\Transaction $transaction, $coloured = true)
- {
- $symbol = $transaction->transactionJournal->transactionCurrency->symbol;
- $amount = floatval($transaction->amount);
-
- return $this->formatWithSymbol($symbol, $amount, $coloured);
-
-
- }
-
- /**
- * @return string
- */
- public function getCurrencyCode()
- {
- if (defined('FFCURRENCYCODE')) {
- return FFCURRENCYCODE;
- }
- if (\Cache::has('FFCURRENCYCODE')) {
- define('FFCURRENCYCODE', \Cache::get('FFCURRENCYCODE'));
-
- return FFCURRENCYCODE;
- }
-
- /** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencies */
- $currencies = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
-
- /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
- $preferences = \App::make('FireflyIII\Shared\Preferences\Preferences');
-
- $currencyPreference = $preferences->get('currencyPreference', 'EUR');
- $currency = $currencies->findByCode($currencyPreference->data);
-
- \Cache::forever('FFCURRENCYCODE', $currency->code);
-
- define('FFCURRENCYCODE', $currency->code);
-
- return $currency->code;
- }
-
- /**
- * @return string
- */
- public function getDefaultCurrency()
- {
- /** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencies */
- $currencies = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency');
-
- /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
- $preferences = \App::make('FireflyIII\Shared\Preferences\Preferences');
-
- $currencyPreference = $preferences->get('currencyPreference', 'EUR');
- $currency = $currencies->findByCode($currencyPreference->data);
-
- return $currency;
- }
-
-}
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Date.php b/app/lib/FireflyIII/Shared/Toolkit/Date.php
deleted file mode 100644
index 65d1d49ab9..0000000000
--- a/app/lib/FireflyIII/Shared/Toolkit/Date.php
+++ /dev/null
@@ -1,258 +0,0 @@
- 'addDays',
- 'weekly' => 'addWeeks',
- 'week' => 'addWeeks',
- 'month' => 'addMonths',
- 'monthly' => 'addMonths',
- 'quarter' => 'addMonths',
- 'quarterly' => 'addMonths',
- 'half-year' => 'addMonths',
- 'year' => 'addYears',
- 'yearly' => 'addYears',
- ];
- $modifierMap = [
- 'quarter' => 3,
- 'quarterly' => 3,
- 'half-year' => 6,
- ];
- if (!isset($functionMap[$repeatFreq])) {
- throw new FireflyException('Cannot do addPeriod for $repeat_freq "' . $repeatFreq . '"');
- }
- if (isset($modifierMap[$repeatFreq])) {
- $add = $add * $modifierMap[$repeatFreq];
- }
- $function = $functionMap[$repeatFreq];
- $date->$function($add);
-
- return $date;
- }
-
- /**
- * @param Carbon $theCurrentEnd
- * @param $repeatFreq
- *
- * @return Carbon
- * @throws FireflyException
- */
- public function endOfPeriod(Carbon $theCurrentEnd, $repeatFreq)
- {
- $currentEnd = clone $theCurrentEnd;
-
- $functionMap = [
- 'daily' => 'addDay',
- 'week' => 'addWeek',
- 'weekly' => 'addWeek',
- 'month' => 'addMonth',
- 'monthly' => 'addMonth',
- 'quarter' => 'addMonths',
- 'quarterly' => 'addMonths',
- 'half-year' => 'addMonths',
- 'year' => 'addYear',
- 'yearly' => 'addYear',
- ];
- $modifierMap = [
- 'quarter' => 3,
- 'quarterly' => 3,
- 'half-year' => 6,
- ];
-
- $subDay = ['week', 'weekly', 'month', 'monthly', 'quarter', 'quarterly', 'half-year', 'year', 'yearly'];
-
- if (!isset($functionMap[$repeatFreq])) {
- throw new FireflyException('Cannot do endOfPeriod for $repeat_freq ' . $repeatFreq);
- }
- $function = $functionMap[$repeatFreq];
- if (isset($modifierMap[$repeatFreq])) {
- $currentEnd->$function($modifierMap[$repeatFreq]);
- } else {
- $currentEnd->$function();
- }
- if (in_array($repeatFreq, $subDay)) {
- $currentEnd->subDay();
- }
-
- return $currentEnd;
- }
-
- /**
- * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
- *
- * @param Carbon $theCurrentEnd
- * @param $repeatFreq
- * @param Carbon $maxDate
- *
- * @return Carbon
- * @throws FireflyException
- */
- public function endOfX(Carbon $theCurrentEnd, $repeatFreq, Carbon $maxDate)
- {
- $functionMap = [
- 'daily' => 'endOfDay',
- 'week' => 'endOfWeek',
- 'weekly' => 'endOfWeek',
- 'month' => 'endOfMonth',
- 'monthly' => 'endOfMonth',
- 'quarter' => 'lastOfQuarter',
- 'quarterly' => 'lastOfQuarter',
- 'year' => 'endOfYear',
- 'yearly' => 'endOfYear',
- ];
- $specials = ['mont', 'monthly'];
-
- $currentEnd = clone $theCurrentEnd;
-
- if (isset($functionMap[$repeatFreq])) {
- $function = $functionMap[$repeatFreq];
- $currentEnd->$function();
-
- }
- if (isset($specials[$repeatFreq])) {
- $month = intval($theCurrentEnd->format('m'));
- $currentEnd->endOfYear();
- if ($month <= 6) {
- $currentEnd->subMonths(6);
- }
- }
- if ($currentEnd > $maxDate) {
- return clone $maxDate;
- }
-
- return $currentEnd;
- }
-
- /**
- * @param Carbon $date
- * @param $repeatFrequency
- *
- * @return string
- * @throws FireflyException
- */
- public function periodShow(Carbon $date, $repeatFrequency)
- {
- $formatMap = [
- 'daily' => 'j F Y',
- 'week' => '\W\e\e\k W, Y',
- 'weekly' => '\W\e\e\k W, Y',
- 'quarter' => 'F Y',
- 'month' => 'F Y',
- 'monthly' => 'F Y',
- 'year' => 'Y',
- 'yearly' => 'Y',
-
- ];
- if (isset($formatMap[$repeatFrequency])) {
- return $date->format($formatMap[$repeatFrequency]);
- }
- throw new FireflyException('No date formats for frequency "' . $repeatFrequency . '"!');
- }
-
- /**
- * @param Carbon $theDate
- * @param $repeatFreq
- *
- * @return Carbon
- * @throws FireflyException
- */
- public function startOfPeriod(Carbon $theDate, $repeatFreq)
- {
- $date = clone $theDate;
-
- $functionMap = [
- 'daily' => 'startOfDay',
- 'week' => 'startOfWeek',
- 'weekly' => 'startOfWeek',
- 'month' => 'startOfMonth',
- 'monthly' => 'startOfMonth',
- 'quarter' => 'firstOfQuarter',
- 'quartly' => 'firstOfQuarter',
- 'year' => 'startOfYear',
- 'yearly' => 'startOfYear',
- ];
- if (isset($functionMap[$repeatFreq])) {
- $function = $functionMap[$repeatFreq];
- $date->$function();
-
- return $date;
- }
- if ($repeatFreq == 'half-year') {
- $month = intval($date->format('m'));
- $date->startOfYear();
- if ($month >= 7) {
- $date->addMonths(6);
- }
-
- return $date;
- }
- throw new FireflyException('Cannot do startOfPeriod for $repeat_freq ' . $repeatFreq);
- }
-
- /**
- * @param Carbon $theDate
- * @param $repeatFreq
- * @param int $subtract
- *
- * @return Carbon
- * @throws FireflyException
- */
- public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1)
- {
- $date = clone $theDate;
-
- $functionMap = [
- 'daily' => 'subDays',
- 'week' => 'subWeeks',
- 'weekly' => 'subWeeks',
- 'month' => 'subMonths',
- 'monthly' => 'subMonths',
- 'year' => 'subYears',
- 'yearly' => 'subYears',
- ];
- $modifierMap = [
- 'quarter' => 3,
- 'quarterly' => 3,
- 'half-year' => 6,
- ];
- if (isset($functionMap[$repeatFreq])) {
- $function = $functionMap[$repeatFreq];
- $date->$function($subtract);
-
- return $date;
- }
- if (isset($modifierMap[$repeatFreq])) {
- $subtract = $subtract * $modifierMap[$repeatFreq];
- $date->subMonths($subtract);
-
- return $date;
- }
-
- throw new FireflyException('Cannot do subtractPeriod for $repeat_freq ' . $repeatFreq);
- }
-}
-
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Filter.php b/app/lib/FireflyIII/Shared/Toolkit/Filter.php
deleted file mode 100644
index 0602b72624..0000000000
--- a/app/lib/FireflyIII/Shared/Toolkit/Filter.php
+++ /dev/null
@@ -1,253 +0,0 @@
-setSessionRangeValue();
- $start = \Session::has('start') ? \Session::get('start') : new Carbon;
- $start = $this->updateStartDate($range, $start);
- $end = $this->updateEndDate($range, $start);
- $period = $this->periodName($range, $start);
- $prev = $this->previous($range, clone $start);
- $next = $this->next($range, clone $start);
-
- \Session::put('start', $start);
- \Session::put('end', $end);
- \Session::put('range', $range);
- \Session::put('period', $period);
- \Session::put('prev', $this->periodName($range, $prev));
- \Session::put('next', $this->periodName($range, $next));
-
- return null;
-
- }
-
- /**
- * Checks and sets the currently set 'range' or defaults to a session
- * and if that fails, defaults to 1M. Always returns the final value.
- *
- * @return string
- */
- public function setSessionRangeValue()
- {
- if (!is_null(\Session::get('range'))) {
- // @codeCoverageIgnoreStart
- $range = \Session::get('range');
- // @codeCoverageIgnoreEnd
- } else {
- /** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
- $preferences = \App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
- $viewRange = $preferences->get('viewRange', '1M');
-
- // default range:
- $range = $viewRange->data;
- \Session::put('range', $range);
- }
-
- return $range;
-
- }
-
- /**
- * @param $range
- * @param Carbon $start
- *
- * @return Carbon
- * @throws FireflyException
- * @codeCoverageIgnore
- */
- protected function updateStartDate($range, Carbon $start)
- {
- $functionMap = [
- '1D' => 'startOfDay',
- '1W' => 'startOfWeek',
- '1M' => 'startOfMonth',
- '3M' => 'firstOfQuarter',
- '1Y' => 'startOfYear',
- ];
- if (isset($functionMap[$range])) {
- $function = $functionMap[$range];
- $start->$function();
-
- return $start;
- }
- if ($range == '6M') {
- if (intval($start->format('m')) >= 7) {
- $start->startOfYear()->addMonths(6);
- } else {
- $start->startOfYear();
- }
-
- return $start;
- }
- throw new FireflyException('updateStartDate cannot handle $range ' . $range);
- }
-
- /**
- * @param $range
- * @param Carbon $start
- *
- * @return Carbon
- * @throws FireflyException
- * @codeCoverageIgnore
- */
- protected function updateEndDate($range, Carbon $start)
- {
- $functionMap = [
- '1D' => 'endOfDay',
- '1W' => 'endOfWeek',
- '1M' => 'endOfMonth',
- '3M' => 'lastOfQuarter',
- '1Y' => 'endOfYear',
- ];
- $end = clone $start;
-
- if (isset($functionMap[$range])) {
- $function = $functionMap[$range];
- $end->$function();
-
- return $end;
- }
- if ($range == '6M') {
- if (intval($start->format('m')) >= 7) {
- $end->endOfYear();
- } else {
- $end->startOfYear()->addMonths(6);
- }
-
- return $end;
- }
- throw new FireflyException('updateEndDate cannot handle $range ' . $range);
- }
-
- /**
- * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
- *
- * @param $range
- * @param Carbon $date
- *
- * @return string
- * @throws FireflyException
- * @codeCoverageIgnore
- */
- protected function periodName($range, Carbon $date)
- {
- $formatMap = [
- '1D' => 'jS F Y',
- '1W' => '\w\e\ek W, Y',
- '1M' => 'F Y',
- '1Y' => 'Y',
- ];
- if (isset($formatMap[$range])) {
- return $date->format($formatMap[$range]);
- }
- if ($range == '3M') {
- $month = intval($date->format('m'));
-
- return 'Q' . ceil(($month / 12) * 4) . ' ' . $date->format('Y');
- }
- if ($range == '6M') {
- $month = intval($date->format('m'));
- $half = ceil(($month / 12) * 2);
- $halfName = $half == 1 ? 'first' : 'second';
-
- return $halfName . ' half of ' . $date->format('d-m-Y');
- }
- throw new FireflyException('No _periodName() for range "' . $range . '"');
- }
-
- /**
- * @param $range
- * @param Carbon $date
- *
- * @return Carbon
- * @throws FireflyException
- */
- public function previous($range, Carbon $date)
- {
- $functionMap = [
- '1D' => 'Day',
- '1W' => 'Week',
- '1M' => 'Month',
- '1Y' => 'Year'
- ];
-
- if (isset($functionMap[$range])) {
- $startFunction = 'startOf' . $functionMap[$range];
- $subFunction = 'sub' . $functionMap[$range];
- $date->$startFunction()->$subFunction();
-
- return $date;
- }
- if ($range == '3M') {
- $date->firstOfQuarter()->subMonths(3)->firstOfQuarter();
-
- return $date;
- }
- if ($range == '6M') {
- $month = intval($date->format('m'));
- $date->startOfYear();
- if ($month <= 6) {
- $date->subMonths(6);
- }
-
- return $date;
- }
- throw new FireflyException('Cannot do _previous() on ' . $range);
- }
-
- /**
- * @param $range
- * @param Carbon $date
- *
- * @return Carbon
- * @throws FireflyException
- */
- public function next($range, Carbon $date)
- {
- switch ($range) {
- case '1D':
- $date->endOfDay()->addDay();
- break;
- case '1W':
- $date->endOfWeek()->addDay()->startOfWeek();
- break;
- case '1M':
- $date->endOfMonth()->addDay()->startOfMonth();
- break;
- case '3M':
- $date->lastOfQuarter()->addDay();
- break;
- case '6M':
- if (intval($date->format('m')) >= 7) {
- $date->startOfYear()->addYear();
- } else {
- $date->startOfYear()->addMonths(6);
- }
- break;
- case '1Y':
- $date->startOfYear()->addYear();
- break;
- default:
- throw new FireflyException('Cannot do _next() on ' . $range);
- break;
- }
-
- return $date;
- }
-}
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Form.php b/app/lib/FireflyIII/Shared/Toolkit/Form.php
deleted file mode 100644
index 1f51fe357a..0000000000
--- a/app/lib/FireflyIII/Shared/Toolkit/Form.php
+++ /dev/null
@@ -1,47 +0,0 @@
-id);
- $title = null;
-
- foreach ($fields as $field) {
- if (isset($entry->$field)) {
- $title = $entry->$field;
- }
- }
- $selectList[$id] = $title;
- }
-
-
- return $selectList;
- }
-}
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Navigation.php b/app/lib/FireflyIII/Shared/Toolkit/Navigation.php
deleted file mode 100644
index ce99351190..0000000000
--- a/app/lib/FireflyIII/Shared/Toolkit/Navigation.php
+++ /dev/null
@@ -1,69 +0,0 @@
-setSessionRangeValue();
- $start = \Session::get('start', Carbon::now()->startOfMonth());
-
- /*
- * Add some period to $start.
- */
- $next = $filter->next($range, clone $start);
-
- /*
- * Save in session:
- */
- \Session::put('start', $next);
-
- return true;
- }
-
- /**
- * @return bool
- * @throws FireflyException
- */
- public function prev()
- {
- /*
- * Get the start date and the range from the session
- */
- $filter = new Filter;
-
- $range = $filter->setSessionRangeValue();
- $start = \Session::get('start', Carbon::now()->startOfMonth());
-
- /*
- * Subtract some period to $start.
- */
- $prev = $filter->previous($range, clone $start);
-
- /*
- * Save in session:
- */
- \Session::put('start', $prev);
-
- return true;
- }
-}
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php b/app/lib/FireflyIII/Shared/Toolkit/Reminders.php
deleted file mode 100644
index 11b75259e1..0000000000
--- a/app/lib/FireflyIII/Shared/Toolkit/Reminders.php
+++ /dev/null
@@ -1,106 +0,0 @@
-remindersable)) {
-
- case 'PiggyBank':
- $start = new Carbon;
- $end = !is_null($reminder->remindersable->targetdate) ? clone $reminder->remindersable->targetdate : new Carbon;
- $reminders = 0;
- while ($start <= $end) {
- $reminders++;
- $start = \DateKit::addPeriod($start, $reminder->remindersable->reminder, $reminder->remindersable->reminder_skip);
- }
- /*
- * Now find amount yet to save.
- */
- $repetition = $reminder->remindersable->currentRelevantRep();
- $leftToSave = floatval($reminder->remindersable->targetamount) - floatval($repetition->currentamount);
- $reminders = $reminders == 0 ? 1 : $reminders;
-
- return $leftToSave / $reminders;
- break;
- default:
- throw new FireflyException('Cannot handle class ' . get_class($reminder->remindersable) . ' in amountForReminder.');
- break;
- }
- }
-
- /**
- *
- */
- public function getReminders()
- {
- $reminders = \Auth::user()->reminders()
- ->where('active', 1)
- ->where('startdate', '<=', Carbon::now()->format('Y-m-d'))
- ->where('enddate', '>=', Carbon::now()->format('Y-m-d'))
- ->get();
-
- return $reminders;
- }
-
- /**
- * @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
- */
- public function updateReminders()
- {
- /** @var Collection $set */
- $set = \PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
- ->where('accounts.user_id', \Auth::user()->id)
- ->whereNotNull('reminder')->get(['piggy_banks.*']);
-
-
- $today = Carbon::now();
-
- /** @var \PiggyBank $piggyBank */
- foreach ($set as $piggyBank) {
- /** @var \PiggyBankRepetition $repetition */
- $repetition = $piggyBank->currentRelevantRep();
- $start = \DateKit::startOfPeriod($today, $piggyBank->reminder);
- if ($repetition->targetdate && $repetition->targetdate <= $today) {
- // break when no longer relevant:
- continue;
- }
- $end = \DateKit::endOfPeriod(clone $start, $piggyBank->reminder);
- // should have a reminder for this period:
- /** @var Collection $reminders */
- $reminders = $piggyBank->reminders()->dateIs($start, $end)->get();
- if ($reminders->count() == 0) {
- // create new!
- $reminder = new \Reminder;
- $reminder->startdate = $start;
- $reminder->enddate = $end;
- $reminder->active = 1;
- $reminder->user()->associate(\Auth::getUser());
- $reminder->remindersable_id = $piggyBank->id;
- $reminder->remindersable_type = 'PiggyBank';
- $reminder->save();
- }
- }
- }
-}
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Steam.php b/app/lib/FireflyIII/Shared/Toolkit/Steam.php
deleted file mode 100644
index 584fa13ee8..0000000000
--- a/app/lib/FireflyIII/Shared/Toolkit/Steam.php
+++ /dev/null
@@ -1,85 +0,0 @@
-transactions()->leftJoin(
- 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
- )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
- );
-
- return $balance;
- }
-
- /**
- * @codeCoverageIgnore
- * @param $boolean
- *
- * @return string
- */
- public function boolString($boolean)
- {
- if ($boolean === true) {
- return 'BOOLEAN TRUE';
- }
- if ($boolean === false) {
- return 'BOOLEAN FALSE';
- }
-
- return 'NO BOOLEAN: ' . $boolean;
- }
-
- /**
- * @param \PiggyBank $piggyBank
- * @param \PiggyBankRepetition $repetition
- *
- * @return int
- */
- public function percentage(\PiggyBank $piggyBank, \PiggyBankRepetition $repetition)
- {
- $pct = $repetition->currentamount / $piggyBank->targetamount * 100;
- if ($pct > 100) {
- // @codeCoverageIgnoreStart
- return 100;
- // @codeCoverageIgnoreEnd
- } else {
- return floor($pct);
- }
- }
-
- /**
- * @codeCoverageIgnore
- * @throws \Exception
- */
- public function removeEmptyBudgetLimits()
- {
- $user = \Auth::user();
- if ($user) {
- \BudgetLimit::where('amount', 0)->delete();
- }
- }
-
-}
diff --git a/app/lib/FireflyIII/Shared/Validation/FireflyValidator.php b/app/lib/FireflyIII/Shared/Validation/FireflyValidator.php
deleted file mode 100644
index 33795d563b..0000000000
--- a/app/lib/FireflyIII/Shared/Validation/FireflyValidator.php
+++ /dev/null
@@ -1,31 +0,0 @@
-app->validator->resolver(
- function ($translator, $data, $rules, $messages) {
- return new FireflyValidator($translator, $data, $rules, $messages);
- }
- );
- }
-
- public function register()
- {
- }
-}
diff --git a/app/models/Account.php b/app/models/Account.php
deleted file mode 100644
index 9bf3bbe4a9..0000000000
--- a/app/models/Account.php
+++ /dev/null
@@ -1,156 +0,0 @@
- [
- 'name' => 'required|between:1,100',
- 'user_id' => 'required|exists:users,id',
- 'account_type_id' => 'required|exists:account_types,id',
- 'active' => 'required|boolean'
- ],
- 'form_input' => [
- 'name' => 'required|between:1,100',
- 'active' => 'required|boolean',
- ]
- ];
-
- /**
- * Account type.
- *
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function accountType()
- {
- return $this->belongsTo('AccountType');
- }
-
- /**
- *
- * @param $fieldName
- *
- * @return mixed
- */
- public function getMeta($fieldName)
- {
- foreach ($this->accountMeta as $meta) {
- if ($meta->name == $fieldName) {
- return $meta->data;
- }
- }
-
- return null;
-
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function piggyBanks()
- {
- return $this->hasMany('PiggyBank');
- }
-
- /**
- *
- * @param EloquentBuilder $query
- * @param array $types
- */
- public function scopeAccountTypeIn(EloquentBuilder $query, array $types)
- {
- if (is_null($this->joinedAccountTypes)) {
- $query->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id');
- $this->joinedAccountTypes = true;
- }
- $query->whereIn('account_types.type', $types);
- }
-
- /**
- *
- * @param EloquentBuilder $query
- * @param string $field
- */
- public function scopeWithMeta(EloquentBuilder $query, $field = 'accountRole')
- {
- $query->leftJoin(
- 'account_meta', function (JoinClause $join) use ($field) {
- $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', $field);
- }
- );
- }
-
- /**
- * Transactions.
- *
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function transactions()
- {
- return $this->hasMany('Transaction');
- }
-
- /**
- * @param $fieldName
- * @param $fieldValue
- *
- * @return AccountMeta
- */
- public function updateMeta($fieldName, $fieldValue)
- {
- $meta = $this->accountMeta()->get();
- /** @var AccountMeta $entry */
- foreach ($meta as $entry) {
- if ($entry->name == $fieldName) {
- $entry->data = $fieldValue;
- $entry->save();
-
- return $entry;
- }
- }
- $meta = new AccountMeta;
- $meta->account()->associate($this);
- $meta->name = $fieldName;
- $meta->data = $fieldValue;
- $meta->save();
-
- return $meta;
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function accountMeta()
- {
- return $this->hasMany('AccountMeta');
- }
-
- /**
- * User
- *
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('User');
- }
-
-
-}
diff --git a/app/models/AccountMeta.php b/app/models/AccountMeta.php
deleted file mode 100644
index 5a481a2c90..0000000000
--- a/app/models/AccountMeta.php
+++ /dev/null
@@ -1,51 +0,0 @@
- 'numeric|required|exists:accounts,id',
- 'name' => 'required|between:1,250',
- 'data' => 'required'
- ];
- /**
- * @var array
- */
- protected $fillable = ['account_id', 'name', 'date'];
- protected $table = 'account_meta';
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function account()
- {
- return $this->belongsTo('Account');
- }
-
- /**
- * @param $value
- *
- * @return mixed
- */
- public function getDataAttribute($value)
- {
- return json_decode($value);
- }
-
- /**
- * @param $value
- */
- public function setDataAttribute($value)
- {
- $this->attributes['data'] = json_encode($value);
- }
-
-}
diff --git a/app/models/AccountType.php b/app/models/AccountType.php
deleted file mode 100644
index eb3f495e87..0000000000
--- a/app/models/AccountType.php
+++ /dev/null
@@ -1,25 +0,0 @@
- ['required', 'between:1,50', 'alphabasic'],
- 'editable' => 'required|boolean',
-
- ];
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function accounts()
- {
- return $this->hasMany('Account');
- }
-}
diff --git a/app/models/Bill.php b/app/models/Bill.php
deleted file mode 100644
index bc5500ebe2..0000000000
--- a/app/models/Bill.php
+++ /dev/null
@@ -1,49 +0,0 @@
- 'required|exists:users,id',
- 'name' => 'required|between:1,255|min:1',
- 'match' => 'required',
- 'amount_max' => 'required|between:0,65536',
- 'amount_min' => 'required|between:0,65536',
- 'date' => 'required|date',
- 'active' => 'between:0,1',
- 'automatch' => 'between:0,1',
- 'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
- 'skip' => 'required|between:0,31',];
- protected $fillable = ['user_id', 'name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'active', 'automatch'];
- /**
- * @return array
- */
- public function getDates()
- {
- return ['created_at', 'updated_at', 'date'];
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function transactionjournals()
- {
- return $this->hasMany('TransactionJournal');
- }
-
-
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('User');
- }
-}
diff --git a/app/models/Budget.php b/app/models/Budget.php
deleted file mode 100644
index 83368d9143..0000000000
--- a/app/models/Budget.php
+++ /dev/null
@@ -1,50 +0,0 @@
- 'exists:users,id|required',
- 'name' => 'required|between:1,100|alphabasic',
- ];
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
- */
- public function limitrepetitions()
- {
- return $this->hasManyThrough('LimitRepetition', 'BudgetLimit', 'budget_id');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function budgetlimits()
- {
- return $this->hasMany('BudgetLimit');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
- */
- public function transactionjournals()
- {
- return $this->belongsToMany('TransactionJournal', 'budget_transaction_journal', 'budget_id');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('User');
- }
-
-}
diff --git a/app/models/BudgetLimit.php b/app/models/BudgetLimit.php
deleted file mode 100644
index 192639fda8..0000000000
--- a/app/models/BudgetLimit.php
+++ /dev/null
@@ -1,49 +0,0 @@
- 'required|exists:budgets,id',
- 'startdate' => 'required|date',
- 'amount' => 'numeric|required|min:0.01',
- 'repeats' => 'required|boolean',
- 'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly'
-
- ];
-
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function budget()
- {
- return $this->belongsTo('Budget');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function limitrepetitions()
- {
- return $this->hasMany('LimitRepetition');
- }
-
-
- /**
- * @return array
- */
- public function getDates()
- {
- return ['created_at', 'updated_at', 'startdate', 'enddate'];
- }
-
-
-}
diff --git a/app/models/Category.php b/app/models/Category.php
deleted file mode 100644
index dab2639a0b..0000000000
--- a/app/models/Category.php
+++ /dev/null
@@ -1,49 +0,0 @@
- 'exists:users,id|required',
- 'name' => 'required|between:1,100|alphabasic',
- ];
-
- /**
- * remove this method in favour of something in the FireflyIII libraries.
- *
- * @return Carbon
- */
- public function lastActionDate()
- {
- $transaction = $this->transactionjournals()->orderBy('updated_at', 'DESC')->first();
- if (is_null($transaction)) {
- return null;
- }
-
- return $transaction->date;
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
- */
- public function transactionjournals()
- {
- return $this->belongsToMany('TransactionJournal', 'category_transaction_journal', 'category_id');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('User');
- }
-}
diff --git a/app/models/Component.php b/app/models/Component.php
deleted file mode 100644
index e09edbe19b..0000000000
--- a/app/models/Component.php
+++ /dev/null
@@ -1,20 +0,0 @@
- 'exists:users,id|required',
- 'name' => 'required|between:1,100|alphabasic',
- 'class' => 'required',
- ];
- protected $dates = ['deleted_at', 'created_at', 'updated_at'];
- protected $fillable = ['name', 'user_id','class'];
- protected $table = 'components';
- use ValidatingTrait;
-}
diff --git a/app/models/LimitRepetition.php b/app/models/LimitRepetition.php
deleted file mode 100644
index afb0b3c439..0000000000
--- a/app/models/LimitRepetition.php
+++ /dev/null
@@ -1,54 +0,0 @@
- 'required|exists:budgetlimits,id',
- 'startdate' => 'required|date',
- 'enddate' => 'required|date',
- 'amount' => 'numeric|required|min:0.01',
- ];
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function budgetLimit()
- {
- return $this->belongsTo('BudgetLimit');
- }
-
- /**
- * @return array
- */
- public function getDates()
- {
- return ['created_at', 'updated_at', 'startdate', 'enddate'];
- }
-
- /**
- *
- * @return float
- */
- public function spentInRepetition()
- {
- $sum = \DB::table('transactions')
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
- ->leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budget_transaction_journal.budget_id')
- ->leftJoin('limit_repetitions', 'limit_repetitions.budget_limit_id', '=', 'budget_limits.id')
- ->where('transaction_journals.date', '>=', $this->startdate->format('Y-m-d'))
- ->where('transaction_journals.date', '<=', $this->enddate->format('Y-m-d'))
- ->where('transactions.amount', '>', 0)
- ->where('limit_repetitions.id', '=', $this->id)
- ->sum('transactions.amount');
-
- return floatval($sum);
- }
-}
diff --git a/app/models/Piggybank.php b/app/models/Piggybank.php
deleted file mode 100644
index 49e7563445..0000000000
--- a/app/models/Piggybank.php
+++ /dev/null
@@ -1,127 +0,0 @@
- 'required|exists:accounts,id', // link to Account
- 'name' => 'required|between:1,255', // name
- 'targetamount' => 'required|min:0.01|numeric', // amount you want to save
- 'startdate' => 'date', // when you started
- 'targetdate' => 'date', // when its due
- 'repeats' => 'required|boolean', // does it repeat?
- 'rep_length' => 'in:day,week,month,quarter,year', // how long is the period?
- 'rep_every' => 'required|min:1|max:100', // how often does it repeat? every 3 years.
- 'rep_times' => 'min:1|max:100', // how many times do you want to save this amount? eg. 3 times
- 'reminder' => 'in:day,week,quarter,month,year', // want a reminder to put money in this?
- 'reminder_skip' => 'required|min:0|max:100', // every week? every 2 months?
- 'remind_me' => 'required|boolean', 'order' => 'required:min:1', // not yet used.
- ];
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function account()
- {
- return $this->belongsTo('Account');
- }
-
- /**
- * Grabs the PiggyBankRepetition that's currently relevant / active
- *
- * @returns \PiggyBankRepetition
- */
- public function currentRelevantRep()
- {
- if ($this->currentRep) {
- return $this->currentRep;
- }
- if ($this->repeats == 0) {
- $rep = $this->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
- $this->currentRep = $rep;
-
- return $rep;
- } else {
- $query = $this->piggyBankRepetitions()->where(
- function (EloquentBuilder $q) {
-
- $q->where(
- function (EloquentBuilder $q) {
-
- $q->where(
- function (EloquentBuilder $q) {
- $today = new Carbon;
- $q->whereNull('startdate');
- $q->orWhere('startdate', '<=', $today->format('Y-m-d 00:00:00'));
- }
- )->where(
- function (EloquentBuilder $q) {
- $today = new Carbon;
- $q->whereNull('targetdate');
- $q->orWhere('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
- }
- );
- }
- )->orWhere(
- function (EloquentBuilder $q) {
- $today = new Carbon;
- $q->where('startdate', '>=', $today->format('Y-m-d 00:00:00'));
- $q->where('targetdate', '>=', $today->format('Y-m-d 00:00:00'));
- }
- );
-
- }
- )->orderBy('startdate', 'ASC');
- $result = $query->first(['piggy_bank_repetitions.*']);
- $this->currentRep = $result;
- \Log::debug('Found relevant rep in currentRelevantRep(): ' . $result->id);
-
- return $result;
- }
-
-
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function piggyBankRepetitions()
- {
- return $this->hasMany('PiggyBankRepetition');
- }
-
- /**
- * @return array
- */
- public function getDates()
- {
- return ['created_at', 'updated_at', 'targetdate', 'startdate'];
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function piggyBankEvents()
- {
- return $this->hasMany('PiggyBankEvent');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\MorphMany
- */
- public function reminders()
- {
- return $this->morphMany('Reminder', 'remindersable');
- }
-}
diff --git a/app/models/PiggybankEvent.php b/app/models/PiggybankEvent.php
deleted file mode 100644
index 1861c45319..0000000000
--- a/app/models/PiggybankEvent.php
+++ /dev/null
@@ -1,42 +0,0 @@
- 'required|exists:piggy_banks,id',
- 'date' => 'required|date',
- 'amount' => 'required|numeric'
- ];
- use ValidatingTrait;
-
- /**
- * @return array
- */
- public function getDates()
- {
- return ['created_at', 'updated_at', 'date'];
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function piggyBank()
- {
- return $this->belongsTo('PiggyBank');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function transactionJournal()
- {
- return $this->belongsTo('TransactionJournal');
- }
-
-}
diff --git a/app/models/PiggybankRepetition.php b/app/models/PiggybankRepetition.php
deleted file mode 100644
index e38eabd4b4..0000000000
--- a/app/models/PiggybankRepetition.php
+++ /dev/null
@@ -1,54 +0,0 @@
- 'required|exists:piggy_banks,id',
- 'targetdate' => 'date',
- 'startdate' => 'date',
- 'currentamount' => 'required|numeric'];
-
- /**
- * @return array
- */
- public function getDates()
- {
- return ['created_at', 'updated_at', 'targetdate', 'startdate'];
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function piggyBank()
- {
- return $this->belongsTo('PiggyBank');
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Carbon $date
- */
- public function scopeStarts(EloquentBuilder $query, Carbon $date)
- {
- $query->where('startdate', $date->format('Y-m-d 00:00:00'));
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Carbon $date
- */
- public function scopeTargets(EloquentBuilder $query, Carbon $date)
- {
- $query->where('targetdate', $date->format('Y-m-d 00:00:00'));
- }
-
-
-}
diff --git a/app/models/Preference.php b/app/models/Preference.php
deleted file mode 100644
index b3e12a7ec6..0000000000
--- a/app/models/Preference.php
+++ /dev/null
@@ -1,41 +0,0 @@
- 'required|exists:users,id', 'name' => 'required|between:1,255', 'data' => 'required'];
-
- /**
- * @param $value
- *
- * @return mixed
- */
- public function getDataAttribute($value)
- {
- return json_decode($value);
- }
-
- /**
- * @param $value
- */
- public function setDataAttribute($value)
- {
- $this->attributes['data'] = json_encode($value);
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('User');
- }
-
-}
diff --git a/app/models/Reminder.php b/app/models/Reminder.php
deleted file mode 100644
index b9c7b326b8..0000000000
--- a/app/models/Reminder.php
+++ /dev/null
@@ -1,58 +0,0 @@
-morphTo();
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return mixed
- */
- public function scopeDateIs(EloquentBuilder $query, Carbon $start, Carbon $end)
- {
- return $query->where('startdate', $start->format('Y-m-d 00:00:00'))->where('enddate', $end->format('Y-m-d 00:00:00'));
- }
-
- /**
- * User
- *
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('User');
- }
-
-
-}
diff --git a/app/models/Transaction.php b/app/models/Transaction.php
deleted file mode 100644
index bb5c423bec..0000000000
--- a/app/models/Transaction.php
+++ /dev/null
@@ -1,114 +0,0 @@
- 'numeric|required|exists:accounts,id',
- 'transaction_journal_id' => 'numeric|required|exists:transaction_journals,id',
- 'description' => 'between:1,255',
- 'amount' => 'required|between:-65536,65536|not_in:0,0.00',];
-
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function account()
- {
- return $this->belongsTo('Account');
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Account $account
- */
- public function scopeAccountIs(EloquentBuilder $query, Account $account)
- {
- $query->where('transactions.account_id', $account->id);
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Carbon $date
- */
- public function scopeAfter(EloquentBuilder $query, Carbon $date)
- {
- if (is_null($this->joinedJournals)) {
- $query->leftJoin(
- 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
- );
- $this->joinedJournals = true;
- }
- $query->where('transaction_journals.date', '>=', $date->format('Y-m-d'));
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Carbon $date
- */
- public function scopeBefore(EloquentBuilder $query, Carbon $date)
- {
- if (is_null($this->joinedJournals)) {
- $query->leftJoin(
- 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
- );
- $this->joinedJournals = true;
- }
- $query->where('transaction_journals.date', '<=', $date->format('Y-m-d'));
- }
-
- /**
- * @param EloquentBuilder $query
- * @param $amount
- */
- public function scopeLessThan(EloquentBuilder $query, $amount)
- {
- $query->where('amount', '<', $amount);
- }
-
- /**
- * @param EloquentBuilder $query
- * @param $amount
- */
- public function scopeMoreThan(EloquentBuilder $query, $amount)
- {
- $query->where('amount', '>', $amount);
- }
-
- /**
- * @param EloquentBuilder $query
- * @param array $types
- */
- public function scopeTransactionTypes(EloquentBuilder $query, array $types)
- {
- if (is_null($this->joinedJournals)) {
- $query->leftJoin(
- 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
- );
- $this->joinedJournals = true;
- }
- if (is_null($this->joinedTransactionTypes)) {
- $query->leftJoin(
- 'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
- );
- $this->joinedTransactionTypes = true;
- }
- $query->whereIn('transaction_types.type', $types);
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function transactionJournal()
- {
- return $this->belongsTo('TransactionJournal');
- }
-}
diff --git a/app/models/TransactionCurrency.php b/app/models/TransactionCurrency.php
deleted file mode 100644
index a72d8168df..0000000000
--- a/app/models/TransactionCurrency.php
+++ /dev/null
@@ -1,29 +0,0 @@
- 'required|alpha|between:3,3|min:3|max:3',
- 'name' => 'required|between:3,48|min:3|max:48',
- 'symbol' => 'required|between:1,8|min:1|max:8',
- ];
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function transactionJournals()
- {
- return $this->hasMany('TransactionJournal');
- }
-
-}
diff --git a/app/models/TransactionGroup.php b/app/models/TransactionGroup.php
deleted file mode 100644
index dea100af17..0000000000
--- a/app/models/TransactionGroup.php
+++ /dev/null
@@ -1,45 +0,0 @@
- 'required|in:balance'
- ];
-
- /**
- * @return array
- */
- public function getDates()
- {
- return ['created_at', 'updated_at'];
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function transactionjournals()
- {
- return $this->belongsToMany('TransactionJournal');
- }
-
- /**
- * User
- *
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('User');
- }
-
-
-}
diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php
deleted file mode 100644
index da22e42fe9..0000000000
--- a/app/models/TransactionJournal.php
+++ /dev/null
@@ -1,267 +0,0 @@
- 'required|exists:transaction_types,id',
- 'transaction_currency_id' => 'required|exists:transaction_currencies,id',
- 'description' => 'required|between:1,1024',
- 'date' => 'required|date',
- 'completed' => 'required|between:0,1'];
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function bill()
- {
- return $this->belongsTo('Bill');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
- */
- public function budgets()
- {
- return $this->belongsToMany(
- 'Budget'
- );
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
- */
- public function categories()
- {
- return $this->belongsToMany(
- 'Category'
- );
- }
-
- /**
- * @param Account $account
- *
- * @return float
- */
- public function getAmount(\Account $account = null)
- {
- $amount = 0;
- foreach ($this->transactions as $t) {
- if (!is_null($account) && $account->id == $t->account_id) {
- $amount = floatval($t->amount);
- break;
- }
- if (floatval($t->amount) > 0) {
- $amount = floatval($t->amount);
- break;
- }
- }
-
- return $amount;
- }
-
- /**
- * @return array
- */
- public function getDates()
- {
- return ['created_at', 'updated_at', 'date'];
- }
-
- /**
- * @param $value
- *
- * @return string
- */
- public function getDescriptionAttribute($value)
- {
- if ($this->encrypted) {
- return Crypt::decrypt($value);
- }
- // @codeCoverageIgnoreStart
- return $value;
- // @codeCoverageIgnoreEnd
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function piggyBankEvents()
- {
- return $this->hasMany('PiggyBankEvent');
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Account $account
- */
- public function scopeAccountIs(EloquentBuilder $query, \Account $account)
- {
- if (!isset($this->joinedTransactions)) {
- $query->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id');
- $this->joinedTransactions = true;
- }
- $query->where('transactions.account_id', $account->id);
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Carbon $date
- *
- * @return mixed
- */
- public function scopeAfter(EloquentBuilder $query, Carbon $date)
- {
- return $query->where('transaction_journals.date', '>=', $date->format('Y-m-d 00:00:00'));
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Carbon $date
- *
- * @return mixed
- */
- public function scopeBefore(EloquentBuilder $query, Carbon $date)
- {
- return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
- }
-
- /**
- * @param EloquentBuilder $query
- * @param $amount
- */
- public function scopeLessThan(EloquentBuilder $query, $amount)
- {
- if (is_null($this->joinedTransactions)) {
- $query->leftJoin(
- 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
- );
- $this->joinedTransactions = true;
- }
-
- $query->where('transactions.amount', '<=', $amount);
- }
-
- /**
- * @param EloquentBuilder $query
- * @param $amount
- */
- public function scopeMoreThan(EloquentBuilder $query, $amount)
- {
- if (is_null($this->joinedTransactions)) {
- $query->leftJoin(
- 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
- );
- $this->joinedTransactions = true;
- }
-
- $query->where('transactions.amount', '>=', $amount);
- }
-
- /**
- * @param EloquentBuilder $query
- * @param Carbon $date
- *
- * @return mixed
- */
- public function scopeOnDate(EloquentBuilder $query, Carbon $date)
- {
- return $query->where('date', '=', $date->format('Y-m-d'));
- }
-
- /**
- * @param EloquentBuilder $query
- * @param array $types
- */
- public function scopeTransactionTypes(EloquentBuilder $query, array $types)
- {
- if (is_null($this->joinedTransactionTypes)) {
- $query->leftJoin(
- 'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
- );
- $this->joinedTransactionTypes = true;
- }
- $query->whereIn('transaction_types.type', $types);
- }
-
- /**
- * Automatically includes the 'with' parameters to get relevant related
- * objects.
- *
- * @param EloquentBuilder $query
- */
- public function scopeWithRelevantData(EloquentBuilder $query)
- {
- $query->with(
- ['transactions' => function (HasMany $q) {
- $q->orderBy('amount', 'ASC');
- }, 'transactiontype', 'budgets', 'categories', 'transactions.account.accounttype', 'bill', 'budgets', 'categories']
- );
- }
-
- /**
- * @param $value
- */
- public function setDescriptionAttribute($value)
- {
- $this->attributes['description'] = Crypt::encrypt($value);
- $this->attributes['encrypted'] = true;
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function transactionCurrency()
- {
- return $this->belongsTo('TransactionCurrency');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function transactionType()
- {
- return $this->belongsTo('TransactionType');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
- */
- public function transactiongroups()
- {
- return $this->belongsToMany('TransactionGroup');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function transactions()
- {
- return $this->hasMany('Transaction');
- }
-
- /**
- * User
- *
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('User');
- }
-
-}
diff --git a/app/models/TransactionRelation.php b/app/models/TransactionRelation.php
deleted file mode 100644
index cd34f354e9..0000000000
--- a/app/models/TransactionRelation.php
+++ /dev/null
@@ -1,10 +0,0 @@
-hasMany('TransactionJournal');
- }
-
-}
diff --git a/app/models/User.php b/app/models/User.php
deleted file mode 100644
index a3dc1a47ce..0000000000
--- a/app/models/User.php
+++ /dev/null
@@ -1,102 +0,0 @@
- 'required|email|unique:users,email',
- 'password' => 'required|between:60,60',
- 'reset' => 'between:32,32',
- ];
- protected $table = 'users';
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function accounts()
- {
- return $this->hasMany('Account');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function bills()
- {
- return $this->hasMany('Bill');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function budgets()
- {
- return $this->hasMany('Budget');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function categories()
- {
- return $this->hasMany('Category');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
- */
- public function piggyBanks()
- {
- return $this->hasManyThrough('PiggyBank', 'Account');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function preferences()
- {
- return $this->hasMany('Preference');
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function reminders()
- {
- return $this->hasMany('Reminder');
- }
-
- /**
- * @param $value
- */
- public function setPasswordAttribute($value)
- {
- $this->attributes['password'] = Hash::make($value);
- }
-
- /**
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function transactionjournals()
- {
- return $this->hasMany('TransactionJournal');
- }
-
-
-}
diff --git a/app/routes.php b/app/routes.php
deleted file mode 100644
index 1f534f5811..0000000000
--- a/app/routes.php
+++ /dev/null
@@ -1,408 +0,0 @@
-where('account_types.editable', 1)
- ->where('accounts.id', $value)
- ->where('user_id', Auth::user()->id)
- ->first(['accounts.*']);
- if ($account) {
- return $account;
- }
- }
- App::abort(404);
- }
-);
-
-Route::bind(
- 'accountname', function ($value, $route) {
- if (Auth::check()) {
- return Account::
- leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')->where('account_types.editable', 1)->where('name', $value)->where(
- 'user_id', Auth::user()->id
- )->first();
- }
-
- return null;
-}
-);
-
-
-Route::bind(
- 'bill', function ($value, $route) {
- if (Auth::check()) {
- return Bill::
- where('id', $value)->where('user_id', Auth::user()->id)->first();
- }
-
- return null;
-}
-);
-Route::bind(
- 'budget', function ($value, $route) {
- if (Auth::check()) {
- return Budget::
- where('id', $value)->where('user_id', Auth::user()->id)->first();
- }
-
- return null;
-}
-);
-
-Route::bind(
- 'component', function ($value, $route) {
- if (Auth::check()) {
- return Component::
- where('id', $value)->where('user_id', Auth::user()->id)->first();
- }
-
- return null;
-}
-);
-
-Route::bind(
- 'reminder', function ($value, $route) {
- if (Auth::check()) {
- return Reminder::
- where('id', $value)->where('user_id', Auth::user()->id)->first();
- }
-
- return null;
-}
-);
-
-Route::bind(
- 'category', function ($value, $route) {
- if (Auth::check()) {
- return Category::
- where('id', $value)->where('user_id', Auth::user()->id)->first();
- }
-
- return null;
-}
-);
-
-Route::bind(
- 'tj', function ($value, $route) {
- if (Auth::check()) {
- return TransactionJournal::
- where('id', $value)->where('user_id', Auth::user()->id)->first();
- }
-
- return null;
-}
-);
-Route::bind(
- 'tjSecond', function ($value, $route) {
- if (Auth::check()) {
- return TransactionJournal::
- where('id', $value)->where('user_id', Auth::user()->id)->first();
- }
-
- return null;
-}
-);
-
-Route::bind(
- 'currency', function ($value, $route) {
- return TransactionCurrency::find($value);
-}
-);
-
-Route::bind(
- 'limitrepetition', function ($value, $route) {
- if (Auth::check()) {
- return LimitRepetition::where('limit_repetitions.id', $value)
- ->leftjoin('budget_limits', 'budget_limits.id', '=', 'limit_repetitions.budget_limit_id')
- ->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
- ->where('budgets.user_id', Auth::user()->id)
- ->first(['limit_repetitions.*']);
- }
-
- return null;
-}
-);
-
-Route::bind(
- 'piggyBank', function ($value, $route) {
- if (Auth::check()) {
- return PiggyBank::
- where('piggy_banks.id', $value)
- ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
- ->where('accounts.user_id', Auth::user()->id)
- ->where('repeats', 0)->first(['piggy_banks.*']);
- }
-
- return null;
-}
-);
-
-Route::bind(
- 'repeatedExpense', function ($value, $route) {
- if (Auth::check()) {
- return PiggyBank::
- where('piggy_banks.id', $value)
- ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
- ->where('accounts.user_id', Auth::user()->id)
- ->where('repeats', 1)->first(['piggy_banks.*']);
- }
-
- return null;
-}
-);
-
-Route::bind(
- 'repeated', function ($value, $route) {
- if (Auth::check()) {
- return PiggyBank::
- where('piggy_banks.id', $value)
- ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
- ->where('accounts.user_id', Auth::user()->id)
- ->where('repeats', 1)->first(['piggy_banks.*']);
- }
-
- return null;
-}
-);
-
-// protected routes:
-Route::group(
- ['before' => 'auth'], function () {
-
-
- // some date routes used for (well duh) date-based navigation.
- Route::get('/prev', ['uses' => 'HomeController@sessionPrev', 'as' => 'sessionPrev']);
- Route::get('/next', ['uses' => 'HomeController@sessionNext', 'as' => 'sessionNext']);
- Route::get('/jump/{range}', ['uses' => 'HomeController@rangeJump', 'as' => 'rangeJump']);
-
-
- // account controller:
- Route::get('/accounts/{what}', ['uses' => 'AccountController@index', 'as' => 'accounts.index'])->where('what', 'revenue|asset|expense');
- Route::get('/accounts/create/{what}', ['uses' => 'AccountController@create', 'as' => 'accounts.create'])->where('what', 'revenue|asset|expense');
- Route::get('/accounts/edit/{account}', ['uses' => 'AccountController@edit', 'as' => 'accounts.edit']);
- Route::get('/accounts/delete/{account}', ['uses' => 'AccountController@delete', 'as' => 'accounts.delete']);
- Route::get('/accounts/show/{account}/{view?}', ['uses' => 'AccountController@show', 'as' => 'accounts.show']);
-
-
- // budget controller:
- Route::get('/budgets', ['uses' => 'BudgetController@index', 'as' => 'budgets.index']);
- Route::get('/budgets/income', ['uses' => 'BudgetController@updateIncome', 'as' => 'budgets.income']); # extra.
- Route::get('/budgets/create', ['uses' => 'BudgetController@create', 'as' => 'budgets.create']);
- Route::get('/budgets/edit/{budget}', ['uses' => 'BudgetController@edit', 'as' => 'budgets.edit']);
- Route::get('/budgets/delete/{budget}', ['uses' => 'BudgetController@delete', 'as' => 'budgets.delete']);
- Route::get('/budgets/show/{budget}/{limitrepetition?}', ['uses' => 'BudgetController@show', 'as' => 'budgets.show']);
- Route::get('/budgets/list/noBudget', ['uses' => 'BudgetController@noBudget', 'as' => 'budgets.noBudget']);
-
- // category controller:
- Route::get('/categories', ['uses' => 'CategoryController@index', 'as' => 'categories.index']);
- Route::get('/categories/create', ['uses' => 'CategoryController@create', 'as' => 'categories.create']);
- Route::get('/categories/edit/{category}', ['uses' => 'CategoryController@edit', 'as' => 'categories.edit']);
- Route::get('/categories/delete/{category}', ['uses' => 'CategoryController@delete', 'as' => 'categories.delete']);
- Route::get('/categories/show/{category}', ['uses' => 'CategoryController@show', 'as' => 'categories.show']);
- Route::get('/categories/list/noCategory', ['uses' => 'CategoryController@noCategory', 'as' => 'categories.noCategory']);
-
- // currency controller
- Route::get('/currency', ['uses' => 'CurrencyController@index', 'as' => 'currency.index']);
- Route::get('/currency/create', ['uses' => 'CurrencyController@create', 'as' => 'currency.create']);
- Route::get('/currency/edit/{currency}', ['uses' => 'CurrencyController@edit', 'as' => 'currency.edit']);
- Route::get('/currency/delete/{currency}', ['uses' => 'CurrencyController@delete', 'as' => 'currency.delete']);
- Route::get('/currency/default/{currency}', ['uses' => 'CurrencyController@defaultCurrency', 'as' => 'currency.default']);
-
- // google chart controller
- Route::get('/chart/home/account', ['uses' => 'GoogleChartController@allAccountsBalanceChart']);
- Route::get('/chart/home/budgets', ['uses' => 'GoogleChartController@allBudgetsHomeChart']);
- Route::get('/chart/home/categories', ['uses' => 'GoogleChartController@allCategoriesHomeChart']);
- Route::get('/chart/home/bills', ['uses' => 'GoogleChartController@billsOverview']);
- Route::get('/chart/account/{account}/{view?}', ['uses' => 'GoogleChartController@accountBalanceChart']);
- Route::get('/chart/reports/income-expenses/{year}', ['uses' => 'GoogleChartController@yearInExp']);
- Route::get('/chart/reports/income-expenses-sum/{year}', ['uses' => 'GoogleChartController@yearInExpSum']);
- Route::get('/chart/bills/{bill}', ['uses' => 'GoogleChartController@billOverview']);
-
- Route::get('/chart/piggy_history/{piggyBank}', ['uses' => 'GoogleChartController@piggyBankHistory']);
-
- // google chart for components (categories + budgets combined)
- Route::get('/chart/budget/{budget}/spending/{year?}', ['uses' => 'GoogleChartController@budgetsAndSpending']);
- Route::get('/chart/budgets/spending/{year?}', ['uses' => 'GoogleChartController@allBudgetsAndSpending']);
- Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'GoogleChartController@budgetLimitSpending']);
- Route::get('/chart/category/{category}/spending/{year}', ['uses' => 'GoogleChartController@categoriesAndSpending']);
-
- // help controller
- Route::get('/help/{route}', ['uses' => 'HelpController@show', 'as' => 'help.show']);
-
- // home controller
- Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
- Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']); # even though nothing is cached.
-
- // JSON controller
- Route::get('/json/expense-accounts', ['uses' => 'JsonController@expenseAccounts', 'as' => 'json.expense-accounts']);
- Route::get('/json/revenue-accounts', ['uses' => 'JsonController@revenueAccounts', 'as' => 'json.revenue-accounts']);
- Route::get('/json/categories', ['uses' => 'JsonController@categories', 'as' => 'json.categories']);
-
-
- // piggy bank controller
- Route::get('/piggy_banks', ['uses' => 'PiggyBankController@index', 'as' => 'piggy_banks.index']);
- Route::get('/piggy_banks/add/{piggyBank}', ['uses' => 'PiggyBankController@add']); # add money
- Route::get('/piggy_banks/remove/{piggyBank}', ['uses' => 'PiggyBankController@remove']); #remove money
-
- Route::get('/piggy_banks/create', ['uses' => 'PiggyBankController@create', 'as' => 'piggy_banks.create']);
- Route::get('/piggy_banks/edit/{piggyBank}', ['uses' => 'PiggyBankController@edit', 'as' => 'piggy_banks.edit']);
- Route::get('/piggy_banks/delete/{piggyBank}', ['uses' => 'PiggyBankController@delete', 'as' => 'piggy_banks.delete']);
- Route::get('/piggy_banks/show/{piggyBank}', ['uses' => 'PiggyBankController@show', 'as' => 'piggy_banks.show']);
-
- // preferences controller
- Route::get('/preferences', ['uses' => 'PreferencesController@index', 'as' => 'preferences']);
-
- //profile controller
- Route::get('/profile', ['uses' => 'ProfileController@index', 'as' => 'profile']);
- Route::get('/profile/change-password', ['uses' => 'ProfileController@changePassword', 'as' => 'change-password']);
-
- // related controller:
- Route::get('/related/alreadyRelated/{tj}', ['uses' => 'RelatedController@alreadyRelated', 'as' => 'related.alreadyRelated']);
- Route::post('/related/relate/{tj}/{tjSecond}', ['uses' => 'RelatedController@relate', 'as' => 'related.relate']);
- Route::get('/related/removeRelation/{tj}/{tjSecond}', ['uses' => 'RelatedController@removeRelation', 'as' => 'related.removeRelation']);
- Route::get('/related/related/{tj}', ['uses' => 'RelatedController@related', 'as' => 'related.related']);
- Route::post('/related/search/{tj}', ['uses' => 'RelatedController@search', 'as' => 'related.search']);
-
- // bills controller
- Route::get('/bills', ['uses' => 'BillController@index', 'as' => 'bills.index']);
- Route::get('/bills/rescan/{bill}', ['uses' => 'BillController@rescan', 'as' => 'bills.rescan']); # rescan for matching.
- Route::get('/bills/create', ['uses' => 'BillController@create', 'as' => 'bills.create']);
- Route::get('/bills/edit/{bill}', ['uses' => 'BillController@edit', 'as' => 'bills.edit']);
- Route::get('/bills/delete/{bill}', ['uses' => 'BillController@delete', 'as' => 'bills.delete']);
- Route::get('/bills/show/{bill}', ['uses' => 'BillController@show', 'as' => 'bills.show']);
-
- // repeated expenses controller:
- Route::get('/repeatedexpenses', ['uses' => 'RepeatedExpenseController@index', 'as' => 'repeated.index']);
- Route::get('/repeatedexpenses/create', ['uses' => 'RepeatedExpenseController@create', 'as' => 'repeated.create']);
- Route::get('/repeatedexpenses/edit/{repeatedExpense}', ['uses' => 'RepeatedExpenseController@edit', 'as' => 'repeated.edit']);
- Route::get('/repeatedexpenses/delete/{repeatedExpense}', ['uses' => 'RepeatedExpenseController@delete', 'as' => 'repeated.delete']);
- Route::get('/repeatedexpenses/show/{repeatedExpense}', ['uses' => 'RepeatedExpenseController@show', 'as' => 'repeated.show']);
-
- // report controller:
- Route::get('/reports', ['uses' => 'ReportController@index', 'as' => 'reports.index']);
- Route::get('/reports/{year}', ['uses' => 'ReportController@year', 'as' => 'reports.year']);
- Route::get('/reports/{year}/{month}', ['uses' => 'ReportController@month', 'as' => 'reports.month']);
- Route::get('/reports/budget/{year}/{month}', ['uses' => 'ReportController@budget', 'as' => 'reports.budget']);
-
- // reminder controller
- Route::get('/reminders/{reminder}', ['uses' => 'ReminderController@show', 'as' => 'reminders.show']);
- Route::get('/reminders/{reminder}/dismiss', ['uses' => 'ReminderController@dismiss', 'as' => 'reminders.dismiss']);
- Route::get('/reminders/{reminder}/notNow', ['uses' => 'ReminderController@notNow', 'as' => 'reminders.notNow']);
- Route::get('/reminders/{reminder}/act', ['uses' => 'ReminderController@act', 'as' => 'reminders.act']);
-
- // search controller:
- Route::get('/search', ['uses' => 'SearchController@index', 'as' => 'search']);
-
- // transaction controller:
- Route::get('/transactions/{what}', ['uses' => 'TransactionController@index', 'as' => 'transactions.index'])->where(
- ['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']
- );
- Route::get('/transactions/create/{what}', ['uses' => 'TransactionController@create', 'as' => 'transactions.create'])->where(
- ['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']
- );
- Route::get('/transaction/edit/{tj}', ['uses' => 'TransactionController@edit', 'as' => 'transactions.edit']);
- Route::get('/transaction/delete/{tj}', ['uses' => 'TransactionController@delete', 'as' => 'transactions.delete']);
- Route::get('/transaction/show/{tj}', ['uses' => 'TransactionController@show', 'as' => 'transactions.show']);
- Route::get('/transaction/relate/{tj}', ['uses' => 'TransactionController@relate', 'as' => 'transactions.relate']);
- Route::post('/transactions/relatedSearch/{tj}', ['uses' => 'TransactionController@relatedSearch', 'as' => 'transactions.relatedSearch']);
- Route::post('/transactions/alreadyRelated/{tj}', ['uses' => 'TransactionController@alreadyRelated', 'as' => 'transactions.alreadyRelated']);
- Route::post('/transactions/doRelate', ['uses' => 'TransactionController@doRelate', 'as' => 'transactions.doRelate']);
- Route::any('/transactions/unrelate/{tj}', ['uses' => 'TransactionController@unrelate', 'as' => 'transactions.unrelate']);
-
- // user controller
- Route::get('/logout', ['uses' => 'UserController@logout', 'as' => 'logout']);
-
- Route::post('budgets/amount/{budget}', ['uses' => 'BudgetController@amount']);
-
-
-}
-);
-
-// protected + csrf routes (POST)
-Route::group(
- ['before' => 'csrf|auth'], function () {
- // account controller:
- Route::post('/accounts/store', ['uses' => 'AccountController@store', 'as' => 'accounts.store']);
- Route::post('/accounts/update/{account}', ['uses' => 'AccountController@update', 'as' => 'accounts.update']);
- Route::post('/accounts/destroy/{account}', ['uses' => 'AccountController@destroy', 'as' => 'accounts.destroy']);
-
- // budget controller:
- Route::post('/budgets/income', ['uses' => 'BudgetController@postUpdateIncome', 'as' => 'budgets.postIncome']);
- Route::post('/budgets/store', ['uses' => 'BudgetController@store', 'as' => 'budgets.store']);
- Route::post('/budgets/update/{budget}', ['uses' => 'BudgetController@update', 'as' => 'budgets.update']);
- Route::post('/budgets/destroy/{budget}', ['uses' => 'BudgetController@destroy', 'as' => 'budgets.destroy']);
-
- // category controller
- Route::post('/categories/store', ['uses' => 'CategoryController@store', 'as' => 'categories.store']);
- Route::post('/categories/update/{category}', ['uses' => 'CategoryController@update', 'as' => 'categories.update']);
- Route::post('/categories/destroy/{category}', ['uses' => 'CategoryController@destroy', 'as' => 'categories.destroy']);
-
- // currency controller
- Route::post('/currency/store', ['uses' => 'CurrencyController@store', 'as' => 'currency.store']);
- Route::post('/currency/update/{currency}', ['uses' => 'CurrencyController@update', 'as' => 'currency.update']);
- Route::post('/currency/destroy/{currency}', ['uses' => 'CurrencyController@destroy', 'as' => 'currency.destroy']);
-
- // piggy bank controller
- Route::post('/piggy_banks/store', ['uses' => 'PiggyBankController@store', 'as' => 'piggy_banks.store']);
- Route::post('/piggy_banks/update/{piggyBank}', ['uses' => 'PiggyBankController@update', 'as' => 'piggy_banks.update']);
- Route::post('/piggy_banks/destroy/{piggyBank}', ['uses' => 'PiggyBankController@destroy', 'as' => 'piggy_banks.destroy']);
- Route::post('/piggy_banks/add/{piggyBank}', ['uses' => 'PiggyBankController@postAdd', 'as' => 'piggy_banks.add']); # add money
- Route::post('/piggy_banks/remove/{piggyBank}', ['uses' => 'PiggyBankController@postRemove', 'as' => 'piggy_banks.remove']); # remove money.
-
- // repeated expense controller
- Route::post('/repeatedexpense/store', ['uses' => 'RepeatedExpenseController@store', 'as' => 'repeated.store']);
- Route::post('/repeatedexpense/update/{repeatedExpense}', ['uses' => 'RepeatedExpenseController@update', 'as' => 'repeated.update']);
- Route::post('/repeatedexpense/destroy/{repeatedExpense}', ['uses' => 'RepeatedExpenseController@destroy', 'as' => 'repeated.destroy']);
-
- // preferences controller
- Route::post('/preferences', ['uses' => 'PreferencesController@postIndex']);
-
- // profile controller
- Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword']);
-
- // bills controller
- Route::post('/bills/store', ['uses' => 'BillController@store', 'as' => 'bills.store']);
- Route::post('/bills/update/{bill}', ['uses' => 'BillController@update', 'as' => 'bills.update']);
- Route::post('/bills/destroy/{bill}', ['uses' => 'BillController@destroy', 'as' => 'bills.destroy']);
-
- // transaction controller:
- Route::post('/transactions/store/{what}', ['uses' => 'TransactionController@store', 'as' => 'transactions.store'])->where(
- ['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']
- );
- Route::post('/transaction/update/{tj}', ['uses' => 'TransactionController@update', 'as' => 'transactions.update']);
- Route::post('/transaction/destroy/{tj}', ['uses' => 'TransactionController@destroy', 'as' => 'transactions.destroy']);
-
-}
-);
-
-// guest routes:
-Route::group(
- ['before' => 'guest'], function () {
- // user controller
- Route::get('/login', ['uses' => 'UserController@login', 'as' => 'login']);
- Route::get('/register', ['uses' => 'UserController@register', 'as' => 'register', 'before' => 'allow-register']);
- Route::get('/reset/{reset}', ['uses' => 'UserController@reset', 'as' => 'reset']);
- Route::get('/remindMe', ['uses' => 'UserController@remindMe', 'as' => 'remindMe']);
-
- Route::get('/oauth2callback', ['uses' => 'HomeController@marauder', 'as' => 'marauder']);
-
-
-}
-);
-
-
-// guest + csrf routes:
-Route::group(
- ['before' => 'csrf|guest'], function () {
-
- // user controller
- Route::post('/login', ['uses' => 'UserController@postLogin', 'as' => 'login.post']);
- Route::post('/register', ['uses' => 'UserController@postRegister', 'as' => 'register.post', 'before' => 'allow-register']);
- Route::post('/remindMe', ['uses' => 'UserController@postRemindMe', 'as' => 'remindMe.post']);
-}
-);
diff --git a/app/start/artisan.php b/app/start/artisan.php
deleted file mode 100644
index 8e36314924..0000000000
--- a/app/start/artisan.php
+++ /dev/null
@@ -1,14 +0,0 @@
-prepareForTests();
-
- }
-
- static public function setupBeforeClass()
- {
- f::loadFactories(__DIR__ . '/factories');
- }
-
- public function tearDown()
- {
- //m::close();
- }
-
- /**
- * Migrates the database and set the mailer to 'pretend'.
- * This will cause the tests to run quickly.
- *
- */
- private function prepareForTests()
- {
- Artisan::call('migrate');
- Mail::pretend(true);
- }
-}
diff --git a/app/tests/factories/Account.php b/app/tests/factories/Account.php
deleted file mode 100644
index 3d4032b4d1..0000000000
--- a/app/tests/factories/Account.php
+++ /dev/null
@@ -1,10 +0,0 @@
- 'factory|User',
- 'account_type_id' => 'factory|AccountType',
- 'name' => 'word',
- 'active' => 'boolean',
- ]
-);
diff --git a/app/tests/factories/AccountMeta.php b/app/tests/factories/AccountMeta.php
deleted file mode 100644
index a282aa9748..0000000000
--- a/app/tests/factories/AccountMeta.php
+++ /dev/null
@@ -1,9 +0,0 @@
- 'factory|Account',
- 'name' => 'word',
- 'data' => 'text'
- ]
-);
diff --git a/app/tests/factories/AccountType.php b/app/tests/factories/AccountType.php
deleted file mode 100644
index e893ea89af..0000000000
--- a/app/tests/factories/AccountType.php
+++ /dev/null
@@ -1,8 +0,0 @@
- 'word',
- 'editable' => 'boolean'
- ]
-);
diff --git a/app/tests/factories/Budget.php b/app/tests/factories/Budget.php
deleted file mode 100644
index 1975cf53b0..0000000000
--- a/app/tests/factories/Budget.php
+++ /dev/null
@@ -1,8 +0,0 @@
- 'word',
- 'user_id' => 'factory|User'
- ]
-);
diff --git a/app/tests/factories/PiggyBank.php b/app/tests/factories/PiggyBank.php
deleted file mode 100644
index aaab88cd71..0000000000
--- a/app/tests/factories/PiggyBank.php
+++ /dev/null
@@ -1,38 +0,0 @@
- 'factory|Account',
- 'name' => 'word',
- 'targetamount' => function () {
- return rand(1, 400);
- },
- 'startdate' => 'date|Y-m-d',
- 'targetdate' => 'date|Y-m-d',
- 'repeats' => 'boolean',
- 'rep_length' => function () {
- $set = ['day', 'week', 'quarter', 'month', 'year'];
-
- return $set[rand(0, count($set) - 1)];
- },
- 'rep_every' => function () {
- return rand(0, 3);
- },
- 'rep_times' => function () {
- return rand(0, 3);
- },
- 'reminder' => function () {
- $set = ['day', 'week', 'quarter', 'month', 'year'];
-
- return $set[rand(0, count($set) - 1)];
- },
- 'reminder_skip' => function () {
- return rand(0, 3);
- },
- 'remind_me' => 'boolean',
- 'order' => function () {
- return rand(0, 10);
- },
-
- ]
-);
diff --git a/app/tests/factories/PiggyBankRepetition.php b/app/tests/factories/PiggyBankRepetition.php
deleted file mode 100644
index a266af2283..0000000000
--- a/app/tests/factories/PiggyBankRepetition.php
+++ /dev/null
@@ -1,13 +0,0 @@
- 'factory|PiggyBank',
- 'startdate' => 'date|Y-m-d',
- 'targetdate' => 'date|Y-m-d',
- 'currentamount' => function () {
- return rand(0, 100);
- },
-
- ]
-);
diff --git a/app/tests/factories/Preference.php b/app/tests/factories/Preference.php
deleted file mode 100644
index 89a26f5812..0000000000
--- a/app/tests/factories/Preference.php
+++ /dev/null
@@ -1,9 +0,0 @@
- 'factory|User',
- 'name' => 'word',
- 'data' => 'sentence',
- ]
-);
diff --git a/app/tests/factories/Reminder.php b/app/tests/factories/Reminder.php
deleted file mode 100644
index 62f2a3d513..0000000000
--- a/app/tests/factories/Reminder.php
+++ /dev/null
@@ -1,13 +0,0 @@
- 'factory|User',
- 'startdate' => 'date|Y-m-d',
- 'enddate' => 'date|Y-m-d',
- 'active' => 'boolean',
- 'notnow' => 'boolean',
- 'remindersable_id' => 0,
- 'remindersable_type' => '',
- ]
-);
diff --git a/app/tests/factories/Transaction.php b/app/tests/factories/Transaction.php
deleted file mode 100644
index 39f50f7ca5..0000000000
--- a/app/tests/factories/Transaction.php
+++ /dev/null
@@ -1,12 +0,0 @@
- 'factory|Account',
- 'transaction_journal_id' => 'factory|TransactionJournal',
- 'description' => 'sentence',
- 'amount' => function () {
- return round(rand(100, 10000) / 100, 2);
- }
- ]
-);
diff --git a/app/tests/factories/TransactionCurrency.php b/app/tests/factories/TransactionCurrency.php
deleted file mode 100644
index cfb3b685b0..0000000000
--- a/app/tests/factories/TransactionCurrency.php
+++ /dev/null
@@ -1,30 +0,0 @@
- function () {
- $code = '';
- for ($i = 0; $i < 3; $i++) {
- $code .= chr(rand(65, 90));
- }
-
- return $code;
- },
- 'name' => function () {
- $code = '';
- for ($i = 0; $i < 8; $i++) {
- $code .= chr(rand(65, 90));
- }
-
- return $code;
- },
- 'symbol' => function () {
- $code = '';
- for ($i = 0; $i < 2; $i++) {
- $code .= chr(rand(65, 90));
- }
-
- return $code;
- }
- ]
-);
diff --git a/app/tests/factories/TransactionGroup.php b/app/tests/factories/TransactionGroup.php
deleted file mode 100644
index 74e917a8ae..0000000000
--- a/app/tests/factories/TransactionGroup.php
+++ /dev/null
@@ -1,8 +0,0 @@
- 'factory|User',
- 'relation' => 'balance',
- ]
-);
diff --git a/app/tests/factories/TransactionJournal.php b/app/tests/factories/TransactionJournal.php
deleted file mode 100644
index 58fd89d200..0000000000
--- a/app/tests/factories/TransactionJournal.php
+++ /dev/null
@@ -1,12 +0,0 @@
- 'factory|TransactionType',
- 'transaction_currency_id' => 'factory|TransactionCurrency',
- 'description' => 'text',
- 'date' => 'date|Y-m-d',
- 'completed' => 'boolean',
- 'user_id' => 'factory|User'
- ]
-);
diff --git a/app/tests/factories/TransactionType.php b/app/tests/factories/TransactionType.php
deleted file mode 100644
index 0876277d2c..0000000000
--- a/app/tests/factories/TransactionType.php
+++ /dev/null
@@ -1,7 +0,0 @@
- 'word',
- ]
-);
diff --git a/app/tests/factories/User.php b/app/tests/factories/User.php
deleted file mode 100644
index 92efe04843..0000000000
--- a/app/tests/factories/User.php
+++ /dev/null
@@ -1,7 +0,0 @@
- 'email',
- 'password' => 'empty'
- ]
-);
diff --git a/app/views/accounts/create.blade.php b/app/views/accounts/create.blade.php
deleted file mode 100644
index a0455b2c00..0000000000
--- a/app/views/accounts/create.blade.php
+++ /dev/null
@@ -1,55 +0,0 @@
-@extends('layouts.default')
-@section('content')
-{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $what) }}
-{{Form::open(['class' => 'form-horizontal','id' => 'store','route' => 'accounts.store'])}}
-{{Form::hidden('what',$what)}}
-- -
-- Are you sure? -
- - @if($account->transactions()->count() > 0) -- Account "{{{$account->name}}}" still has {{$account->transactions()->count()}} transaction(s) associated to it. - These will be deleted as well. -
- @endif - -- - Cancel -
-- -
-- @if($range == 'all') - Stick to date-range - @else - Show all transactions - @endif -
-- -
-- Are you sure? -
- -- - Cancel -
-- -
-- Matching on - @foreach(explode(',',$bill->match) as $word) - {{{$word}}} - @endforeach - between {{Amount::format($bill->amount_min)}} and {{Amount::format($bill->amount_max)}}. - Repeats {{$bill->repeat_freq}}. | - -|
Next expected match | -- @if($bill->nextExpectedMatch) - {{$bill->nextExpectedMatch->format('j F Y')}} - @else - Unknown - @endif - | -
- -
- -- Are you sure? -
- -- - Cancel -
-Use budgets to organize and limit your expenses.
-- -
-- @if($budget->currentRep) - - @else - - @endif -
- -- - - @if($budget->currentRep) - - Budgeted: - - - @if($budget->currentRep->amount > $budget->spent) - {{Amount::getCurrencySymbol()}} - @else - {{Amount::getCurrencySymbol()}} - @endif - - @else - No budget - - - @endif - - -
-- Spent: {{Amount::format($budget->spent)}} -
-- -
-- Are you sure? -
- -- - Cancel -
-- -
-- -
-- Are you sure? -
-- - Cancel -
-- -
-- Firefly III supports various currencies which you can set and enable here. -
-- Hi! -
-- Here's the password you need to login at Firefly: {{$password}} -
-- Cya! -
- - - diff --git a/app/views/emails/user/register-text.blade.php b/app/views/emails/user/register-text.blade.php deleted file mode 100644 index 0993031a88..0000000000 --- a/app/views/emails/user/register-text.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -Hi! - -Here's the password you need to login at Firefly: {{$password}} - -Cya! diff --git a/app/views/emails/user/verify-html.blade.php b/app/views/emails/user/verify-html.blade.php deleted file mode 100644 index 90b477e351..0000000000 --- a/app/views/emails/user/verify-html.blade.php +++ /dev/null @@ -1,19 +0,0 @@ - - - - - -- Hi! -
-- To verify your registration, please verify your e-mail address. -
-- Cya! -
- - - diff --git a/app/views/emails/user/verify-text.blade.php b/app/views/emails/user/verify-text.blade.php deleted file mode 100644 index 27f1d553a0..0000000000 --- a/app/views/emails/user/verify-text.blade.php +++ /dev/null @@ -1,7 +0,0 @@ -Hi! - -To verify your registration, please verify your e-mail address: - -{{route('reset',$reset)}} - -Cya! diff --git a/app/views/error.blade.php b/app/views/error.blade.php deleted file mode 100644 index 4140018572..0000000000 --- a/app/views/error.blade.php +++ /dev/null @@ -1,16 +0,0 @@ -@extends('layouts.guest') -@section('content') -{{{Session::get('errors')->first($name)}}}
-@endif -@if(Session::has('warnings') && Session::get('warnings')->has($name)) - -{{{Session::get('warnings')->first($name)}}}
-@endif -@if(Session::has('successes') && Session::get('successes')->has($name)) - -{{{Session::get('successes')->first($name)}}}
-@endif \ No newline at end of file diff --git a/app/views/form/integer.blade.php b/app/views/form/integer.blade.php deleted file mode 100644 index fd10ca6ca6..0000000000 --- a/app/views/form/integer.blade.php +++ /dev/null @@ -1,9 +0,0 @@ -Welcome to Firefly III.
- -- Create a new asset account to get started. -
-- | Name | -Role | -Current balance | -Active | -Last activity | -
---|---|---|---|---|---|
- - | -{{{$account->name}}} | -{{{$account->accountRole}}} | -{{Amount::format(Steam::balance($account))}} | -- @if($account->active) - - @else - - @endif - | -- @if($account->lastActivityDate) - {{{$account->lastActivityDate->format('j F Y')}}} - @else - Never - @endif - | -
- | Name | -Matches on | -Matching amount | -Last seen match | -Next expected match | -Is active | -Will be automatched | -Repeats every | -
---|---|---|---|---|---|---|---|---|
- - | -- {{{$entry->name}}} - | -- @foreach(explode(',',$entry->match) as $match) - {{{$match}}} - @endforeach - | -- {{Amount::format($entry->amount_min)}} - — - {{Amount::format($entry->amount_max)}} - | -- @if($entry->lastFoundMatch) - {{$entry->lastFoundMatch->format('j F Y')}} - @else - Unknown - @endif - | -- @if($entry->nextExpectedMatch) - {{$entry->nextExpectedMatch->format('j F Y')}} - @else - Unknown - @endif - | -- @if($entry->active) - - @else - - @endif - | -- @if($entry->automatch) - - @else - - @endif - | -- {{{$entry->repeat_freq}}} - @if($entry->skip > 0) - skips over {{$entry->skip}} - @endif - | -
- | Name | -Last activity | -
---|---|---|
- | Without a category | -- |
- - | -- {{{$category->name}}} - | -- lastActionDate(); ?> - @if($active) - {{{$active->format('j F Y')}}} - @else - Never - @endif - | -
- | Description | -Amount | -Date | -From | -To | - @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) -- @endif - @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) - | - @endif - @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) - | - @endif - | |
---|---|---|---|---|---|---|---|---|---|
- - | -- | {{{$journal->description}}} | -Invalid journal: Found {{$journal->transactions()->count()}} transaction(s) | -||||||
- - | -- @if($journal->transactiontype->type == 'Withdrawal') - - @endif - @if($journal->transactiontype->type == 'Deposit') - - @endif - @if($journal->transactiontype->type == 'Transfer') - - @endif - @if($journal->transactiontype->type == 'Opening balance') - - @endif - | -- {{{$journal->description}}} - | -- @if($journal->transactiontype->type == 'Withdrawal') - {{Amount::formatTransaction($journal->transactions[1],false)}} - @endif - @if($journal->transactiontype->type == 'Deposit') - {{Amount::formatTransaction($journal->transactions[1],false)}} - @endif - @if($journal->transactiontype->type == 'Transfer') - {{Amount::formatTransaction($journal->transactions[1],false)}} - @endif - | -- {{$journal->date->format('j F Y')}} - | -- @if($journal->transactions[0]->account->accounttype->description == 'Cash account') - (cash) - @else - {{{$journal->transactions[0]->account->name}}} - @endif - | -- @if($journal->transactions[1]->account->accounttype->description == 'Cash account') - (cash) - @else - {{{$journal->transactions[1]->account->name}}} - @endif - | - @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) -- budgets[0]) ? $journal->budgets[0] : null; ?> - @if($budget) - {{{$budget->name}}} - @endif - | - @endif - @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) -- categories[0]) ? $journal->categories[0] : null; ?> - @if($category) - {{{$category->name}}} - @endif - | - @endif - @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) -- @if($journal->bill) - {{{$journal->bill->name}}} - @endif - | - @endif - - -
- {{{$journal->description}}} - | -- transactions[1]->amount);?> - @if($journal->transactiontype->type == 'Withdrawal') - {{Amount::formatTransaction($journal->transactions[1],false)}} - @endif - @if($journal->transactiontype->type == 'Deposit') - {{Amount::formatTransaction($journal->transactions[1],false)}} - @endif - @if($journal->transactiontype->type == 'Transfer') - {{Amount::formatTransaction($journal->transactions[1],false)}} - @endif - | -- {{$journal->date->format('j F Y')}} - | -- @foreach($journal->transactions as $t) - @if(floatval($t->amount < 0)) - @if($t->account->accounttype->description == 'Cash account') - (cash) - @else - {{{$t->account->name}}} - @endif - @endif - @endforeach - | -
Sum | -{{Amount::format($tableSum)}} | - -
Piggy bank | - @endif -Date | -Amount | -
---|---|---|
- {{{$event->piggyBank->name}}} - | - @endif -- @if(!is_null($event->transaction_journal_id)) - {{$event->date->format('j F Y')}} - @else - {{$event->date->format('j F Y')}} - @endif - | - -- @if($event->amount < 0) - Removed {{Amount::format($event->amount*-1,false)}} - @else - Added {{Amount::format($event->amount,false)}} - @endif - | -
- -
-{{$errors->first('reminder')}}
- @else - Enter a number and a period and Firefly will remind you to add money - to this piggy bank every now and then. - @endif -- Are you sure? -
- -- - Cancel -
-- -
-{{$errors->first('reminder')}}
- @else - Enter a number and a period and Firefly will remind you to add money - to this piggy bank every now and then. - @endif -Account | -Balance | -Left for piggy banks | -Sum of piggy banks | -Saved so far | -Left to save | -
---|---|---|---|---|---|
{{{$info['name']}}} | -{{Amount::format($info['balance'])}} | -{{Amount::format($info['leftForPiggyBanks'])}} | -{{Amount::format($info['sumOfTargets'])}} | -{{Amount::format($info['sumOfSaved'])}} | -{{Amount::format($info['leftToSave'])}} | -
Account | -{{{$piggyBank->account->name}}} | -
Target amount | -{{Amount::format($piggyBank->targetamount)}} | -
Saved so far | -{{Amount::format($piggyBank->currentRelevantRep()->currentamount)}} | -
Left to save | -{{Amount::format($piggyBank->targetamount-$piggyBank->currentRelevantRep()->currentamount)}} | -
Start date | -- @if(is_null($piggyBank->startdate)) - No start date - @endif - @if(is_object($piggyBank->startdate)) - {{$piggyBank->startdate->format('jS F Y')}} - @endif - | -
Target date | -- @if(is_null($piggyBank->targetdate)) - No target date - @endif - @if(is_object($piggyBank->targetdate)) - {{$piggyBank->targetdate->format('jS F Y')}} - @endif - | -
Reminder | -- @if(intval($piggyBank->remind_me) == 0) - (no reminder) - @else - Every - @if($piggyBank->reminder_skip != 0) - {{$piggyBank->reminder_skip}} - @endif - {{$piggyBank->reminder}}(s) - @endif - | -
Reminders left | -(in progress...) | -
Expected amount per reminder | -(in progress...) | -
Which accounts should be displayed on the home page?
- @foreach($accounts as $account) -- What's the maximum amount of money a budget envelope may contain? -
- {{Form::ffAmount('budgetMaximum',$budgetMaximum,['label' => 'Budget maximum'])}} -By default, Firefly will show you one month of data.
-- @if(get_class($reminder->remindersable) == 'Piggybank') - Somewhere between {{$reminder->startdate->format('j F Y')}} and {{$reminder->enddate->format('j F Y')}} you - should deposit {{Amount::format($amount)}} in piggy bank {{{$reminder->remindersable->name}}} - in order to make your goal of saving {{Amount::format($reminder->remindersable->targetamount)}} on {{$reminder->remindersable->targetdate->format('j F Y')}} - - @endif -
-- I want to do this - I already did this - Not this time - -
-- -
-{{$errors->first('reminder')}}
- @else - Enter a number and a period and Firefly will remind you to add money - to this piggy bank every now and then. - @endif -- Are you sure? -
- -- - Cancel -
-- -
-{{$errors->first('reminder')}}
- @else - Enter a number and a period and Firefly will remind you to add money - to this piggy bank every now and then. - @endif -- Target amount: {{Amount::format($repeatedExpense->targetamount)}}. Currently saved: {{Amount::format($rep->currentamount)}}. -
-Account | -Start of month | -Current balance | -Spent | -
---|---|---|---|
{{{$account->name}}} | -{{Amount::format($account->startBalance)}} | -{{Amount::format($account->endBalance)}} | -{{Amount::format($account->startBalance - $account->endBalance,false)}} | -
Budgets | - - @foreach($accounts as $account) -{{{$account->name}}} | - id] = 0; - ?> - @endforeach -- Left in budget - | -|||
---|---|---|---|---|---|
{{{$budget['name']}}} - @if($id == 0) - - @endif - | -{{Amount::format($budget['amount'])}} | - - @foreach($accounts as $account) - @if(isset($account->budgetInformation[$id])) -- @if($id == 0) - {{Amount::format($account->budgetInformation[$id]['amount'])}} - @else - {{Amount::format($account->budgetInformation[$id]['amount'])}} - @endif - | - budgetInformation[$id]['amount']); - $accountSums[$account->id] += floatval($account->budgetInformation[$id]['amount']); - ?> - @else -{{Amount::format(0)}} | - @endif - @endforeach -{{Amount::format($budget['amount'] + $budget['spent'])}} | -{{Amount::format($budget['amount'] + $spent)}} | -
Without budget - - | - @foreach($accounts as $account) - @if(isset($account->budgetInformation[0])) -- {{Amount::format($account->budgetInformation[0]['amount'])}} - | - @else -{{Amount::format(0)}} | - @endif - @endforeach -- | ||
Balanced by transfers | - @foreach($accounts as $account) -- {{Amount::format($account->balancedAmount)}} - | - @endforeach -- | |||
Left unbalanced | - @foreach($accounts as $account) - id] += $account->balancedAmount; - ?> - @if(isset($account->budgetInformation[0])) -- {{Amount::format($account->budgetInformation[0]['amount'] + $account->balancedAmount)}} - | - @else -{{Amount::format(0)}} | - @endif - @endforeach -- | ||
Sum | - @foreach($accounts as $account) -{{Amount::format($accountSums[$account->id])}} | - @endforeach -- | |||
Expected balance | - @foreach($accounts as $account) -{{Amount::format($account->startBalance + $accountSums[$account->id])}} | - @endforeach -- |
- {{{$entry->description}}} - | -- amount);?> - @if($entry->type == 'Withdrawal') - {{Amount::format($entry->amount,false)}} - @endif - @if($entry->type == 'Deposit') - {{Amount::format($entry->amount,false)}} - @endif - @if($entry->type == 'Transfer') - {{Amount::format($entry->amount,false)}} - @endif - | -- {{$entry->date->format('j F Y')}} - | -- {{{$entry->name}}} - | -
Sum | -{{Amount::format($tableSum)}} | - -
{{{$expense['name']}}} | - @else -{{{$expense['name']}}} | - @endif -{{Amount::format($expense['amount'])}} | -
Sum | -{{Amount::format($sum)}} | -
In | -{{Amount::format($in)}} | -
Out | -{{Amount::format($sum)}} | -
Difference | -{{Amount::format($in - $sum)}} | -
Budget | -Envelope | -Spent | -Left | -
---|---|---|---|
- @if($id > 0) - {{{$budget['name']}}} - @else - {{{$budget['name']}}} - @endif - | -{{Amount::format($budget['amount'])}} | -{{Amount::format($budget['spent'],false)}} | -{{Amount::format($budget['amount'] + $budget['spent'])}} | -
Sum | -{{Amount::format($sumEnvelope)}} | -{{Amount::format($sumSpent)}} | -{{Amount::format($sumLeft)}} | -
Category | -Spent | -
---|---|
- @if($id > 0) - {{{$category['name']}}} - @else - {{{$category['name']}}} - @endif - | -{{Amount::format($category['amount'],false)}} | -
Sum | -{{Amount::format($sum)}} | -
{{{$account['name']}}} | -{{Amount::format($account['startBalance'])}} | -{{Amount::format($account['endBalance'])}} | -{{Amount::format($account['difference'])}} | -
Sum | -{{Amount::format($sumStart)}} | -{{Amount::format($sumEnd)}} | -{{Amount::format($sumDiff)}} | -
- {{{$balance['account']->name}}} - @if($balance['shared']) - shared - @endif - | -{{Amount::format($balance['start'])}} | -{{Amount::format($balance['end'])}} | -{{Amount::format($balance['end']-$balance['start'])}} | -
Sum of sums | -{{Amount::format($start)}} | -{{Amount::format($end)}} | -{{Amount::format($diff)}} | -
In | -{{Amount::format($incomeSum)}} | -
Out | -{{Amount::format($expenseSum*-1)}} | -
Difference | -{{Amount::format($incomeSum - $expenseSum)}} | -
{{{$income->name}}} | -{{Amount::format(floatval($income->amount)*-1)}} | -
Sum | -{{Amount::format($sum)}} | -
{{{$expense['name']}}} | -{{Amount::format(floatval($expense['amount'])*-1)}} | -
Sum | -{{Amount::format($sum)}} | -
Bla bla
-- -
- -- Deleting stuff from Firefly is permanent. This action will remove the transaction and all - associated data. -
-- This action will not destroy categories, piggy banks, accounts, etc. -
-- Are you sure? -
- -- -
- -Date | -{{{$journal->date->format('jS F Y')}}} | -
Currency | -{{{$journal->transactioncurrency->code}}} | -
Type | -{{{$journal->transactiontype->type}}} | -
Completed | -- @if($journal->completed == 1) - Yes - @else - No - @endif - | -
{{$budget->class}} | -{{{$budget->name}}} | -
{{$category->class}} | -{{{$category->name}}} | -
- No related transactions -
-- | {{{$jrnl->description}}} | -{{Amount::formatJournal($jrnl, $jrnl->getAmount())}} | -
Amount | -{{Amount::formatTransaction($t)}} | -
New balance | -{{Amount::format($t->before)}} → {{Amount::format($t->after)}} | -
Description | -{{{$t->description}}} | -
- -
-- Registering an account on Firefly requires an e-mail address. - All instructions will be sent to you. -
- {{Form::open(['id' => 'register'])}} -- -
- {{Form::close()}} - - - -- You're about to get an e-mail. Use the contents to log in. -
-- Hi! -
-- To get a new password, please verify your e-mail address. -
-- Cya! -
- - - diff --git a/app/views/user/remindMe-text.blade.php b/app/views/user/remindMe-text.blade.php deleted file mode 100644 index 8d1980a3e4..0000000000 --- a/app/views/user/remindMe-text.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -Hi! - -To get a new password, please verify your e-mail address: {{route('reset',$reset)}} - -Cya! diff --git a/app/views/user/remindMe.blade.php b/app/views/user/remindMe.blade.php deleted file mode 100644 index 18b48954ac..0000000000 --- a/app/views/user/remindMe.blade.php +++ /dev/null @@ -1,27 +0,0 @@ -@extends('layouts.guest') -@section('content') -- -
- {{Form::close()}} - -- You're about to get an e-mail. Please follow its instructions. -
-t |