Merge branch 'develop' of github.com:JC5/firefly-iii into develop

This commit is contained in:
James Cole
2017-10-27 13:00:36 +02:00
748 changed files with 16534 additions and 3330 deletions

View File

@@ -1,12 +1,22 @@
<?php
/**
* AccountController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -269,7 +279,12 @@ class AccountController extends Controller
$start = null;
$end = null;
$periods = new Collection;
$currency = $currencyRepos->find(intval($account->getMeta('currency_id')));
$currencyId = intval($account->getMeta('currency_id'));
$currency = $currencyRepos->find($currencyId);
if ($currencyId === 0) {
$currency = app('amount')->getDefaultCurrency();
}
// prep for "all" view.
if ($moment === 'all') {

View File

@@ -1,12 +1,22 @@
<?php
/**
* ConfigurationController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* HomeController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -2,10 +2,21 @@
/**
* LinkController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* UserController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* AttachmentController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,4 +1,24 @@
<?php
/**
* ForgotPasswordController.php
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,4 +1,24 @@
<?php
/**
* LoginController.php
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,4 +1,24 @@
<?php
/**
* RegisterController.php
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,4 +1,24 @@
<?php
/**
* ResetPasswordController.php
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* TwoFactorController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* BillController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -241,7 +251,7 @@ class BillController extends Controller
{
$billData = $request->getBillData();
$bill = $repository->store($billData);
$request->session()->flash('success', strval(trans('firefly.stored_new_bill', ['name' => e($bill->name)])));
$request->session()->flash('success', strval(trans('firefly.stored_new_bill', ['name' => $bill->name])));
Preferences::mark();
if (intval($request->get('create_another')) === 1) {
@@ -269,7 +279,7 @@ class BillController extends Controller
$billData = $request->getBillData();
$bill = $repository->update($bill, $billData);
$request->session()->flash('success', strval(trans('firefly.updated_bill', ['name' => e($bill->name)])));
$request->session()->flash('success', strval(trans('firefly.updated_bill', ['name' => $bill->name])));
Preferences::mark();
if (intval($request->get('return_to_edit')) === 1) {

View File

@@ -1,12 +1,22 @@
<?php
/**
* BudgetController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -19,11 +29,9 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Requests\BudgetFormRequest;
use FireflyIII\Http\Requests\BudgetIncomeRequest;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties;
@@ -40,6 +48,7 @@ use View;
*
* @package FireflyIII\Http\Controllers
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class BudgetController extends Controller
{
@@ -136,7 +145,7 @@ class BudgetController extends Controller
$name = $budget->name;
$this->repository->destroy($budget);
$request->session()->flash('success', strval(trans('firefly.deleted_budget', ['name' => e($name)])));
$request->session()->flash('success', strval(trans('firefly.deleted_budget', ['name' => $name])));
Preferences::mark();
return redirect($this->getPreviousUri('budgets.delete.uri'));
@@ -247,6 +256,7 @@ class BudgetController extends Controller
/**
* @param Carbon $start
* @param Carbon $end
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
@@ -260,50 +270,49 @@ class BudgetController extends Controller
if ($cache->has()) {
$result = $cache->get(); // @codeCoverageIgnore
return view('budgets.info', compact('result', 'begin', 'currentEnd'));
}
if (!$cache->has()) {
$result = [
'available' => '0',
'earned' => '0',
'suggested' => '0',
];
$currency = app('amount')->getDefaultCurrency();
$range = Preferences::get('viewRange', '1M')->data;
$begin = Navigation::subtractPeriod($start, $range, 3);
$result = [
'available' => '0',
'earned' => '0',
'suggested' => '0',
];
$currency = app('amount')->getDefaultCurrency();
$range = Preferences::get('viewRange', '1M')->data;
$begin = Navigation::subtractPeriod($start, $range, 3);
// get average amount available.
$total = '0';
$count = 0;
$currentStart = clone $begin;
while ($currentStart < $start) {
$currentEnd = Navigation::endOfPeriod($currentStart, $range);
$total = bcadd($total, $this->repository->getAvailableBudget($currency, $currentStart, $currentEnd));
$currentStart = Navigation::addPeriod($currentStart, $range, 0);
$count++;
}
$result['available'] = bcdiv($total, strval($count));
// amount earned in this period:
$subDay = clone $end;
$subDay->subDay();
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::DEPOSIT])->withOpposingAccount();
$result['earned'] = bcdiv(strval($collector->getJournals()->sum('transaction_amount')), strval($count));
// amount spent in period
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::WITHDRAWAL])->withOpposingAccount();
$result['spent'] = bcdiv(strval($collector->getJournals()->sum('transaction_amount')), strval($count));
// suggestion starts with the amount spent
$result['suggested'] = bcmul($result['spent'], '-1');
$result['suggested'] = bccomp($result['suggested'], $result['earned']) === 1 ? $result['earned'] : $result['suggested'];
// unless it's more than you earned. So min() of suggested/earned
$cache->store($result);
// get average amount available.
$total = '0';
$count = 0;
$currentStart = clone $begin;
while ($currentStart < $start) {
$currentEnd = Navigation::endOfPeriod($currentStart, $range);
$total = bcadd($total, $this->repository->getAvailableBudget($currency, $currentStart, $currentEnd));
$currentStart = Navigation::addPeriod($currentStart, $range, 0);
$count++;
}
$result['available'] = bcdiv($total, strval($count));
// amount earned in this period:
$subDay = clone $end;
$subDay->subDay();
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::DEPOSIT])->withOpposingAccount();
$result['earned'] = bcdiv(strval($collector->getJournals()->sum('transaction_amount')), strval($count));
// amount spent in period
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($begin, $subDay)->setTypes([TransactionType::WITHDRAWAL])->withOpposingAccount();
$result['spent'] = bcdiv(strval($collector->getJournals()->sum('transaction_amount')), strval($count));
// suggestion starts with the amount spent
$result['suggested'] = bcmul($result['spent'], '-1');
$result['suggested'] = bccomp($result['suggested'], $result['earned']) === 1 ? $result['earned'] : $result['suggested'];
// unless it's more than you earned. So min() of suggested/earned
$cache->store($result);
return view('budgets.info', compact('result', 'begin', 'currentEnd'));
@@ -406,7 +415,7 @@ class BudgetController extends Controller
// collector:
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withCategoryInformation();
$collector->setAllAssetAccounts()->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
$journals = $collector->getPaginatedJournals();
$journals->setPath(route('budgets.show', [$budget->id]));
@@ -444,11 +453,9 @@ class BudgetController extends Controller
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($budgetLimit->start_date, $budgetLimit->end_date)
->setBudget($budget)->setLimit($pageSize)->setPage($page)->withCategoryInformation();
->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
$journals = $collector->getPaginatedJournals();
$journals->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
$start = session('first', Carbon::create()->startOfYear());
$end = new Carbon;
$limits = $this->getLimits($budget, $start, $end);
@@ -467,7 +474,7 @@ class BudgetController extends Controller
$data = $request->getBudgetData();
$budget = $this->repository->store($data);
$request->session()->flash('success', strval(trans('firefly.stored_new_budget', ['name' => e($budget->name)])));
$request->session()->flash('success', strval(trans('firefly.stored_new_budget', ['name' => $budget->name])));
Preferences::mark();
if (intval($request->get('create_another')) === 1) {
@@ -492,7 +499,7 @@ class BudgetController extends Controller
$data = $request->getBudgetData();
$this->repository->update($budget, $data);
$request->session()->flash('success', strval(trans('firefly.updated_budget', ['name' => e($budget->name)])));
$request->session()->flash('success', strval(trans('firefly.updated_budget', ['name' => $budget->name])));
Preferences::mark();
if (intval($request->get('return_to_edit')) === 1) {
@@ -541,15 +548,12 @@ class BudgetController extends Controller
return $cache->get(); // @codeCoverageIgnore
}
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
$set = $this->repository->getBudgetLimits($budget, $start, $end);
$limits = new Collection();
$set = $this->repository->getBudgetLimits($budget, $start, $end);
$limits = new Collection();
/** @var BudgetLimit $entry */
foreach ($set as $entry) {
$entry->spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $entry->start_date, $entry->end_date);
$entry->spent = $this->repository->spentInPeriod(new Collection([$budget]), new Collection(), $entry->start_date, $entry->end_date);
$limits->push($entry);
}
$cache->store($limits);
@@ -569,9 +573,7 @@ class BudgetController extends Controller
$start = Navigation::startOfPeriod($start, $range);
$end = Navigation::endOfX(new Carbon, $range, null);
$entries = new Collection;
// properties for cache
$cache = new CacheProperties;
$cache = new CacheProperties;
$cache->addProperty($start);
$cache->addProperty($end);
$cache->addProperty('no-budget-period-entries');
@@ -584,8 +586,6 @@ class BudgetController extends Controller
while ($end >= $start) {
$end = Navigation::startOfPeriod($end, $range);
$currentEnd = Navigation::endOfPeriod($end, $range);
// count journals without budget in this period:
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setRange($end, $currentEnd)->withoutBudget()->withOpposingAccount()->setTypes([TransactionType::WITHDRAWAL]);
@@ -594,15 +594,7 @@ class BudgetController extends Controller
$journals = $set->count();
$dateStr = $end->format('Y-m-d');
$dateName = Navigation::periodShow($end, $range);
$entries->push(
[
'string' => $dateStr,
'name' => $dateName,
'count' => $journals,
'sum' => $sum,
'date' => clone $end,
]
);
$entries->push(['string' => $dateStr, 'name' => $dateName, 'count' => $journals, 'sum' => $sum, 'date' => clone $end,]);
$end = Navigation::subtractPeriod($end, $range, 1);
}
$cache->store($entries);

