mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Code cleanup [skip ci]
This commit is contained in:
@@ -64,6 +64,7 @@ class BalanceLine
|
||||
if ($this->getRole() == self::ROLE_DIFFROLE) {
|
||||
return trans('firefly.leftUnbalanced');
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@@ -70,6 +70,7 @@ class ReportHelper implements ReportHelperInterface
|
||||
if ($account->accountType->type != 'Cash account') {
|
||||
return $account;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
@@ -5,9 +5,9 @@ namespace FireflyIII\Helpers\Report;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collection\Account as AccountCollection;
|
||||
use FireflyIII\Helpers\Collection\Balance;
|
||||
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
||||
use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
|
||||
use FireflyIII\Helpers\Collection\Category as CategoryCollection;
|
||||
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
||||
use FireflyIII\Helpers\Collection\Expense;
|
||||
use FireflyIII\Helpers\Collection\Income;
|
||||
|
||||
|
@@ -72,6 +72,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
if ($journal->amount != 0) {
|
||||
return $journal;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
@@ -189,6 +190,7 @@ class ReportQuery implements ReportQueryInterface
|
||||
if ($journal->amount != 0) {
|
||||
return $journal;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
@@ -7,12 +7,13 @@ use FireflyIII\Http\Requests\AccountFormRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use Steam;
|
||||
use URL;
|
||||
use View;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
*
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
use Auth;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -11,7 +9,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Grumpydictator\Gchart\GChart;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Response;
|
||||
use Session;
|
||||
@@ -43,15 +40,14 @@ class AccountController extends Controller
|
||||
$end->endOfMonth();
|
||||
|
||||
// chart properties for cache:
|
||||
$chartProperties = new CacheProperties();
|
||||
$chartProperties->addProperty($start);
|
||||
$chartProperties->addProperty($end);
|
||||
$chartProperties->addProperty('all');
|
||||
$chartProperties->addProperty('accounts');
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('all');
|
||||
$cache->addProperty('accounts');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
|
||||
$chart->addColumn(trans('firefly.dayOfMonth'), 'date');
|
||||
@@ -91,7 +87,7 @@ class AccountController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
@@ -114,15 +110,14 @@ class AccountController extends Controller
|
||||
$accounts = $repository->getFrontpageAccounts($frontPage);
|
||||
|
||||
// chart properties for cache:
|
||||
$chartProperties = new CacheProperties();
|
||||
$chartProperties->addProperty($start);
|
||||
$chartProperties->addProperty($end);
|
||||
$chartProperties->addProperty('frontpage');
|
||||
$chartProperties->addProperty('accounts');
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('frontpage');
|
||||
$cache->addProperty('accounts');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
|
||||
$index = 1;
|
||||
@@ -148,7 +143,7 @@ class AccountController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
@@ -174,18 +169,15 @@ class AccountController extends Controller
|
||||
$today = new Carbon;
|
||||
|
||||
// chart properties for cache:
|
||||
$chartProperties = new CacheProperties();
|
||||
$chartProperties->addProperty($start);
|
||||
$chartProperties->addProperty($end);
|
||||
$chartProperties->addProperty('frontpage');
|
||||
$chartProperties->addProperty('single');
|
||||
$chartProperties->addProperty($account->id);
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('frontpage');
|
||||
$cache->addProperty('single');
|
||||
$cache->addProperty($account->id);
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
|
||||
|
||||
while ($end >= $current) {
|
||||
$certain = $current < $today;
|
||||
@@ -197,7 +189,7 @@ class AccountController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
@@ -14,8 +14,7 @@ use Illuminate\Support\Collection;
|
||||
use Response;
|
||||
use Session;
|
||||
use Steam;
|
||||
use Cache;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class BillController
|
||||
*
|
||||
@@ -40,14 +39,13 @@ class BillController extends Controller
|
||||
$chart->addColumn(trans('firefly.minAmount'), 'number');
|
||||
$chart->addColumn(trans('firefly.billEntry'), 'number');
|
||||
|
||||
$chartProperties = new CacheProperties;
|
||||
$chartProperties->addProperty('single');
|
||||
$chartProperties->addProperty('bill');
|
||||
$chartProperties->addProperty($bill->id);
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty('single');
|
||||
$cache->addProperty('bill');
|
||||
$cache->addProperty($bill->id);
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
// get first transaction or today for start:
|
||||
$results = $repository->getJournals($bill);
|
||||
@@ -59,7 +57,7 @@ class BillController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
@@ -84,15 +82,14 @@ class BillController extends Controller
|
||||
|
||||
|
||||
// chart properties for cache:
|
||||
$chartProperties = new CacheProperties();
|
||||
$chartProperties->addProperty($start);
|
||||
$chartProperties->addProperty($end);
|
||||
$chartProperties->addProperty('bills');
|
||||
$chartProperties->addProperty('frontpage');
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('bills');
|
||||
$cache->addProperty('frontpage');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
$bills = $repository->getActiveBills();
|
||||
$paid = new Collection; // journals.
|
||||
@@ -163,7 +160,7 @@ class BillController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Budget;
|
||||
@@ -11,7 +10,6 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Grumpydictator\Gchart\GChart;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Navigation;
|
||||
use Preferences;
|
||||
use Response;
|
||||
@@ -45,15 +43,14 @@ class BudgetController extends Controller
|
||||
$last = Navigation::endOfX($last, $range, $final);
|
||||
|
||||
// chart properties for cache:
|
||||
$chartProperties = new CacheProperties();
|
||||
$chartProperties->addProperty($first);
|
||||
$chartProperties->addProperty($last);
|
||||
$chartProperties->addProperty('budget');
|
||||
$chartProperties->addProperty('budget');
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($first);
|
||||
$cache->addProperty($last);
|
||||
$cache->addProperty('budget');
|
||||
$cache->addProperty('budget');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
|
||||
while ($first < $last) {
|
||||
@@ -69,7 +66,7 @@ class BudgetController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
@@ -90,17 +87,16 @@ class BudgetController extends Controller
|
||||
$end = $repetition->enddate;
|
||||
|
||||
// chart properties for cache:
|
||||
$chartProperties = new CacheProperties();
|
||||
$chartProperties->addProperty($start);
|
||||
$chartProperties->addProperty($end);
|
||||
$chartProperties->addProperty('budget');
|
||||
$chartProperties->addProperty('limit');
|
||||
$chartProperties->addProperty($budget->id);
|
||||
$chartProperties->addProperty($repetition->id);
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('budget');
|
||||
$cache->addProperty('limit');
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($repetition->id);
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
$chart->addColumn(trans('firefly.day'), 'date');
|
||||
$chart->addColumn(trans('firefly.left'), 'number');
|
||||
@@ -120,7 +116,7 @@ class BudgetController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
@@ -147,15 +143,14 @@ class BudgetController extends Controller
|
||||
$allEntries = new Collection;
|
||||
|
||||
// chart properties for cache:
|
||||
$chartProperties = new CacheProperties();
|
||||
$chartProperties->addProperty($start);
|
||||
$chartProperties->addProperty($end);
|
||||
$chartProperties->addProperty('budget');
|
||||
$chartProperties->addProperty('all');
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('budget');
|
||||
$cache->addProperty('all');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
|
||||
/** @var Budget $budget */
|
||||
@@ -194,7 +189,7 @@ class BudgetController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
@@ -218,15 +213,14 @@ class BudgetController extends Controller
|
||||
$budgets = $repository->getBudgets();
|
||||
|
||||
// chart properties for cache:
|
||||
$chartProperties = new CacheProperties();
|
||||
$chartProperties->addProperty($start);
|
||||
$chartProperties->addProperty($end);
|
||||
$chartProperties->addProperty('budget');
|
||||
$chartProperties->addProperty('year');
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('budget');
|
||||
$cache->addProperty('year');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
// add columns:
|
||||
$chart->addColumn(trans('firefly.month'), 'date');
|
||||
@@ -254,7 +248,7 @@ class BudgetController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
@@ -3,14 +3,12 @@
|
||||
namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Grumpydictator\Gchart\GChart;
|
||||
use Log;
|
||||
use Navigation;
|
||||
use Preferences;
|
||||
use Response;
|
||||
@@ -80,15 +78,14 @@ class CategoryController extends Controller
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
|
||||
// chart properties for cache:
|
||||
$chartProperties = new CacheProperties;
|
||||
$chartProperties->addProperty($start);
|
||||
$chartProperties->addProperty($end);
|
||||
$chartProperties->addProperty('category');
|
||||
$chartProperties->addProperty('frontpage');
|
||||
if ($chartProperties->has()) {
|
||||
return Response::json($chartProperties->get());
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('category');
|
||||
$cache->addProperty('frontpage');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $chartProperties->getMd5();
|
||||
|
||||
$set = $repository->getCategoriesAndExpensesCorrected($start, $end);
|
||||
|
||||
@@ -115,7 +112,7 @@ class CategoryController extends Controller
|
||||
$chart->generate();
|
||||
|
||||
$data = $chart->getData();
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Input;
|
||||
use Preferences;
|
||||
@@ -74,7 +73,6 @@ class HomeController extends Controller
|
||||
$piggyBankAccounts = $repository->getPiggyBankAccounts();
|
||||
|
||||
|
||||
|
||||
$savingsTotal = 0;
|
||||
foreach ($savings as $savingAccount) {
|
||||
$savingsTotal += Steam::balance($savingAccount, $end);
|
||||
@@ -95,6 +93,7 @@ class HomeController extends Controller
|
||||
$transactions[] = [$set, $account];
|
||||
}
|
||||
}
|
||||
|
||||
return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts'));
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<?php namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Amount;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Report\ReportQueryInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -39,14 +38,13 @@ class JsonController extends Controller
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
|
||||
// works for json too!
|
||||
$prop = new CacheProperties;
|
||||
$prop->addProperty($start);
|
||||
$prop->addProperty($end);
|
||||
$prop->addProperty('box-bills-paid');
|
||||
if ($prop->has()) {
|
||||
return Response::json($prop->get());
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('box-bills-paid');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $prop->getMd5();
|
||||
|
||||
$amount = 0;
|
||||
|
||||
@@ -75,7 +73,8 @@ class JsonController extends Controller
|
||||
}
|
||||
}
|
||||
$data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
@@ -93,14 +92,13 @@ class JsonController extends Controller
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
|
||||
// works for json too!
|
||||
$prop = new CacheProperties;
|
||||
$prop->addProperty($start);
|
||||
$prop->addProperty($end);
|
||||
$prop->addProperty('box-bills-unpaid');
|
||||
if ($prop->has()) {
|
||||
return Response::json($prop->get());
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('box-bills-unpaid');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $prop->getMd5();
|
||||
|
||||
$bills = $repository->getActiveBills();
|
||||
$unpaid = new Collection; // bills
|
||||
@@ -137,7 +135,7 @@ class JsonController extends Controller
|
||||
}
|
||||
|
||||
$data = ['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
@@ -153,19 +151,18 @@ class JsonController extends Controller
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
|
||||
// works for json too!
|
||||
$prop = new CacheProperties;
|
||||
$prop->addProperty($start);
|
||||
$prop->addProperty($end);
|
||||
$prop->addProperty('box-in');
|
||||
if ($prop->has()) {
|
||||
return Response::json($prop->get());
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('box-in');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $prop->getMd5();
|
||||
|
||||
$amount = $reportQuery->incomeInPeriodCorrected($start, $end, true)->sum('amount');
|
||||
|
||||
$data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
@@ -182,19 +179,18 @@ class JsonController extends Controller
|
||||
|
||||
|
||||
// works for json too!
|
||||
$prop = new CacheProperties;
|
||||
$prop->addProperty($start);
|
||||
$prop->addProperty($end);
|
||||
$prop->addProperty('box-out');
|
||||
if ($prop->has()) {
|
||||
return Response::json($prop->get());
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('box-out');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$md5 = $prop->getMd5();
|
||||
|
||||
$amount = $reportQuery->expenseInPeriodCorrected($start, $end, true)->sum('amount');
|
||||
|
||||
$data = ['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
Cache::forever($md5, $data);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
@@ -1,12 +1,13 @@
|
||||
<?php namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use App;
|
||||
use Carbon\Carbon;
|
||||
use Closure;
|
||||
use Config;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
use Preferences;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class Authenticate
|
||||
*
|
||||
|
@@ -3,7 +3,6 @@
|
||||
namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use App;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use Closure;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
@@ -54,17 +53,15 @@ class Reminders
|
||||
// do reminders stuff.
|
||||
|
||||
// abuse CacheProperties to find out if we need to do this:
|
||||
$properties = new CacheProperties;
|
||||
$cache = new CacheProperties;
|
||||
|
||||
$properties->addProperty('reminders');
|
||||
if ($properties->has()) {
|
||||
$reminders = $properties->get();
|
||||
$cache->addProperty('reminders');
|
||||
if ($cache->has()) {
|
||||
$reminders = $cache->get();
|
||||
View::share('reminders', $reminders);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
$md5 = $properties->getMd5();
|
||||
|
||||
|
||||
$piggyBanks = $this->auth->user()->piggyBanks()->where('remind_me', 1)->get();
|
||||
|
||||
@@ -89,7 +86,7 @@ class Reminders
|
||||
$reminder->description = $helper->getReminderText($reminder);
|
||||
}
|
||||
);
|
||||
Cache::forever($md5, $reminders);
|
||||
$cache->store($reminders);
|
||||
View::share('reminders', $reminders);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use Crypt;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
@@ -136,13 +135,12 @@ class TransactionJournal extends Model
|
||||
*/
|
||||
public function getAmountAttribute()
|
||||
{
|
||||
$prop = new CacheProperties();
|
||||
$prop->addProperty($this->id);
|
||||
$prop->addProperty('amount');
|
||||
if ($prop->has()) {
|
||||
return $prop->get();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($this->id);
|
||||
$cache->addProperty('amount');
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$md5 = $prop->getMd5();
|
||||
|
||||
|
||||
$amount = '0';
|
||||
@@ -158,7 +156,7 @@ class TransactionJournal extends Model
|
||||
* If the journal has tags, it gets complicated.
|
||||
*/
|
||||
if ($this->tags->count() == 0) {
|
||||
Cache::forever($md5, $amount);
|
||||
$cache->store($amount);
|
||||
|
||||
return $amount;
|
||||
}
|
||||
@@ -173,7 +171,7 @@ class TransactionJournal extends Model
|
||||
foreach ($others as $other) {
|
||||
$amount = bcsub($amount, $other->actual_amount);
|
||||
}
|
||||
Cache::forever($md5, $amount);
|
||||
$cache->store($amount);
|
||||
|
||||
return $amount;
|
||||
}
|
||||
@@ -181,7 +179,7 @@ class TransactionJournal extends Model
|
||||
// if this journal is part of an advancePayment AND the journal is a deposit,
|
||||
// then the journal amount is correcting a withdrawal, and the amount is zero:
|
||||
if ($advancePayment && $this->transactionType->type == 'Deposit') {
|
||||
Cache::forever($md5, '0');
|
||||
$cache->store('0');
|
||||
|
||||
return '0';
|
||||
}
|
||||
@@ -196,14 +194,14 @@ class TransactionJournal extends Model
|
||||
$transfer = $balancingAct->transactionJournals()->transactionTypes(['Transfer'])->first();
|
||||
if ($transfer) {
|
||||
$amount = bcsub($amount, $transfer->actual_amount);
|
||||
Cache::forever($md5, $amount);
|
||||
$cache->store($amount);
|
||||
|
||||
return $amount;
|
||||
}
|
||||
} // @codeCoverageIgnore
|
||||
} // @codeCoverageIgnore
|
||||
|
||||
Cache::forever($md5, $amount);
|
||||
$cache->store($amount);
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ namespace FireflyIII\Repositories\Account;
|
||||
|
||||
use App;
|
||||
use Auth;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use Config;
|
||||
use DB;
|
||||
@@ -117,7 +116,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$md5 = $cache->getMd5();
|
||||
|
||||
|
||||
if ($preference->data == []) {
|
||||
@@ -126,7 +124,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$accounts = Auth::user()->accounts()->whereIn('id', $preference->data)->orderBy('accounts.name', 'ASC')->get(['accounts.*']);
|
||||
}
|
||||
|
||||
Cache::forever($md5, $accounts);
|
||||
$cache->store($accounts);
|
||||
|
||||
return $accounts;
|
||||
}
|
||||
@@ -144,14 +142,13 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
public function getFrontpageTransactions(Account $account, Carbon $start, Carbon $end)
|
||||
{
|
||||
$prop = new CacheProperties();
|
||||
$prop->addProperty($account->id);
|
||||
$prop->addProperty($start);
|
||||
$prop->addProperty($end);
|
||||
if ($prop->has()) {
|
||||
return $prop->get();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($account->id);
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$md5 = $prop->getMd5();
|
||||
|
||||
$set = Auth::user()
|
||||
->transactionjournals()
|
||||
@@ -166,7 +163,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
->orderBy('transaction_journals.id', 'DESC')
|
||||
->take(10)
|
||||
->get(['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']);
|
||||
Cache::forever($md5, $set);
|
||||
$cache->store($set);
|
||||
|
||||
return $set;
|
||||
}
|
||||
@@ -238,7 +235,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$md5 = $cache->getMd5();
|
||||
|
||||
$ids = array_unique($ids);
|
||||
if (count($ids) > 0) {
|
||||
@@ -264,7 +260,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
}
|
||||
);
|
||||
|
||||
Cache::forever($md5, $accounts);
|
||||
$cache->store($accounts);
|
||||
|
||||
return $accounts;
|
||||
|
||||
|
@@ -99,4 +99,12 @@ class CacheProperties
|
||||
|
||||
$this->md5 = md5($this->md5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*/
|
||||
public function store($data)
|
||||
{
|
||||
Cache::forever($this->md5, $data);
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@ namespace FireflyIII\Support;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Preference;
|
||||
|
||||
/**
|
||||
* Class Preferences
|
||||
*
|
||||
@@ -21,14 +22,6 @@ class Preferences
|
||||
return md5($preference);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function mark() {
|
||||
$this->set('lastActivity',microtime());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $default
|
||||
@@ -85,4 +78,14 @@ class Preferences
|
||||
return $pref;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function mark()
|
||||
{
|
||||
$this->set('lastActivity', microtime());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
|
||||
@@ -25,15 +24,14 @@ class Steam
|
||||
{
|
||||
|
||||
// abuse chart properties:
|
||||
$properties = new CacheProperties;
|
||||
$properties->addProperty($account->id);
|
||||
$properties->addProperty('balance');
|
||||
$properties->addProperty($date);
|
||||
$properties->addProperty($ignoreVirtualBalance);
|
||||
if ($properties->has()) {
|
||||
return $properties->get();
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($account->id);
|
||||
$cache->addProperty('balance');
|
||||
$cache->addProperty($date);
|
||||
$cache->addProperty($ignoreVirtualBalance);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$md5 = $properties->getMd5();
|
||||
|
||||
|
||||
// find the first known transaction on this account:
|
||||
@@ -57,7 +55,7 @@ class Steam
|
||||
if (!$ignoreVirtualBalance) {
|
||||
$balance = bcadd($balance, $account->virtual_balance);
|
||||
}
|
||||
Cache::forever($md5, round($balance, 2));
|
||||
$cache->store(round($balance, 2));
|
||||
|
||||
return round($balance, 2);
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ namespace FireflyIII\Support\Twig;
|
||||
|
||||
|
||||
use App;
|
||||
use Cache;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Twig_Extension;
|
||||
@@ -30,13 +29,12 @@ class Journal extends Twig_Extension
|
||||
$filters[] = new Twig_SimpleFilter(
|
||||
'typeIcon', function (TransactionJournal $journal) {
|
||||
|
||||
$prop = new CacheProperties();
|
||||
$prop->addProperty($journal->id);
|
||||
$prop->addProperty('typeIcon');
|
||||
if ($prop->has()) {
|
||||
return $prop->get();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($journal->id);
|
||||
$cache->addProperty('typeIcon');
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$md5 = $prop->getMd5();
|
||||
|
||||
$type = $journal->transactionType->type;
|
||||
|
||||
@@ -57,7 +55,7 @@ class Journal extends Twig_Extension
|
||||
$txt = '';
|
||||
break;
|
||||
}
|
||||
Cache::forever($md5, $txt);
|
||||
$cache->store($txt);
|
||||
|
||||
return $txt;
|
||||
|
||||
|
Reference in New Issue
Block a user