diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index 3a560fa376..1181029657 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -257,7 +257,7 @@ class AccountController extends Controller
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
- public function reconcile(Request $request, Account $account, string $moment = '')
+ public function reconcile(Request $request, Account $account, Carbon $start = null, Carbon $end = null)
{
if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
return $this->redirectToOriginalAccount($account);
@@ -270,21 +270,39 @@ class AccountController extends Controller
$currency = app('amount')->getDefaultCurrency();
}
- // get start and end
+ // no start or 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);
+
+ // get start and end
+ if(is_null($start) && is_null($end)) {
+ $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
+ $end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
+ }
+ if(is_null($end)) {
+ $end = Navigation::endOfPeriod($start, $range);
+ }
+
+ $startDate = clone $start;
+ $startDate->subDays(1);
+ $startBalance = round(app('steam')->balance($account, $startDate), $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);
- }
+ // get the transactions
+ $selectionStart = clone $start;
+ $selectionStart->subDays(7);
+ $selectionEnd = clone $end;
+ $selectionEnd->addDays(5);
- return view('accounts.reconcile', compact('account', 'currency', 'subTitleIcon', 'start', 'end', 'subTitle', 'startBalance', 'endBalance'));
+ // grab transactions:
+ /** @var JournalCollectorInterface $collector */
+ $collector = app(JournalCollectorInterface::class);
+ $collector->setAccounts(new Collection([$account]))
+ ->setRange($selectionStart, $selectionEnd)->withBudgetInformation()->withOpposingAccount()->withCategoryInformation();
+ $transactions = $collector->getJournals();
+
+ return view('accounts.reconcile', compact('account', 'currency', 'subTitleIcon', 'start', 'end', 'subTitle', 'startBalance', 'endBalance','transactions','selectionStart','selectionEnd'));
// prep for "specific date" view.
if (strlen($moment) > 0 && $moment !== 'all') {
@@ -292,14 +310,7 @@ class AccountController extends Controller
$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',
diff --git a/public/js/ff/accounts/reconcile.js b/public/js/ff/accounts/reconcile.js
new file mode 100644
index 0000000000..c19b64d482
--- /dev/null
+++ b/public/js/ff/accounts/reconcile.js
@@ -0,0 +1,37 @@
+/*
+ * reconcile.js
+ * Copyright (c) 2017 thegrumpydictator@gmail.com
+ *
+ * This file is part of Firefly III.
+ *
+ * Firefly III is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Firefly III is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Firefly III. If not, see .
+ */
+
+
+$(function () {
+ "use strict";
+ $('input[type="date"]').on('change', showUpdateButton);
+ $('.update_view').on('click', updateView);
+});
+
+function showUpdateButton() {
+ $('.update_date_button').show();
+}
+
+function updateView() {
+ var startDate = $('input[name="start_date"]').val();
+ var endDate = $('input[name="end_date"]').val();
+ window.location = '/accounts/reconcile/2/' + startDate + '/' + endDate;
+ return false;
+}
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 399222cc02..c6b211e967 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -619,6 +619,8 @@ return [
'cash_accounts' => 'Cash accounts',
'Cash account' => 'Cash account',
'reconcile_account' => 'Reconcile account ":account"',
+ 'end_of_reconcile_period' => 'End of reconcile period: :period',
+ 'start_of_reconcile_period' => 'Start of reconcile period: :period',
'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.twig
index f5da194cec..1cb62fc343 100644
--- a/resources/views/accounts/reconcile.twig
+++ b/resources/views/accounts/reconcile.twig
@@ -13,7 +13,7 @@
{{ 'reconcile_range'|_ }}
-
+
{{ 'start_balance'|_ }} |
@@ -67,11 +67,12 @@
-
+
-
- {{ 'update'|_ }}
+
+ {{ 'update_view'|_ }}
+ (unsaved progress will be lost!)
|
@@ -84,8 +85,28 @@
-
- Do something
+
+
+
+
+ {{ 'difference'|_ }} |
+ {{ 'actions'|_ }} |
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
@@ -99,6 +120,111 @@
{{ 'transactions'|_ }}
@@ -112,6 +238,8 @@
{% endblock %}
diff --git a/resources/views/list/journals.twig b/resources/views/list/journals.twig
index 6752cc2c9c..1a070710d6 100644
--- a/resources/views/list/journals.twig
+++ b/resources/views/list/journals.twig
@@ -48,7 +48,11 @@
{{ 'stop_selection'|_ }}
{% if showReconcile == true %}
- {{ 'reconcile_this_account'|_ }}
+ {% if moment == 'all' %}
+ {{ 'reconcile_this_account'|_ }}
+ {% else %}
+ {{ 'reconcile_this_account'|_ }}
+ {% endif %}
{% endif %}
diff --git a/routes/web.php b/routes/web.php
index 559c2a4f2f..163db19429 100755
--- a/routes/web.php
+++ b/routes/web.php
@@ -90,7 +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('reconcile/{account}/{start_date?}/{end_date?}', ['uses' => 'AccountController@reconcile', 'as' => 'reconcile']);
Route::get('delete/{account}', ['uses' => 'AccountController@delete', 'as' => 'delete']);
Route::get('show/{account}/{moment?}', ['uses' => 'AccountController@show', 'as' => 'show']);