mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 07:38:29 +00:00
Code cleanup [skip ci]
This commit is contained in:
@@ -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
|
||||
*
|
||||
@@ -155,7 +156,7 @@ class AccountController extends Controller
|
||||
$start = clone Session::get('start', Carbon::now()->startOfMonth());
|
||||
$start->subDay();
|
||||
$accounts->each(
|
||||
function(Account $account) use ($start, $repository) {
|
||||
function (Account $account) use ($start, $repository) {
|
||||
$account->lastActivityDate = $repository->getLastActivity($account);
|
||||
$account->startBalance = Steam::balance($account, $start);
|
||||
$account->endBalance = Steam::balance($account, clone Session::get('end', Carbon::now()->endOfMonth()));
|
||||
@@ -200,11 +201,11 @@ class AccountController extends Controller
|
||||
'user' => Auth::user()->id,
|
||||
'accountRole' => $request->input('accountRole'),
|
||||
'openingBalance' => floatval($request->input('openingBalance')),
|
||||
'openingBalanceDate' => new Carbon((string) $request->input('openingBalanceDate')),
|
||||
'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')),
|
||||
'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
|
||||
|
||||
];
|
||||
$account = $repository->store($accountData);
|
||||
$account = $repository->store($accountData);
|
||||
|
||||
Session::flash('success', 'New account "' . $account->name . '" stored!');
|
||||
Preferences::mark();
|
||||
@@ -239,7 +240,7 @@ class AccountController extends Controller
|
||||
'accountRole' => $request->input('accountRole'),
|
||||
'virtualBalance' => floatval($request->input('virtualBalance')),
|
||||
'openingBalance' => floatval($request->input('openingBalance')),
|
||||
'openingBalanceDate' => new Carbon((string) $request->input('openingBalanceDate')),
|
||||
'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')),
|
||||
'openingBalanceCurrency' => intval($request->input('balance_currency_id')),
|
||||
'ccType' => $request->input('ccType'),
|
||||
'ccMonthlyPaymentDate' => $request->input('ccMonthlyPaymentDate'),
|
||||
|
||||
@@ -109,7 +109,7 @@ class AuthController extends Controller
|
||||
if (User::count() == 1) {
|
||||
$admin = Role::where('name', 'owner')->first();
|
||||
$this->auth->user()->attachRole($admin);
|
||||
// $this->auth->user()->roles()->save($admin);
|
||||
// $this->auth->user()->roles()->save($admin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class BillController extends Controller
|
||||
{
|
||||
$bills = $repository->getBills();
|
||||
$bills->each(
|
||||
function(Bill $bill) use ($repository) {
|
||||
function (Bill $bill) use ($repository) {
|
||||
$bill->nextExpectedMatch = $repository->nextExpectedMatch($bill);
|
||||
$bill->lastFoundMatch = $repository->lastFoundMatch($bill);
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ class BudgetController extends Controller
|
||||
'name' => $request->input('name'),
|
||||
'user' => Auth::user()->id,
|
||||
];
|
||||
$budget = $repository->store($budgetData);
|
||||
$budget = $repository->store($budgetData);
|
||||
|
||||
Session::flash('success', 'New budget "' . $budget->name . '" stored!');
|
||||
Preferences::mark();
|
||||
|
||||
@@ -114,7 +114,7 @@ class CategoryController extends Controller
|
||||
$categories = $repository->getCategories();
|
||||
|
||||
$categories->each(
|
||||
function(Category $category) use ($repository) {
|
||||
function (Category $category) use ($repository) {
|
||||
$category->lastActivity = $repository->getLatestActivity($category);
|
||||
}
|
||||
);
|
||||
@@ -167,7 +167,7 @@ class CategoryController extends Controller
|
||||
'name' => $request->input('name'),
|
||||
'user' => Auth::user()->id,
|
||||
];
|
||||
$category = $repository->store($categoryData);
|
||||
$category = $repository->store($categoryData);
|
||||
|
||||
Session::flash('success', 'New category "' . $category->name . '" stored!');
|
||||
Preferences::mark();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -79,20 +77,19 @@ class BillController extends Controller
|
||||
$chart->addColumn(trans('firefly.name'), 'string');
|
||||
$chart->addColumn(trans('firefly.amount'), 'number');
|
||||
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
|
||||
|
||||
// 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,22 +78,21 @@ 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);
|
||||
$set = $repository->getCategoriesAndExpensesCorrected($start, $end);
|
||||
|
||||
// sort by callback:
|
||||
uasort(
|
||||
$set,
|
||||
function($left, $right) {
|
||||
function ($left, $right) {
|
||||
if ($left['sum'] == $right['sum']) {
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
@@ -61,20 +60,19 @@ class HomeController extends Controller
|
||||
return Redirect::route('new-user.index');
|
||||
}
|
||||
|
||||
$title = 'Firefly';
|
||||
$subTitle = trans('firefly.welcomeBack');
|
||||
$mainTitleIcon = 'fa-fire';
|
||||
$transactions = [];
|
||||
$frontPage = Preferences::get('frontPageAccounts', []);
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$accounts = $repository->getFrontpageAccounts($frontPage);
|
||||
$savings = $repository->getSavingsAccounts();
|
||||
$title = 'Firefly';
|
||||
$subTitle = trans('firefly.welcomeBack');
|
||||
$mainTitleIcon = 'fa-fire';
|
||||
$transactions = [];
|
||||
$frontPage = Preferences::get('frontPageAccounts', []);
|
||||
$start = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$end = Session::get('end', Carbon::now()->endOfMonth());
|
||||
$accounts = $repository->getFrontpageAccounts($frontPage);
|
||||
$savings = $repository->getSavingsAccounts();
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class NewUserController extends Controller
|
||||
AccountMeta::create(
|
||||
[
|
||||
'name' => 'ccMonthlyPaymentDate',
|
||||
'data' => Carbon::now()->year.'-01-01',
|
||||
'data' => Carbon::now()->year . '-01-01',
|
||||
'account_id' => $creditCard->id,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -139,11 +139,11 @@ class PiggyBankController extends Controller
|
||||
$targetDate = $targetDate->format('Y-m-d');
|
||||
}
|
||||
$preFilled = ['name' => $piggyBank->name,
|
||||
'account_id' => $piggyBank->account_id,
|
||||
'targetamount' => $piggyBank->targetamount,
|
||||
'targetdate' => $targetDate,
|
||||
'reminder' => $piggyBank->reminder,
|
||||
'remind_me' => intval($piggyBank->remind_me) == 1 && !is_null($piggyBank->reminder) ? true : false
|
||||
'account_id' => $piggyBank->account_id,
|
||||
'targetamount' => $piggyBank->targetamount,
|
||||
'targetdate' => $targetDate,
|
||||
'reminder' => $piggyBank->reminder,
|
||||
'remind_me' => intval($piggyBank->remind_me) == 1 && !is_null($piggyBank->reminder) ? true : false
|
||||
];
|
||||
Session::flash('preFilled', $preFilled);
|
||||
Session::flash('gaEventCategory', 'piggy-banks');
|
||||
|
||||
@@ -253,7 +253,7 @@ class TransactionController extends Controller
|
||||
public function show(JournalRepositoryInterface $repository, TransactionJournal $journal)
|
||||
{
|
||||
$journal->transactions->each(
|
||||
function(Transaction $t) use ($journal, $repository) {
|
||||
function (Transaction $t) use ($journal, $repository) {
|
||||
$t->before = $repository->getAmountBefore($journal, $t);
|
||||
$t->after = $t->before + $t->amount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user