diff --git a/app/Http/Controllers/ExchangeRates/IndexController.php b/app/Http/Controllers/ExchangeRates/IndexController.php new file mode 100644 index 0000000000..0fa0180c24 --- /dev/null +++ b/app/Http/Controllers/ExchangeRates/IndexController.php @@ -0,0 +1,52 @@ +middleware( + function ($request, $next) { + app('view')->share('mainTitleIcon', 'fa-exchange'); + app('view')->share('title', (string) trans('firefly.header_exchange_rates')); + return $next($request); + } + ); + } + + public function index() + { + return view('exchange-rates.index'); + } + +} diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index fbbb9d8969..1de3cb857c 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -242,7 +242,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface return $room; } - // amount is negative and $currentamount is smaller than $amount + // amount is negative and $currentAmount is smaller than $amount if (-1 === bccomp($amount, '0') && 1 === bccomp($compare, $amount)) { app('log')->debug(sprintf('Max amount to remove is %f', $repetition->current_amount)); app('log')->debug(sprintf('Cannot remove %f from piggy bank #%d ("%s")', $amount, $piggyBank->id, $piggyBank->name)); diff --git a/resources/lang/en_US/breadcrumbs.php b/resources/lang/en_US/breadcrumbs.php index 5a89a6b9b3..9dba742c88 100644 --- a/resources/lang/en_US/breadcrumbs.php +++ b/resources/lang/en_US/breadcrumbs.php @@ -89,4 +89,7 @@ return [ // notifications 'notification_index' => 'Owner notifications', + + // exchange rates + 'exchange_rates_index' => 'Exchange rates', ]; diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index b435d5e571..fa0cb6b42b 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -1394,6 +1394,11 @@ return [ 'slack_url_label' => 'Slack "incoming webhook" URL', 'discord_url_label' => 'Discord webhook URL', + // exchange rates + 'menu_exchange_rates_index' => 'Exchange rates', + 'header_exchange_rates' => 'Exchange rates', + 'exchange_rates_intro' =>'Firefly III supports downloading and using exchange rates. Read more about this in the documentation.', + // Financial administrations 'administration_index' => 'Financial administration', 'administrations_index_menu' => 'Financial administration(s)', diff --git a/resources/views/exchange-rates/index.twig b/resources/views/exchange-rates/index.twig new file mode 100644 index 0000000000..6bab169fd7 --- /dev/null +++ b/resources/views/exchange-rates/index.twig @@ -0,0 +1,51 @@ +{% extends './layout/default' %} + +{% block breadcrumbs %} + {{ Breadcrumbs.render(Route.getCurrentRoute.getName) }} +{% endblock %} + +{% block content %} +
+
+
+
+

{{ 'header_exchange_rates'|_ }}

+
+
+

+ {{ 'exchange_rates_intro'|_ }} +

+
+
+
+
+
+
+ {% for currency in currencies %} +
+
+

{{ currency.name }}

+
+
+ {% if currencies.count > 0 %} +
    + {% for sub in currencies %} + {% if sub.id != currency.id %} +
  • From {{ currency.name }} to {{ sub.name }}
  • + {% endif %} + {% endfor %} +
+ {% endif %} +
+
+ {% endfor %} +
+
+ +{% endblock %} + +{% block styles %} +{% endblock %} + +{% block scripts %} +{% endblock %} diff --git a/resources/views/partials/menu-sidebar.twig b/resources/views/partials/menu-sidebar.twig index f3487f6e8c..c9443ff939 100644 --- a/resources/views/partials/menu-sidebar.twig +++ b/resources/views/partials/menu-sidebar.twig @@ -189,7 +189,7 @@ {% endif %} -
  • @@ -220,6 +220,12 @@
  • {% if hasRole('owner') %} +
  • + + + {{ 'menu_exchange_rates_index'|_ }} + +
  • diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php index dde259dfb7..37d8a7ca4e 100644 --- a/routes/breadcrumbs.php +++ b/routes/breadcrumbs.php @@ -753,6 +753,15 @@ Breadcrumbs::for( } ); +// exchange rates +Breadcrumbs::for( + 'exchange-rates.index', + static function (Generator $breadcrumbs): void { + $breadcrumbs->parent('home'); + $breadcrumbs->push(trans('breadcrumbs.exchange_rates_index'), route('exchange-rates.index')); + } +); + // PROFILE diff --git a/routes/web.php b/routes/web.php index 7334c316cf..31cfa511c8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -360,6 +360,20 @@ Route::group( } ); +// exchange rates controller +Route::group( + ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\ExchangeRates', 'prefix' => 'exchange-rates', 'as' => 'exchange-rates.'], + static function (): void { + Route::get('', ['uses' => 'IndexController@index', 'as' => 'index']); +// Route::get('create', ['uses' => 'CreateController@create', 'as' => 'create']); +// Route::get('edit/{currency}', ['uses' => 'EditController@edit', 'as' => 'edit']); +// Route::get('delete/{currency}', ['uses' => 'DeleteController@delete', 'as' => 'delete']); +// Route::post('store', ['uses' => 'CreateController@store', 'as' => 'store']); +// Route::post('update/{currency}', ['uses' => 'EditController@update', 'as' => 'update']); +// Route::post('destroy/{currency}', ['uses' => 'DeleteController@destroy', 'as' => 'destroy']); + } +); + // Chart\Account Controller (default report). Route::group( ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/account', 'as' => 'chart.account.'],