Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
New code for #736
James Coleb899628dbede
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.phpindex 0af04d700d..3a560fa376 100644--- a/app/Http/Controllers/AccountController.php+++ b/app/Http/Controllers/AccountController.php@@ -250,6 +250,62 @@ class AccountController extends Controllerreturn view('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));}+ /**+ * @param Request $request+ * @param Account $account+ * @param string $moment+ *+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View+ */+ public function reconcile(Request $request, Account $account, string $moment = '')+ {+ if ($account->accountType->type === AccountType::INITIAL_BALANCE) {+ return $this->redirectToOriginalAccount($account);+ }+ /** @var CurrencyRepositoryInterface $currencyRepos */+ $currencyRepos = app(CurrencyRepositoryInterface::class);+ $currencyId = intval($account->getMeta('currency_id'));+ $currency = $currencyRepos->find($currencyId);+ if ($currencyId === 0) {+ $currency = app('amount')->getDefaultCurrency();+ }++ // get start and end+ $range = Preferences::get('viewRange', '1M')->data;+ $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));+ $end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));+ $startBalance = round(app('steam')->balance($account, $start), $currency->decimal_places);+ $endBalance = round(app('steam')->balance($account, $end), $currency->decimal_places);+ $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);+ $subTitle = trans('firefly.reconcile_account', ['account' => $account->name]);++ if(strlen($moment) > 0 && $moment !== 'all') {+ $start = new Carbon($moment);+ $end = Navigation::endOfPeriod($start, $range);+ }++ return view('accounts.reconcile', compact('account', 'currency', 'subTitleIcon', 'start', 'end', 'subTitle', 'startBalance', 'endBalance'));++ // prep for "specific date" view.+ if (strlen($moment) > 0 && $moment !== 'all') {+ $start = new Carbon($moment);+ $end = Navigation::endOfPeriod($start, $range);+ }++ // grab journals:+ $collector = app(JournalCollectorInterface::class);+ $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);+ if (!is_null($start)) {+ $collector->setRange($start, $end);+ }+ $transactions = $collector->getPaginatedJournals();+ $transactions->setPath(route('accounts.show', [$account->id, $moment]));++ return view(+ 'accounts.show',+ compact('account', 'currency', 'moment', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end', 'chartUri')+ );+ }/*** Show an account.diff --git a/public/js/ff/transactions/list.js b/public/js/ff/transactions/list.jsindex f58eb6c703..7004447dfa 100644--- a/public/js/ff/transactions/list.js+++ b/public/js/ff/transactions/list.js@@ -48,7 +48,7 @@ $(document).ready(function () {// click the delete button:$('.mass_delete').click(goToMassDelete);// click reconcile button- $('.mass_reconcile').click(goToReconcile);+ // $('.mass_reconcile').click(goToReconcile);});/**@@ -226,6 +226,9 @@ function stopMassSelect() {// hide the stop button$('.mass_stop_select').hide();+ // show reconcile account button, if present+ $('.mass_reconcile').show();+return false;}@@ -253,5 +256,8 @@ function startMassSelect() {// show the stop button$('.mass_stop_select').show();+ // hide reconcile account button, if present+ $('.mass_reconcile').hide();+return false;}\ No newline at end of filediff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex 66e3a5891b..399222cc02 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -589,6 +589,7 @@ return ['bill_is_active' => 'Bill is active','bill_will_automatch' => 'Bill will automatically linked to matching transactions','skips_over' => 'skips over',+// accounts:'details_for_asset' => 'Details for asset account ":name"','details_for_expense' => 'Details for expense account ":name"',@@ -617,6 +618,7 @@ return ['revenue_accounts' => 'Revenue accounts','cash_accounts' => 'Cash accounts','Cash account' => 'Cash account',+ 'reconcile_account' => 'Reconcile account ":account"','cash' => 'cash','account_type' => 'Account type','save_transactions_by_moving' => 'Save these transaction(s) by moving them to another account:',diff --git a/resources/views/accounts/reconcile.twig b/resources/views/accounts/reconcile.twignew file mode 100644index 0000000000..f5da194cec--- /dev/null+++ b/resources/views/accounts/reconcile.twig@@ -0,0 +1,117 @@+{% extends "./layout/default" %}++{% block breadcrumbs %}+ {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, moment, start, end) }}+{% endblock %}++{% block content %}++ <div class="row">+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'reconcile_range'|_ }}</h3>+ </div>+ <div class="box-body no-padding">+ <table class="table">+ <thead>+ <tr>+ <th colspan="2" style="width:50%;">{{ 'start_balance'|_ }}</th>+ <th colspan="2">{{ 'end_balance'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ <tr>+ <td style="width:25%;">+ {{ 'date'|_ }}+ </td>+ <td style="width:25%;">+ {{ 'balance'|_ }}+ </td>+ <td style="width:25%;">+ {{ 'date'|_ }}+ </td>+ <td style="width:25%;">+ {{ 'balance'|_ }}+ </td>+ </tr>+ <tr>+ <td>+ <div class="input-group">+ <div class="input-group-addon">+ <i class="fa fa-calendar"></i>+ </div>+ <input type="date" value="{{ start.format('Y-m-d') }}" name="start_date" class="form-control">+ </div>+ </td>+ <td>+ <div class="input-group">+ <span class="input-group-addon non-selectable-currency-symbol">{{ currency.symbol }}</span>+ <input type="number" value="{{ startBalance }}" name="start_balance" class="form-control">+ </div>+ </td>+ <td>+ <div class="input-group">+ <div class="input-group-addon">+ <i class="fa fa-calendar"></i>+ </div>+ <input type="date" value="{{ end.format('Y-m-d') }}" name="end_date" class="form-control">+ </div>+ </td>+ <td>+ <div class="input-group">+ <span class="input-group-addon non-selectable-currency-symbol">{{ currency.symbol }}</span>+ <input type="number" value="{{ endBalance }}" name="end_balance" class="form-control">+ </div>+ </td>+ </tr>+ </tbody>+ <tfoot>+ <tr>+ <td colspan="4">+ <a href="#" class="btn btn-default">+ {{ 'update'|_ }}+ </a>+ </td>+ </tr>+ </tfoot>+ </table>+ </div>+ </div>+ </div>+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'reconcile_options'|_ }}</h3>+ </div>+ <div class="box-body">+ Do something+ </div>+ </div>+ </div>++ </div>++ <div class="row">+ <div class="col-lg-12 col-md-12 col-sm-12">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'transactions'|_ }}</h3>+ </div>+ <div class="box-body">+ </div>+ </div>+ </div>+ </div>++++{% endblock %}++{% block scripts %}+ <script type="text/javascript">+ currencySymbol = "{{ currency.symbol }}";+ var accountID = {{ account.id }};+ </script>+ <script src="js/ff/accounts/reconcile.js?v={{ FF_VERSION }}" type="text/javascript"></script>+{% endblock %}diff --git a/resources/views/accounts/show.twig b/resources/views/accounts/show.twigindex 43c219fc54..194d232703 100644--- a/resources/views/accounts/show.twig+++ b/resources/views/accounts/show.twig@@ -85,7 +85,7 @@<h3 class="box-title">{{ 'transactions'|_ }}</h3></div><div class="box-body">- {% include 'list.journals' with {sorting:true, hideBills:true, hideBudgets: true, hideCategories: true} %}+ {% include 'list.journals' with {sorting:true, hideBills:true, hideBudgets: true, hideCategories: true, showReconcile: true} %}{% if periods.count > 0 %}<p><i class="fa fa-calendar"></i>diff --git a/resources/views/list/accounts.twig b/resources/views/list/accounts.twigindex af7a7be7f7..800480da45 100644--- a/resources/views/list/accounts.twig+++ b/resources/views/list/accounts.twig@@ -19,8 +19,9 @@<tr><td class="hidden-sm hidden-xs"><div class="btn-group btn-group-xs">- <a class="btn btn-default btn-xs" href="{{ route('accounts.edit',account.id) }}"><i class="fa fa-fw fa-pencil"></i></a>- <a class="btn btn-danger btn-xs" href="{{ route('accounts.delete',account.id) }}"><i class="fa fa-fw fa-trash-o"></i></a>+ <a class="btn btn-default btn-xs" title="{{ 'edit'|_ }}" href="{{ route('accounts.edit',account.id) }}"><i class="fa fa-fw fa-pencil"></i></a>+ <a class="btn btn-default btn-xs" title="{{ 'reconcile'|_ }}" href="{{ route('accounts.reconcile',account.id) }}"><i class="fa fa-fw fa-check"></i></a>+ <a class="btn btn-danger btn-xs" title="{{ 'delete'|_ }}" href="{{ route('accounts.delete',account.id) }}"><i class="fa fa-fw fa-trash-o"></i></a></div></td><td data-value="{{ account.name }}"><a href="{{ route('accounts.show',account.id) }}">{{ account.name }}</a></td>diff --git a/resources/views/list/journals.twig b/resources/views/list/journals.twigindex fdb0685e80..6752cc2c9c 100644--- a/resources/views/list/journals.twig+++ b/resources/views/list/journals.twig@@ -36,7 +36,7 @@<div class="col-lg-8 col-md-12 col-sm-12 col-xs-12"><div class="mass_button_options btn-group btn-group" style="display:none;"><a href="#" class="btn btn-default mass_edit"><i class="fa fa-fw fa-pencil"></i> <span>{{ 'edit'|_ }}</span></a>- <a href="#" class="btn btn-default mass_reconcile"><i class="fa fa-fw fa-check"></i> <span>{{ 'reconcile_selected'|_ }} (<i class="fa fa-spinner fa-spin"></i>)</span></a>+ {#<a href="#" class="btn btn-default mass_reconcile"><i class="fa fa-fw fa-check"></i> <span>{{ 'reconcile_selected'|_ }} (<i class="fa fa-spinner fa-spin"></i>)</span></a>#}<a href="#" class="btn btn-danger mass_delete"><i class="fa fa-fw fa-trash"></i> <span>{{ 'delete'|_ }}</span></a></div>@@ -47,6 +47,9 @@<a href="#" class="btn btn-default mass_select"><i class="fa fa-fw fa-check-square-o"></i> {{ 'select_transactions'|_ }}</a><a href="#" class="btn btn-default mass_stop_select" style="display:none;"><i class="fa faw-fw fa-square-o"></i> {{ 'stop_selection'|_ }}</a>+ {% if showReconcile == true %}+ <a href="{{ route('accounts.reconcile', [account.id, moment]) }}" class="btn btn-info mass_reconcile"><i class="fa fa-fw fa-check"></i> {{ 'reconcile_this_account'|_ }}</a>+ {% endif %}</div></div></div>@@ -58,5 +61,5 @@<script type="text/javascript">var edit_selected_txt = "{{ 'edit'|_ }}";var delete_selected_txt = "{{ 'delete'|_ }}";- var reconcile_selected_txt = "{{ 'reconcile_selected'|_ }}";+ {# var reconcile_selected_txt = "{{ 'reconcile_selected'|_ }}"; #}</script>diff --git a/resources/views/search/index.twig b/resources/views/search/index.twigindex 98600a006b..d915476cd6 100644--- a/resources/views/search/index.twig+++ b/resources/views/search/index.twig@@ -109,7 +109,7 @@<script type="text/javascript">var edit_selected_txt = "{{ 'edit'|_ }}";var delete_selected_txt = "{{ 'delete'|_ }}";- var reconcile_selected_txt = "{{ 'reconcile_selected'|_ }}";+ {# var reconcile_selected_txt = "{{ 'reconcile_selected'|_ }}"; #}var searchQuery = "{{ fullQuery|escape('js') }}";var searchUri = "{{ route('search.search') }}";diff --git a/routes/web.php b/routes/web.phpindex 4258dac321..559c2a4f2f 100755--- a/routes/web.php+++ b/routes/web.php@@ -90,6 +90,7 @@ Route::group(Route::get('{what}', ['uses' => 'AccountController@index', 'as' => 'index'])->where('what', 'revenue|asset|expense');Route::get('create/{what}', ['uses' => 'AccountController@create', 'as' => 'create'])->where('what', 'revenue|asset|expense');Route::get('edit/{account}', ['uses' => 'AccountController@edit', 'as' => 'edit']);+ Route::get('reconcile/{account}/{moment?}', ['uses' => 'AccountController@reconcile', 'as' => 'reconcile']);Route::get('delete/{account}', ['uses' => 'AccountController@delete', 'as' => 'delete']);Route::get('show/{account}/{moment?}', ['uses' => 'AccountController@show', 'as' => 'show']);