From a0e501f9fdf13c2881c858c0a58481078a21f596 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 1 May 2015 08:29:41 +0200 Subject: [PATCH 01/29] First attempt at implementing Twig. --- .env.backup | 18 ++ .env.local | 18 ++ app/Http/Controllers/Auth/AuthController.php | 11 ++ app/Providers/FireflyServiceProvider.php | 9 + bootstrap/app.php | 6 + composer.json | 4 +- composer.lock | 176 ++++++++++++++++++- config/app.php | 9 +- config/view.php | 2 +- resources/twig/auth/login.twig | 57 ++++++ resources/twig/layout/guest.twig | 62 +++++++ 11 files changed, 366 insertions(+), 6 deletions(-) create mode 100755 .env.backup create mode 100755 .env.local create mode 100644 resources/twig/auth/login.twig create mode 100644 resources/twig/layout/guest.twig diff --git a/.env.backup b/.env.backup new file mode 100755 index 0000000000..6e6fd0fa1a --- /dev/null +++ b/.env.backup @@ -0,0 +1,18 @@ +APP_ENV=local +APP_DEBUG=true +APP_KEY=SomeRandomString + +DB_CONNECTION=mysql +DB_HOST=localhost +DB_DATABASE=homestead +DB_USERNAME=homestead +DB_PASSWORD=secret + +CACHE_DRIVER=file +SESSION_DRIVER=file + +EMAIL_SMTP= +EMAIL_DRIVER=smtp +EMAIL_USERNAME= +EMAIL_PASSWORD= +ANALYTICS_ID= \ No newline at end of file diff --git a/.env.local b/.env.local new file mode 100755 index 0000000000..6e6fd0fa1a --- /dev/null +++ b/.env.local @@ -0,0 +1,18 @@ +APP_ENV=local +APP_DEBUG=true +APP_KEY=SomeRandomString + +DB_CONNECTION=mysql +DB_HOST=localhost +DB_DATABASE=homestead +DB_USERNAME=homestead +DB_PASSWORD=secret + +CACHE_DRIVER=file +SESSION_DRIVER=file + +EMAIL_SMTP= +EMAIL_DRIVER=smtp +EMAIL_USERNAME= +EMAIL_PASSWORD= +ANALYTICS_ID= \ No newline at end of file diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 97bb5bc4b1..079ec4dcf3 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -8,6 +8,7 @@ use Illuminate\Http\Request; use Illuminate\Mail\Message; use Mail; use Session; +use Twig; /** * Class AuthController @@ -47,6 +48,16 @@ class AuthController extends Controller $this->middleware('guest', ['except' => 'getLogout']); } + /** + * Show the application login form. + * + * @return \Illuminate\Http\Response + */ + public function getLogin() + { + return Twig::render('auth.login'); + } + /** * Handle a registration request for the application. * diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 542475d282..1b57c3508e 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -2,6 +2,7 @@ namespace FireflyIII\Providers; +use App; use FireflyIII\Support\Amount; use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\Navigation; @@ -9,6 +10,8 @@ use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; use FireflyIII\Validation\FireflyValidator; use Illuminate\Support\ServiceProvider; +use Twig; +use TwigBridge\Extension\Loader\Functions; use Validator; /** @@ -25,10 +28,15 @@ class FireflyServiceProvider extends ServiceProvider return new FireflyValidator($translator, $data, $rules, $messages); } ); + } public function register() { + + $config = App::make('config'); + Twig::addExtension(new Functions($config)); + $this->app->bind( 'preferences', function () { return new Preferences; @@ -72,6 +80,7 @@ class FireflyServiceProvider extends ServiceProvider $this->app->bind('FireflyIII\Helpers\Report\ReportHelperInterface', 'FireflyIII\Helpers\Report\ReportHelper'); $this->app->bind('FireflyIII\Helpers\Report\ReportQueryInterface', 'FireflyIII\Helpers\Report\ReportQuery'); + } } diff --git a/bootstrap/app.php b/bootstrap/app.php index e3ec5b5519..5b299a9c83 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -11,6 +11,7 @@ | */ + $app = new Illuminate\Foundation\Application( realpath(__DIR__ . '/../') ); @@ -26,6 +27,8 @@ $app = new Illuminate\Foundation\Application( | */ + + $app->singleton( 'Illuminate\Contracts\Http\Kernel', 'FireflyIII\Http\Kernel' @@ -41,6 +44,9 @@ $app->singleton( 'FireflyIII\Exceptions\Handler' ); + + + /* |-------------------------------------------------------------------------- | Return The Application diff --git a/composer.json b/composer.json index c9459d4f3f..5bbf617f3b 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,9 @@ "watson/validating": "~1.0", "doctrine/dbal": "~2.5", "illuminate/html": "~5.0", - "league/commonmark": "0.7.*" + "league/commonmark": "0.7.*", + "rcrowe/twigbridge": "0.7.x@dev", + "twig/extensions": "~1.2" }, "require-dev": { "barryvdh/laravel-debugbar": "@stable", diff --git a/composer.lock b/composer.lock index 394312ec5e..bce1a9507c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "0d43c4c85607c5cdc901cde2d18b75d5", + "hash": "e3e90dd365b74f4878cf3b5b4a1c4007", "packages": [ { "name": "classpreloader/classpreloader", @@ -1527,6 +1527,70 @@ ], "time": "2015-03-26 18:43:54" }, + { + "name": "rcrowe/twigbridge", + "version": "0.7.x-dev", + "source": { + "type": "git", + "url": "https://github.com/rcrowe/TwigBridge.git", + "reference": "ac0bfb5bcdb4fcd0cd01ab8425620ff07f6af026" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rcrowe/TwigBridge/zipball/ac0bfb5bcdb4fcd0cd01ab8425620ff07f6af026", + "reference": "ac0bfb5bcdb4fcd0cd01ab8425620ff07f6af026", + "shasum": "" + }, + "require": { + "illuminate/support": "5.0.*", + "illuminate/view": "5.0.*", + "php": ">=5.4.0", + "twig/twig": "~1.15" + }, + "require-dev": { + "laravel/framework": "5.0.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "~0.6", + "squizlabs/php_codesniffer": "~1.5" + }, + "suggest": { + "laravelcollective/html": "For bringing back html/form in Laravel 5.x", + "twig/extensions": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.7-dev" + } + }, + "autoload": { + "psr-4": { + "TwigBridge\\": "src", + "TwigBridge\\Tests\\": "tests" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + }, + { + "name": "Rob Crowe", + "email": "hello@vivalacrowe.com" + } + ], + "description": "Adds the power of Twig to Laravel", + "keywords": [ + "laravel", + "twig" + ], + "time": "2015-04-22 09:19:03" + }, { "name": "swiftmailer/swiftmailer", "version": "v5.4.0", @@ -2291,6 +2355,115 @@ ], "time": "2015-03-31 08:12:29" }, + { + "name": "twig/extensions", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig-extensions.git", + "reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/8cf4b9fe04077bd54fc73f4fde83347040c3b8cd", + "reference": "8cf4b9fe04077bd54fc73f4fde83347040c3b8cd", + "shasum": "" + }, + "require": { + "twig/twig": "~1.12" + }, + "require-dev": { + "symfony/translation": "~2.3" + }, + "suggest": { + "symfony/translation": "Allow the time_diff output to be translated" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_Extensions_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Common additional features for Twig that do not directly belong in core", + "homepage": "http://twig.sensiolabs.org/doc/extensions/index.html", + "keywords": [ + "i18n", + "text" + ], + "time": "2014-10-30 14:30:03" + }, + { + "name": "twig/twig", + "version": "v1.18.1", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/9f70492f44398e276d1b81c1b43adfe6751c7b7f", + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f", + "shasum": "" + }, + "require": { + "php": ">=5.2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "http://twig.sensiolabs.org/contributors", + "role": "Contributors" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", + "keywords": [ + "templating" + ], + "time": "2015-04-19 08:30:27" + }, { "name": "vlucas/phpdotenv", "version": "v1.1.0", @@ -4179,6 +4352,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "rcrowe/twigbridge": 20, "barryvdh/laravel-debugbar": 0 }, "prefer-stable": false, diff --git a/config/app.php b/config/app.php index 17bf91779e..f0b8a7a614 100644 --- a/config/app.php +++ b/config/app.php @@ -136,11 +136,12 @@ return [ 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Illuminate\Html\HtmlServiceProvider', + 'TwigBridge\ServiceProvider', + 'DaveJamesMiller\Breadcrumbs\ServiceProvider', 'Barryvdh\Debugbar\ServiceProvider', 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', - /* * Application Service Providers... */ @@ -152,6 +153,7 @@ return [ 'FireflyIII\Providers\FireflyServiceProvider', 'FireflyIII\Providers\TestingServiceProvider', + ], /* @@ -201,13 +203,14 @@ return [ 'View' => 'Illuminate\Support\Facades\View', 'Form' => 'Illuminate\Html\FormFacade', 'Html' => 'Illuminate\Html\HtmlFacade', - 'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade', - + 'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade', 'Preferences' => 'FireflyIII\Support\Facades\Preferences', 'Navigation' => 'FireflyIII\Support\Facades\Navigation', 'Amount' => 'FireflyIII\Support\Facades\Amount', 'Steam' => 'FireflyIII\Support\Facades\Steam', 'ExpandedForm' => 'FireflyIII\Support\Facades\ExpandedForm', + 'Twig' => 'TwigBridge\Facade\Twig', + ], diff --git a/config/view.php b/config/view.php index 88fc534aeb..6e1a698a10 100644 --- a/config/view.php +++ b/config/view.php @@ -14,7 +14,7 @@ return [ */ 'paths' => [ - realpath(base_path('resources/views')) + realpath(base_path('resources/twig')) ], /* diff --git a/resources/twig/auth/login.twig b/resources/twig/auth/login.twig new file mode 100644 index 0000000000..6853a7f764 --- /dev/null +++ b/resources/twig/auth/login.twig @@ -0,0 +1,57 @@ +{% extends "./layout/guest.twig" %} + +{% block content %} + +{% if errors.has('email') %} +
+
+ +
+
+{% endif %} + + +
+
+ +
+
+{% endblock %} + diff --git a/resources/twig/layout/guest.twig b/resources/twig/layout/guest.twig new file mode 100644 index 0000000000..1d81e22141 --- /dev/null +++ b/resources/twig/layout/guest.twig @@ -0,0 +1,62 @@ + + + + + + + + Firefly III + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + {% block content %}{% endblock %} +
+ + + + + + + + From c98275e73a126b5c7d795fcfc73803f55025e69b Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 1 May 2015 18:44:49 +0200 Subject: [PATCH 02/29] More templates converted to twig. --- app/Http/breadcrumbs.php | 8 + app/Providers/AppServiceProvider.php | 1 + app/Providers/ConfigServiceProvider.php | 207 +++++++++++++++++++++- app/Providers/FireflyServiceProvider.php | 83 ++++++++- app/Validation/FireflyValidator.php | 13 ++ resources/twig/index.twig | 215 +++++++++++++++++++++++ resources/twig/layout/default.twig | 157 +++++++++++++++++ resources/twig/list/journals-tiny.twig | 37 ++++ resources/twig/partials/boxes.twig | 92 ++++++++++ resources/twig/partials/flashes.twig | 27 +++ resources/twig/partials/menu.twig | 182 +++++++++++++++++++ 11 files changed, 1019 insertions(+), 3 deletions(-) create mode 100644 resources/twig/index.twig create mode 100644 resources/twig/layout/default.twig create mode 100644 resources/twig/list/journals-tiny.twig create mode 100644 resources/twig/partials/boxes.twig create mode 100644 resources/twig/partials/flashes.twig create mode 100644 resources/twig/partials/menu.twig diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index 610ad4418f..0574f00b80 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -22,6 +22,14 @@ Breadcrumbs::register( } ); +Breadcrumbs::register( + 'index', + function (Generator $breadcrumbs) { + + $breadcrumbs->push('Home', route('index')); + } +); + // accounts Breadcrumbs::register( 'accounts.index', function (Generator $breadcrumbs, $what) { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index bfff79a9f2..af0a5a5b8e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -35,6 +35,7 @@ class AppServiceProvider extends ServiceProvider 'Illuminate\Contracts\Auth\Registrar', 'FireflyIII\Services\Registrar' ); + } } diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index 94d9ee03fd..c4deebb1d1 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -23,7 +23,212 @@ class ConfigServiceProvider extends ServiceProvider { config( [ - // + 'twigbridge' => [ + + 'twig' => [ + /* + |-------------------------------------------------------------------------- + | Extension + |-------------------------------------------------------------------------- + | + | File extension for Twig view files. + | + */ + 'extension' => 'twig', + + /* + |-------------------------------------------------------------------------- + | Accepts all Twig environment configuration options + |-------------------------------------------------------------------------- + | + | http://twig.sensiolabs.org/doc/api.html#environment-options + | + */ + 'environment' => [ + + // When set to true, the generated templates have a __toString() method + // that you can use to display the generated nodes. + // default: false + 'debug' => config('app.debug', false), + + // The charset used by the templates. + // default: utf-8 + 'charset' => 'utf-8', + + // The base template class to use for generated templates. + // default: TwigBridge\Twig\Template + 'base_template_class' => 'TwigBridge\Twig\Template', + + // An absolute path where to store the compiled templates, or false to disable caching. If null + // then the cache file path is used. + // default: cache file storage path + 'cache' => null, + + // When developing with Twig, it's useful to recompile the template + // whenever the source code changes. If you don't provide a value + // for the auto_reload option, it will be determined automatically based on the debug value. + 'auto_reload' => true, + + // If set to false, Twig will silently ignore invalid variables + // (variables and or attributes/methods that do not exist) and + // replace them with a null value. When set to true, Twig throws an exception instead. + // default: false + 'strict_variables' => false, + + // If set to true, auto-escaping will be enabled by default for all templates. + // default: true + 'autoescape' => true, + + // A flag that indicates which optimizations to apply + // (default to -1 -- all optimizations are enabled; set it to 0 to disable) + 'optimizations' => -1, + ], + + /* + |-------------------------------------------------------------------------- + | Global variables + |-------------------------------------------------------------------------- + | + | These will always be passed in and can be accessed as Twig variables. + | NOTE: these will be overwritten if you pass data into the view with the same key. + | + */ + 'globals' => [], + ], + + 'extensions' => [ + + /* + |-------------------------------------------------------------------------- + | Extensions + |-------------------------------------------------------------------------- + | + | Enabled extensions. + | + | `Twig_Extension_Debug` is enabled automatically if twig.debug is TRUE. + | + */ + 'enabled' => [ + 'TwigBridge\Extension\Loader\Facades', + 'TwigBridge\Extension\Loader\Filters', + 'TwigBridge\Extension\Loader\Functions', + + 'TwigBridge\Extension\Laravel\Auth', + 'TwigBridge\Extension\Laravel\Config', + 'TwigBridge\Extension\Laravel\Dump', + 'TwigBridge\Extension\Laravel\Input', + 'TwigBridge\Extension\Laravel\Session', + 'TwigBridge\Extension\Laravel\String', + 'TwigBridge\Extension\Laravel\Translator', + 'TwigBridge\Extension\Laravel\Url', + + // 'TwigBridge\Extension\Laravel\Form', + // 'TwigBridge\Extension\Laravel\Html', + // 'TwigBridge\Extension\Laravel\Legacy\Facades', + ], + + /* + |-------------------------------------------------------------------------- + | Facades + |-------------------------------------------------------------------------- + | + | Available facades. Access like `{{ Config.get('foo.bar') }}`. + | + | Each facade can take an optional array of options. To mark the whole facade + | as safe you can set the option `'is_safe' => true`. Setting the facade as + | safe means that any HTML returned will not be escaped. + | + | It is advisable to not set the whole facade as safe and instead mark the + | each appropriate method as safe for security reasons. You can do that with + | the following syntax: + | + | + | 'Form' => [ + | 'is_safe' => [ + | 'open' + | ] + | ] + | + | + | The values of the `is_safe` array must match the called method on the facade + | in order to be marked as safe. + | + */ + 'facades' => [ + 'Breadcrumbs' => [ + 'is_safe' => [ + 'renderIfExists' + ] + ], + 'Session', + 'Route' + ], + + /* + |-------------------------------------------------------------------------- + | Functions + |-------------------------------------------------------------------------- + | + | Available functions. Access like `{{ secure_url(...) }}`. + | + | Each function can take an optional array of options. These options are + | passed directly to `Twig_SimpleFunction`. + | + | So for example, to mark a function as safe you can do the following: + | + | + | 'link_to' => [ + | 'is_safe' => ['html'] + | ] + | + | + | The options array also takes a `callback` that allows you to name the + | function differently in your Twig templates than what it's actually called. + | + | + | 'link' => [ + | 'callback' => 'link_to' + | ] + | + | + */ + 'functions' => [ + 'elixir', + 'head', + 'last', + ], + + /* + |-------------------------------------------------------------------------- + | Filters + |-------------------------------------------------------------------------- + | + | Available filters. Access like `{{ variable|filter }}`. + | + | Each filter can take an optional array of options. These options are + | passed directly to `Twig_SimpleFilter`. + | + | So for example, to mark a filter as safe you can do the following: + | + | + | 'studly_case' => [ + | 'is_safe' => ['html'] + | ] + | + | + | The options array also takes a `callback` that allows you to name the + | filter differently in your Twig templates than what is actually called. + | + | + | 'snake' => [ + | 'callback' => 'snake_case' + | ] + | + | + */ + 'filters' => [], + ], + ] ] ); } diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 1b57c3508e..e047b1dbb9 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -3,6 +3,7 @@ namespace FireflyIII\Providers; use App; +use FireflyIII\Models\Account; use FireflyIII\Support\Amount; use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\Navigation; @@ -10,7 +11,10 @@ use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; use FireflyIII\Validation\FireflyValidator; use Illuminate\Support\ServiceProvider; +use Route; use Twig; +use Twig_SimpleFilter; +use Twig_SimpleFunction; use TwigBridge\Extension\Loader\Functions; use Validator; @@ -28,14 +32,89 @@ class FireflyServiceProvider extends ServiceProvider return new FireflyValidator($translator, $data, $rules, $messages); } ); + /* + * Default Twig configuration: + */ + $config = App::make('config'); + Twig::addExtension(new Functions($config)); + + /* + * Amount::format + */ + $filter = new Twig_SimpleFilter( + 'formatAmount', function ($string) { + return App::make('amount')->format($string); + }, ['is_safe' => ['html']] + ); + Twig::addFilter($filter); + + /* + * Amount::formatJournal + */ + $filter = new Twig_SimpleFilter( + 'formatJournal', function ($journal) { + return App::make('amount')->formatJournal($journal); + }, ['is_safe' => ['html']] + ); + Twig::addFilter($filter); + + /* + * Steam::balance() + */ + + $filter = new Twig_SimpleFilter( + 'balance', function (Account $account = null) { + if (is_null($account)) { + return 'NULL'; + } + + return App::make('amount')->format(App::make('steam')->balance($account)); + //return App::make('steam')->balance($account); + },['is_safe' => ['html']] + ); + Twig::addFilter($filter); + + + /* + * Current active route. + */ + $filter = new Twig_SimpleFilter( + 'activeRoute', function ($string) { + if (Route::getCurrentRoute()->getName() == $string) { + return 'active'; + } + + return ''; + } + ); + Twig::addFilter($filter); + + /* + * Amount::getCurrencyCode() + */ + $function = new Twig_SimpleFunction( + 'getCurrencyCode', function () { + return App::make('amount')->getCurrencyCode(); + } + ); + Twig::addFunction($function); + + + /* + * env + */ + $function = new Twig_SimpleFunction( + 'env', function ($a, $b) { + return env($a, $b); + } + ); + Twig::addFunction($function); } public function register() { - $config = App::make('config'); - Twig::addExtension(new Functions($config)); $this->app->bind( 'preferences', function () { diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index b886074aa9..b8cf753024 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -13,6 +13,7 @@ use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Validation\Validator; use Log; use Navigation; +use Symfony\Component\Translation\TranslatorInterface; /** * Class FireflyValidator @@ -22,6 +23,18 @@ use Navigation; class FireflyValidator extends Validator { + /** + * @param TranslatorInterface $translator + * @param array $data + * @param array $rules + * @param array $messages + * @param array $customAttributes + */ + public function __construct(TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = []) + { + parent::__construct($translator, $data, $rules, $messages); + } + /** * @param $attribute * @param $value diff --git a/resources/twig/index.twig b/resources/twig/index.twig new file mode 100644 index 0000000000..c767243e4c --- /dev/null +++ b/resources/twig/index.twig @@ -0,0 +1,215 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{{ Breadcrumbs.renderIfExists }} + +{% if count == 0 %} +
+
+

Welcome to Firefly III.

+ +

+ Create a new asset account to get started. +

+
+
+
+ +{% else %} + + + {% include 'partials/boxes.twig' %} + +
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ + +
+
+ Savings + {{ savingsTotal|formatAmount }} +
+
+ {% if savings|length == 0 %} +

Mark your asset accounts as "Savings account" to fill this panel.

+ {% else %} + {% for account in savings %} + +
+ +
{{ account.startBalance|formatAmount }}
+ +
+ {% if account.difference < 0 %} + +
+
+ {% if account.percentage <= 50 %} + {{account.difference|formatAmount}} + {% endif %} +
+
+ {% if account.percentage > 50 %} + {{account.difference|formatAmount}} + {% endif %} +
+
+ {% else %} + +
+
+ {% if account.percentage <= 50 %} + {{account.difference|formatAmount}} + {{account.difference|formatAmount}} + {% endif %} +
+
+ {% if account.percentage > 50 %} + {{account.difference|formatAmount}} + {% endif %} +
+
+ {% endif %} + +
+ +
{{ account.endBalance|formatAmount }}
+
+ {% endfor %} + {% endif %} +
+
+ + +
+
+ Piggy banks +
+
+ {% if piggyBankAccounts|length == 0%} +

Create piggy banks to fill this panel.

+ {% else %} + {% for account in piggyBankAccounts %} + +
+ +
{{ account.startBalance|formatAmount }}
+ +
+ +
+
+ {% if account.percentage <= 50 %} + {{account.piggyBalance|formatAmount}} divided + {% endif %} +
+
+ {% if account.percentage > 50 %} + {{account.difference|formatAmount}} left to divide + {% endif %} +
+
+
+ +
{{ account.piggyBalance|formatAmount }}
+
+ {% endfor %} + {% endif %} +
+
+ + +
+
+ + +
+
+ Bills +
+
+
+
+
+ + + {% for data in transactions %} +
+
+ + {{data[1].name}} ({{ data[1]|balance }}) + + + +
+
+ + +
+
+ + + +
+
+ + {% include 'list/journals-tiny.twig' with {'transactions': data[0],'account': data[1]} %} +
+
+ {% endfor %} +
+
+ +{% endif %} + + +{% endblock %} +{% block scripts %} + + + + + + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/layout/default.twig b/resources/twig/layout/default.twig new file mode 100644 index 0000000000..58d5289c8e --- /dev/null +++ b/resources/twig/layout/default.twig @@ -0,0 +1,157 @@ + + + + + + + + Firefly + {% if title != "Firefly" %} + // {{ title }} + {% endif %} + + {% if subTitle %} + // {{subTitle}} + {% endif %} + + + + + + + + + + + + + + {% block styles %}{% endblock %} + + + + + + + + + + + + + + + + + + + + + + + +
+ + {% include('partials/menu.twig') %} + +
+ +
+
+

+ {% if mainTitleIcon %} + + {% endif %} + + {{ title }} + + {% if subTitle %} + + {% if subTitleIcon %} + + {% endif %} + {{ subTitle }} + + {% endif %} + +

+ +
+ +
+ + {% include('partials/flashes.twig') %} + {% block content %}{% endblock %} + + + + +
+
+ + + + + + + + + + + + + + + + + + + + +{% block scripts %}{% endblock %} + + + + diff --git a/resources/twig/list/journals-tiny.twig b/resources/twig/list/journals-tiny.twig new file mode 100644 index 0000000000..e4ca10fb72 --- /dev/null +++ b/resources/twig/list/journals-tiny.twig @@ -0,0 +1,37 @@ + diff --git a/resources/twig/partials/boxes.twig b/resources/twig/partials/boxes.twig new file mode 100644 index 0000000000..748e3cb960 --- /dev/null +++ b/resources/twig/partials/boxes.twig @@ -0,0 +1,92 @@ + +
+ + + + +
+ diff --git a/resources/twig/partials/flashes.twig b/resources/twig/partials/flashes.twig new file mode 100644 index 0000000000..de601e38c7 --- /dev/null +++ b/resources/twig/partials/flashes.twig @@ -0,0 +1,27 @@ +{% if Session.has('success') %} + +{% endif %} + +{% if Session.has('info') %} + +{% endif %} + +{% if Session.has('warning') %} + +{% endif %} + +{% if Session.has('error') %} + +{% endif %} diff --git a/resources/twig/partials/menu.twig b/resources/twig/partials/menu.twig new file mode 100644 index 0000000000..2c6dfe5056 --- /dev/null +++ b/resources/twig/partials/menu.twig @@ -0,0 +1,182 @@ + + + From bda18f296db6921be1fd4a0c2515eb36fdd91142 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 1 May 2015 20:17:06 +0200 Subject: [PATCH 03/29] Optimised Twig extensions. --- app/Providers/FireflyServiceProvider.php | 79 +-------------------- app/Support/TwigSupport.php | 90 ++++++++++++++++++++++++ resources/twig/auth/login.twig | 2 +- 3 files changed, 94 insertions(+), 77 deletions(-) create mode 100644 app/Support/TwigSupport.php diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index e047b1dbb9..844db98847 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -9,12 +9,10 @@ use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\Navigation; use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; +use FireflyIII\Support\TwigSupport; use FireflyIII\Validation\FireflyValidator; use Illuminate\Support\ServiceProvider; -use Route; use Twig; -use Twig_SimpleFilter; -use Twig_SimpleFunction; use TwigBridge\Extension\Loader\Functions; use Validator; @@ -35,81 +33,10 @@ class FireflyServiceProvider extends ServiceProvider /* * Default Twig configuration: */ + $config = App::make('config'); Twig::addExtension(new Functions($config)); - - /* - * Amount::format - */ - $filter = new Twig_SimpleFilter( - 'formatAmount', function ($string) { - return App::make('amount')->format($string); - }, ['is_safe' => ['html']] - ); - Twig::addFilter($filter); - - /* - * Amount::formatJournal - */ - $filter = new Twig_SimpleFilter( - 'formatJournal', function ($journal) { - return App::make('amount')->formatJournal($journal); - }, ['is_safe' => ['html']] - ); - Twig::addFilter($filter); - - /* - * Steam::balance() - */ - - $filter = new Twig_SimpleFilter( - 'balance', function (Account $account = null) { - if (is_null($account)) { - return 'NULL'; - } - - return App::make('amount')->format(App::make('steam')->balance($account)); - //return App::make('steam')->balance($account); - },['is_safe' => ['html']] - ); - Twig::addFilter($filter); - - - /* - * Current active route. - */ - $filter = new Twig_SimpleFilter( - 'activeRoute', function ($string) { - if (Route::getCurrentRoute()->getName() == $string) { - return 'active'; - } - - return ''; - } - ); - Twig::addFilter($filter); - - /* - * Amount::getCurrencyCode() - */ - $function = new Twig_SimpleFunction( - 'getCurrencyCode', function () { - return App::make('amount')->getCurrencyCode(); - } - ); - Twig::addFunction($function); - - - /* - * env - */ - $function = new Twig_SimpleFunction( - 'env', function ($a, $b) { - return env($a, $b); - } - ); - Twig::addFunction($function); - + Twig::addExtension(new TwigSupport); } public function register() diff --git a/app/Support/TwigSupport.php b/app/Support/TwigSupport.php new file mode 100644 index 0000000000..9e09690a3a --- /dev/null +++ b/app/Support/TwigSupport.php @@ -0,0 +1,90 @@ +format($string); + }, ['is_safe' => ['html']] + ); + + $filters[] = new Twig_SimpleFilter( + 'formatJournal', function ($journal) { + return App::make('amount')->formatJournal($journal); + }, ['is_safe' => ['html']] + ); + + $filters[] = new Twig_SimpleFilter( + 'balance', function (Account $account = null) { + if (is_null($account)) { + return 'NULL'; + } + + return App::make('amount')->format(App::make('steam')->balance($account)); + }, ['is_safe' => ['html']] + ); + $filters[] = new Twig_SimpleFilter( + 'activeRoute', function ($string) { + if (Route::getCurrentRoute()->getName() == $string) { + return 'active'; + } + + return ''; + } + ); + return $filters; + } + + /** + * {@inheritDoc} + */ + public function getFunctions() + { + $functions = []; + + $functions[] = new Twig_SimpleFunction( + 'getCurrencyCode', function () { + return App::make('amount')->getCurrencyCode(); + } + ); + + $functions[] = new Twig_SimpleFunction( + 'env', function ($name, $default) { + return env($name, $default); + } + ); + + return $functions; + + + } + + /** + * {@inheritDoc} + */ + public function getName() + { + return 'FireflyIII\Support\TwigSupport'; + } + +} \ No newline at end of file diff --git a/resources/twig/auth/login.twig b/resources/twig/auth/login.twig index 6853a7f764..b8a75141db 100644 --- a/resources/twig/auth/login.twig +++ b/resources/twig/auth/login.twig @@ -22,7 +22,7 @@
- +
From 3e5e5b376fd782d79a34c22c63be04d4ff931be0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 1 May 2015 22:44:35 +0200 Subject: [PATCH 04/29] Made it almost to the accounts. --- app/Providers/ConfigServiceProvider.php | 4 +- app/Providers/FireflyServiceProvider.php | 6 +- .../{TwigSupport.php => Twig/General.php} | 51 ++++++-- app/Support/Twig/Journals.php | 78 ++++++++++++ public/js/sb-admin-2.js | 4 +- resources/twig/accounts/create.twig | 61 ++++++++++ resources/twig/accounts/delete.twig | 36 ++++++ resources/twig/accounts/edit.twig | 72 +++++++++++ resources/twig/accounts/index.twig | 46 +++++++ resources/twig/accounts/show.twig | 60 ++++++++++ resources/twig/index.twig | 3 - resources/twig/layout/default.twig | 69 ++++++----- resources/twig/list/accounts.twig | 59 +++++++++ resources/twig/list/journals.twig | 113 ++++++++++++++++++ resources/twig/partials/menu.twig | 42 +++---- 15 files changed, 633 insertions(+), 71 deletions(-) rename app/Support/{TwigSupport.php => Twig/General.php} (54%) create mode 100644 app/Support/Twig/Journals.php create mode 100644 resources/twig/accounts/create.twig create mode 100644 resources/twig/accounts/delete.twig create mode 100644 resources/twig/accounts/edit.twig create mode 100644 resources/twig/accounts/index.twig create mode 100644 resources/twig/accounts/show.twig create mode 100644 resources/twig/list/accounts.twig create mode 100644 resources/twig/list/journals.twig diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index c4deebb1d1..77dd2eef93 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -161,7 +161,9 @@ class ConfigServiceProvider extends ServiceProvider ] ], 'Session', - 'Route' + 'Route', + 'Config', + 'ExpandedForm' ], /* diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 844db98847..b9d5601eaa 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -9,7 +9,8 @@ use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\Navigation; use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; -use FireflyIII\Support\TwigSupport; +use FireflyIII\Support\Twig\General; +use FireflyIII\Support\Twig\Journals; use FireflyIII\Validation\FireflyValidator; use Illuminate\Support\ServiceProvider; use Twig; @@ -36,7 +37,8 @@ class FireflyServiceProvider extends ServiceProvider $config = App::make('config'); Twig::addExtension(new Functions($config)); - Twig::addExtension(new TwigSupport); + Twig::addExtension(new General); + Twig::addExtension(new Journals); } public function register() diff --git a/app/Support/TwigSupport.php b/app/Support/Twig/General.php similarity index 54% rename from app/Support/TwigSupport.php rename to app/Support/Twig/General.php index 9e09690a3a..e80e327bdc 100644 --- a/app/Support/TwigSupport.php +++ b/app/Support/Twig/General.php @@ -1,8 +1,9 @@ format(App::make('steam')->balance($account)); - }, ['is_safe' => ['html']] - ); - $filters[] = new Twig_SimpleFilter( - 'activeRoute', function ($string) { - if (Route::getCurrentRoute()->getName() == $string) { - return 'active'; - } - - return ''; + return App::make('steam')->balance($account); } ); + + // should be a function but OK + $filters[] = new Twig_SimpleFilter( + 'getAccountRole', function ($name) { + return Config::get('firefly.accountRoles.' . $name); + } + ); + return $filters; } @@ -68,12 +71,34 @@ class TwigSupport extends Twig_Extension } ); + $functions[] = new Twig_SimpleFunction( 'env', function ($name, $default) { return env($name, $default); } ); + $functions[] = new Twig_SimpleFunction( + 'activeRoute', function ($context) { + $args = func_get_args(); + $route = $args[1]; + $what = isset($args[2]) ? $args[2] : false; + $activeWhat = isset($context['what']) ? $context['what'] : false; + // activeRoute + if (!($what === false)) { + if ($what == $activeWhat && Route::getCurrentRoute()->getName() == $route) { + return 'active because-active-what'; + } + } else { + if (Route::getCurrentRoute()->getName() == $route) { + return 'active because-route-matches'; + } + } + + return 'not-xxx-at-all'; + }, ['needs_context' => true] + ); + return $functions; @@ -84,7 +109,7 @@ class TwigSupport extends Twig_Extension */ public function getName() { - return 'FireflyIII\Support\TwigSupport'; + return 'FireflyIII\Support\Twig\General'; } } \ No newline at end of file diff --git a/app/Support/Twig/Journals.php b/app/Support/Twig/Journals.php new file mode 100644 index 0000000000..a8c2105832 --- /dev/null +++ b/app/Support/Twig/Journals.php @@ -0,0 +1,78 @@ +transactionType->type; + if ($type == 'Withdrawal') { + return ''; + } + if ($type == 'Deposit') { + return ''; + } + if ($type == 'Transfer') { + return ''; + } + if ($type == 'Opening balance') { + return ''; + } + + + }, ['is_safe' => ['html']] + ); + + return $filters; + } + + public function getFunctions() + { + $functions = []; + + $functions[] = new Twig_SimpleFunction( + 'invalidJournal', function (TransactionJournal $journal) { + if (!isset($journal->transactions[1]) || !isset($journal->transactions[0])) { + return true; + } + + return false; + } + ); + + $functions[] = new Twig_SimpleFunction( + 'relevantTags', function (TransactionJournal $journal) { + return 'TODO'.$journal->amount; + } + ); + + return $functions; + } + + /** + * Returns the name of the extension. + * + * @return string The extension name + */ + public function getName() + { + return 'FireflyIII\Support\Twig\Journals'; + } +} \ No newline at end of file diff --git a/public/js/sb-admin-2.js b/public/js/sb-admin-2.js index 5be2c883ad..469460fd16 100755 --- a/public/js/sb-admin-2.js +++ b/public/js/sb-admin-2.js @@ -29,8 +29,8 @@ $(function() { var url = window.location; var element = $('ul.nav a').filter(function() { return this.href == url || url.href.indexOf(this.href) == 0; - }).addClass('active').parent().parent().addClass('in').parent(); + }).parent().parent().addClass('in').parent();/*addClass('active')*/ if (element.is('li')) { - element.addClass('active'); + //element.addClass('active'); } }); diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig new file mode 100644 index 0000000000..9439400236 --- /dev/null +++ b/resources/twig/accounts/create.twig @@ -0,0 +1,61 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, what) }} + + + +
+
+
+
+ Mandatory fields +
+
+ {{ ExpandedForm.text('name') }} +
+
+
+ +
+ + @if(what == 'asset') +
+
+ Optional fields +
+
+ + {{ ExpandedForm.balance('openingBalance') }} + {{ ExpandedForm.date('openingBalanceDate', date('Y-m-d')) }} + {{ ExpandedForm.select('accountRole',Config.get('firefly.accountRoles'), null, {'helpText' : 'Any extra options resulting from your choice can be set later.'}) }} + {{ ExpandedForm.balance('virtualBalance') }} + +
+
+ @endif + + +
+
+ Options +
+
+ {{ ExpandedForm.optionsList('create','account') }} +
+
+ +
+
+
+
+

+ +

+
+
+ + +--> +{% endblock %} \ No newline at end of file diff --git a/resources/twig/accounts/delete.twig b/resources/twig/accounts/delete.twig new file mode 100644 index 0000000000..f6ee597cdb --- /dev/null +++ b/resources/twig/accounts/delete.twig @@ -0,0 +1,36 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) !!} +{!! Form::open(['class' => 'form-horizontal','id' => 'destroy','url' => route('accounts.destroy',$account->id)]) !!} +
+
+
+
+ Delete account "{{{$account->name}}}" +
+
+