View File

@@ -1,12 +1,22 @@
<?php
/**
* CategoryController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -108,7 +118,7 @@ class CategoryController extends Controller
$name = $category->name;
$repository->destroy($category);
$request->session()->flash('success', strval(trans('firefly.deleted_category', ['name' => e($name)])));
$request->session()->flash('success', strval(trans('firefly.deleted_category', ['name' => $name])));
Preferences::mark();
return redirect($this->getPreviousUri('categories.delete.uri'));
@@ -292,7 +302,7 @@ class CategoryController extends Controller
$data = $request->getCategoryData();
$category = $repository->store($data);
$request->session()->flash('success', strval(trans('firefly.stored_category', ['name' => e($category->name)])));
$request->session()->flash('success', strval(trans('firefly.stored_category', ['name' => $category->name])));
Preferences::mark();
if (intval($request->get('create_another')) === 1) {
@@ -319,7 +329,7 @@ class CategoryController extends Controller
$data = $request->getCategoryData();
$repository->update($category, $data);
$request->session()->flash('success', strval(trans('firefly.updated_category', ['name' => e($category->name)])));
$request->session()->flash('success', strval(trans('firefly.updated_category', ['name' => $category->name])));
Preferences::mark();
if (intval($request->get('return_to_edit')) === 1) {

View File

@@ -1,12 +1,22 @@
<?php
/**
* AccountController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* BillController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* BudgetController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -74,17 +84,17 @@ class BudgetController extends Controller
*/
public function budget(Budget $budget)
{
$first = $this->repository->firstUseDate($budget);
$range = Preferences::get('viewRange', '1M')->data;
$last = session('end', new Carbon);
$cache = new CacheProperties();
$first = $this->repository->firstUseDate($budget);
$range = Preferences::get('viewRange', '1M')->data;
$currentStart = Navigation::startOfPeriod($first, $range);
$last = session('end', new Carbon);
$cache = new CacheProperties();
$cache->addProperty($first);
$cache->addProperty($last);
$cache->addProperty('chart.budget.budget');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
return Response::json($cache->get()); // @codeCoverageIgnore
}
$final = clone $last;
@@ -92,17 +102,16 @@ class BudgetController extends Controller
$budgetCollection = new Collection([$budget]);
$last = Navigation::endOfX($last, $range, $final); // not to overshoot.
$entries = [];
while ($first < $last) {
while ($currentStart < $last) {
// periodspecific dates:
$currentStart = Navigation::startOfPeriod($first, $range);
$currentEnd = Navigation::endOfPeriod($first, $range);
$currentEnd = Navigation::endOfPeriod($currentStart, $range);
// sub another day because reasons.
$currentEnd->subDay();
$spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $currentStart, $currentEnd);
$format = Navigation::periodShow($first, $range);
$format = Navigation::periodShow($currentStart, $range);
$entries[$format] = bcmul($spent, '-1');
$first = Navigation::addPeriod($first, $range, 0);
$currentStart = clone $currentEnd;
$currentStart->addDays(2);
}
$data = $this->generator->singleSet(strval(trans('firefly.spent')), $entries);
@@ -175,7 +184,7 @@ class BudgetController extends Controller
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget);
$collector->setAllAssetAccounts()->setBudget($budget);
if (!is_null($budgetLimit->id)) {
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
}
@@ -220,7 +229,7 @@ class BudgetController extends Controller
/** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAllAssetAccounts()->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withCategoryInformation();
$collector->setAllAssetAccounts()->setBudget($budget)->withCategoryInformation();
if (!is_null($budgetLimit->id)) {
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
}
@@ -439,7 +448,7 @@ class BudgetController extends Controller
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$accounts = $repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::EXPENSE]);
$accounts = $repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::CASH]);
$grouped = $accounts->groupBy('id')->toArray();
$return = [];
foreach ($accountIds as $accountId) {

View File

@@ -1,12 +1,22 @@
<?php
/**
* BudgetReportController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* CategoryController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* CategoryReportController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* PiggyBankController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* ReportController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -2,9 +2,21 @@
/**
* TagReportController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* Controller.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* CurrencyController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -207,11 +217,13 @@ class CurrencyController extends Controller
{
$currencies = $this->repository->get();
$defaultCurrency = $this->repository->getCurrencyByPreference(Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR')));
$isOwner = true;
if (!$this->userRepository->hasRole(auth()->user(), 'owner')) {
$request->session()->flash('info', trans('firefly.ask_site_owner', ['owner' => env('SITE_OWNER')]));
$isOwner = false;
}
return view('currencies.index', compact('currencies', 'defaultCurrency'));
return view('currencies.index', compact('currencies', 'defaultCurrency','isOwner'));
}
/**

View File

@@ -1,12 +1,22 @@
<?php
/**
* ExportController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* HelpController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* HomeController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -138,6 +148,7 @@ class HomeController extends Controller
$billRepository = app(BillRepositoryInterface::class);
$billCount = $billRepository->getBills()->count();
foreach ($accounts as $account) {
$collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit(10)->setPage(1);
@@ -146,7 +157,7 @@ class HomeController extends Controller
}
return view(
'index', compact('count', 'subTitle', 'transactions', 'showDeps', 'billCount')
'index', compact('count', 'subTitle', 'transactions', 'showDeps','billCount')
);
}

View File

@@ -2,9 +2,21 @@
/**
* BankController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -2,9 +2,21 @@
/**
* FileController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* ImportController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -2,9 +2,21 @@
/**
* JavascriptController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -2,10 +2,21 @@
/**
* AutoCompleteController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -2,10 +2,21 @@
/**
* BoxController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -166,16 +177,30 @@ class BoxController extends Controller
*/
public function netWorth(AccountRepositoryInterface $repository)
{
$today = new Carbon(date('Y-m-d')); // needed so its per day.
$date = new Carbon(date('Y-m-d')); // needed so its per day.
/** @var Carbon $start */
$start = session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
$end = session('end', Carbon::now()->endOfMonth());
// start and end in the future? use $end
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
$date = $end;
}
// start and end in the past? use $end
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
$date = $end;
}
// start in the past, end in the future? use $date
$cache = new CacheProperties;
$cache->addProperty($today);
$cache->addProperty($date);
$cache->addProperty('box-net-worth');
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
}
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$currency = app('amount')->getDefaultCurrency();
$balances = app('steam')->balancesByAccounts($accounts, $today);
$balances = app('steam')->balancesByAccounts($accounts, $date);
$sum = '0';
foreach ($balances as $entry) {
$sum = bcadd($sum, $entry);

View File

@@ -2,9 +2,21 @@
/**
* ExchangeController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -0,0 +1,74 @@
<?php
/**
* FrontpageController.php
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Response;
/**
* Class FrontpageController
*
* @package FireflyIII\Http\Controllers\Json
*/
class FrontpageController extends Controller
{
/**
* @return \Illuminate\Http\JsonResponse
*/
public function piggyBanks(PiggyBankRepositoryInterface $repository)
{
$set = $repository->getPiggyBanks();
$info = [];
/** @var PiggyBank $piggyBank */
foreach ($set as $piggyBank) {
$rep = $piggyBank->currentRelevantRep();
$amount = strval($rep->currentamount);
if (!is_null($rep->id) && bccomp($amount, '0') === 1) {
// percentage!
$pct = round(($amount / $piggyBank->targetamount) * 100);
$entry = [
'id' => $piggyBank->id,
'name' => $piggyBank->name,
'amount' => $amount,
'target' => $piggyBank->targetamount,
'percentage' => $pct,
];
$info[] = $entry;
}
}
$html = '';
if (count($info) > 0) {
$html = view('json.piggy-banks', compact('info'))->render();
}
return Response::json(['html' => $html]);
}
}

View File

@@ -2,9 +2,21 @@
/**
* IntroController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* JsonController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* NewUserController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* PiggyBankController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -149,7 +159,7 @@ class PiggyBankController extends Controller
*/
public function destroy(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{
Session::flash('success', strval(trans('firefly.deleted_piggy_bank', ['name' => e($piggyBank->name)])));
Session::flash('success', strval(trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name])));
Preferences::mark();
$repository->destroy($piggyBank);
@@ -275,7 +285,7 @@ class PiggyBankController extends Controller
*/
public function postAdd(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{
$amount = $request->get('amount');
$amount = $request->get('amount') ?? '0';
$currency = app('amount')->getDefaultCurrency();
if ($repository->canAddAmount($piggyBank, $amount)) {
$repository->addAmount($piggyBank, $amount);
@@ -297,7 +307,7 @@ class PiggyBankController extends Controller
'error', strval(
trans(
'firefly.cannot_add_amount_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
)
);
@@ -314,7 +324,7 @@ class PiggyBankController extends Controller
*/
public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{
$amount = $request->get('amount');
$amount = $request->get('amount') ?? '0';
$currency = app('amount')->getDefaultCurrency();
if ($repository->canRemoveAmount($piggyBank, $amount)) {
$repository->removeAmount($piggyBank, $amount);
@@ -337,7 +347,7 @@ class PiggyBankController extends Controller
'error', strval(
trans(
'firefly.cannot_remove_from_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
)
);
@@ -395,7 +405,7 @@ class PiggyBankController extends Controller
$data = $request->getPiggyBankData();
$piggyBank = $repository->store($data);
Session::flash('success', strval(trans('firefly.stored_piggy_bank', ['name' => e($piggyBank->name)])));
Session::flash('success', strval(trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name])));
Preferences::mark();
if (intval($request->get('create_another')) === 1) {
@@ -421,7 +431,7 @@ class PiggyBankController extends Controller
$data = $request->getPiggyBankData();
$piggyBank = $repository->update($piggyBank, $data);
Session::flash('success', strval(trans('firefly.updated_piggy_bank', ['name' => e($piggyBank->name)])));
Session::flash('success', strval(trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name])));
Preferences::mark();
if (intval($request->get('return_to_edit')) === 1) {

View File

@@ -1,12 +1,22 @@
<?php
/**
* ReportController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* PreferencesController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -57,9 +67,9 @@ class PreferencesController extends Controller
public function code(Google2FA $google2fa)
{
$domain = $this->getDomain();
$secret = $google2fa->generateSecretKey(16);
$secret = $google2fa->generateSecretKey();
Session::flash('two-factor-secret', $secret);
$image = $google2fa->getQRCodeInline('Firefly III at ' . $domain, auth()->user()->email, $secret, 150);
$image = $google2fa->getQRCodeInline($domain, auth()->user()->email, $secret, 200);
return view('preferences.code', compact('image'));

View File

@@ -1,12 +1,22 @@
<?php
/**
* ProfileController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* AccountController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* BalanceController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* BudgetController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* CategoryController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* OperationsController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* ReportController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -251,6 +261,7 @@ class ReportController extends Controller
* @param ReportFormRequest $request
*
* @return RedirectResponse|\Illuminate\Routing\Redirector
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function postIndex(ReportFormRequest $request)
{
@@ -289,7 +300,7 @@ class ReportController extends Controller
return redirect(route('reports.index'));
}
if ($end < $start) {
if ($request->getEndDate() < $request->getStartDate()) {
return view('error')->with('message', trans('firefly.end_after_start_date'));
}

View File

@@ -1,12 +1,22 @@
<?php
/**
* RuleController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -168,20 +178,27 @@ class RuleController extends Controller
{
/** @var RuleGroupRepositoryInterface $ruleGroupRepository */
$ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$oldTriggers = $this->getCurrentTriggers($rule);
$triggerCount = count($oldTriggers);
$oldActions = $this->getCurrentActions($rule);
$actionCount = count($oldActions);
$ruleGroups = ExpandedForm::makeSelectList($ruleGroupRepository->get());
$triggerCount = 0;
$actionCount = 0;
$oldActions = [];
$oldTriggers = [];
// has old input?
if ($request->old()) {
if (count($request->old()) > 0) {
$oldTriggers = $this->getPreviousTriggers($request);
$triggerCount = count($oldTriggers);
$oldActions = $this->getPreviousActions($request);
$actionCount = count($oldActions);
}
// overrule old input when it as no rule data:
if ($triggerCount === 0 && $actionCount === 0) {
$oldTriggers = $this->getCurrentTriggers($rule);
$triggerCount = count($oldTriggers);
$oldActions = $this->getCurrentActions($rule);
$actionCount = count($oldActions);
}
// get rule trigger for update / store-journal:
$primaryTrigger = $repository->getPrimaryTrigger($rule);
$subTitle = trans('firefly.edit_rule', ['title' => $rule->title]);

View File

@@ -1,12 +1,22 @@
<?php
/**
* RuleGroupController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,18 +1,29 @@
<?php
/**
* SearchController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Search\SearchInterface;
use Illuminate\Http\Request;
use Response;
@@ -65,11 +76,25 @@ class SearchController extends Controller
{
$fullQuery = strval($request->get('query'));
// parse search terms:
$searcher->parseQuery($fullQuery);
$searcher->setLimit(20);
$transactions = $searcher->searchTransactions();
$html = view('search.search', compact('transactions'))->render();
// cache
$cache = new CacheProperties;
$cache->addProperty('search');
$cache->addProperty($fullQuery);
if ($cache->has()) {
$transactions = $cache->get();
}
if (!$cache->has()) {
// parse search terms:
$searcher->parseQuery($fullQuery);
$searcher->setLimit(20);
$transactions = $searcher->searchTransactions();
$cache->store($transactions);
}
$html = view('search.search', compact('transactions'))->render();
return Response::json(['count' => $transactions->count(), 'html' => $html]);

View File

@@ -1,12 +1,22 @@
<?php
/**
* TagController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -118,7 +128,7 @@ class TagController extends Controller
$tagName = $tag->tag;
$this->repository->destroy($tag);
Session::flash('success', strval(trans('firefly.deleted_tag', ['tag' => e($tagName)])));
Session::flash('success', strval(trans('firefly.deleted_tag', ['tag' => $tagName])));
Preferences::mark();
return redirect($this->getPreviousUri('tags.delete.uri'));
@@ -262,7 +272,7 @@ class TagController extends Controller
$data = $request->collectTagData();
$this->repository->store($data);
Session::flash('success', strval(trans('firefly.created_tag', ['tag' => e($data['tag'])])));
Session::flash('success', strval(trans('firefly.created_tag', ['tag' => $data['tag']])));
Preferences::mark();
if (intval($request->get('create_another')) === 1) {
@@ -288,7 +298,7 @@ class TagController extends Controller
$data = $request->collectTagData();
$this->repository->update($tag, $data);
Session::flash('success', strval(trans('firefly.updated_tag', ['tag' => e($data['tag'])])));
Session::flash('success', strval(trans('firefly.updated_tag', ['tag' => $data['tag']])));
Preferences::mark();
if (intval($request->get('return_to_edit')) === 1) {

View File

@@ -1,12 +1,22 @@
<?php
/**
* ConvertController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -2,10 +2,21 @@
/**
* LinkController.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* MassController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);

View File

@@ -1,12 +1,22 @@
<?php
/**
* SingleController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -222,7 +232,7 @@ class SingleController extends Controller
}
// @codeCoverageIgnoreEnd
$type = $transactionJournal->transactionTypeStr();
Session::flash('success', strval(trans('firefly.deleted_' . strtolower($type), ['description' => e($transactionJournal->description)])));
Session::flash('success', strval(trans('firefly.deleted_' . strtolower($type), ['description' => $transactionJournal->description])));
$this->repository->delete($transactionJournal);
@@ -356,7 +366,7 @@ class SingleController extends Controller
event(new StoredTransactionJournal($journal, $data['piggy_bank_id']));
Session::flash('success', strval(trans('firefly.stored_journal', ['description' => e($journal->description)])));
Session::flash('success', strval(trans('firefly.stored_journal', ['description' => $journal->description])));
Preferences::mark();
// @codeCoverageIgnoreStart
@@ -409,7 +419,7 @@ class SingleController extends Controller
// update, get events by date and sort DESC
$type = strtolower($journal->transactionTypeStr());
Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => e($data['description'])])));
Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => $data['description']])));
Preferences::mark();
// @codeCoverageIgnoreStart

View File

@@ -1,12 +1,22 @@
<?php
/**
* SplitController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -21,6 +31,7 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\SplitJournalFormRequest;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
@@ -161,7 +172,7 @@ class SplitController extends Controller
// @codeCoverageIgnoreEnd
$type = strtolower($journal->transactionTypeStr());
Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => e($data['journal_description'])])));
Session::flash('success', strval(trans('firefly.updated_' . $type, ['description' => $data['journal_description']])));
Preferences::mark();
// @codeCoverageIgnoreStart
@@ -221,6 +232,12 @@ class SplitController extends Controller
{
$sourceAccounts = $journal->sourceAccountList();
$destinationAccounts = $journal->destinationAccountList();
$notes = '';
/** @var Note $note */
$note = $journal->notes()->first();
if (!is_null($note)) {
$notes = $note->text;
}
$array = [
'journal_description' => $request->old('journal_description', $journal->description),
'journal_amount' => $journal->amountPositive(),
@@ -241,7 +258,7 @@ class SplitController extends Controller
'payment_date' => $request->old('payment_date', $journal->getMeta('payment_date')),
'invoice_date' => $request->old('invoice_date', $journal->getMeta('invoice_date')),
'internal_reference' => $request->old('internal_reference', $journal->getMeta('internal_reference')),
'notes' => $request->old('notes', $journal->getMeta('notes')),
'notes' => $request->old('notes', $notes),
// transactions.
'transactions' => $this->getTransactionDataFromJournal($journal),

View File

@@ -1,12 +1,22 @@
<?php
/**
* TransactionController.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
* This file is part of Firefly III.
*
* See the LICENSE file for details.
* 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 <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
@@ -168,7 +178,7 @@ class TransactionController extends Controller
$events = $tasker->getPiggyBankEvents($journal);
$transactions = $tasker->getTransactionsOverview($journal);
$what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
$subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"';
$subTitle = trans('firefly.' . $what) . ' "' . $journal->description . '"';
return view('transactions.show', compact('journal', 'events', 'subTitle', 'what', 'transactions', 'linkTypes', 'links'));