diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 0af04d700d..3a560fa376 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -250,6 +250,62 @@ class AccountController extends Controller return 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.js index 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 file diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 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.twig new file mode 100644 index 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 %} + +
+
+
+
+

{{ 'reconcile_range'|_ }}

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
{{ 'start_balance'|_ }}{{ 'end_balance'|_ }}
+ {{ 'date'|_ }} + + {{ 'balance'|_ }} + + {{ 'date'|_ }} + + {{ 'balance'|_ }} +
+
+
+ +
+ +
+
+
+ {{ currency.symbol }} + +
+
+
+
+ +
+ +
+
+
+ {{ currency.symbol }} + +
+
+ + {{ 'update'|_ }} + +
+
+
+
+
+
+
+

{{ 'reconcile_options'|_ }}

+
+
+ Do something +
+
+
+ +
+ +
+
+
+
+

{{ 'transactions'|_ }}

+
+
+
+
+
+
+ + + +{% endblock %} + +{% block scripts %} + + +{% endblock %} diff --git a/resources/views/accounts/show.twig b/resources/views/accounts/show.twig index 43c219fc54..194d232703 100644 --- a/resources/views/accounts/show.twig +++ b/resources/views/accounts/show.twig @@ -85,7 +85,7 @@

{{ 'transactions'|_ }}

- {% 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 %}

diff --git a/resources/views/list/accounts.twig b/resources/views/list/accounts.twig index af7a7be7f7..800480da45 100644 --- a/resources/views/list/accounts.twig +++ b/resources/views/list/accounts.twig @@ -19,8 +19,9 @@

- - + + +
{{ account.name }} diff --git a/resources/views/list/journals.twig b/resources/views/list/journals.twig index fdb0685e80..6752cc2c9c 100644 --- a/resources/views/list/journals.twig +++ b/resources/views/list/journals.twig @@ -36,7 +36,7 @@
@@ -47,6 +47,9 @@ {{ 'select_transactions'|_ }} + {% if showReconcile == true %} + {{ 'reconcile_this_account'|_ }} + {% endif %}
@@ -58,5 +61,5 @@ diff --git a/resources/views/search/index.twig b/resources/views/search/index.twig index 98600a006b..d915476cd6 100644 --- a/resources/views/search/index.twig +++ b/resources/views/search/index.twig @@ -109,7 +109,7 @@