+ Are you sure that you want to delete the {{strtolower($account->accountType->type)}} "{{$account->name}}"? +

+ + @if($account->transactions()->count() > 0) +

+ {{ucfirst($account->accountType->type)}} "{{{$account->name}}}" still has {{$account->transactions()->count()}} transaction(s) associated to it. These will be deleted as well. +

+ @endif + @if($account->piggyBanks()->count() > 0) +

+ {{ucfirst($account->accountType->type)}} "{{{$account->name}}}" still has {{$account->piggyBanks()->count()}} piggy bank(s) associated to it. These will be deleted as well. +

+ @endif +

+ + Cancel +

+
+
+
+
+ +{!! Form::close() !!} +{% endblock %} diff --git a/resources/twig/accounts/edit.twig b/resources/twig/accounts/edit.twig new file mode 100644 index 0000000000..0ecfceb939 --- /dev/null +++ b/resources/twig/accounts/edit.twig @@ -0,0 +1,72 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) !!} +{!! Form::model($account, ['class' => 'form-horizontal','id' => 'update','url' => route('accounts.update',$account->id)]) !!} + + + +
+
+
+
+ Mandatory fields +
+
+ {!! ExpandedForm::text('name') !!} +
+
+ +
+
+
+
+ Optional fields +
+
+ @if($account->accounttype->type == 'Default account' || $account->accounttype->type == 'Asset account') + {!! ExpandedForm::balance('openingBalance',null, ['currency' => $openingBalance ? $openingBalance->transactionCurrency : null]) !!} + {!! ExpandedForm::date('openingBalanceDate') !!} + {!! ExpandedForm::select('accountRole',Config::get('firefly.accountRoles')) !!} + {!! ExpandedForm::balance('virtualBalance',null) !!} + {!! Form::hidden('id',$account->id) !!} + @endif + {!! ExpandedForm::checkbox('active','1') !!} +
+
+ + + @if(Session::get('preFilled')['accountRole'] == 'ccAsset') +
+
+ Credit card options +
+
+ {!! ExpandedForm::select('ccType',Config::get('firefly.ccTypes')) !!} + {!! ExpandedForm::date('ccMonthlyPaymentDate',null,['helpText' => 'Select any year and any month, it will be ignored anway. Only the day of the month is relevant.']) !!} +
+
+ @endif + + +
+
+ Options +
+
+ {!! ExpandedForm::optionsList('update','account') !!} +
+
+
+
+
+
+

