Skip to content

Firefly III: a personal finances manager

Code cleanup. Moving closer to new release.

James Colea74a64677710
diff --git a/app/Crud/Account/AccountCrud.php b/app/Crud/Account/AccountCrud.php
index 72612f76b4..b09c413407 100644
--- a/app/Crud/Account/AccountCrud.php
+++ b/app/Crud/Account/AccountCrud.php
@@ -140,6 +140,8 @@ class AccountCrud implements AccountCrudInterface
* @param array $data
*
* @return Account
+ *
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function store(array $data): Account
{
@@ -148,7 +150,6 @@ class AccountCrud implements AccountCrudInterface
$this->storeMetadata($newAccount, $data);
}
-
// continue with the opposing account:
if ($data['openingBalance'] != 0) {
$opposingData = [
@@ -202,26 +203,30 @@ class AccountCrud implements AccountCrudInterface
if ($data['openingBalance'] != 0) {
if (!is_null($openingBalance->id)) {
$this->updateInitialBalance($account, $openingBalance, $data);
- } else {
- $type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
- $opposingData = [
- 'user' => $data['user'],
- 'accountType' => $type,
- 'name' => $data['name'] . ' initial balance',
- 'active' => false,
- 'iban' => '',
- 'virtualBalance' => 0,
- ];
- $opposing = $this->storeAccount($opposingData);
- if (!is_null($opposing)) {
- $this->storeInitialBalance($account, $opposing, $data);
- }
+
+ return $account;
}
- } else {
- if ($openingBalance) { // opening balance is zero, should we delete it?
- $openingBalance->delete(); // delete existing opening balance.
+ $type = $data['openingBalance'] < 0 ? 'expense' : 'revenue';
+ $opposingData = [
+ 'user' => $data['user'],
+ 'accountType' => $type,
+ 'name' => $data['name'] . ' initial balance',
+ 'active' => false,
+ 'iban' => '',
+ 'virtualBalance' => 0,
+ ];
+ $opposing = $this->storeAccount($opposingData);
+ if (!is_null($opposing)) {
+ $this->storeInitialBalance($account, $opposing, $data);
}
+
+ return $account;
+
+ }
+
+ if ($openingBalance) { // opening balance is zero, should we delete it?
+ $openingBalance->delete(); // delete existing opening balance.
}
return $account;
@@ -292,16 +297,16 @@ class AccountCrud implements AccountCrudInterface
]
);
+ $firstAccount = $account;
+ $secondAccount = $opposing;
+ $firstAmount = $data['openingBalance'];
+ $secondAmount = $data['openingBalance'] * -1;
+
if ($data['openingBalance'] < 0) {
$firstAccount = $opposing;
$secondAccount = $account;
$firstAmount = $data['openingBalance'] * -1;
$secondAmount = $data['openingBalance'];
- } else {
- $firstAccount = $account;
- $secondAccount = $opposing;
- $firstAmount = $data['openingBalance'];
- $secondAmount = $data['openingBalance'] * -1;
}
$one = new Transaction(['account_id' => $firstAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $firstAmount]);
@@ -378,16 +383,17 @@ class AccountCrud implements AccountCrudInterface
if (!is_null($entry)) {
$entry->data = $data[$field];
$entry->save();
- } else {
- $metaData = new AccountMeta(
- [
- 'account_id' => $account->id,
- 'name' => $field,
- 'data' => $data[$field],
- ]
- );
- $metaData->save();
+
+ continue;
}
+ $metaData = new AccountMeta(
+ [
+ 'account_id' => $account->id,
+ 'name' => $field,
+ 'data' => $data[$field],
+ ]
+ );
+ $metaData->save();
}
}
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index 69e035e6c8..9d1d579bce 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -31,10 +31,6 @@ use stdClass;
*/
class CategoryController extends Controller
{
- const MAKE_POSITIVE = -1;
- const KEEP_POSITIVE = 1;
-
-
/** @var CategoryChartGeneratorInterface */
protected $generator;
@@ -192,20 +188,20 @@ class CategoryController extends Controller
// get data:
if (is_null($category->id)) {
- $name = trans('firefly.noCategory');
- $spent = $repository->spentInPeriodWithoutCategory($accounts, $currentStart, $currentEnd);
- $earned = $repository->earnedInPeriodWithoutCategory($accounts, $currentStart, $currentEnd);
- } else {
-
- $name = $category->name;
- $spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $currentStart, $currentEnd);
- $earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $currentStart, $currentEnd);
- }
+ $entry['name'] = trans('firefly.noCategory');
+ $entry['spent'][$year] = ($repository->spentInPeriodWithoutCategory($accounts, $currentStart, $currentEnd) * -1);
+ $entry['earned'][$year] = $repository->earnedInPeriodWithoutCategory($accounts, $currentStart, $currentEnd);
- // save to array:
- $entry['name'] = $name;
- $entry['spent'][$year] = ($spent * -1);
- $entry['earned'][$year] = $earned;
+ // jump to next year.
+ $currentStart = clone $currentEnd;
+ $currentStart->addDay();
+ continue;
+
+ }
+ // alternative is a normal category:
+ $entry['name'] = $category->name;
+ $entry['spent'][$year] = ($repository->spentInPeriod(new Collection([$category]), $accounts, $currentStart, $currentEnd) * -1);
+ $entry['earned'][$year] = $repository->earnedInPeriod(new Collection([$category]), $accounts, $currentStart, $currentEnd);
// jump to next year.
$currentStart = clone $currentEnd;
@@ -213,8 +209,8 @@ class CategoryController extends Controller
}
$entries->push($entry);
}
- // generate chart with data:
+ // generate chart with data:
$data = $this->generator->multiYear($entries);
$cache->store($data);
diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php
index 13380c6231..3824bfccea 100644
--- a/app/Http/Controllers/Chart/ReportController.php
+++ b/app/Http/Controllers/Chart/ReportController.php
@@ -128,15 +128,18 @@ class ReportController extends Controller
if ($start->diffInMonths($end) > 12) {
// data = method X
$data = $this->multiYearInOut($earnedArray, $spentArray, $start, $end);
- } else {
- // data = method Y
- $data = $this->singleYearInOut($earnedArray, $spentArray, $start, $end);
+ $cache->store($data);
+
+ return Response::json($data);
}
+ // data = method Y
+ $data = $this->singleYearInOut($earnedArray, $spentArray, $start, $end);
$cache->store($data);
return Response::json($data);
+
}
/**
@@ -179,13 +182,16 @@ class ReportController extends Controller
if ($start->diffInMonths($end) > 12) {
// per year
$data = $this->multiYearInOutSummarized($earnedArray, $spentArray, $start, $end);
- } else {
- // per month!
- $data = $this->singleYearInOutSummarized($earnedArray, $spentArray, $start, $end);
+ $cache->store($data);
+
+ return Response::json($data);
}
+ // per month!
+ $data = $this->singleYearInOutSummarized($earnedArray, $spentArray, $start, $end);
$cache->store($data);
return Response::json($data);
+
}
/**
diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php
index 113cebdb15..8f42e9cc59 100644
--- a/app/Http/Controllers/NewUserController.php
+++ b/app/Http/Controllers/NewUserController.php
@@ -67,59 +67,18 @@ class NewUserController extends Controller
{
$count = 1;
// create normal asset account:
- $assetAccount = [
- 'name' => $request->get('bank_name'),
- 'iban' => null,
- 'accountType' => 'asset',
- 'virtualBalance' => 0,
- 'active' => true,
- 'user' => Auth::user()->id,
- 'accountRole' => 'defaultAsset',
- 'openingBalance' => round($request->input('bank_balance'), 2),
- 'openingBalanceDate' => new Carbon,
- 'openingBalanceCurrency' => intval($request->input('amount_currency_id_bank_balance')),
- ];
-
- $crud->store($assetAccount);
+ $this->createAssetAccount($request, $crud);
// create savings account
if (strlen($request->get('savings_balance') > 0)) {
- $savingsAccount = [
- 'name' => $request->get('bank_name') . ' savings account',
- 'iban' => null,
- 'accountType' => 'asset',
- 'virtualBalance' => 0,
- 'active' => true,
- 'user' => Auth::user()->id,
- 'accountRole' => 'savingAsset',
- 'openingBalance' => round($request->input('savings_balance'), 2),
- 'openingBalanceDate' => new Carbon,
- 'openingBalanceCurrency' => intval($request->input('amount_currency_id_savings_balance')),
- ];
- $crud->store($savingsAccount);
+ $this->createSavingsAccount($request, $crud);
$count++;
}
// create credit card.
if (strlen($request->get('credit_card_limit') > 0)) {
- $creditAccount = [
- 'name' => 'Credit card',
- 'iban' => null,
- 'accountType' => 'asset',
- 'virtualBalance' => round($request->get('credit_card_limit'), 2),
- 'active' => true,
- 'user' => Auth::user()->id,
- 'accountRole' => 'ccAsset',
- 'openingBalance' => null,
- 'openingBalanceDate' => null,
- 'openingBalanceCurrency' => intval($request->input('amount_currency_id_credit_card_limit')),
- ];
- $creditCard = $crud->store($creditAccount);
-
- // store meta for CC:
- $crud->storeMeta($creditCard, 'ccType', 'monthlyFull');
- $crud->storeMeta($creditCard, 'ccMonthlyPaymentDate', Carbon::now()->year . '-01-01');
+ $this->storeCreditCard($request, $crud);
$count++;
}
$message = strval(trans('firefly.stored_new_accounts_new_user'));
@@ -132,4 +91,84 @@ class NewUserController extends Controller
return redirect(route('index'));
}
+
+ /**
+ * @param NewUserFormRequest $request
+ * @param AccountCrudInterface $crud
+ *
+ * @return bool
+ */
+ private function createAssetAccount(NewUserFormRequest $request, AccountCrudInterface $crud): bool
+ {
+ $assetAccount = [
+ 'name' => $request->get('bank_name'),
+ 'iban' => null,
+ 'accountType' => 'asset',
+ 'virtualBalance' => 0,
+ 'active' => true,
+ 'user' => Auth::user()->id,
+ 'accountRole' => 'defaultAsset',
+ 'openingBalance' => round($request->input('bank_balance'), 2),
+ 'openingBalanceDate' => new Carbon,
+ 'openingBalanceCurrency' => intval($request->input('amount_currency_id_bank_balance')),
+ ];
+
+ $crud->store($assetAccount);
+
+ return true;
+ }
+
+ /**
+ * @param NewUserFormRequest $request
+ * @param AccountCrudInterface $crud
+ *
+ * @return bool
+ */
+ private function createSavingsAccount(NewUserFormRequest $request, AccountCrudInterface $crud): bool
+ {
+ $savingsAccount = [
+ 'name' => $request->get('bank_name') . ' savings account',
+ 'iban' => null,
+ 'accountType' => 'asset',
+ 'virtualBalance' => 0,
+ 'active' => true,
+ 'user' => Auth::user()->id,
+ 'accountRole' => 'savingAsset',
+ 'openingBalance' => round($request->input('savings_balance'), 2),
+ 'openingBalanceDate' => new Carbon,
+ 'openingBalanceCurrency' => intval($request->input('amount_currency_id_savings_balance')),
+ ];
+ $crud->store($savingsAccount);
+
+ return true;
+ }
+
+ /**
+ * @param NewUserFormRequest $request
+ * @param AccountCrudInterface $crud
+ *
+ * @return bool
+ */
+ private function storeCreditCard(NewUserFormRequest $request, AccountCrudInterface $crud): bool
+ {
+ $creditAccount = [
+ 'name' => 'Credit card',
+ 'iban' => null,
+ 'accountType' => 'asset',
+ 'virtualBalance' => round($request->get('credit_card_limit'), 2),
+ 'active' => true,
+ 'user' => Auth::user()->id,
+ 'accountRole' => 'ccAsset',
+ 'openingBalance' => null,
+ 'openingBalanceDate' => null,
+ 'openingBalanceCurrency' => intval($request->input('amount_currency_id_credit_card_limit')),
+ ];
+ $creditCard = $crud->store($creditAccount);
+
+ // store meta for CC:
+ $crud->storeMeta($creditCard, 'ccType', 'monthlyFull');
+ $crud->storeMeta($creditCard, 'ccMonthlyPaymentDate', Carbon::now()->year . '-01-01');
+
+ return true;
+ }
}
diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php
index 11eac0793a..85b34ae973 100644
--- a/app/Http/Controllers/RuleController.php
+++ b/app/Http/Controllers/RuleController.php
@@ -152,17 +152,17 @@ class RuleController extends Controller
*/
public function edit(RuleRepositoryInterface $repository, Rule $rule)
{
+ $oldTriggers = $this->getCurrentTriggers($rule);
+ $triggerCount = count($oldTriggers);
+ $oldActions = $this->getCurrentActions($rule);
+ $actionCount = count($oldActions);
+
// has old input?
if (Input::old()) {
$oldTriggers = $this->getPreviousTriggers();
$triggerCount = count($oldTriggers);
$oldActions = $this->getPreviousActions();
$actionCount = count($oldActions);
- } else {
- $oldTriggers = $this->getCurrentTriggers($rule);
- $triggerCount = count($oldTriggers);
- $oldActions = $this->getCurrentActions($rule);
- $actionCount = count($oldActions);
}
// get rule trigger for update / store-journal:
@@ -306,10 +306,9 @@ class RuleController extends Controller
$warning = '';
if (count($matchingTransactions) == $limit) {
$warning = trans('firefly.warning_transaction_subset', ['max_num_transactions' => $limit]);
- } else {
- if (count($matchingTransactions) == 0) {
- $warning = trans('firefly.warning_no_matching_transactions', ['num_transactions' => $range]);
- }
+ }
+ if (count($matchingTransactions) == 0) {
+ $warning = trans('firefly.warning_no_matching_transactions', ['num_transactions' => $range]);
}
// Return json response
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index 482085bbaf..bf71bb329b 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -37,16 +37,15 @@ class Authenticate
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
- } else {
- return redirect()->guest('login');
}
- } else {
- if (intval(Auth::user()->blocked) === 1) {
- Auth::guard($guard)->logout();
- Session::flash('logoutMessage', trans('firefly.block_account_logout'));
- return redirect()->guest('login');
- }
+ return redirect()->guest('login');
+ }
+ if (intval(Auth::user()->blocked) === 1) {
+ Auth::guard($guard)->logout();
+ Session::flash('logoutMessage', trans('firefly.block_account_logout'));
+
+ return redirect()->guest('login');
}
return $next($request);
diff --git a/app/Http/Middleware/AuthenticateTwoFactor.php b/app/Http/Middleware/AuthenticateTwoFactor.php
index a17bed78cb..265b55e8ef 100644
--- a/app/Http/Middleware/AuthenticateTwoFactor.php
+++ b/app/Http/Middleware/AuthenticateTwoFactor.php
@@ -40,17 +40,16 @@ class AuthenticateTwoFactor
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
- } else {
- return redirect()->guest('login');
}
- } else {
- if (intval(Auth::user()->blocked) === 1) {
- Auth::guard($guard)->logout();
- Session::flash('logoutMessage', trans('firefly.block_account_logout'));
+ return redirect()->guest('login');
+ }
- return redirect()->guest('login');
- }
+ if (intval(Auth::user()->blocked) === 1) {
+ Auth::guard($guard)->logout();
+ Session::flash('logoutMessage', trans('firefly.block_account_logout'));
+
+ return redirect()->guest('login');
}
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', false)->data;
$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
diff --git a/app/Http/Middleware/IsAdmin.php b/app/Http/Middleware/IsAdmin.php
index 3df960c954..a75420343c 100644
--- a/app/Http/Middleware/IsAdmin.php
+++ b/app/Http/Middleware/IsAdmin.php
@@ -38,15 +38,14 @@ class IsAdmin
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
- } else {
- return redirect()->guest('login');
- }
- } else {
- /** @var User $user */
- $user = Auth::user();
- if (!$user->hasRole('owner')) {
- return redirect(route('home'));
}
+
+ return redirect()->guest('login');
+ }
+ /** @var User $user */
+ $user = Auth::user();
+ if (!$user->hasRole('owner')) {
+ return redirect(route('home'));
}
return $next($request);
diff --git a/app/Http/Middleware/IsConfirmed.php b/app/Http/Middleware/IsConfirmed.php
index acf23ca13b..df7638cbcb 100644
--- a/app/Http/Middleware/IsConfirmed.php
+++ b/app/Http/Middleware/IsConfirmed.php
@@ -38,21 +38,20 @@ class IsConfirmed
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
- } else {
- return redirect()->guest('login');
}
- } else {
- // must the user be confirmed in the first place?
- $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
- // user must be logged in, then continue:
- $isConfirmed = Preferences::get('user_confirmed', false)->data;
- if ($isConfirmed === false && $confirmAccount === true) {
+ return redirect()->guest('login');
+ }
+ // must the user be confirmed in the first place?
+ $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
+ // user must be logged in, then continue:
+ $isConfirmed = Preferences::get('user_confirmed', false)->data;
- // user account is not confirmed, redirect to
- // confirmation page:
- return redirect(route('confirmation_error'));
- }
+ if ($isConfirmed === false && $confirmAccount === true) {
+
+ // user account is not confirmed, redirect to
+ // confirmation page:
+ return redirect(route('confirmation_error'));
}
return $next($request);
diff --git a/app/Http/Middleware/IsNotConfirmed.php b/app/Http/Middleware/IsNotConfirmed.php
index 3aa40091b0..e0fb82464f 100644
--- a/app/Http/Middleware/IsNotConfirmed.php
+++ b/app/Http/Middleware/IsNotConfirmed.php
@@ -38,18 +38,17 @@ class IsNotConfirmed
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
- } else {
- return redirect()->guest('login');
- }
- } else {
- // must the user be confirmed in the first place?
- $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
- // user must be logged in, then continue:
- $isConfirmed = Preferences::get('user_confirmed', false)->data;
- if ($isConfirmed || $confirmAccount === false) {
- // user account is confirmed, simply send them home.
- return redirect(route('home'));
}
+
+ return redirect()->guest('login');
+ }
+ // must the user be confirmed in the first place?
+ $confirmAccount = env('MUST_CONFIRM_ACCOUNT', false);
+ // user must be logged in, then continue:
+ $isConfirmed = Preferences::get('user_confirmed', false)->data;
+ if ($isConfirmed || $confirmAccount === false) {
+ // user account is confirmed, simply send them home.
+ return redirect(route('home'));
}
return $next($request);
diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php
index 9567ee62f1..2c9638ec97 100644
--- a/app/Http/Middleware/Range.php
+++ b/app/Http/Middleware/Range.php
@@ -77,16 +77,13 @@ class Range
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$journal = $repository->first();
+ $first = Carbon::now()->startOfYear();
+
if (!is_null($journal->id)) {
- Session::put('first', $journal->date);
- } else {
- Session::put('first', Carbon::now()->startOfYear());
+ $first = $journal->date;
}
+ Session::put('first', $first);
}
-
- // check "sum of everything".
-
-
$current = Carbon::now()->formatLocalized('%B %Y');
$next = Carbon::now()->endOfMonth()->addDay()->formatLocalized('%B %Y');
$prev = Carbon::now()->startOfMonth()->subDay()->formatLocalized('%B %Y');
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 66ece94755..170e97086a 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -299,16 +299,23 @@ class AccountRepository implements AccountRepositoryInterface
if ($diff < 0 && $account->startBalance > 0) {
// percentage lost compared to start.
$pct = (($diff * -1) / $account->startBalance) * 100;
- } else {
- if ($diff >= 0 && $account->startBalance > 0) {
- $pct = ($diff / $account->startBalance) * 100;
- } else {
- $pct = 100;
- }
+
+ $pct = $pct > 100 ? 100 : $pct;
+ $account->difference = $diff;
+ $account->percentage = round($pct);
+
+ return;
+ }
+ if ($diff >= 0 && $account->startBalance > 0) {
+ $pct = ($diff / $account->startBalance) * 100;
+ $pct = $pct > 100 ? 100 : $pct;
+ $account->difference = $diff;
+ $account->percentage = round($pct);
+
+ return;
}
- $pct = $pct > 100 ? 100 : $pct;
$account->difference = $diff;
- $account->percentage = round($pct);
+ $account->percentage = 100;
}
);
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index 8eb3e87fe6..51c1ebd969 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -531,12 +531,11 @@ class JournalRepository implements JournalRepositoryInterface
);
return [$fromAccount, $destinationAccount];
- } else {
- $fromType = AccountType::where('type', 'Cash account')->first();
- $fromAccount = Account::firstOrCreateEncrypted(
- ['user_id' => $data['user'], 'account_type_id' => $fromType->id, 'name' => 'Cash account', 'active' => 1]
- );
}
+ $fromType = AccountType::where('type', 'Cash account')->first();
+ $fromAccount = Account::firstOrCreateEncrypted(
+ ['user_id' => $data['user'], 'account_type_id' => $fromType->id, 'name' => 'Cash account', 'active' => 1]
+ );
return [$fromAccount, $destinationAccount];
}
diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php
index 5cb891732b..a24dcf683c 100644
--- a/app/Repositories/RuleGroup/RuleGroupRepository.php
+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php
@@ -60,11 +60,11 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
if (is_null($moveTo)) {
$rule->delete();
- } else {
- // move
- $rule->ruleGroup()->associate($moveTo);
- $rule->save();
+ continue;
}
+ // move
+ $rule->ruleGroup()->associate($moveTo);
+ $rule->save();
}
$ruleGroup->delete();
diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php
index 97144f139a..6744621271 100644
--- a/app/Support/Navigation.php
+++ b/app/Support/Navigation.php
@@ -111,9 +111,14 @@ class Navigation
$function = $functionMap[$repeatFreq];
if (isset($modifierMap[$repeatFreq])) {
$currentEnd->$function($modifierMap[$repeatFreq]);
- } else {
- $currentEnd->$function();
+
+ if (in_array($repeatFreq, $subDay)) {
+ $currentEnd->subDay();
+ }
+
+ return $currentEnd;
}
+ $currentEnd->$function();
if (in_array($repeatFreq, $subDay)) {
$currentEnd->subDay();
}
@@ -370,11 +375,14 @@ class Navigation
if ($range == '6M') {
if ($start->month >= 7) {
$start->startOfYear()->addMonths(6);
- } else {
- $start->startOfYear();
+
+ return $start;
}
+ $start->startOfYear();
return $start;
+
+
}
throw new FireflyException('updateStartDate cannot handle $range "' . $range . '"');
}
diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php
index 8194895de5..aa519155c5 100644
--- a/app/Support/Preferences.php
+++ b/app/Support/Preferences.php
@@ -144,13 +144,18 @@ class Preferences
if (!is_null($pref)) {
$pref->data = $value;
- } else {
- $pref = new Preference;
- $pref->name = $name;
- $pref->data = $value;
- $pref->user()->associate($user);
+ $pref->save();
+
+ Cache::forever($fullName, $pref);
+ return $pref;
}
+
+ $pref = new Preference;
+ $pref->name = $name;
+ $pref->data = $value;
+ $pref->user()->associate($user);
+
$pref->save();
Cache::forever($fullName, $pref);
diff --git a/database/migrations/2014_12_24_191544_changes_for_v322.php b/database/migrations/2014_12_24_191544_changes_for_v322.php
index ce79a649e8..5cd658dc5c 100644
--- a/database/migrations/2014_12_24_191544_changes_for_v322.php
+++ b/database/migrations/2014_12_24_191544_changes_for_v322.php
@@ -7,7 +7,7 @@ use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
- * @SuppressWarnings("PHPMD.ExcessiveMethodLength")
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* Class ChangesForV322
*/
diff --git a/database/migrations/2015_01_18_082406_changes_for_v325.php b/database/migrations/2015_01_18_082406_changes_for_v325.php
index 79f8c00249..b232103ca9 100644
--- a/database/migrations/2015_01_18_082406_changes_for_v325.php
+++ b/database/migrations/2015_01_18_082406_changes_for_v325.php
@@ -7,7 +7,7 @@ use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
- * @SuppressWarnings("PHPMD.ExcessiveMethodLength")
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* Class ChangesForV325
*/
diff --git a/database/migrations/2015_03_29_174140_changes_for_v336.php b/database/migrations/2015_03_29_174140_changes_for_v336.php
index 411caddc9d..315f1ff570 100644
--- a/database/migrations/2015_03_29_174140_changes_for_v336.php
+++ b/database/migrations/2015_03_29_174140_changes_for_v336.php
@@ -7,7 +7,7 @@ use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
- * @SuppressWarnings("PHPMD.ExcessiveMethodLength")
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* Class ChangesForV336
*/