+ +

+
+
+ +{!! Form::close() !!} +{% endblock %} diff --git a/resources/twig/accounts/index.twig b/resources/twig/accounts/index.twig new file mode 100644 index 0000000000..a596dd3111 --- /dev/null +++ b/resources/twig/accounts/index.twig @@ -0,0 +1,46 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, what) }} +
+
+
+
+ {{ subTitle}} + + +
+
+ + +
+
+ + +
+ {% include 'list/accounts.twig' %} +
+
+
+{% endblock %} + +{% block styles %} + +{% endblock %} + +{% block scripts %} + + + + + + + + +{% endblock %} diff --git a/resources/twig/accounts/show.twig b/resources/twig/accounts/show.twig new file mode 100644 index 0000000000..59ea7654ae --- /dev/null +++ b/resources/twig/accounts/show.twig @@ -0,0 +1,60 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account) }} +
+
+
+
+ {{ account.name }} + + + +
+
+ + +
+
+
+
+
+
+
+
+
+ + +
+
+
+
+ Transactions +
+
+ {% include 'list/journals.twig' with {sorting:true} %} +
+
+
+ + + +{% endblock %} + +{% block scripts %} + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/index.twig b/resources/twig/index.twig index c767243e4c..91956567ad 100644 --- a/resources/twig/index.twig +++ b/resources/twig/index.twig @@ -204,9 +204,6 @@ {% endblock %} {% block scripts %} - diff --git a/resources/twig/layout/default.twig b/resources/twig/layout/default.twig index 58d5289c8e..cfe1190903 100644 --- a/resources/twig/layout/default.twig +++ b/resources/twig/layout/default.twig @@ -11,19 +11,19 @@ {% endif %} {% if subTitle %} - // {{subTitle}} + // {{ subTitle }} {% endif %} - - - - - - + + + + + + - + - + {% block styles %}{% endblock %} @@ -52,7 +52,7 @@
- {% include('partials/menu.twig') %} + {% include 'partials/menu.twig' %}
@@ -60,20 +60,21 @@

{% if mainTitleIcon %} - + {% endif %} {{ title }} {% if subTitle %} - - {% if subTitleIcon %} - - {% endif %} - {{ subTitle }} - + + {% if subTitleIcon %} + + {% endif %} + {{ subTitle }} + {% endif %} - +

@@ -88,18 +89,20 @@ -
+
+
@@ -130,26 +133,34 @@ var token = "{{csrf_token()}}"; var firstDate = moment("{{Session.get('first').format('Y-m-d')}}"); var currentMonthName = "{{ currentMonthName }}"; - var previousMonthName = "{{ previousMonthName }}"; - var nextMonthName = "{{ nextMonthName }}"; - $('#daterange span').text(titleString); + var previousMonthName = "{{ previousMonthName }}"; + var nextMonthName = "{{ nextMonthName }}"; + var currencyCode = '{{getCurrencyCode() }}'; + $('#daterange span').text(titleString); {% block scripts %}{% endblock %} diff --git a/resources/twig/list/accounts.twig b/resources/twig/list/accounts.twig new file mode 100644 index 0000000000..200f09eb04 --- /dev/null +++ b/resources/twig/list/accounts.twig @@ -0,0 +1,59 @@ + + + + + + {% if what == 'asset' %} + + {% endif %} + + + + + + + + {% for account in accounts %} + + + + {% if what == "asset" %} + + {% endif %} + + + {% if account.lastActivityDate %} + + {% else %} + + {% endif %} + + + + + {% endfor %} + +
 NameRoleCurrent balanceActiveLast activityBalance difference between {{ Session.get('start').format('jS F Y') }} and {{ Session.get('end').format('jS F Y') }}
+
+ + +
+
{{ account.name }} + {% for entry in account.accountmeta %} + {% if entry.name == 'accountRole' %} + {{ entry.data|getAccountRole }} + {% endif %} + {% endfor %} + {{ account|balance|formatAmount }} + {% if account.active %} + + {% else %} + + {% endif %} + + {{ account.lastActivityDate.format('j F Y') }} + + Never + + {{ (account.endBalance - account.startBalance)|formatAmount }} +
\ No newline at end of file diff --git a/resources/twig/list/journals.twig b/resources/twig/list/journals.twig new file mode 100644 index 0000000000..34ff958003 --- /dev/null +++ b/resources/twig/list/journals.twig @@ -0,0 +1,113 @@ +{{ journals.render }} + + + + + + + + + + + {% if not hideBudgets %} + + {% endif %} + + + {% if not hideCategories %} + + {% endif %} + + + {% if not hideBills %} + + {% endif %} + + {% for journal in journals %} + {% if invalidJournal(journal) %} + + + + + + + {% else %} + + + + + + + + + + + + {% if not hideBudgets %} + + {% endif %} + + + {% if not hideCategories %} + + {% endif %} + + + {% if not hideBills %} + + {% endif %} + + {% endif %} + + {% endfor %} +
 DescriptionAmountDateFromTo
+
+ +
+
 {{ journal.description }}Invalid journal: Found {{journal.transactions.count() }} transaction(s)
+
+ {% if sorting %} + + {% endif %} + + +
+
+ {{ journal|typeIcon }} + + {{journal.description}} + + {% if not hideTags %} + {{ relevantTags(journal) }} + {% else %} + {{ journal|formatJournal }} + {% endif %} + + {{journal.date.format('j F Y')}} + + {% if journal.transactions[0].account.accountType.type == 'Cash account' %} + (cash) + {% else %} + {{journal.transactions[0].account.name}} + {% endif %} + + {% if journal.transactions[1].account.accountType.type == 'Cash account' %} + (cash) + {% else %} + {{journal.transactions[1].account.name}} + {% endif %} + + {% if journal.budgets[0] %} + {{journal.budgets[0].name}} + {% endif %} + + {% if journal.categories[0] %} + {{journal.categories[0].name}} + {% endif %} + + {% if journal.bill %} + {{journal.bill.name}} + {% endif %} +
+ +{{ journals.render }} diff --git a/resources/twig/partials/menu.twig b/resources/twig/partials/menu.twig index 2c6dfe5056..91eec49241 100644 --- a/resources/twig/partials/menu.twig +++ b/resources/twig/partials/menu.twig @@ -90,86 +90,86 @@
  • - Dashboard + Dashboard
  • -
  • +
  • Accounts
  • - Budgets + Budgets
  • - Categories + Categories
  • - Tags + Tags
  • - Reports + Reports
  • -
  • +
  • Transactions
  • -
  • +
  • Money management
  • -
  • +
  • Create new From 11baa968cdfac231c11dfad60889ac536249a2e9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 1 May 2015 23:17:17 +0200 Subject: [PATCH 05/29] Can create accounts. --- app/Providers/ConfigServiceProvider.php | 27 +++++--- app/Support/Twig/General.php | 6 ++ resources/twig/accounts/create.twig | 86 ++++++++++++------------- resources/twig/form/balance.twig | 22 +++++++ resources/twig/form/date.twig | 8 +++ resources/twig/form/feedback.twig | 4 ++ resources/twig/form/help.twig | 3 + resources/twig/form/options.twig | 30 +++++++++ resources/twig/form/select.twig | 9 +++ resources/twig/form/text.twig | 7 ++ 10 files changed, 150 insertions(+), 52 deletions(-) create mode 100644 resources/twig/form/balance.twig create mode 100644 resources/twig/form/date.twig create mode 100644 resources/twig/form/feedback.twig create mode 100644 resources/twig/form/help.twig create mode 100644 resources/twig/form/options.twig create mode 100644 resources/twig/form/select.twig create mode 100644 resources/twig/form/text.twig diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index 77dd2eef93..0af1c058c7 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -108,7 +108,7 @@ class ConfigServiceProvider extends ServiceProvider | `Twig_Extension_Debug` is enabled automatically if twig.debug is TRUE. | */ - 'enabled' => [ + 'enabled' => [ 'TwigBridge\Extension\Loader\Facades', 'TwigBridge\Extension\Loader\Filters', 'TwigBridge\Extension\Loader\Functions', @@ -122,7 +122,7 @@ class ConfigServiceProvider extends ServiceProvider 'TwigBridge\Extension\Laravel\Translator', 'TwigBridge\Extension\Laravel\Url', - // 'TwigBridge\Extension\Laravel\Form', + // 'TwigBridge\Extension\Laravel\Form', // 'TwigBridge\Extension\Laravel\Html', // 'TwigBridge\Extension\Laravel\Legacy\Facades', ], @@ -154,8 +154,8 @@ class ConfigServiceProvider extends ServiceProvider | in order to be marked as safe. | */ - 'facades' => [ - 'Breadcrumbs' => [ + 'facades' => [ + 'Breadcrumbs' => [ 'is_safe' => [ 'renderIfExists' ] @@ -163,7 +163,16 @@ class ConfigServiceProvider extends ServiceProvider 'Session', 'Route', 'Config', - 'ExpandedForm' + 'ExpandedForm' => [ + 'is_safe' => [ + 'date','text','select','balance','optionsList' + ] + ], + 'Form' => [ + 'is_safe' => [ + 'input','select','checkbox' + ] + ], ], /* @@ -195,10 +204,10 @@ class ConfigServiceProvider extends ServiceProvider | */ 'functions' => [ - 'elixir', - 'head', - 'last', - ], + 'elixir', + 'head', + 'last', + ], /* |-------------------------------------------------------------------------- diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index e80e327bdc..3f0410e7ab 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -71,6 +71,12 @@ class General extends Twig_Extension } ); + $functions[] = new Twig_SimpleFunction( + 'phpdate', function ($str) { + return date($str); + } + ); + $functions[] = new Twig_SimpleFunction( 'env', function ($name, $default) { diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig index 9439400236..20da44b186 100644 --- a/resources/twig/accounts/create.twig +++ b/resources/twig/accounts/create.twig @@ -2,60 +2,60 @@ {% block content %} {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, what) }}
    + -
    -
    -
    -
    - Mandatory fields +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('name') }} +
    +
    -
    - {{ ExpandedForm.text('name') }} -
    -
    -
    -
    +
    - @if(what == 'asset') -
    -
    - Optional fields -
    -
    + {% if what == 'asset' %} +
    +
    + Optional fields +
    +
    - {{ ExpandedForm.balance('openingBalance') }} - {{ ExpandedForm.date('openingBalanceDate', date('Y-m-d')) }} - {{ ExpandedForm.select('accountRole',Config.get('firefly.accountRoles'), null, {'helpText' : 'Any extra options resulting from your choice can be set later.'}) }} - {{ ExpandedForm.balance('virtualBalance') }} + {{ ExpandedForm.balance('openingBalance') }} + {{ ExpandedForm.date('openingBalanceDate', phpdate('Y-m-d')) }} + {{ ExpandedForm.select('accountRole') }} + {{ ExpandedForm.balance('virtualBalance') }} + +
    +
    + {% endif %} + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('create','account') }} +
    +
    - @endif - - -
    -
    - Options -
    -
    - {{ ExpandedForm.optionsList('create','account') }} +
    +
    +

    + +

    -
    -
    -
    -
    -

    - -

    -
    -
    - ---> {% endblock %} \ No newline at end of file diff --git a/resources/twig/form/balance.twig b/resources/twig/form/balance.twig new file mode 100644 index 0000000000..882db8e808 --- /dev/null +++ b/resources/twig/form/balance.twig @@ -0,0 +1,22 @@ +
    + +
    +
    +
    + + +
    + {{ Form.input('number', name, value, options) }} + +
    + {% include 'form/feedback.twig' %} +
    + + +
    diff --git a/resources/twig/form/date.twig b/resources/twig/form/date.twig new file mode 100644 index 0000000000..33a300d057 --- /dev/null +++ b/resources/twig/form/date.twig @@ -0,0 +1,8 @@ +
    + +
    + {{ Form.input('date', name, value, options) }} + {% include 'form/help.twig' %} + {% include 'form/feedback.twig' %} +
    +
    diff --git a/resources/twig/form/feedback.twig b/resources/twig/form/feedback.twig new file mode 100644 index 0000000000..8cebea7222 --- /dev/null +++ b/resources/twig/form/feedback.twig @@ -0,0 +1,4 @@ +{% if errors.has(name) %} + +

    {{ errors.first(name) }}

    +{% endif %} diff --git a/resources/twig/form/help.twig b/resources/twig/form/help.twig new file mode 100644 index 0000000000..e1e2d011ea --- /dev/null +++ b/resources/twig/form/help.twig @@ -0,0 +1,3 @@ +{% if options.helpText %} +

    {{ options.helpText }}

    +{% endif %} diff --git a/resources/twig/form/options.twig b/resources/twig/form/options.twig new file mode 100644 index 0000000000..9af8428ba2 --- /dev/null +++ b/resources/twig/form/options.twig @@ -0,0 +1,30 @@ +{% if type == 'create' %} +
    + +
    +
    + +
    +
    +
    +{% endif %} + +{% if type == 'update' %} +
    + +
    +
    +
    +
    +
    +{% endif %} \ No newline at end of file diff --git a/resources/twig/form/select.twig b/resources/twig/form/select.twig new file mode 100644 index 0000000000..6956207700 --- /dev/null +++ b/resources/twig/form/select.twig @@ -0,0 +1,9 @@ +
    + +
    + {{ Form.select(name, list, selected , options ) }} + {% include 'form/help.twig' %} + {% include 'form/feedback.twig' %} + +
    +
    diff --git a/resources/twig/form/text.twig b/resources/twig/form/text.twig new file mode 100644 index 0000000000..428b238b70 --- /dev/null +++ b/resources/twig/form/text.twig @@ -0,0 +1,7 @@ +
    + +
    + {{ Form.input('text', name, value, options) }} + {% include 'form/feedback.twig' %} +
    +
    From f8e9ce0d52404596359456a32cf33a3b08175359 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 1 May 2015 23:35:35 +0200 Subject: [PATCH 06/29] Can edit as well. --- app/Providers/ConfigServiceProvider.php | 4 +-- resources/twig/accounts/create.twig | 2 +- resources/twig/accounts/edit.twig | 41 ++++++++++++------------- resources/twig/form/checkbox.twig | 11 +++++++ 4 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 resources/twig/form/checkbox.twig diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index 0af1c058c7..a23a061d87 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -165,12 +165,12 @@ class ConfigServiceProvider extends ServiceProvider 'Config', 'ExpandedForm' => [ 'is_safe' => [ - 'date','text','select','balance','optionsList' + 'date','text','select','balance','optionsList','checkbox' ] ], 'Form' => [ 'is_safe' => [ - 'input','select','checkbox' + 'input','select','checkbox','model' ] ], ], diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig index 20da44b186..6ed1f2dfaf 100644 --- a/resources/twig/accounts/create.twig +++ b/resources/twig/accounts/create.twig @@ -28,7 +28,7 @@ {{ ExpandedForm.balance('openingBalance') }} {{ ExpandedForm.date('openingBalanceDate', phpdate('Y-m-d')) }} - {{ ExpandedForm.select('accountRole') }} + {{ ExpandedForm.select('accountRole', Config.get('firefly.accountRoles'),null,{'helpText' : 'Any extra options resulting from your choice can be set later.'}) }} {{ ExpandedForm.balance('virtualBalance') }}
    diff --git a/resources/twig/accounts/edit.twig b/resources/twig/accounts/edit.twig index 0ecfceb939..19968766f8 100644 --- a/resources/twig/accounts/edit.twig +++ b/resources/twig/accounts/edit.twig @@ -1,18 +1,18 @@ {% extends "./layout/default.twig" %} {% block content %} -{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) !!} -{!! Form::model($account, ['class' => 'form-horizontal','id' => 'update','url' => route('accounts.update',$account->id)]) !!} +{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute().getName(), account) }} +{{ Form.model(account, {'class' : 'form-horizontal','id' : 'update','url' : route('accounts.update',account.id) } ) }} - +
    - Mandatory fields + Mandatory fields
    - {!! ExpandedForm::text('name') !!} + {{ ExpandedForm.text('name') }}
    @@ -23,37 +23,37 @@ Optional fields
    - @if($account->accounttype->type == 'Default account' || $account->accounttype->type == 'Asset account') - {!! ExpandedForm::balance('openingBalance',null, ['currency' => $openingBalance ? $openingBalance->transactionCurrency : null]) !!} - {!! ExpandedForm::date('openingBalanceDate') !!} - {!! ExpandedForm::select('accountRole',Config::get('firefly.accountRoles')) !!} - {!! ExpandedForm::balance('virtualBalance',null) !!} - {!! Form::hidden('id',$account->id) !!} - @endif - {!! ExpandedForm::checkbox('active','1') !!} + {% if account.accounttype.type == 'Default account' or account.accounttype.type == 'Asset account' %} + {{ ExpandedForm.balance('openingBalance',null, {'currency' : openingBalance ? openingBalance.transactionCurrency : null}) }} + {{ ExpandedForm.date('openingBalanceDate') }} + {{ ExpandedForm.select('accountRole',Config.get('firefly.accountRoles')) }} + {{ ExpandedForm.balance('virtualBalance',null) }} + + {% endif %} + {{ ExpandedForm.checkbox('active','1') }}
    - @if(Session::get('preFilled')['accountRole'] == 'ccAsset') + {% if Session.get('preFilled').accountRole == 'ccAsset' %}
    Credit card options
    - {!! ExpandedForm::select('ccType',Config::get('firefly.ccTypes')) !!} - {!! ExpandedForm::date('ccMonthlyPaymentDate',null,['helpText' => 'Select any year and any month, it will be ignored anway. Only the day of the month is relevant.']) !!} + {{ ExpandedForm.select('ccType',Config.get('firefly.ccTypes')) }} + {{ ExpandedForm.date('ccMonthlyPaymentDate',null,{'helpText' : 'Select any year and any month, it will be ignored anway. Only the day of the month is relevant.'}) }}
    - @endif + {% endif %} - +
    Options
    - {!! ExpandedForm::optionsList('update','account') !!} + {{ ExpandedForm.optionsList('update','account') }}
    @@ -67,6 +67,5 @@

    - -{!! Form::close() !!} + {% endblock %} diff --git a/resources/twig/form/checkbox.twig b/resources/twig/form/checkbox.twig new file mode 100644 index 0000000000..21d8e59177 --- /dev/null +++ b/resources/twig/form/checkbox.twig @@ -0,0 +1,11 @@ +
    + +
    +
    + +
    + {% include 'form/feedback.twig' %} +
    +
    From 31a1031624fd35c0f07cc9357176b3e68681f0d6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 1 May 2015 23:39:45 +0200 Subject: [PATCH 07/29] And delete is fixed. --- app/Providers/ConfigServiceProvider.php | 2 +- resources/twig/accounts/delete.twig | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index a23a061d87..926e9363c4 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -170,7 +170,7 @@ class ConfigServiceProvider extends ServiceProvider ], 'Form' => [ 'is_safe' => [ - 'input','select','checkbox','model' + 'input','select','checkbox','model','open' ] ], ], diff --git a/resources/twig/accounts/delete.twig b/resources/twig/accounts/delete.twig index f6ee597cdb..ef7cea4dbb 100644 --- a/resources/twig/accounts/delete.twig +++ b/resources/twig/accounts/delete.twig @@ -1,36 +1,36 @@ {% extends "./layout/default.twig" %} {% block content %} -{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) !!} -{!! Form::open(['class' => 'form-horizontal','id' => 'destroy','url' => route('accounts.destroy',$account->id)]) !!} +{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute().getName(), account) }} +{{ Form.open({'class' : 'form-horizontal','id' : 'destroy','url' : route('accounts.destroy',account.id)}) }}
    - Delete account "{{{$account->name}}}" + Delete account "{{ account.name }}"

    - Are you sure that you want to delete the {{strtolower($account->accountType->type)}} "{{$account->name}}"? + Are you sure that you want to delete the {{account.accountType.type|lower}} "{{account.name}}"?

    - @if($account->transactions()->count() > 0) + {% if account.transactions().count() > 0 %}

    - {{ucfirst($account->accountType->type)}} "{{{$account->name}}}" still has {{$account->transactions()->count()}} transaction(s) associated to it. These will be deleted as well. + {{account.accountType.type|capitalize}} "{{ account.name }}" still has {{account.transactions().count()}} transaction(s) associated to it. These will be deleted as well.

    - @endif - @if($account->piggyBanks()->count() > 0) + {% endif %} + {% if account.piggyBanks().count() > 0 %}

    - {{ucfirst($account->accountType->type)}} "{{{$account->name}}}" still has {{$account->piggyBanks()->count()}} piggy bank(s) associated to it. These will be deleted as well. + {{account.accountType.type|capitalize}} "{{ account.name }}" still has {{account.piggyBanks().count()}} piggy bank(s) associated to it. These will be deleted as well.

    - @endif + {% endif %}

    - Cancel + Cancel

    -{!! Form::close() !!} + {% endblock %} From 6dbb80d687cef8189bf22328a9078ffb93ff2c31 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 08:09:54 +0200 Subject: [PATCH 08/29] Optimisations [skip ci] --- resources/twig/accounts/delete.twig | 8 ++++---- resources/twig/list/journals.twig | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/twig/accounts/delete.twig b/resources/twig/accounts/delete.twig index ef7cea4dbb..4608db3fdc 100644 --- a/resources/twig/accounts/delete.twig +++ b/resources/twig/accounts/delete.twig @@ -13,14 +13,14 @@ Are you sure that you want to delete the {{account.accountType.type|lower}} "{{account.name}}"?

    - {% if account.transactions().count() > 0 %} + {% if account.transactions|length > 0 %}

    - {{account.accountType.type|capitalize}} "{{ account.name }}" still has {{account.transactions().count()}} transaction(s) associated to it. These will be deleted as well. + {{account.accountType.type|capitalize}} "{{ account.name }}" still has {{ account.transactions|length }} transaction(s) associated to it. These will be deleted as well.

    {% endif %} - {% if account.piggyBanks().count() > 0 %} + {% if account.piggyBanks|length > 0 %}

    - {{account.accountType.type|capitalize}} "{{ account.name }}" still has {{account.piggyBanks().count()}} piggy bank(s) associated to it. These will be deleted as well. + {{account.accountType.type|capitalize}} "{{ account.name }}" still has {{ account.piggyBanks|length }} piggy bank(s) associated to it. These will be deleted as well.

    {% endif %}

    diff --git a/resources/twig/list/journals.twig b/resources/twig/list/journals.twig index 34ff958003..0fa99ec0ab 100644 --- a/resources/twig/list/journals.twig +++ b/resources/twig/list/journals.twig @@ -33,7 +33,7 @@   {{ journal.description }} - Invalid journal: Found {{journal.transactions.count() }} transaction(s) + Invalid journal: Found {{journal.transactions|length }} transaction(s) {% else %} From e94333f8777e362175a604188373fb470f9683bd Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 08:28:24 +0200 Subject: [PATCH 09/29] Can view budgets [skip ci] --- app/Support/Twig/General.php | 6 + resources/twig/budgets/index.twig | 192 ++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 resources/twig/budgets/index.twig diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 3f0410e7ab..cf9c8cef88 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -71,6 +71,12 @@ class General extends Twig_Extension } ); + $functions[] = new Twig_SimpleFunction( + 'getCurrencySymbol', function () { + return App::make('amount')->getCurrencySymbol(); + } + ); + $functions[] = new Twig_SimpleFunction( 'phpdate', function ($str) { return date($str); diff --git a/resources/twig/budgets/index.twig b/resources/twig/budgets/index.twig new file mode 100644 index 0000000000..383e71f74d --- /dev/null +++ b/resources/twig/budgets/index.twig @@ -0,0 +1,192 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +

    +
    +
    +
    + + {{ Session.get('start').format('F Y') }} +
    +
    +
    +
    + Budgeted: +
    +
    + Available in {{ Session.get('start').format('F Y') }}: + {{ amount|formatAmount }} +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + Spent: {{ spent|formatAmount }} +
    +
    +
    +
    +
    + {% if overspent %} +
    +
    + {% else %} +
    + {% endif %} +
    +
    +
    + +
    +
    +
    +
    + +
    +
    + + Transactions without a budget +
    + +
    +
    + +
    + +
    + {% for budget in budgets %} +
    +
    +
    + + {% if budget.currentRep %} + {{ budget.name }} + {% else %} + {{ budget.name }} + {% endif %} + + + +
    +
    + + +
    +
    + +
    +
    + +

    + {% if budget.currentRep %} + + {% else %} + + {% endif %} +

    + +

    + + + {% if budget.currentRep %} + + Budgeted: + + + {% if budget.currentRep.amount > budget.spent %} + {{ getCurrencySymbol() }} + {% else %} + {{ getCurrencySymbol() }} + {% endif %} + + {% else %} + No budget + + + + {% endif %} + +

    + +

    + Spent: {{ budget.spent|formatAmount }} +

    +
    +
    +
    + {% endfor %} +
    +
    +
    + + Create budget +
    + +
    +
    + {% if inactive|length > 0 %} +
    +
    +
    + + Inactive budgets +
    +
    + {% for index,budget in inactive %} + {% if index != inactive|length-1 %} + {{ budget.name }}, + {% else %} + {{ budget.name }} + {% endif %} + {% endfor %} +
    +
    +
    + {% endif %} +
    + + + + +{% endblock %} +{% block scripts %} + +{% endblock %} From a41d5e9ab31228f5176f7f376180cf8c35712cf3 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 08:32:20 +0200 Subject: [PATCH 10/29] New budget [skip ci] --- resources/twig/budgets/create.twig | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 resources/twig/budgets/create.twig diff --git a/resources/twig/budgets/create.twig b/resources/twig/budgets/create.twig new file mode 100644 index 0000000000..fc4d4a5429 --- /dev/null +++ b/resources/twig/budgets/create.twig @@ -0,0 +1,45 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'store','url' : route('budgets.store')}) }} +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('name') }} +
    +
    +
    +
    + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('create','budget') }} +
    +
    + +
    + +
    +
    +
    +

    + +

    +
    +
    + + + + + + +{% endblock %} From 803827e05c928f909b609a6de314e0634d621e82 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 09:06:07 +0200 Subject: [PATCH 11/29] Fixed more views. [skip ci] --- app/Http/Controllers/BudgetController.php | 1 + app/Providers/ConfigServiceProvider.php | 1 + app/Providers/FireflyServiceProvider.php | 2 + app/Support/Twig/Budget.php | 53 +++++++++++ resources/twig/budgets/delete.twig | 43 +++++++++ resources/twig/budgets/edit.twig | 49 ++++++++++ resources/twig/budgets/income.twig | 22 +++++ resources/twig/budgets/noBudget.twig | 17 ++++ resources/twig/budgets/show.twig | 108 ++++++++++++++++++++++ resources/twig/list/journals.twig | 4 +- 10 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 app/Support/Twig/Budget.php create mode 100644 resources/twig/budgets/delete.twig create mode 100644 resources/twig/budgets/edit.twig create mode 100644 resources/twig/budgets/income.twig create mode 100644 resources/twig/budgets/noBudget.twig create mode 100644 resources/twig/budgets/show.twig diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index f72ec26884..733e08f544 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -190,6 +190,7 @@ class BudgetController extends Controller $journals = $repository->getJournals($budget, $repetition); $limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget); $subTitle = !is_null($repetition->id) ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name); + $journals->setPath('/budgets/show/'.$budget->id); return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle')); } diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index 926e9363c4..c2cfad8399 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -162,6 +162,7 @@ class ConfigServiceProvider extends ServiceProvider ], 'Session', 'Route', + 'URL', 'Config', 'ExpandedForm' => [ 'is_safe' => [ diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index b9d5601eaa..b2a298caf4 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -9,6 +9,7 @@ use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\Navigation; use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; +use FireflyIII\Support\Twig\Budget; use FireflyIII\Support\Twig\General; use FireflyIII\Support\Twig\Journals; use FireflyIII\Validation\FireflyValidator; @@ -39,6 +40,7 @@ class FireflyServiceProvider extends ServiceProvider Twig::addExtension(new Functions($config)); Twig::addExtension(new General); Twig::addExtension(new Journals); + Twig::addExtension(new Budget); } public function register() diff --git a/app/Support/Twig/Budget.php b/app/Support/Twig/Budget.php new file mode 100644 index 0000000000..39ec2a1e04 --- /dev/null +++ b/app/Support/Twig/Budget.php @@ -0,0 +1,53 @@ +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', '>=', $repetition->startdate->format('Y-m-d')) + ->where('transaction_journals.date', '<=', $repetition->enddate->format('Y-m-d')) + ->where('transaction_journals.user_id', Auth::user()->id) + ->whereNull('transactions.deleted_at') + ->where('transactions.amount', '>', 0) + ->where('limit_repetitions.id', '=', $repetition->id) + ->sum('transactions.amount'); + + return floatval($sum); + } + ); + + return $functions; + + } + + /** + * {@inheritDoc} + */ + public function getName() + { + return 'FireflyIII\Support\Twig\Budget'; + } +} \ No newline at end of file diff --git a/resources/twig/budgets/delete.twig b/resources/twig/budgets/delete.twig new file mode 100644 index 0000000000..e1b7e5ef95 --- /dev/null +++ b/resources/twig/budgets/delete.twig @@ -0,0 +1,43 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, budget) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'destroy','url' : route('budgets.destroy',budget.id) }) }} +
    +
    +
    +
    + Delete budget "{{ budget.name}}" +
    +
    +

    + Are you sure that you want to delete budget "{{ budget.name }}"? +

    + + {% if budget.transactionjournals|length > 0 %} +

    + Budget "{{ budget.name }}" still has {{ budget.transactionjournals|length }} transactions connected + to it. These will not be removed but will lose their connection to this budget. +

    + {% endif %} + +

    + + Cancel +

    +
    +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    + + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/budgets/edit.twig b/resources/twig/budgets/edit.twig new file mode 100644 index 0000000000..edb967500f --- /dev/null +++ b/resources/twig/budgets/edit.twig @@ -0,0 +1,49 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, budget) }} +
    +
    +

    Use budgets to organize and limit your expenses.

    +
    +
    + + {{ Form.model(budget, {'class' : 'form-horizontal','id' : 'update','url' : route('budgets.update',budget.id) } ) }} + +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.checkbox('active') }} + {{ ExpandedForm.text('name') }} +
    +
    + +
    +
    + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('update','budget') }} +
    +
    +
    +
    +
    +
    +

    + +

    +
    +
    + + + +{% endblock %} diff --git a/resources/twig/budgets/income.twig b/resources/twig/budgets/income.twig new file mode 100644 index 0000000000..de8420042b --- /dev/null +++ b/resources/twig/budgets/income.twig @@ -0,0 +1,22 @@ +
    + + +
    + diff --git a/resources/twig/budgets/noBudget.twig b/resources/twig/budgets/noBudget.twig new file mode 100644 index 0000000000..df482d3546 --- /dev/null +++ b/resources/twig/budgets/noBudget.twig @@ -0,0 +1,17 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +
    +
    +
    +
    + {{ subTitle }} +
    +
    + {% include 'list/journals.twig' with {'journals': list} %} +
    +
    +
    +
    + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/budgets/show.twig b/resources/twig/budgets/show.twig new file mode 100644 index 0000000000..d062d785a5 --- /dev/null +++ b/resources/twig/budgets/show.twig @@ -0,0 +1,108 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName,budget, repetition) }} +
    +
    +
    +
    + Overview + + + +
    +
    + + +
    +
    +
    +
    +
    +
    +
    + +
    +
    + Transactions +
    + {% include 'list/journals.twig' %} +
    +
    +
    + {% if limits|length == 1 %} +

    Show everything

    + {% endif %} + + {% for limit in limits %} + {% for rep in limit.limitRepetitions %} +
    + +
    +
    +
    + Amount: {{ rep.amount|formatAmount }} +
    +
    + Spent: {{ spentInRepetition(rep)|formatAmount }} +
    +
    +
    +
    + {% set overspent = spentInRepetition(rep) > rep.amount %} + {% if overspent %} + {% set spent = spentInRepetition(rep) %} + {% set pct = (spent != 0 ? (rep.amount / spent)*100 : 0) %} +
    +
    +
    +
    + {% else %} + {% set amount = rep.amount %} + {% set pct = (amount != 0 ? (spentInRepetition(rep) / amount)*100 : 0) %} +
    +
    +
    + {% endif %} +
    +
    +
    +
    + {% endfor %} + {% endfor %} + + {% if limits|length == 1 %} +

    Show everything

    + {% endif %} + +
    +
    + +{% endblock %} +{% block scripts %} + + + + + + + + +{% endblock %} diff --git a/resources/twig/list/journals.twig b/resources/twig/list/journals.twig index 0fa99ec0ab..7e61c16bf4 100644 --- a/resources/twig/list/journals.twig +++ b/resources/twig/list/journals.twig @@ -1,4 +1,4 @@ -{{ journals.render }} +{{ journals.render|raw }} @@ -110,4 +110,4 @@ {% endfor %}
    -{{ journals.render }} +{{ journals.render|raw }} \ No newline at end of file From 4a2b01cd9af74b99408fef215509f9db224211f6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 09:16:17 +0200 Subject: [PATCH 12/29] Menu fixes [skip ci] --- app/Support/Twig/General.php | 16 +++++++++++----- resources/twig/partials/menu.twig | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index cf9c8cef88..5b2088beab 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -92,18 +92,24 @@ class General extends Twig_Extension $functions[] = new Twig_SimpleFunction( 'activeRoute', function ($context) { - $args = func_get_args(); - $route = $args[1]; - $what = isset($args[2]) ? $args[2] : false; + $args = func_get_args(); + $route = $args[1]; + $what = isset($args[2]) ? $args[2] : false; + $strict = isset($args[3]) ? $args[3] : false; $activeWhat = isset($context['what']) ? $context['what'] : false; + // activeRoute if (!($what === false)) { if ($what == $activeWhat && Route::getCurrentRoute()->getName() == $route) { return 'active because-active-what'; } } else { - if (Route::getCurrentRoute()->getName() == $route) { - return 'active because-route-matches'; + if (!$strict && !(strpos(Route::getCurrentRoute()->getName(), $route) === false)) { + return 'active because-route-matches-non-strict'; + } else { + if ($strict && Route::getCurrentRoute()->getName() == $route) { + return 'active because-route-matches-strict'; + } } } diff --git a/resources/twig/partials/menu.twig b/resources/twig/partials/menu.twig index 91eec49241..da0704dfd3 100644 --- a/resources/twig/partials/menu.twig +++ b/resources/twig/partials/menu.twig @@ -90,7 +90,7 @@
  • - Dashboard + Dashboard
  • Accounts From ee4e0617393ddd894361bcd42020c6d9f717b915 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 09:21:32 +0200 Subject: [PATCH 13/29] Removed code from budget index [skip ci] --- resources/twig/budgets/show.twig | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/twig/budgets/show.twig b/resources/twig/budgets/show.twig index d062d785a5..b2041c745a 100644 --- a/resources/twig/budgets/show.twig +++ b/resources/twig/budgets/show.twig @@ -89,7 +89,6 @@ {% block scripts %} + + + + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/list/categories.twig b/resources/twig/list/categories.twig new file mode 100644 index 0000000000..605167cd17 --- /dev/null +++ b/resources/twig/list/categories.twig @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + {% for category in categories %} + + + + {% if category.lastActivity %} + + {% else %} + + {% endif %} + + {% endfor %} + +
     NameLast activity
     Without a category 
    +
    + + +
    +
    + {{ category.name }} + + {{category.lastActivity.format('jS F Y') }} + + Never +
    From be0adb7cf2ec8c2fdca4c334f6379549f707cf10 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 09:25:45 +0200 Subject: [PATCH 15/29] Create / edit category --- resources/twig/categories/create.twig | 45 +++++++++++++++++++++++++++ resources/twig/categories/delete.twig | 33 ++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 resources/twig/categories/create.twig create mode 100644 resources/twig/categories/delete.twig diff --git a/resources/twig/categories/create.twig b/resources/twig/categories/create.twig new file mode 100644 index 0000000000..90ea9c57a5 --- /dev/null +++ b/resources/twig/categories/create.twig @@ -0,0 +1,45 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'store','url' : route('categories.store')}) }} + +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('name') }} +
    +
    +
    + +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('create','category') }} +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    + + + +{% endblock %} + diff --git a/resources/twig/categories/delete.twig b/resources/twig/categories/delete.twig new file mode 100644 index 0000000000..bab3e41d0e --- /dev/null +++ b/resources/twig/categories/delete.twig @@ -0,0 +1,33 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, category) }} +{{ Form.open({'class' : 'form-horizontal','id' : 'destroy','url' : route('categories.destroy',category.id)}) }} +
    +
    +
    +
    + Delete category "{{ category.name }}" +
    +
    +

    + Are you sure that you want to delete category "{{ category.name }}"? +

    + + {% if category.transactionjournals|length > 0 %} +

    + Category "{{ category.name }}" still has {{ category.transactionjournals|length }} transactions connected + to it. These will not be removed but will lose their connection to this category. +

    + {% endif %} + +

    + + Cancel +

    +
    +
    +
    +
    + + +{% endblock %} From a2f5fbdfd356e7f87ba20ff094626318a3b196a1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 09:29:34 +0200 Subject: [PATCH 16/29] Working on two more views [skip ci] --- resources/twig/categories/noCategory.twig | 18 ++++++++ resources/twig/categories/show.twig | 54 +++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 resources/twig/categories/noCategory.twig create mode 100644 resources/twig/categories/show.twig diff --git a/resources/twig/categories/noCategory.twig b/resources/twig/categories/noCategory.twig new file mode 100644 index 0000000000..5755d824d2 --- /dev/null +++ b/resources/twig/categories/noCategory.twig @@ -0,0 +1,18 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +
    +
    +
    +
    + {{ subTitle }} +
    +
    + {% include 'list/journals.twig' with {'journals': list} %} +
    +
    +
    +
    + + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/categories/show.twig b/resources/twig/categories/show.twig new file mode 100644 index 0000000000..b830ccacf0 --- /dev/null +++ b/resources/twig/categories/show.twig @@ -0,0 +1,54 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, category) }} +
    +
    +
    +
    + + Overview +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Overview +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    + + Transactions +
    +
    + {% include 'list/journals' %} +
    +
    +
    +
    + +{% endblock %} +{% block scripts %} + + + + + + + +{% endblock %} \ No newline at end of file From 32c4661233e39bfeed295cab789cbe7c27e949ec Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 09:49:37 +0200 Subject: [PATCH 17/29] Fixed no budget / no category bread crumb [skip ci] --- resources/twig/budgets/noBudget.twig | 2 +- resources/twig/categories/noCategory.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/twig/budgets/noBudget.twig b/resources/twig/budgets/noBudget.twig index df482d3546..2ff705afe8 100644 --- a/resources/twig/budgets/noBudget.twig +++ b/resources/twig/budgets/noBudget.twig @@ -1,6 +1,6 @@ {% extends "./layout/default.twig" %} {% block content %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, subTitle) }}
    diff --git a/resources/twig/categories/noCategory.twig b/resources/twig/categories/noCategory.twig index 5755d824d2..e85d86c942 100644 --- a/resources/twig/categories/noCategory.twig +++ b/resources/twig/categories/noCategory.twig @@ -1,6 +1,6 @@ {% extends "./layout/default.twig" %} {% block content %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, subTitle) }}
    From 356dd2c6cd616d05a4933145c60bac744de16487 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 10:37:16 +0200 Subject: [PATCH 18/29] Creat / edit / index [skip ci] --- resources/twig/currency/create.twig | 44 ++++++++++++++++++++++++++ resources/twig/currency/edit.twig | 45 ++++++++++++++++++++++++++ resources/twig/currency/index.twig | 49 +++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 resources/twig/currency/create.twig create mode 100644 resources/twig/currency/edit.twig create mode 100644 resources/twig/currency/index.twig diff --git a/resources/twig/currency/create.twig b/resources/twig/currency/create.twig new file mode 100644 index 0000000000..810826f79a --- /dev/null +++ b/resources/twig/currency/create.twig @@ -0,0 +1,44 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'store','route' : 'currency.store'}) }} +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('name',null,{'maxlength' : 48}) }} + {{ ExpandedForm.text('symbol',null,{'maxlength': 8}) }} + {{ ExpandedForm.text('code',null,{'maxlength' : 3}) }} +
    +
    + +
    + +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('create','currency') }} +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    + +{% endblock %} diff --git a/resources/twig/currency/edit.twig b/resources/twig/currency/edit.twig new file mode 100644 index 0000000000..8d356fcf4f --- /dev/null +++ b/resources/twig/currency/edit.twig @@ -0,0 +1,45 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, currency) }} + {{ Form.model(currency, {'class' : 'form-horizontal','id' : 'update','url' : route('currency.update',currency.id)}) }} + + +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('name',null,{'maxlength' : 48}) }} + {{ ExpandedForm.text('symbol',null,{'maxlength' : 8}) }} + {{ ExpandedForm.text('code',null,{'maxlength' : 3}) }} +
    +
    +
    + +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('update','currency') }} +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/currency/index.twig b/resources/twig/currency/index.twig new file mode 100644 index 0000000000..77e928bee6 --- /dev/null +++ b/resources/twig/currency/index.twig @@ -0,0 +1,49 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + +
    +
    +
    +
    + Currencies +
    +
    +

    + Firefly III supports various currencies which you can set and enable here. +

    +
      + {% if currencies|length > 0 %} + + + + + + {% for currency in currencies %} + + + + + + + {% endfor %} +
       Currency
      +
      + + +
      +
      {{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }}) + {% if currency.id == defaultCurrency.id %} + default + {% else %} + make default + {% endif %} +
      + {% endif %} +

      Add another currency

      + +
    +
    +
    +
    +{% endblock %} \ No newline at end of file From 466c2a68c2deca5a1121318681dd0b1aaed24432 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 10:42:41 +0200 Subject: [PATCH 19/29] Add delete form [skip ci] --- resources/twig/currency/delete.twig | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 resources/twig/currency/delete.twig diff --git a/resources/twig/currency/delete.twig b/resources/twig/currency/delete.twig new file mode 100644 index 0000000000..b90be97c5c --- /dev/null +++ b/resources/twig/currency/delete.twig @@ -0,0 +1,26 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, currency) }} +{{ Form.open({'class' : 'form-horizontal','id' : 'destroy','url' : route('currency.destroy',currency.id)}) }} +
    +
    +
    +
    + Delete currency "{{ currency.name }}" +
    +
    +

    + Are you sure that you want to delete currency "{{ currency.name }}"? +

    +

    + + Cancel +

    +
    +
    +
    +
    + + + +{% endblock %} \ No newline at end of file From 5cd2ef4a5e3b468130067710c6bb199dfd9cc406 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 10:53:54 +0200 Subject: [PATCH 20/29] Some generic templates and the first piggy bank ones [skip ci] --- app/Support/Twig/General.php | 5 +++ resources/twig/emails/password.twig | 1 + resources/twig/emails/registered.twig | 5 +++ resources/twig/errors/503.twig | 41 ++++++++++++++++++ resources/twig/list/piggy-banks.twig | 56 ++++++++++++++++++++++++ resources/twig/piggy-banks/index.twig | 62 +++++++++++++++++++++++++++ 6 files changed, 170 insertions(+) create mode 100644 resources/twig/emails/password.twig create mode 100644 resources/twig/emails/registered.twig create mode 100644 resources/twig/errors/503.twig create mode 100644 resources/twig/list/piggy-banks.twig create mode 100644 resources/twig/piggy-banks/index.twig diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 5b2088beab..ff7851dd66 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -31,6 +31,11 @@ class General extends Twig_Extension return App::make('amount')->format($string); }, ['is_safe' => ['html']] ); + $filters[] = new Twig_SimpleFilter( + 'formatAmountPlain', function ($string) { + return App::make('amount')->format($string, false); + } + ); $filters[] = new Twig_SimpleFilter( 'formatJournal', function ($journal) { diff --git a/resources/twig/emails/password.twig b/resources/twig/emails/password.twig new file mode 100644 index 0000000000..2aba25c1fc --- /dev/null +++ b/resources/twig/emails/password.twig @@ -0,0 +1 @@ +Click here to reset your password: {{ url('password/reset/' . token) }} diff --git a/resources/twig/emails/registered.twig b/resources/twig/emails/registered.twig new file mode 100644 index 0000000000..4550f79f9d --- /dev/null +++ b/resources/twig/emails/registered.twig @@ -0,0 +1,5 @@ +Hey there! + +Welkome to Firefly III. Your registration has made it, and this email is here to confirm it. + +Thanks for using Firefly! diff --git a/resources/twig/errors/503.twig b/resources/twig/errors/503.twig new file mode 100644 index 0000000000..0847a1c967 --- /dev/null +++ b/resources/twig/errors/503.twig @@ -0,0 +1,41 @@ + + + + + + + +
    +
    +
    Be right back.
    +
    +
    + + diff --git a/resources/twig/list/piggy-banks.twig b/resources/twig/list/piggy-banks.twig new file mode 100644 index 0000000000..ef6cf6be63 --- /dev/null +++ b/resources/twig/list/piggy-banks.twig @@ -0,0 +1,56 @@ + + + {% for piggyBank in piggyBanks %} + + + + + + + + + + + + + +{% endfor %} + +
    + + + +
    + + +
    +
    + {{ piggyBank.name }} + + {{piggyBank.savedSoFar|formatAmountPlain }} + + {% if piggyBank.savedSoFar > 0 %} + + {% endif %} + +
    +
    + {{ piggyBank.percentage }}% +
    +
    +
    + {% if piggyBank.leftToSave > 0 %} + + {% endif %} + + {{ piggyBank.targetamount|formatAmount }} + {% if piggyBank.leftToSave > 0 %} + ({{ piggyBank.leftToSave|formatAmount }}) + {% endif %} +
    \ No newline at end of file diff --git a/resources/twig/piggy-banks/index.twig b/resources/twig/piggy-banks/index.twig new file mode 100644 index 0000000000..62c3e1254f --- /dev/null +++ b/resources/twig/piggy-banks/index.twig @@ -0,0 +1,62 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +
    + +
    + +
    +
    +
    +
    Piggy banks
    + {% include 'list/piggy-banks.twig' %} +
    +
    +
    + +
    +
    +
    +
    + Account status +
    + + + + + + + + + + {% for id,info in accounts %} + + + + + + + + + {% endfor %} +
    AccountBalanceLeft for piggy banksSum of piggy banksSaved so farLeft to save
    {{ info.name }}{{ info.balance|formatAmount }}{{ info.leftForPiggyBanks|formatAmount }}{{ info.sumOfTargets|formatAmount }}{{ info.sumOfSaved|formatAmount }}{{ info.leftToSave|formatAmount }}
    +
    +
    +
    + + + + +{% endblock %} +{% block scripts %} + + +{% endblock %} \ No newline at end of file From 81a2975f1a9578111e09988ccf55a91778dec2b9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 11:32:45 +0200 Subject: [PATCH 21/29] Show piggy banks [skip ci] --- app/Providers/ConfigServiceProvider.php | 18 +-- app/Providers/FireflyServiceProvider.php | 6 +- .../Twig/{Journals.php => Journal.php} | 4 +- app/Support/Twig/PiggyBank.php | 41 ++++++ resources/twig/form/amount.twig | 23 ++++ resources/twig/list/piggy-bank-events.twig | 33 +++++ resources/twig/piggy-banks/add.twig | 27 ++++ resources/twig/piggy-banks/create.twig | 57 +++++++++ resources/twig/piggy-banks/delete.twig | 26 ++++ resources/twig/piggy-banks/edit.twig | 61 +++++++++ resources/twig/piggy-banks/index.twig | 2 +- resources/twig/piggy-banks/remove.twig | 26 ++++ resources/twig/piggy-banks/show.twig | 120 ++++++++++++++++++ 13 files changed, 430 insertions(+), 14 deletions(-) rename app/Support/Twig/{Journals.php => Journal.php} (97%) create mode 100644 app/Support/Twig/PiggyBank.php create mode 100644 resources/twig/form/amount.twig create mode 100644 resources/twig/list/piggy-bank-events.twig create mode 100644 resources/twig/piggy-banks/add.twig create mode 100644 resources/twig/piggy-banks/create.twig create mode 100644 resources/twig/piggy-banks/delete.twig create mode 100644 resources/twig/piggy-banks/edit.twig create mode 100644 resources/twig/piggy-banks/remove.twig create mode 100644 resources/twig/piggy-banks/show.twig diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index c2cfad8399..c7ebe0e489 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -108,7 +108,7 @@ class ConfigServiceProvider extends ServiceProvider | `Twig_Extension_Debug` is enabled automatically if twig.debug is TRUE. | */ - 'enabled' => [ + 'enabled' => [ 'TwigBridge\Extension\Loader\Facades', 'TwigBridge\Extension\Loader\Filters', 'TwigBridge\Extension\Loader\Functions', @@ -154,7 +154,7 @@ class ConfigServiceProvider extends ServiceProvider | in order to be marked as safe. | */ - 'facades' => [ + 'facades' => [ 'Breadcrumbs' => [ 'is_safe' => [ 'renderIfExists' @@ -166,12 +166,12 @@ class ConfigServiceProvider extends ServiceProvider 'Config', 'ExpandedForm' => [ 'is_safe' => [ - 'date','text','select','balance','optionsList','checkbox' + 'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount' ] ], - 'Form' => [ + 'Form' => [ 'is_safe' => [ - 'input','select','checkbox','model','open' + 'input', 'select', 'checkbox', 'model', 'open' ] ], ], @@ -205,10 +205,10 @@ class ConfigServiceProvider extends ServiceProvider | */ 'functions' => [ - 'elixir', - 'head', - 'last', - ], + 'elixir', + 'head', + 'last', + ], /* |-------------------------------------------------------------------------- diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index b2a298caf4..eaecd56528 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -11,7 +11,8 @@ use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; use FireflyIII\Support\Twig\Budget; use FireflyIII\Support\Twig\General; -use FireflyIII\Support\Twig\Journals; +use FireflyIII\Support\Twig\Journal; +use FireflyIII\Support\Twig\PiggyBank; use FireflyIII\Validation\FireflyValidator; use Illuminate\Support\ServiceProvider; use Twig; @@ -38,8 +39,9 @@ class FireflyServiceProvider extends ServiceProvider $config = App::make('config'); Twig::addExtension(new Functions($config)); + Twig::addExtension(new PiggyBank); Twig::addExtension(new General); - Twig::addExtension(new Journals); + Twig::addExtension(new Journal); Twig::addExtension(new Budget); } diff --git a/app/Support/Twig/Journals.php b/app/Support/Twig/Journal.php similarity index 97% rename from app/Support/Twig/Journals.php rename to app/Support/Twig/Journal.php index a8c2105832..2b1be12e9f 100644 --- a/app/Support/Twig/Journals.php +++ b/app/Support/Twig/Journal.php @@ -9,11 +9,11 @@ use Twig_SimpleFilter; use Twig_SimpleFunction; /** - * Class Journals + * Class Journal * * @package FireflyIII\Support\Twig */ -class Journals extends Twig_Extension +class Journal extends Twig_Extension { public function getFilters() diff --git a/app/Support/Twig/PiggyBank.php b/app/Support/Twig/PiggyBank.php new file mode 100644 index 0000000000..4d289a4b43 --- /dev/null +++ b/app/Support/Twig/PiggyBank.php @@ -0,0 +1,41 @@ +currentRelevantRep()->currentamount; + } + ); + return $functions; + } + + /** + * Returns the name of the extension. + * + * @return string The extension name + */ + public function getName() + { + return 'FireflyIII\Support\Twig\PiggyBank'; + } +} \ No newline at end of file diff --git a/resources/twig/form/amount.twig b/resources/twig/form/amount.twig new file mode 100644 index 0000000000..cc0ff82ae1 --- /dev/null +++ b/resources/twig/form/amount.twig @@ -0,0 +1,23 @@ +
    + +
    +
    +
    + + +
    + {{ Form.input('number', name, value, options) }} + + +
    + + {% include 'form/feedback.twig' %} +
    + +
    diff --git a/resources/twig/list/piggy-bank-events.twig b/resources/twig/list/piggy-bank-events.twig new file mode 100644 index 0000000000..d685e73612 --- /dev/null +++ b/resources/twig/list/piggy-bank-events.twig @@ -0,0 +1,33 @@ + + + {% if showPiggyBank %} + + {% endif %} + + + + {% for event in events %} + + {% if showPiggyBank %} + + {% endif %} + + + + + {% endfor %} +
    Piggy bankDateAmount
    + {{ event.piggyBank.name }} + + {% if event.transaction_journal_id %} + {{ event.date.format('j F Y') }} + {% else %} + {{ event.date.format('j F Y') }} + {% endif %} + + {% if event.amount < 0 %} + Removed {{ event.amount*-1|formatAmountPlain }} + {% else %} + Added {{ event.amount|formatAmountPlain }} + {% endif %} +
    diff --git a/resources/twig/piggy-banks/add.twig b/resources/twig/piggy-banks/add.twig new file mode 100644 index 0000000000..85535a4297 --- /dev/null +++ b/resources/twig/piggy-banks/add.twig @@ -0,0 +1,27 @@ + + + diff --git a/resources/twig/piggy-banks/create.twig b/resources/twig/piggy-banks/create.twig new file mode 100644 index 0000000000..3c67f3ad8a --- /dev/null +++ b/resources/twig/piggy-banks/create.twig @@ -0,0 +1,57 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'store','url' : route('piggy-banks.store')}) }} + + +
    +
    +
    +
    + Mandatory fields +
    +
    + + {{ ExpandedForm.text('name') }} + {{ ExpandedForm.select('account_id',accounts,null,{'label' : 'Save on account'}) }} + {{ ExpandedForm.amount('targetamount') }} + +
    +
    +
    +
    + +
    +
    + Optional fields +
    +
    + {{ ExpandedForm.date('targetdate') }} + {{ ExpandedForm.checkbox('remind_me','1',false,{'label' : 'Remind me'}) }} + {{ ExpandedForm.select('reminder',periods,'month',{'label' : 'Remind every'}) }} +
    +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('create','piggy bank') }} +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    + +{% endblock %} diff --git a/resources/twig/piggy-banks/delete.twig b/resources/twig/piggy-banks/delete.twig new file mode 100644 index 0000000000..bc369b1b38 --- /dev/null +++ b/resources/twig/piggy-banks/delete.twig @@ -0,0 +1,26 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, piggyBank) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'destroy','url' : route('piggy-banks.destroy',piggyBank.id)}) }} +
    +
    +
    +
    + Delete piggy bank "{{ piggyBank.name }}" +
    +
    +

    + Are you sure? +

    + +

    + + Cancel +

    +
    +
    +
    +
    + + +{% endblock %} diff --git a/resources/twig/piggy-banks/edit.twig b/resources/twig/piggy-banks/edit.twig new file mode 100644 index 0000000000..a14bd2112a --- /dev/null +++ b/resources/twig/piggy-banks/edit.twig @@ -0,0 +1,61 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, piggyBank) }} + {{ Form.model(piggyBank, {'class' : 'form-horizontal','id' : 'update','url' : route('piggy-banks.update',piggyBank.id)}) }} + + + + +
    +
    +
    +
    + Mandatory fields +
    +
    + + {{ ExpandedForm.text('name') }} + {{ ExpandedForm.select('account_id',accounts,null,{'label' : 'Save on account'}) }} + {{ ExpandedForm.amount('targetamount') }} + +
    +
    + +
    +
    + +
    +
    + Optional fields +
    +
    + {{ ExpandedForm.date('targetdate') }} + {{ ExpandedForm.checkbox('remind_me','1',preFilled.remind_me,{'label' : 'Remind me'}) }} + {{ ExpandedForm.select('reminder',periods,preFilled.reminder,{'label' : 'Remind every'}) }} +
    +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('update','piggy bank') }} +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    + + +{% endblock %} diff --git a/resources/twig/piggy-banks/index.twig b/resources/twig/piggy-banks/index.twig index 62c3e1254f..d0d2563fb6 100644 --- a/resources/twig/piggy-banks/index.twig +++ b/resources/twig/piggy-banks/index.twig @@ -4,7 +4,7 @@ diff --git a/resources/twig/piggy-banks/remove.twig b/resources/twig/piggy-banks/remove.twig new file mode 100644 index 0000000000..657ce02431 --- /dev/null +++ b/resources/twig/piggy-banks/remove.twig @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/resources/twig/piggy-banks/show.twig b/resources/twig/piggy-banks/show.twig new file mode 100644 index 0000000000..9c27bdc27c --- /dev/null +++ b/resources/twig/piggy-banks/show.twig @@ -0,0 +1,120 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, piggyBank) }} +
    +
    +
    +
    + Events +
    +
    +
    +
    +
    +
    +
    +
    +
    + Details + + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + {% if piggyBank.reminder %} + + + + + {% endif %} + + + + + + + + +
    Account{{ piggyBank.account.name }}
    Target amount{{ piggyBank.targetAmount|formatAmount }}
    Saved so far{{ currentRelevantRepAmount(piggyBank)|formatAmount }}
    Left to save{{ piggyBank.targetamount - currentRelevantRepAmount(piggyBank)|formatAmount }}
    Start date + {% if piggyBank.startdate %} + {{ piggyBank.startdate.format('jS F Y')}} + {% else %} + No start date + {% endif %} +
    Target date + {% if piggyBank.targetdate %} + {{ piggyBank.targetdate.format('jS F Y') }} + {% else %} + No start date + {% endif %} +
    Reminder + {% if piggyBank.remind_me == 0 %} + (no reminder) + {% else %} + Every + {% if piggyBank.reminder_skip != 0 %} + {{ piggyBank.reminder_skip }} + {% else %} + {{ piggyBank.reminder }}(s) + {% endif %} + {% endif %} +
    Reminders left(in progress...)
    Expected amount per reminder(in progress...)
    +
    +
    +
    + Table +
    + {% include 'list/piggy-bank-events' %} +
    +
    + +
    +{% endblock %} + +{% block scripts %} + + + + + + + +{% endblock %} From dee0422effcb9d3eb7f81bf23b8a2875682146a2 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 12:22:19 +0200 Subject: [PATCH 22/29] Fix preferences [skip ci] --- resources/twig/preferences/index.twig | 102 ++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 resources/twig/preferences/index.twig diff --git a/resources/twig/preferences/index.twig b/resources/twig/preferences/index.twig new file mode 100644 index 0000000000..c3fb13f655 --- /dev/null +++ b/resources/twig/preferences/index.twig @@ -0,0 +1,102 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, piggyBank) }} + + {{ Form.open({'class' : 'form-horizontal','id' : 'preferences'}) }} + +
    +
    +
    +
    + Home screen accounts +
    +
    +

    Which accounts should be displayed on the home page?

    + {% for account in accounts %} +
    +
    +
    + +
    +
    +
    + {% endfor %} +
    +
    +
    +
    + Budget settings +
    +
    +

    + What's the maximum amount of money a budget envelope may contain? +

    + {{ ExpandedForm.amount('budgetMaximum',budgetMaximum,{'label' : 'Budget maximum'}) }} +
    +
    + +
    +
    +
    +
    + View range +
    +
    +

    Some charts are automatically grouped in periods. What period would you prefer?

    +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + + +{% endblock %} From 184ec13f9938d2c8095b371302c2be4b66a43e15 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 12:51:02 +0200 Subject: [PATCH 23/29] Fixed bills [skip ci] --- app/Providers/ConfigServiceProvider.php | 2 +- resources/twig/bills/create.twig | 69 +++++++++++++++ resources/twig/bills/delete.twig | 32 +++++++ resources/twig/bills/edit.twig | 66 ++++++++++++++ resources/twig/bills/index.twig | 27 ++++++ resources/twig/bills/show.twig | 113 ++++++++++++++++++++++++ resources/twig/form/integer.twig | 9 ++ resources/twig/form/tags.twig | 7 ++ resources/twig/list/bills.twig | 78 ++++++++++++++++ 9 files changed, 402 insertions(+), 1 deletion(-) create mode 100644 resources/twig/bills/create.twig create mode 100644 resources/twig/bills/delete.twig create mode 100644 resources/twig/bills/edit.twig create mode 100644 resources/twig/bills/index.twig create mode 100644 resources/twig/bills/show.twig create mode 100644 resources/twig/form/integer.twig create mode 100644 resources/twig/form/tags.twig create mode 100644 resources/twig/list/bills.twig diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index c7ebe0e489..cc915d0f6f 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -166,7 +166,7 @@ class ConfigServiceProvider extends ServiceProvider 'Config', 'ExpandedForm' => [ 'is_safe' => [ - 'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount' + 'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer' ] ], 'Form' => [ diff --git a/resources/twig/bills/create.twig b/resources/twig/bills/create.twig new file mode 100644 index 0000000000..f7719b3214 --- /dev/null +++ b/resources/twig/bills/create.twig @@ -0,0 +1,69 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, piggyBank) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'store','url' : route('bills.store')}) }} + +
    +
    + +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('name') }} + {{ ExpandedForm.tags('match') }} + {{ ExpandedForm.amount('amount_min') }} + {{ ExpandedForm.amount('amount_max') }} + {{ ExpandedForm.date('date',phpdate('Y-m-d')) }} + {{ ExpandedForm.select('repeat_freq',periods,'monthly') }} +
    +
    + +
    +
    + +
    +
    + Optional fields +
    +
    + {{ ExpandedForm.integer('skip',0) }} + {{ ExpandedForm.checkbox('automatch',1,true) }} + {{ ExpandedForm.checkbox('active',1,true) }} +
    +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('create','bill') }} +
    +
    + +
    + +
    +
    +
    +

    + +

    +
    +
    + + + +{% endblock %} + +{% block styles %} + +{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/resources/twig/bills/delete.twig b/resources/twig/bills/delete.twig new file mode 100644 index 0000000000..f58fd3db68 --- /dev/null +++ b/resources/twig/bills/delete.twig @@ -0,0 +1,32 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, bill) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'destroy','url' : route('bills.destroy',bill.id)}) }} +
    +
    +
    +
    + Delete bill "{{ bill.name }}" +
    +
    +

    + Are you sure that you want to delete bill "{{ bill.name }}"? +

    + + {% if bill.transactionjournals|length > 0 %} +

    + Bill "{{ bill.name }}" still has {{ bill.transactionjournals|length }} transactions connected + to it. These will not be removed but will lose their connection to this bill. +

    + {% endif %} + +

    + + Cancel +

    +
    +
    +
    +
    + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/bills/edit.twig b/resources/twig/bills/edit.twig new file mode 100644 index 0000000000..5fd7e02a0e --- /dev/null +++ b/resources/twig/bills/edit.twig @@ -0,0 +1,66 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, bill) }} + {{ Form.model(bill, {'class' : 'form-horizontal','id' : 'update','url' : route('bills.update', bill.id)}) }} + + + +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('name') }} + {{ ExpandedForm.tags('match') }} + {{ ExpandedForm.amount('amount_min') }} + {{ ExpandedForm.amount('amount_max') }} + {{ ExpandedForm.date('date',bill.date.format('Y-m-d')) }} + {{ ExpandedForm.select('repeat_freq',periods) }} +
    +
    + + +
    +
    +
    +
    + Optional fields +
    +
    + {{ ExpandedForm.integer('skip') }} + {{ ExpandedForm.checkbox('automatch',1) }} + {{ ExpandedForm.checkbox('active',1) }} + +
    +
    +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('update','bill') }} +
    + +
    +
    +
    +
    +
    +

    + +

    +
    +
    + + +{% endblock %} +{% block styles %} + +{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/resources/twig/bills/index.twig b/resources/twig/bills/index.twig new file mode 100644 index 0000000000..ef488037a5 --- /dev/null +++ b/resources/twig/bills/index.twig @@ -0,0 +1,27 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, piggyBank) }} +
    +
    +
    +
    + {{ title }} + + +
    +
    + + +
    +
    +
    + {% include 'list/bills.twig' %} +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/resources/twig/bills/show.twig b/resources/twig/bills/show.twig new file mode 100644 index 0000000000..e6297668a7 --- /dev/null +++ b/resources/twig/bills/show.twig @@ -0,0 +1,113 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, bill) }} +
    +
    +
    +
    + {{ bill.name }} + + {% if bill.active %} + + {% else %} + + {% endif %} + + {% if bill.automatch %} + + {% else %} + + {% endif %} + +
    +
    + + +
    +
    + +
    +
    + + + + + + + + + +
    + Matching on + {% for word in bill.match|split(',') %} + {{ word }} + {% endfor %} + between {{ bill.amount_min|formatAmount }} and {{ bill.amount_max|formatAmount }}. + Repeats {{ bill.repeat_freq }}.
    Next expected match + {% if bill.nextExpectedMatch %} + {{bill.nextExpectedMatch.format('j F Y')}} + {% else %} + Unknown + {% endif %} +
    +
    +
    +
    +
    +
    +
    + More +
    + +
    +
    +
    + +
    +
    +
    +
    + Chart +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + Connected transaction journals +
    +
    + {% include 'list/journals' %} +
    +
    +
    +
    + +{% endblock %} + +{% block scripts %} + + + + + + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/form/integer.twig b/resources/twig/form/integer.twig new file mode 100644 index 0000000000..527a5b2fea --- /dev/null +++ b/resources/twig/form/integer.twig @@ -0,0 +1,9 @@ +
    + +
    +
    + {{ Form.input('number', name, value, options) }} + {% include 'form/feedback.twig' %} +
    +
    +
    diff --git a/resources/twig/form/tags.twig b/resources/twig/form/tags.twig new file mode 100644 index 0000000000..9160512040 --- /dev/null +++ b/resources/twig/form/tags.twig @@ -0,0 +1,7 @@ +
    + +
    + {{ Form.input('text', name, value, options) }} + {% include 'form/feedback.twig' %} +
    +
    diff --git a/resources/twig/list/bills.twig b/resources/twig/list/bills.twig new file mode 100644 index 0000000000..2432efaf88 --- /dev/null +++ b/resources/twig/list/bills.twig @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + {% for entry in bills %} + + + + + + + + + + + + + + + {% endfor %} +
     NameMatches onMatching amountLast seen matchNext expected matchIs activeWill be automatchedRepeats every 
    +
    + + +
    +
    + {{ entry.name }} + + {% for match in entry.match|split(',') %} + {{ match }} + {% endfor %} + + {{ entry.amount_min|formatAmount }} + + {{ entry.amount_max|formatAmount }} + + {% 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 %} + + {% if entry.active %} + + {% endif %} +
    From 81d9d4dbc76fdc619530bce1037760ae95ce2661 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 13:20:49 +0200 Subject: [PATCH 24/29] Various files updated to twig [skip ci] --- app/Providers/ConfigServiceProvider.php | 2 + resources/twig/auth/password.twig | 45 ++++++++++++++++ resources/twig/auth/register.twig | 58 +++++++++++++++++++++ resources/twig/list/reminders.twig | 45 ++++++++++++++++ resources/twig/profile/change-password.twig | 55 +++++++++++++++++++ resources/twig/profile/delete-account.twig | 49 +++++++++++++++++ resources/twig/profile/index.twig | 19 +++++++ resources/twig/reminders/index.twig | 37 +++++++++++++ resources/twig/reminders/show.twig | 40 ++++++++++++++ 9 files changed, 350 insertions(+) create mode 100644 resources/twig/auth/password.twig create mode 100644 resources/twig/auth/register.twig create mode 100644 resources/twig/list/reminders.twig create mode 100644 resources/twig/profile/change-password.twig create mode 100644 resources/twig/profile/delete-account.twig create mode 100644 resources/twig/profile/index.twig create mode 100644 resources/twig/reminders/index.twig create mode 100644 resources/twig/reminders/show.twig diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index cc915d0f6f..1f55469074 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -162,6 +162,7 @@ class ConfigServiceProvider extends ServiceProvider ], 'Session', 'Route', + 'Auth', 'URL', 'Config', 'ExpandedForm' => [ @@ -208,6 +209,7 @@ class ConfigServiceProvider extends ServiceProvider 'elixir', 'head', 'last', + 'old' ], /* diff --git a/resources/twig/auth/password.twig b/resources/twig/auth/password.twig new file mode 100644 index 0000000000..720bce9a88 --- /dev/null +++ b/resources/twig/auth/password.twig @@ -0,0 +1,45 @@ +{% extends "./layout/guest.twig" %} + +{% block content %} +
    +
    + +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/resources/twig/auth/register.twig b/resources/twig/auth/register.twig new file mode 100644 index 0000000000..d564378099 --- /dev/null +++ b/resources/twig/auth/register.twig @@ -0,0 +1,58 @@ +{% extends "./layout/guest.twig" %} + +{% block content %} +
    +
    + +
    +
    +{% endblock %} diff --git a/resources/twig/list/reminders.twig b/resources/twig/list/reminders.twig new file mode 100644 index 0000000000..991b8b37ee --- /dev/null +++ b/resources/twig/list/reminders.twig @@ -0,0 +1,45 @@ +
    + {% if reminders|length > 0 %} + {% for reminder in reminders %} +
    +
    + +
    +

    + This reminder is active between {{reminder.startdate.format('jS F Y')}} + and {{reminder.enddate.format('jS F Y')}}. +

    + {% if reminder.description %} +

    {{ reminder.description|raw }}

    + {% endif %} +
    + +
    +
    + {% endfor %} + {% else %} +
    +

    + (No reminders) +

    +
    + {% endif %} +
    diff --git a/resources/twig/profile/change-password.twig b/resources/twig/profile/change-password.twig new file mode 100644 index 0000000000..16900564f3 --- /dev/null +++ b/resources/twig/profile/change-password.twig @@ -0,0 +1,55 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +
    +
    +
    +
    + Change your password +
    +
    + + {% if errors|length > 0 %} +
      +
        + {% for error in errors.all %} +
      • {{ error }}
      • + {% endfor %} +
      +
    + + {% endif %} + + + {{ Form.open({'class' : 'form-horizontal','id' : 'change-password'}) }} +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/resources/twig/profile/delete-account.twig b/resources/twig/profile/delete-account.twig new file mode 100644 index 0000000000..f3e5f94e1c --- /dev/null +++ b/resources/twig/profile/delete-account.twig @@ -0,0 +1,49 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +
    +
    +
    +
    + Delete your account +
    +
    + +

    + Deleting your account will also delete any accounts, transactions, anything + you might have saved into Firefly III. It'll be GONE. +

    +

    + Enter your password to continue. +

    + + {% if errors|length > 0 %} +
      +
        + {% for error in errors.all %} +
      • {{ error }}
      • + {% endfor %} +
      +
    + + {% endif %} + + {{ Form.open({'class' : 'form-horizontal','id' : 'change-password'}) }} +
    + +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/resources/twig/profile/index.twig b/resources/twig/profile/index.twig new file mode 100644 index 0000000000..244a1a6e35 --- /dev/null +++ b/resources/twig/profile/index.twig @@ -0,0 +1,19 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +
    +
    +
    +
    + Options +
    + +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/resources/twig/reminders/index.twig b/resources/twig/reminders/index.twig new file mode 100644 index 0000000000..d2fbedf270 --- /dev/null +++ b/resources/twig/reminders/index.twig @@ -0,0 +1,37 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + +
    +
    +

    Active reminders

    +
    +
    + + {% include 'list/reminders.twig' with {'reminders': active} %} + +
    +
    +

    Dismissed reminders

    +
    +
    + + {% include 'list/reminders.twig' with {'reminders': dismissed} %} + +
    +
    +

    Expired reminders

    +
    +
    + + {% include 'list/reminders.twig' with {'reminders': expired} %} + +
    +
    +

    Inactive reminders

    +
    +
    + + {% include 'list/reminders.twig' with {'reminders': inactive} %} + +{% endblock %} diff --git a/resources/twig/reminders/show.twig b/resources/twig/reminders/show.twig new file mode 100644 index 0000000000..b78eb138a0 --- /dev/null +++ b/resources/twig/reminders/show.twig @@ -0,0 +1,40 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, reminder) }} +
    +
    +
    + +
    +

    + Active between {{reminder.startdate.format('jS F Y')}} + and {{reminder.enddate.format('jS F Y')}}. +

    + + {% if reminder.description %} +

    {!! reminder.description !!}

    + {% endif %} +
    + +
    +
    +
    +{% endblock %} \ No newline at end of file From 73d4a1035121d197e321a377d9f5769543b640da Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 18:26:55 +0200 Subject: [PATCH 25/29] Fixed reports [skip ci] --- app/Http/Controllers/ReportController.php | 67 +++--- resources/twig/reports/budget.twig | 159 +++++++++++++ resources/twig/reports/index.twig | 74 +++++++ resources/twig/reports/month.twig | 257 ++++++++++++++++++++++ resources/twig/reports/year.twig | 185 ++++++++++++++++ 5 files changed, 709 insertions(+), 33 deletions(-) create mode 100644 resources/twig/reports/budget.twig create mode 100644 resources/twig/reports/index.twig create mode 100644 resources/twig/reports/month.twig create mode 100644 resources/twig/reports/year.twig diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 9c82e2f7cc..6799c3f3a4 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -47,50 +47,51 @@ class ReportController extends Controller */ public function budget($year = '2014', $month = '1') { - try { - new Carbon($year . '-' . $month . '-01'); - } catch (Exception $e) { - return view('error')->with('message', 'Invalid date'); - } - $date = new Carbon($year . '-' . $month . '-01'); - $start = clone $date; + $date = new Carbon($year . '-' . $month . '-01'); + $subTitle = 'Budget report for ' . $date->format('F Y'); + $subTitleIcon = 'fa-calendar'; + $start = clone $date; + + $start->startOfMonth(); $end = clone $date; $end->endOfMonth(); - $start->subDay(); + // should show shared reports? /** @var Preference $pref */ $pref = Preferences::get('showSharedReports', false); $showSharedReports = $pref->data; + $accountAmounts = []; // array with sums of spent amounts on each account. + $accounts = $this->query->getAllAccounts($start, $end, $showSharedReports); // all accounts and some data. + foreach ($accounts as $account) { - $dayEarly = clone $date; - $subTitle = 'Budget report for ' . $date->format('F Y'); - $subTitleIcon = 'fa-calendar'; - $dayEarly = $dayEarly->subDay(); - $accounts = $this->query->getAllAccounts($start, $end, $showSharedReports); - $start->addDay(); + $budgets = $this->query->getBudgetSummary($account, $start, $end);// get budget summary for this account: + $balancedAmount = $this->query->balancedTransactionsSum($account, $start, $end); + $accountAmounts[$account->id] = $balancedAmount; + // balance out the transactions (see transaction groups & tags) ^^ - $accounts->each( - function (Account $account) use ($start, $end) { - $budgets = $this->query->getBudgetSummary($account, $start, $end); - $balancedAmount = $this->query->balancedTransactionsSum($account, $start, $end); - $array = []; - $hide = true; - foreach ($budgets as $budget) { - $id = intval($budget->id); - $data = $budget->toArray(); - $array[$id] = $data; - if (floatval($data['queryAmount']) != 0) { - $hide = false; - } + // array with budget information for each account: + $array = []; + // should always hide account + $hide = true; + // loop all budgets + foreach ($budgets as $budget) { + $id = intval($budget->id); + $data = $budget->toArray(); + $array[$id] = $data; + + // no longer hide account if any budget has money in it. + if (floatval($data['queryAmount']) != 0) { + $hide = false; } - $account->hide = $hide; - $account->budgetInformation = $array; - $account->balancedAmount = $balancedAmount; - + $accountAmounts[$account->id] += $data['queryAmount']; } - ); + $account->hide = $hide; + $account->budgetInformation = $array; + $account->balancedAmount = $balancedAmount; + + } /** * Start getBudgetsForMonth DONE @@ -101,7 +102,7 @@ class ReportController extends Controller * End getBudgetsForMonth DONE */ - return view('reports.budget', compact('subTitle', 'year', 'month', 'subTitleIcon', 'date', 'accounts', 'budgets', 'dayEarly')); + return view('reports.budget', compact('subTitle', 'accountAmounts', 'year', 'month', 'subTitleIcon', 'date', 'accounts', 'budgets')); } diff --git a/resources/twig/reports/budget.twig b/resources/twig/reports/budget.twig new file mode 100644 index 0000000000..11af7d0b90 --- /dev/null +++ b/resources/twig/reports/budget.twig @@ -0,0 +1,159 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date) }} + +
    +
    +
    +
    + + Accounts +
    + + + + + + + + + + {% for account in accounts %} + + + + + + + + {% endfor %} +
    AccountStart of monthCurrent balanceSpentEarned
    {{ account.name }}{{ account.startBalance|formatAmount }}{{ account.endBalance|formatAmount }} + {% if account.startBalance - account.endBalance > 0 %} + {{ (account.startBalance - account.endBalance)|formatAmountPlain }} + {% endif %} + + {% if account.startBalance - account.endBalance < 0 %} + {{ ((account.startBalance - account.endBalance)*-1)|formatAmountPlain }} + {% endif %} +
    +
    +
    +
    +
    +
    +
    +
    + + Budgets +
    + + + + {% for account in accounts %} + {% if not account.hide %} + + {% endif %} + {% endfor %} + + + {% for id,budget in budgets %} + + + + {% set spent = 0 %} + {% for account in accounts %} + {% if not account.hide %} + {% if account.budgetInformation[id] %} + + {% set spent = spent + account.budgetInformation[id].queryAmount %} + {% else %} + + {% endif %} + {% endif %} + {% endfor %} + + + + {% endfor %} + + + {% for account in accounts %} + {% if not account.hide %} + + {% endif %} + {% endfor %} + + + + + {% for account in accounts %} + + {% if not account.hide %} + {% if account.budgetInformation[0] %} + + {% else %} + + {% endif %} + {% endif %} + {% endfor %} + + + + + {% for account in accounts %} + {% if not account.hide %} + + {% endif %} + {% endfor %} + + + + + {% for account in accounts %} + {% if not account.hide %} + + {% endif %} + {% endfor %} + + + +
    Budgets{{ account.name }} + Left in budget +
    {{ budget.name }}{{ budget.queryAmount|formatAmount }} + {% if id == 0 %} + + {{ account.budgetInformation[id].queryAmount|formatAmount }} + + {% else %} + {{ account.budgetInformation[id].queryAmount|formatAmount }} + {% endif %} + {{ 0|formatAmount }}{{ (budget.queryAmount + budget.spent)|formatAmount }}{{ (budget.queryAmount + spent)|formatAmount }}
    Balanced by transfers + {{ account.balancedAmount|formatAmount }} +  
    Left unbalanced + {% if account.budgetInformation[0].queryAmount + account.balancedAmount != 0.0 %} + {{ (account.budgetInformation[0].queryAmount + account.balancedAmount)|formatAmount }} + {% else %} + {{ (account.budgetInformation[0].queryAmount + account.balancedAmount)|formatAmount }} + {% endif %} + {{ 0|formatAmount }} 
    Sum{{ accountAmounts[account.id]|formatAmount }} 
    Expected balance{{ (account.startBalance + accountAmounts[account.id])|formatAmount }} 
    +
    +
    +
    + + + + +{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/resources/twig/reports/index.twig b/resources/twig/reports/index.twig new file mode 100644 index 0000000000..0768e23c4a --- /dev/null +++ b/resources/twig/reports/index.twig @@ -0,0 +1,74 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + +
    +
    +
    +
    + + Yearly reports +
    +
    +
      + {% for year in years %} +
    • {{ year }}
    • + {% endfor %} +
    +
    +
    +
    + +
    +
    +
    + + Monthly reports +
    +
    + + {% for year, entries in months %} +
    {{ year }}
    + + {% endfor %} + +
    +
    +
    + +
    +
    +
    + + Budget reports +
    +
    + {% for year, entries in months %} +
    {{ year }}
    + + {% endfor %} +
    +
    +
    +
    +{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/resources/twig/reports/month.twig b/resources/twig/reports/month.twig new file mode 100644 index 0000000000..62f1212e44 --- /dev/null +++ b/resources/twig/reports/month.twig @@ -0,0 +1,257 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date) }} + +
    +
    +
    +
    + + Income +
    + + {% set sum = 0 %} + {% for entry in income %} + {% set sum = sum + entry.queryAmount %} + + + + + + + {% endfor %} + {% if displaySum %} + + + + + {% endif %} +
    + {{ entry.description }} + + {% if entry.type == 'Withdrawal' %} + {{entry.queryAmount|formatAmountPlain}} + {% endif %} + {% if entry.type == 'Deposit' %} + {{entry.queryAmount|formatAmountPlain}} + {% endif %} + {% if entry.type == 'Transfer' %} + {{entry.queryAmount|formatAmountPlain}} + {% endif %} + + {{entry.date.format('j F Y')}} + + {{ entry.name }} +
    Sum{{ sum|formatAmount }}
    +
    +
    +
    +
    +
    + + Expenses (top 10) +
    + + {% set sum = 0 %} + + {% for id,expense in expenses %} + {% set sum = sum + expense.queryAmount %} + + {% if id > 0 %} + + {% else %} + + {% endif %} + + + {% endfor %} + + + + +
    {{ expense.name }}{{ expense.name }}{{ expense.queryAmount|formatAmountPlain }}
    Sum{{ sum|formatAmountPlain }}
    +
    +
    +
    +
    +
    + + Sums +
    + {% set totalIn = 0 %} + {% for entry in income %} + {% set totalIn = totalIn + entry.queryAmount %} + {% endfor %} + + + + + + + + + + + + + +
    In{{ totalIn|formatAmount }}
    Out{{ sum|formatAmountPlain }}
    Difference{{ (totalIn - sum)|formatAmount }}
    +
    +
    +
    +
    +
    +
    +
    + + Budgets +
    + + + + + + + + {% set sumSpent = 0 %} + {% set sumEnvelope = 0 %} + {% set sumLeft = 0 %} + {% for id,budget in budgets %} + {% set sumSpent = sumSpent + budget.spent %} + {% set sumEnvelope = sumEnvelope + budget.queryAmount %} + {% set sumLeft = sumLeft + budget.queryAmount + budget.spent %} + + {% if budget.queryAmount != 0 or budget.spent != 0 %} + + + + + + + {% endif %} + {% endfor %} + + + + + + +
    BudgetEnvelopeSpentLeft
    + {% if id > 0 %} + {{ budget.name }} + {% else %} + {{ budget.name }} + {% endif %} + {{ budget.queryAmount|formatAmount }}{{ (budget.spent*-1)|formatAmountPlain }}{{ (budget.queryAmount + budget.spent)|formatAmount }}
    Sum{{ sumEnvelope|formatAmount }}{{ sumSpent|formatAmount }}{{ sumLeft|formatAmount }}
    +
    +
    +
    +
    +
    + + Categories +
    + + + + + + {% set sum = 0 %} + {% for id,category in categories %} + {% set sum = sum + category.queryAmount %} + + + + + {% endfor %} + + + + +
    CategorySpent
    + {% if id > 0 %} + {{ category.name }} + {% else %} + {{ category.name }} + {% endif %} + {{ (category.queryAmount * -1)|formatAmountPlain }}
    Sum{{ (sum * -1)|formatAmountPlain }}
    +
    +
    +
    +
    +
    +
    +
    + + Accounts +
    + + {% set sumStart = 0 %} + {% set sumEnd = 0 %} + {% set sumDiff = 0 %} + {% for id,account in accounts %} + + {% set sumStart = sumStart + account.startBalance %} + {% set sumEnd = sumEnd + account.endBalance %} + {% set sumDiff = sumDiff + account.difference %} + + + + + + + {% endfor %} + + + + + + +
    {{ account.name }}{{ account.startBalance|formatAmount }}{{ account.endBalance|formatAmount }}{{ account.difference|formatAmount }}
    Sum{{ sumStart|formatAmount }}{{ sumEnd|formatAmount }}{{ sumDiff|formatAmount }}
    +
    +
    +
    +
    +
    +
    +
    + + Piggy banks +
    +
    Body
    +
    +
    +
    +
    +
    +
    +
    + + Bills +
    +
    Body
    +
    +
    +
    +
    +
    +
    +
    + + Outside of budgets +
    +
    Body
    +
    +
    +
    +{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/resources/twig/reports/year.twig b/resources/twig/reports/year.twig new file mode 100644 index 0000000000..d59c747791 --- /dev/null +++ b/resources/twig/reports/year.twig @@ -0,0 +1,185 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date) }} + +
    +
    +
    +
    + + Income vs. expenses +
    +
    +
    +
    +
    +
    +
    +
    +
    + + Income vs. expenses +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + + Account balance +
    + + + + + + + + {% set start = 0 %} + {% set end = 0 %} + {% set diff = 0 %} + {% for balance in balances %} + {% set start = start + balance.start %} + {% set end = end + balance.end %} + {% set diff = diff + (balance.end - balance.start) %} + {% if not balance.hide %} + + + + + + + {% endif %} + {% endfor %} + + + + + + +
    NameBalance at start of yearBalance at end of yearDifference
    + {{ balance.account.name }} + {% if balance.shared %} + shared + {% endif %} + {{ balance.start|formatAmount }}{{ balance.end|formatAmount }}{{ (balance.end - balance.start)|formatAmount }}
    Sum of sums{{ start|formatAmount }}{{ end|formatAmount }}{{ diff|formatAmount }}
    +
    + +
    +
    + + Income vs. expense +
    + {% set incomeSum = 0 %} + {% set expenseSum = 0 %} + {% for income in groupedIncomes %} + {% set incomeSum = incomeSum + (income.queryAmount*-1) %} + {% endfor %} + + {% for expense in groupedExpenses %} + {% set expenseSum = expenseSum + expense.queryAmount %} + {% endfor %} + + + + + + + + + + + + + + +
    In{{ incomeSum|formatAmount }}
    Out{{ (expenseSum*-1)|formatAmount }}
    Difference{{ (incomeSum - expenseSum)|formatAmount }}
    +
    +
    +
    +
    +
    + + Income +
    + + {% set sum = 0 %} + {% for income in groupedIncomes %} + {% set sum = sum + (income.queryAmount * -1) %} + + + + + {% endfor %} + + + + +
    {{ income.name }}{{ (income.queryAmount * -1)|formatAmount }}
    Sum{{ sum|formatAmount }}
    +
    +
    +
    +
    +
    + + Expenses +
    + + {% set sum =0 %} + {% for expense in groupedExpenses %} + + + + + {% set sum = sum + (expense.queryAmount * -1) %} + {% endfor %} + + + + +
    {{ expense.name }}{{ (expense.queryAmount*-1)|formatAmount }}
    Sum{{ sum|formatAmount }}
    +
    +
    +
    +
    +
    +
    +
    + + Budgets +
    +
    +
    +
    +
    +
    +
    + +{% endblock %} +{% block scripts %} + + + + + + + + + +{% endblock %} From 8e31d0491df8695c53d431bf98217f95a37694ed Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 18:30:59 +0200 Subject: [PATCH 26/29] Fixed search [skip ci] --- resources/twig/search/index.twig | 106 +++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 resources/twig/search/index.twig diff --git a/resources/twig/search/index.twig b/resources/twig/search/index.twig new file mode 100644 index 0000000000..a4783911cc --- /dev/null +++ b/resources/twig/search/index.twig @@ -0,0 +1,106 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, query) }} +{% if query %} +
    + {% if result.transactions|length > 0 %} +
    +
    +
    + Transactions ({ result.transactions|length }}) +
    +
    + {% include 'list/journals-tiny' with {'transactions' : result.transactions} %} +
    +
    +
    + {% endif %} + {% if result.categories|length > 0 %} +
    +
    +
    + Categories ({{result['categories'].count()}}) +
    +
    +
    + {% for category in result.categories %} + + {{ category.name }} + + {% endfor %} +
    +
    +
    +
    + {% endif %} + {% if result.tags|length > 0 %} +
    +
    +
    + Tags ({{result['tags'].count()}}) +
    +
    +

    Bla bla

    +
    +
    +
    + {% endif %} + {% if result.accounts|length > 0 %} +
    +
    +
    + Accounts ({{result['accounts'].count()}}) +
    +
    +
    + {% for account in result.accounts %} + + {{ account.name }} + + {% endfor %} +
    +
    +
    +
    + {% endif %} + {% if result.budgets|length > 0 %} +
    +
    +
    + Budgets ({{result['budgets'].count()}}) +
    +
    +
    + {% for budget in result.budgets %} + + {{ budget.name }} + + {% endfor %} +
    +
    +
    +
    + {% endif %} + +
    +{% endif %} + + + +{% endblock %} +{% block scripts %} + +{% endblock %} \ No newline at end of file From efe6f59f793f737006304a38c256503e287de296 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 19:19:47 +0200 Subject: [PATCH 27/29] Last templates. Should cover everything. [skip ci] --- app/Providers/ConfigServiceProvider.php | 5 +- app/Support/Twig/General.php | 8 ++ phpunit.xml | 3 +- resources/twig/form/location.twig | 14 +++ resources/twig/form/multiRadio.twig | 16 +++ resources/twig/form/textarea.twig | 7 ++ resources/twig/tags/create.twig | 85 +++++++++++++++ resources/twig/tags/delete.twig | 33 ++++++ resources/twig/tags/edit.twig | 87 ++++++++++++++++ resources/twig/tags/index.twig | 75 +++++++++++++ resources/twig/tags/show.twig | 77 ++++++++++++++ resources/twig/transactions/create.twig | 107 +++++++++++++++++++ resources/twig/transactions/delete.twig | 43 ++++++++ resources/twig/transactions/edit.twig | 111 ++++++++++++++++++++ resources/twig/transactions/index.twig | 19 ++++ resources/twig/transactions/show.twig | 133 ++++++++++++++++++++++++ 16 files changed, 820 insertions(+), 3 deletions(-) create mode 100644 resources/twig/form/location.twig create mode 100644 resources/twig/form/multiRadio.twig create mode 100644 resources/twig/form/textarea.twig create mode 100644 resources/twig/tags/create.twig create mode 100644 resources/twig/tags/delete.twig create mode 100644 resources/twig/tags/edit.twig create mode 100644 resources/twig/tags/index.twig create mode 100644 resources/twig/tags/show.twig create mode 100644 resources/twig/transactions/create.twig create mode 100644 resources/twig/transactions/delete.twig create mode 100644 resources/twig/transactions/edit.twig create mode 100644 resources/twig/transactions/index.twig create mode 100644 resources/twig/transactions/show.twig diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index 1f55469074..bd01842727 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -167,12 +167,13 @@ class ConfigServiceProvider extends ServiceProvider 'Config', 'ExpandedForm' => [ 'is_safe' => [ - 'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer' + 'date', 'text', 'select', 'balance', 'optionsList', 'checkbox', 'amount', 'tags', 'integer', 'textarea', 'location', + 'multiRadio' ] ], 'Form' => [ 'is_safe' => [ - 'input', 'select', 'checkbox', 'model', 'open' + 'input', 'select', 'checkbox', 'model', 'open','radio','textarea' ] ], ], diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index ff7851dd66..f5faf71981 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -5,6 +5,7 @@ namespace FireflyIII\Support\Twig; use App; use Config; use FireflyIII\Models\Account; +use FireflyIII\Models\Transaction; use Route; use Twig_Extension; use Twig_SimpleFilter; @@ -31,6 +32,13 @@ class General extends Twig_Extension return App::make('amount')->format($string); }, ['is_safe' => ['html']] ); + + $filters[] = new Twig_SimpleFilter( + 'formatTransaction', function (Transaction $transaction) { + return App::make('amount')->formatTransaction($transaction); + }, ['is_safe' => ['html']] + ); + $filters[] = new Twig_SimpleFilter( 'formatAmountPlain', function ($string) { return App::make('amount')->format($string, false); diff --git a/phpunit.xml b/phpunit.xml index 677b0226c7..b1eba9eb5a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,10 +20,11 @@ - + diff --git a/resources/twig/form/location.twig b/resources/twig/form/location.twig new file mode 100644 index 0000000000..efb95bb6c3 --- /dev/null +++ b/resources/twig/form/location.twig @@ -0,0 +1,14 @@ +
    + +
    +
    +

    Right-click to set the tag's location. + Clear location +

    + + + + + {% include 'form/feedback.twig' %} +
    +
    diff --git a/resources/twig/form/multiRadio.twig b/resources/twig/form/multiRadio.twig new file mode 100644 index 0000000000..b79ff1559c --- /dev/null +++ b/resources/twig/form/multiRadio.twig @@ -0,0 +1,16 @@ +
    + +
    + {% for value,description in list %} +
    + +
    + {% endfor %} + {% include 'form/help.twig' %} + {% include 'form/feedback.twig' %} + +
    +
    diff --git a/resources/twig/form/textarea.twig b/resources/twig/form/textarea.twig new file mode 100644 index 0000000000..6d1d950a04 --- /dev/null +++ b/resources/twig/form/textarea.twig @@ -0,0 +1,7 @@ +
    + +
    + {{ Form.textarea(name, value, options) }} + {% include 'form/feedback.twig' %} +
    +
    diff --git a/resources/twig/tags/create.twig b/resources/twig/tags/create.twig new file mode 100644 index 0000000000..ab957ce3bf --- /dev/null +++ b/resources/twig/tags/create.twig @@ -0,0 +1,85 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'store','route' : 'tags.store'}) }} + +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('tag') }} + {{ ExpandedForm.multiRadio('tagMode',tagOptions) }} +
    +
    +
    + +
    + +
    +
    + Optional fields +
    +
    + {{ ExpandedForm.date('date') }} + {{ ExpandedForm.textarea('description') }} + {{ ExpandedForm.location('tagPosition') }} +
    +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('create','tag') }} +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    + + +{% endblock %} +{% block scripts %} + + + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/tags/delete.twig b/resources/twig/tags/delete.twig new file mode 100644 index 0000000000..82ea36f45d --- /dev/null +++ b/resources/twig/tags/delete.twig @@ -0,0 +1,33 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, tag) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'destroy','url' : route('tags.destroy',tag.id)}) }} +
    +
    +
    +
    + Delete tag "{{ tag.tag }}" +
    +
    +

    + Are you sure that you want to delete tag "{{ tag.tag }}"? +

    + + {% if tag.transactionjournals|length > 0 %} +

    + Tag "{{ tag.tag }}" still has {{ tag.transactionjournals|length }} transaction(s) connected + to it. These will not be removed but will lose their connection to this tag. +

    + {% endif %} + +

    + + Cancel +

    +
    +
    +
    +
    + + +{% endblock %} diff --git a/resources/twig/tags/edit.twig b/resources/twig/tags/edit.twig new file mode 100644 index 0000000000..85f5e3503f --- /dev/null +++ b/resources/twig/tags/edit.twig @@ -0,0 +1,87 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, tag) }} + {{ Form.model(tag, {'class' : 'form-horizontal','id' : 'update','url' : route('tags.update',tag.id)}) }} + + + +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('tag') }} + {{ ExpandedForm.multiRadio('tagMode',tagOptions) }} +
    +
    +
    + +
    + +
    +
    + Optional fields +
    +
    + {{ ExpandedForm.date('date') }} + {{ ExpandedForm.textarea('description') }} + {{ ExpandedForm.location('tagPosition') }} +
    +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('update','tag') }} +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    + + +{% endblock %} +{% block scripts %} + + + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/tags/index.twig b/resources/twig/tags/index.twig new file mode 100644 index 0000000000..9b520969a5 --- /dev/null +++ b/resources/twig/tags/index.twig @@ -0,0 +1,75 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} +
    +
    +
    +
    Tags
    +
    +
    +

    + Usually tags are singular words, designed to quickly band items together + using things like expensive, + bill or + for-party. In Firefly III, tags can have more properties + such as a date, description and location. This allows you to join transactions together in a more meaningful + way. For example, you could make a tag called Christmas dinner with friends + and add information about the restaurant. Such tags are "singular", you would only use them for a single occasion, + perhaps with multiple transactions. +

    +

    + Tags group transactions together, which makes it possible to store reimbursements + (in case you front money for others) and other "balancing acts" where expenses + are summed up (the payments on your new TV) or where expenses and deposits + are cancelling each other out (buying something with saved money). It's all up to you. + Using tags the old-fashioned way is of course always possible. +

    +

    + Create a tag to get started or enter tags when creating new transactions. +

    +
    +

    + +

    +

    + Create new tag +

    +

    + {% if tags|length == 0 %} + No tags + {% else %} + {% for tag in tags %} + +

    + {% if tag.tagMode == 'nothing' %} + + {% endif %} + {% if tag.tagMode == 'balancingAct' %} + + {% endif %} + {% if tag.tagMode == 'advancePayment' %} + + {% endif %} + {{tag.tag}} +

    + {% endfor %} + {% endif %} +

    +
    +
    +
    +
    +{% endblock %} +{% block scripts %} + +{% endblock %} \ No newline at end of file diff --git a/resources/twig/tags/show.twig b/resources/twig/tags/show.twig new file mode 100644 index 0000000000..ae61d5b587 --- /dev/null +++ b/resources/twig/tags/show.twig @@ -0,0 +1,77 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, tag) }} + + {% if tag.latitude and tag.longitude and tag.zoomLevel %} +
    +
    +
    +
    + {{ tag.tag }} + {% if tag.date %} + on {{tag.date.format('jS F Y')}} + {% endif %} + +
    +
    + + +
    +
    +
    +
    + {% if tag.description %} +

    + {{tag.description}} +

    + {% endif %} + {% if tag.latitude and tag.longitude and tag.zoomLevel %} +

    + +

    + {% endif %} +
    +
    +
    +
    + {% endif %} + +
    +
    +
    +
    + Transactions + + {% if not (tag.latitude and tag.longitude and tag.zoomLevel) %} + +
    +
    + + +
    +
    + {% endif %} +
    + {% include 'list/journals.twig' with {'journals': tag.transactionjournals} %} +
    +
    +
    + +{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/resources/twig/transactions/create.twig b/resources/twig/transactions/create.twig new file mode 100644 index 0000000000..01ef307391 --- /dev/null +++ b/resources/twig/transactions/create.twig @@ -0,0 +1,107 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, what) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'store','url' : route('transactions.store',what)}) }} + + +
    +
    + +
    +
    + Mandatory fields +
    +
    + + {{ ExpandedForm.text('description') }} + {% if what == 'deposit' or what == 'withdrawal' %} + {{ ExpandedForm.select('account_id',accounts) }} + {% endif %} + + + + {% if what == 'withdrawal' %} + {{ ExpandedForm.text('expense_account') }} + {% endif %} + + + {% if what == 'deposit' %} + {{ ExpandedForm.text('revenue_account') }} + {% endif %} + + + + {% if what == 'transfer' %} + {{ ExpandedForm.select('account_from_id',accounts) }} + {{ ExpandedForm.select('account_to_id',accounts) }} + {% endif %} + + + + {{ ExpandedForm.amount('amount') }} + + + {{ ExpandedForm.date('date', phpdate('Y-m-d')) }} +
    +
    +
    +
    + +
    +
    + Optional fields +
    +
    + + {% if what == 'withdrawal' %} + {{ ExpandedForm.select('budget_id',budgets,0) }} + {% endif %} + + {{ ExpandedForm.text('category') }} + + + {{ ExpandedForm.text('tags') }} + + + + {% if what == 'withdrawal' and piggies|length > 0 %} + {{ ExpandedForm.select('piggy_bank_id',piggies) }} + {% endif %} +
    +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('create','transaction') }} +
    +
    +
    +
    +
    +
    +

    + +

    +
    +
    + + +{% endblock %} +{% block scripts %} + + + + +{% endblock %} + +{% block styles %} + +{% endblock %} diff --git a/resources/twig/transactions/delete.twig b/resources/twig/transactions/delete.twig new file mode 100644 index 0000000000..b10a9a83a0 --- /dev/null +++ b/resources/twig/transactions/delete.twig @@ -0,0 +1,43 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, journal) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'destroy','url' : route('transactions.destroy',journal.id)}) }} + +
    +
    + +
    +
    + Destroy "{{ journal.description }}" +
    +
    +

    + 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? +

    +
    + + {% if journal.transactiontype.type == 'Withdrawal' %} + Cancel + {% endif %} + {% if journal.transactiontype.type == 'Deposit' %} + Cancel + {% endif %} + {% if journal.transactiontype.type == 'Transfer' %} + Cancel + {% endif %} +
    +
    +
    +
    +
    + + + +{% endblock %} diff --git a/resources/twig/transactions/edit.twig b/resources/twig/transactions/edit.twig new file mode 100644 index 0000000000..5ac5f371bd --- /dev/null +++ b/resources/twig/transactions/edit.twig @@ -0,0 +1,111 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, journal) }} + {{ Form.open({'class' : 'form-horizontal','id' : 'update','url' : route('transactions.update',journal.id)}) }} + + + + +
    +
    + +
    +
    + Mandatory fields +
    +
    + + {{ ExpandedForm.text('description',journal.description) }} + + + {% if what == 'deposit' or what == 'withdrawal' %} + {{ ExpandedForm.select('account_id',accounts,data['account_id']) }} + {% endif %} + + + {% if what == 'withdrawal' %} + {{ ExpandedForm.text('expense_account',data['expense_account']) }} + {% endif %} + + + {% if what == 'deposit' %} + {{ ExpandedForm.text('revenue_account',data['revenue_account']) }} + {% endif %} + + + {% if what == 'transfer' %} + {{ ExpandedForm.select('account_from_id',accounts,data['account_from_id']) }} + {{ ExpandedForm.select('account_to_id',accounts,data['account_to_id']) }} + {% endif %} + + + {{ ExpandedForm.amount('amount',data.amount,{'currency' : journal.transactionCurrency}) }} + + + {{ ExpandedForm.date('date',data['date']) }} +
    +
    + +
    +
    + +
    +
    + Optional fields +
    +
    + + {% if what == 'withdrawal' %} + {{ ExpandedForm.select('budget_id',budgets,data['budget_id']) }} + {% endif %} + + + {{ ExpandedForm.text('category',data['category']) }} + + + {{ ExpandedForm.text('tags') }} + + + {% if what == 'withdrawal' and piggies|length > 0 %} + {{ ExpandedForm.select('piggy_bank_id',piggies,data['piggy_bank_id']) }} + {% endif %} + +
    +
    + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('update','transaction') }} +
    +
    +
    +
    + +
    +
    +

    + +

    +
    +
    + + + +{% endblock %} +{% block scripts %} + + + + +{% endblock %} +{% block styles %} + +{% endblock %} diff --git a/resources/twig/transactions/index.twig b/resources/twig/transactions/index.twig new file mode 100644 index 0000000000..25b11854a9 --- /dev/null +++ b/resources/twig/transactions/index.twig @@ -0,0 +1,19 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, what) }} +
    +
    +
    +
    + {{ subTitle }} +
    + {% include 'list.journals' %} +
    +
    +
    + +{% endblock %} +{% block scripts %} + + +{% endblock %} diff --git a/resources/twig/transactions/show.twig b/resources/twig/transactions/show.twig new file mode 100644 index 0000000000..7c58bed910 --- /dev/null +++ b/resources/twig/transactions/show.twig @@ -0,0 +1,133 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, journal) }} +
    +
    +
    +
    + + Metadata +
    + + + + + + + + + + + + + + {% for budget in journal.budgets %} + + + + + {% endfor %} + {% for category in journal.categories %} + + + + + {% endfor %} + {% if journal.tags|length > 0 %} + + + + + {% endif %} +
    Date{{ journal.date.format('jS F Y') }}
    Type{{ journal.transactiontype.type }}
    Completed + {% if journal.completed %} + Yes + {% else %} + No + {% endif %} +
    Budget{{ budget.name }}
    Category{{ category.name }}
    Tags + {% for tag in journal.tags %} + +

    + {% if tag.tagMode == 'nothing' %} + + {% endif %} + {% if tag.tagMode == 'balancingAct' %} + + {% endif %} + {% if tag.tagMode == 'advancePayment' %} + + {% endif %} + {{tag.tag}} +

    + {% endfor %} +
    +
    + + {% if journal.piggyBankEvents|length > 0 %} +
    +
    + Piggy banks +
    +
    + {% include 'list/piggy-bank-events' with {'events': journal.piggyBankEvents, 'showPiggyBank':true} %} +
    +
    + {% endif %} +
    +
    + + {% for t in journal.transactions %} +
    +
    + {% if t.account.accounttype.type == 'Asset account' %} + + {% endif %} + {% if t.account.accounttype.type == 'Default account' %} + + {% endif %} + {% if t.account.accounttype.type == 'Expense account' %} + + {% endif %} + {% if t.account.accounttype.type == 'Beneficiary account' %} + + {% endif %} + + {% if t.account.accounttype.type == 'Revenue account' %} + + {% endif %} + {{ t.account.name }}
    {{ t.account.accounttype.description }} +
    + + + + + + + + + + {% if t.description %} + + + + + {% endif %} +
    Amount{{ t|formatTransaction }}
    New balance{{ t.before|formatAmount }} → {{ t.after|formatAmount }}
    Description{{ t.description }}
    +
    + {% endfor %} +
    +
    + +
    +
    + +
    +
    + +{% endblock %} +{% block scripts %} + +{% endblock %} From c7ae15a41a69afe544a6c350031f9cb6640b7018 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 19:44:12 +0200 Subject: [PATCH 28/29] This should fix all twig tests. Let's find out! --- app/Http/Controllers/BudgetController.php | 5 ++- app/Support/Amount.php | 9 ++-- phpunit.xml | 2 +- resources/twig/categories/edit.twig | 44 +++++++++++++++++++ resources/twig/error.twig | 18 ++++++++ tests/TestCase.php | 27 ++++++++++-- tests/controllers/AccountControllerTest.php | 6 ++- tests/controllers/BillControllerTest.php | 5 +++ tests/controllers/BudgetControllerTest.php | 5 +++ tests/controllers/JsonControllerTest.php | 4 ++ tests/controllers/PiggyBankControllerTest.php | 7 +++ .../controllers/PreferencesControllerTest.php | 1 + 12 files changed, 123 insertions(+), 10 deletions(-) create mode 100644 resources/twig/categories/edit.twig create mode 100644 resources/twig/error.twig diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 733e08f544..daa31181b4 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -8,6 +8,7 @@ use FireflyIII\Models\Budget; use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\LimitRepetition; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; +use Illuminate\Support\Collection; use Input; use Preferences; use Redirect; @@ -190,7 +191,9 @@ class BudgetController extends Controller $journals = $repository->getJournals($budget, $repetition); $limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget); $subTitle = !is_null($repetition->id) ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name); - $journals->setPath('/budgets/show/'.$budget->id); + if (!$journals instanceof Collection) { + $journals->setPath('/budgets/show/' . $budget->id); + } return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle')); } diff --git a/app/Support/Amount.php b/app/Support/Amount.php index aed7c6bfcb..db7aecb52c 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -160,12 +160,15 @@ class Amount $currencyPreference = Prefs::get('currencyPreference', 'EUR'); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); + if ($currency) { - \Cache::forever('FFCURRENCYCODE', $currency->code); + Cache::forever('FFCURRENCYCODE', $currency->code); + define('FFCURRENCYCODE', $currency->code); - define('FFCURRENCYCODE', $currency->code); + return $currency->code; + } - return $currency->code; + return 'EUR'; } public function getDefaultCurrency() diff --git a/phpunit.xml b/phpunit.xml index b1eba9eb5a..076f2928e3 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" + stopOnFailure="true" syntaxCheck="false"> diff --git a/resources/twig/categories/edit.twig b/resources/twig/categories/edit.twig new file mode 100644 index 0000000000..b35cfbe9ff --- /dev/null +++ b/resources/twig/categories/edit.twig @@ -0,0 +1,44 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, category) }} +{{ Form.model(category, {'class' : 'form-horizontal','id' : 'update','url' : route('categories.update',category.id)}) }} + +
    +
    +
    +
    + Mandatory fields +
    +
    + {{ ExpandedForm.text('name') }} +
    +
    + +
    +
    + + + +
    +
    + Options +
    +
    + {{ ExpandedForm.optionsList('update','category') }} +
    +
    + +
    +
    +
    +
    +

    + +

    +
    +
    + + +{% endblock %} diff --git a/resources/twig/error.twig b/resources/twig/error.twig new file mode 100644 index 0000000000..edbee43c63 --- /dev/null +++ b/resources/twig/error.twig @@ -0,0 +1,18 @@ +{% extends "./layout/guest.twig" %} + +{% block content %} + +
    +
    +

    Firefly
    + Error +

    +
    +
    + +
    +
    + {{ message |default('General unknown errror') }} +
    +
    +{% endblock %} diff --git a/tests/TestCase.php b/tests/TestCase.php index cc436f7446..9c2541fa8f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,5 +1,7 @@ code = 'EUR'; + $currency->save(); + Log::debug('Created new EUR currency.'); } else { if (file_exists($copy)) { copy($copy, $original); @@ -45,7 +57,16 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase } // if the database copy does exists, copy back as original. - FactoryMuffin::loadFactories(__DIR__ . '/factories'); + $this->session( + [ + 'start' => Carbon::now()->startOfMonth(), + 'end' => Carbon::now()->endOfMonth(), + 'first' => Carbon::now()->startOfYear() + ] + ); + + + } diff --git a/tests/controllers/AccountControllerTest.php b/tests/controllers/AccountControllerTest.php index 58b908c640..d89449d252 100644 --- a/tests/controllers/AccountControllerTest.php +++ b/tests/controllers/AccountControllerTest.php @@ -69,6 +69,7 @@ class AccountControllerTest extends TestCase $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/accounts/create/asset'); $this->assertResponseOk(); @@ -127,6 +128,7 @@ class AccountControllerTest extends TestCase $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); // get edit page: $this->call('GET', '/accounts/edit/' . $this->account->id); @@ -153,7 +155,7 @@ class AccountControllerTest extends TestCase $repository->shouldReceive('getLastActivity')->andReturn(null); Amount::shouldReceive('format')->andReturn(''); - Amount::shouldReceive('getCurrencyCode')->once()->andReturn('A'); + Amount::shouldReceive('getCurrencyCode')->andReturn('A'); // put stuff in session: @@ -172,7 +174,7 @@ class AccountControllerTest extends TestCase $this->be($this->account->user); // mock! - Amount::shouldReceive('getCurrencyCode')->once()->andReturn('A'); + Amount::shouldReceive('getCurrencyCode')->andReturn('A'); $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $repository->shouldReceive('getJournals')->andReturn(new LengthAwarePaginator([], 0, 10)); diff --git a/tests/controllers/BillControllerTest.php b/tests/controllers/BillControllerTest.php index eab8b1c0f6..e664a5929a 100644 --- a/tests/controllers/BillControllerTest.php +++ b/tests/controllers/BillControllerTest.php @@ -72,6 +72,7 @@ class BillControllerTest extends TestCase $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/bills/create'); $this->assertViewHas('subTitle', 'Create new'); @@ -111,6 +112,7 @@ class BillControllerTest extends TestCase $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/bills/edit/' . $bill->id); $this->assertViewHas('subTitle', 'Edit "' . e($bill->name) . '"'); @@ -126,6 +128,7 @@ class BillControllerTest extends TestCase $collection->push($bill); Amount::shouldReceive('format')->andReturn('XX'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); $repository->shouldReceive('getBills')->once()->andReturn($collection); @@ -187,6 +190,8 @@ class BillControllerTest extends TestCase Amount::shouldReceive('format')->andReturn('XX'); Amount::shouldReceive('getCurrencyCode')->andReturn('XX'); + + $this->call('GET', '/bills/show/' . $bill->id); } diff --git a/tests/controllers/BudgetControllerTest.php b/tests/controllers/BudgetControllerTest.php index 50ea295ca7..f57fe39918 100644 --- a/tests/controllers/BudgetControllerTest.php +++ b/tests/controllers/BudgetControllerTest.php @@ -115,6 +115,7 @@ class BudgetControllerTest extends TestCase $repository->shouldReceive('getCurrentRepetition')->once(); Amount::shouldReceive('getCurrencySymbol')->andReturn('x'); Amount::shouldReceive('format')->andReturn('x'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/budgets'); $this->assertResponseOk(); @@ -304,6 +305,10 @@ class BudgetControllerTest extends TestCase $pref = FactoryMuffin::create('FireflyIII\Models\Preference'); Preferences::shouldReceive('get')->withArgs(['budgetIncomeTotal' . $date, 1000])->andReturn($pref); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); + Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); + + $this->call('GET', '/budgets/income'); $this->assertResponseOk(); diff --git a/tests/controllers/JsonControllerTest.php b/tests/controllers/JsonControllerTest.php index 0f8390d6cc..32f320161c 100644 --- a/tests/controllers/JsonControllerTest.php +++ b/tests/controllers/JsonControllerTest.php @@ -56,6 +56,7 @@ class JsonControllerTest extends TestCase $accounts->shouldReceive('getCreditCards')->andReturn($ccs); $accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Steam::shouldReceive('balance')->andReturn(0); @@ -83,6 +84,7 @@ class JsonControllerTest extends TestCase $bills->shouldReceive('createFakeBill')->andReturn($bill); $accounts->shouldReceive('getCreditCards')->andReturn($ccs); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Steam::shouldReceive('balance')->andReturn(-1); $this->call('GET', '/json/box/bills-unpaid'); @@ -97,6 +99,7 @@ class JsonControllerTest extends TestCase $repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface'); $repository->shouldReceive('incomeByPeriod')->andReturn(new Collection); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/json/box/in'); $this->assertResponseOk(); @@ -110,6 +113,7 @@ class JsonControllerTest extends TestCase $repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface'); $repository->shouldReceive('journalsByExpenseAccount')->andReturn(new Collection); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/json/box/out'); $this->assertResponseOk(); diff --git a/tests/controllers/PiggyBankControllerTest.php b/tests/controllers/PiggyBankControllerTest.php index fe49823479..38b1b62b0d 100644 --- a/tests/controllers/PiggyBankControllerTest.php +++ b/tests/controllers/PiggyBankControllerTest.php @@ -50,6 +50,8 @@ class PiggyBankControllerTest extends TestCase $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $repository->shouldReceive('leftOnAccount')->withAnyArgs()->andReturn(12); Amount::shouldReceive('format')->andReturn('XXxx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); + Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); $this->call('GET', '/piggy-banks/add/' . $piggyBank->id); $this->assertResponseOk(); @@ -179,6 +181,7 @@ class PiggyBankControllerTest extends TestCase Steam::shouldReceive('balance')->andReturn(20); $accounts->shouldReceive('leftOnAccount')->andReturn(12); Amount::shouldReceive('format')->andReturn('123'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/piggy-banks'); @@ -218,6 +221,7 @@ class PiggyBankControllerTest extends TestCase $piggyBanks->shouldReceive('createEvent')->once(); Amount::shouldReceive('format')->andReturn('something'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe']); $this->assertResponseStatus(302); @@ -235,6 +239,7 @@ class PiggyBankControllerTest extends TestCase $piggyBanks->shouldReceive('createEvent')->once(); Amount::shouldReceive('format')->andReturn('something'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe', 'amount' => '10000']); $this->assertResponseStatus(302); @@ -283,6 +288,8 @@ class PiggyBankControllerTest extends TestCase $this->be($piggyBank->account->user); Amount::shouldReceive('format')->andReturn('something'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); + Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); $this->call('GET', '/piggy-banks/remove/' . $piggyBank->id); $this->assertResponseOk(); diff --git a/tests/controllers/PreferencesControllerTest.php b/tests/controllers/PreferencesControllerTest.php index 02f61910d6..af27739081 100644 --- a/tests/controllers/PreferencesControllerTest.php +++ b/tests/controllers/PreferencesControllerTest.php @@ -55,6 +55,7 @@ class PreferencesControllerTest extends TestCase Preferences::shouldReceive('get')->once()->withArgs(['budgetMaximum', 1000])->andReturn($pref); Preferences::shouldReceive('get')->once()->withArgs(['currencyPreference', 'EUR'])->andReturn($pref); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getAllCurrencies')->andReturn(new Collection); Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); From 1ff8b62cb7084da6d00d58c82207b753607b232f Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 2 May 2015 19:44:31 +0200 Subject: [PATCH 29/29] And now with actual coverage. --- phpunit.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 076f2928e3..bf13ff1240 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,11 +20,11 @@ - - --> +