mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-20 11:33:59 +00:00
Refactoring.
This commit is contained in:
@@ -6,8 +6,11 @@ use ExpandedForm;
|
||||
use FireflyIII\Http\Requests\AccountFormRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Input;
|
||||
use Navigation;
|
||||
use Preferences;
|
||||
use Session;
|
||||
use Steam;
|
||||
@@ -66,7 +69,7 @@ class AccountController extends Controller
|
||||
{
|
||||
$typeName = config('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||
$subTitle = trans('firefly.delete_' . $typeName . '_account', ['name' => $account->name]);
|
||||
$accountList = ExpandedForm::makeSelectListWithEmpty($repository->getAccounts([$account->accountType->type]));
|
||||
$accountList = ExpandedForm::makeSelectListWithEmpty($repository->getAccountsByType([$account->accountType->type]));
|
||||
unset($accountList[$account->id]);
|
||||
|
||||
// put previous url in session
|
||||
@@ -157,7 +160,7 @@ class AccountController extends Controller
|
||||
$subTitle = trans('firefly.' . $what . '_accounts');
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
|
||||
$types = config('firefly.accountTypesByIdentifier.' . $what);
|
||||
$accounts = $repository->getAccounts($types);
|
||||
$accounts = $repository->getAccountsByType($types);
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
@@ -180,6 +183,32 @@ class AccountController extends Controller
|
||||
return view('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ARI $repository
|
||||
* @param Account $account
|
||||
* @param string $date
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function showWithDate(ARI $repository, Account $account, string $date)
|
||||
{
|
||||
$carbon = new Carbon($date);
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
$start = Navigation::startOfPeriod($carbon, $range);
|
||||
$end = Navigation::endOfPeriod($carbon, $range);
|
||||
$subTitle = $account->name;
|
||||
$page = intval(Input::get('page'));
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$offset = ($page - 1) * $pageSize;
|
||||
$set = $repository->journalsInPeriod(new Collection([$account]), [], $start, $end);
|
||||
$count = $set->count();
|
||||
$subSet = $set->splice($offset, $pageSize);
|
||||
$journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);
|
||||
$journals->setPath('categories/show/' . $account->id . '/' . $date);
|
||||
|
||||
return view('accounts.show_with_date', compact('category', 'journals', 'subTitle', 'carbon'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ARI $repository
|
||||
* @param Account $account
|
||||
@@ -188,16 +217,59 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function show(ARI $repository, Account $account)
|
||||
{
|
||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$subTitleIcon = config('firefly.subTitlesByIdentifier.' . $account->accountType->type);
|
||||
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||
$journals = $repository->getJournals($account, $page, $pageSize);
|
||||
$subTitle = trans('firefly.details_for_' . $what, ['name' => $account->name]);
|
||||
// show journals from current period only:
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
$start = session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$page = intval(Input::get('page'));
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$offset = ($page - 1) * $pageSize;
|
||||
$set = $repository->journalsInPeriod(new Collection([$account]), [], $start, $end);
|
||||
$count = $set->count();
|
||||
$subSet = $set->splice($offset, $pageSize);
|
||||
$journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);
|
||||
$journals->setPath('accounts/show/' . $account->id);
|
||||
|
||||
// grouped other months thing:
|
||||
// oldest transaction in account:
|
||||
$start = $repository->firstUseDate($account);
|
||||
if ($start->year == 1900) {
|
||||
$start = new Carbon;
|
||||
}
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
$start = Navigation::startOfPeriod($start, $range);
|
||||
$end = Navigation::endOfX(new Carbon, $range);
|
||||
$entries = new Collection;
|
||||
|
||||
return view('accounts.show', compact('account', 'what', 'subTitleIcon', 'journals', 'subTitle'));
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('account-show');
|
||||
$cache->addProperty($account->id);
|
||||
|
||||
|
||||
if ($cache->has()) {
|
||||
//$entries = $cache->get();
|
||||
//return view('categories.show', compact('category', 'journals', 'entries', 'hideCategory', 'subTitle'));
|
||||
}
|
||||
|
||||
|
||||
$accountCollection = new Collection([$account]);
|
||||
while ($end >= $start) {
|
||||
$end = Navigation::startOfPeriod($end, $range);
|
||||
$currentEnd = Navigation::endOfPeriod($end, $range);
|
||||
$spent = $repository->spentInPeriod($accountCollection, $end, $currentEnd);
|
||||
$earned = $repository->earnedInPeriod($accountCollection, $end, $currentEnd);
|
||||
$dateStr = $end->format('Y-m-d');
|
||||
$dateName = Navigation::periodShow($end, $range);
|
||||
$entries->push([$dateStr, $dateName, $spent, $earned]);
|
||||
$end = Navigation::subtractPeriod($end, $range, 1);
|
||||
|
||||
}
|
||||
$cache->store($entries);
|
||||
|
||||
return view('accounts.show', compact('account', 'what', 'entries', 'subTitleIcon', 'journals', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -174,7 +174,7 @@ class BudgetController extends Controller
|
||||
$period = Navigation::periodShow($start, $range);
|
||||
$periodStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||
$periodEnd = $end->formatLocalized($this->monthAndDayFormat);
|
||||
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
|
||||
$accounts = $accountRepository->getAccountsByType(['Default account', 'Asset account', 'Cash account']);
|
||||
$startAsString = $start->format('Y-m-d');
|
||||
$endAsString = $end->format('Y-m-d');
|
||||
|
||||
|
@@ -3,7 +3,6 @@
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Requests\CategoryFormRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface as CRI;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
@@ -153,16 +152,25 @@ class CategoryController extends Controller
|
||||
*/
|
||||
public function show(CRI $repository, Category $category)
|
||||
{
|
||||
/** @var Carbon $carbon */
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
$start = session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$hideCategory = true; // used in list.
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$page = intval(Input::get('page'));
|
||||
$journals = $repository->getJournals($category, $page, $pageSize);
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$offset = ($page - 1) * $pageSize;
|
||||
$set = $repository->journalsInPeriod(new Collection([$category]), new Collection, [], $start, $end);
|
||||
$count = $set->count();
|
||||
$subSet = $set->splice($offset, $pageSize);
|
||||
$journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);
|
||||
$journals->setPath('categories/show/' . $category->id);
|
||||
|
||||
// list of ranges for list of periods:
|
||||
|
||||
// oldest transaction in category:
|
||||
$start = $repository->firstUseDate($category, new Collection);
|
||||
$start = $repository->firstUseDate($category, new Collection);
|
||||
if ($start->year == 1900) {
|
||||
$start = new Carbon;
|
||||
}
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
$start = Navigation::startOfPeriod($start, $range);
|
||||
$end = Navigation::endOfX(new Carbon, $range);
|
||||
@@ -177,8 +185,9 @@ class CategoryController extends Controller
|
||||
|
||||
|
||||
if ($cache->has()) {
|
||||
//$entries = $cache->get();
|
||||
//return view('categories.show', compact('category', 'journals', 'entries', 'hideCategory', 'subTitle'));
|
||||
$entries = $cache->get();
|
||||
|
||||
return view('categories.show', compact('category', 'journals', 'entries', 'hideCategory', 'subTitle'));
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +232,7 @@ class CategoryController extends Controller
|
||||
$set = $repository->journalsInPeriod(new Collection([$category]), new Collection, [], $start, $end);
|
||||
$count = $set->count();
|
||||
$subSet = $set->splice($offset, $pageSize);
|
||||
$journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);
|
||||
$journals = new LengthAwarePaginator($subSet, $count, $pageSize, $page);
|
||||
$journals->setPath('categories/show/' . $category->id . '/' . $date);
|
||||
|
||||
return view('categories.show_with_date', compact('category', 'journals', 'hideCategory', 'subTitle', 'carbon'));
|
||||
|
@@ -8,10 +8,7 @@ use FireflyIII\Generator\Chart\Account\AccountChartGeneratorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use Preferences;
|
||||
use Response;
|
||||
|
||||
/** checked
|
||||
* Class AccountController
|
||||
@@ -34,39 +31,6 @@ class AccountController extends Controller
|
||||
$this->generator = app(AccountChartGeneratorInterface::class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shows the balances for a given set of dates and accounts.
|
||||
*
|
||||
* @param $reportType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('all');
|
||||
$cache->addProperty('accounts');
|
||||
$cache->addProperty('default');
|
||||
$cache->addProperty($reportType);
|
||||
$cache->addProperty($accounts);
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
|
||||
// make chart:
|
||||
$data = $this->generator->frontpage($accounts, $start, $end);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the balances for all the user's expense accounts.
|
||||
*
|
||||
@@ -76,6 +40,7 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function expenseAccounts(ARI $repository)
|
||||
{
|
||||
/*
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
$accounts = $repository->getAccounts(['Expense account', 'Beneficiary account']);
|
||||
@@ -94,7 +59,7 @@ class AccountController extends Controller
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,6 +71,7 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function frontpage(ARI $repository)
|
||||
{
|
||||
/*
|
||||
$frontPage = Preferences::get('frontPageAccounts', []);
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
@@ -125,7 +91,41 @@ class AccountController extends Controller
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the balances for a given set of dates and accounts.
|
||||
*
|
||||
* @param $reportType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
/*
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('all');
|
||||
$cache->addProperty('accounts');
|
||||
$cache->addProperty('default');
|
||||
$cache->addProperty($reportType);
|
||||
$cache->addProperty($accounts);
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
|
||||
// make chart:
|
||||
$data = $this->generator->frontpage($accounts, $start, $end);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function single(Account $account)
|
||||
{
|
||||
|
||||
/*
|
||||
|
||||
$start = clone session('start', Carbon::now()->startOfMonth());
|
||||
$end = clone session('end', Carbon::now()->endOfMonth());
|
||||
@@ -157,5 +157,6 @@ class AccountController extends Controller
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@@ -42,26 +42,11 @@ class BillController extends Controller
|
||||
*/
|
||||
public function frontpage(BillRepositoryInterface $repository)
|
||||
{
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$paid = $repository->getBillsPaidInRange($start, $end); // will be a negative amount.
|
||||
$unpaid = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount.
|
||||
$creditCardDue = $repository->getCreditCardBill($start, $end);
|
||||
|
||||
if ($creditCardDue < 0) {
|
||||
// expenses are negative (bill not yet paid),
|
||||
$creditCardDue = bcmul($creditCardDue, '-1');
|
||||
$unpaid = bcadd($unpaid, $creditCardDue);
|
||||
}
|
||||
|
||||
// if $creditCardDue more than zero, the bill has been paid: (transfer = positive).
|
||||
// amount must be negative to be added to $paid:
|
||||
if ($creditCardDue >= 0) {
|
||||
$paid = bcadd($paid, $creditCardDue);
|
||||
}
|
||||
|
||||
// build chart:
|
||||
$data = $this->generator->frontpage($paid, $unpaid);
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$paid = $repository->getBillsPaidInRange($start, $end); // will be a negative amount.
|
||||
$unpaid = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount.
|
||||
$data = $this->generator->frontpage($paid, $unpaid);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty($repetition->id);
|
||||
|
||||
if ($cache->has()) {
|
||||
// return Response::json($cache->get());
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
|
||||
$entries = new Collection;
|
||||
@@ -150,7 +150,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty('budget');
|
||||
$cache->addProperty('all');
|
||||
if ($cache->has()) {
|
||||
//return Response::json($cache->get());
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$budgets = $repository->getActiveBudgets();
|
||||
$repetitions = $repository->getAllBudgetLimitRepetitions($start, $end);
|
||||
@@ -203,8 +203,6 @@ class BudgetController extends Controller
|
||||
$data = $this->generator->frontpage($allEntries);
|
||||
$cache->store($data);
|
||||
|
||||
return ' ' . json_encode($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
@@ -230,7 +228,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty('multiYearBudget');
|
||||
|
||||
if ($cache->has()) {
|
||||
//return Response::json($cache->get());
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$budgetIds = $budgets->pluck('id')->toArray();
|
||||
$repetitions = $repository->getAllBudgetLimitRepetitions($start, $end);
|
||||
@@ -300,7 +298,7 @@ class BudgetController extends Controller
|
||||
$cache->addProperty('budget');
|
||||
$cache->addProperty('period');
|
||||
if ($cache->has()) {
|
||||
//return Response::json($cache->get());
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
// loop over period, add by users range:
|
||||
$current = clone $start;
|
||||
|
@@ -64,7 +64,7 @@ class CategoryController extends Controller
|
||||
$cache->addProperty('all');
|
||||
$cache->addProperty('categories');
|
||||
if ($cache->has()) {
|
||||
//return Response::json($cache->get());
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
|
||||
while ($start <= $end) {
|
||||
@@ -119,7 +119,7 @@ class CategoryController extends Controller
|
||||
$cache->addProperty('category');
|
||||
$cache->addProperty('frontpage');
|
||||
if ($cache->has()) {
|
||||
//return Response::json($cache->get());
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$categories = $repository->getCategories();
|
||||
$set = new Collection;
|
||||
@@ -169,7 +169,7 @@ class CategoryController extends Controller
|
||||
$cache->addProperty('multiYearCategory');
|
||||
|
||||
if ($cache->has()) {
|
||||
//return Response::json($cache->get());
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
|
||||
$entries = new Collection;
|
||||
@@ -237,7 +237,7 @@ class CategoryController extends Controller
|
||||
$cache->addProperty('category');
|
||||
$cache->addProperty('period');
|
||||
if ($cache->has()) {
|
||||
// return Response::json($cache->get());
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
|
||||
/** @var CRI $repository */
|
||||
|
@@ -190,7 +190,7 @@ class CsvController extends Controller
|
||||
];
|
||||
|
||||
// get a list of asset accounts:
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Asset account', 'Default account']));
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccountsByType(['Asset account', 'Default account']));
|
||||
|
||||
// can actually upload?
|
||||
$uploadPossible = is_writable(storage_path('upload'));
|
||||
|
@@ -102,7 +102,7 @@ class ExportController extends Controller
|
||||
$jobs->cleanup();
|
||||
|
||||
// does the user have shared accounts?
|
||||
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
$accounts = $repository->getAccountsByType(['Default account', 'Asset account']);
|
||||
$accountList = ExpandedForm::makeSelectList($accounts);
|
||||
$checked = array_keys($accountList);
|
||||
$formats = array_keys(config('firefly.export_formats'));
|
||||
|
@@ -7,6 +7,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Input;
|
||||
use Preferences;
|
||||
use Route;
|
||||
@@ -116,7 +117,7 @@ class HomeController extends Controller
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$showTour = Preferences::get('tour', true)->data;
|
||||
$accounts = $repository->getFrontpageAccounts($frontPage);
|
||||
$accounts = $repository->getAccountsById($frontPage->data);
|
||||
$savings = $repository->getSavingsAccounts();
|
||||
$piggyBankAccounts = $repository->getPiggyBankAccounts();
|
||||
|
||||
@@ -133,7 +134,8 @@ class HomeController extends Controller
|
||||
}
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$set = $repository->getFrontpageTransactions($account, $start, $end);
|
||||
$set = $repository->journalsInPeriod(new Collection([$account]), [], $start, $end);
|
||||
$set = $set->splice(0, 10);
|
||||
|
||||
if (count($set) > 0) {
|
||||
$transactions[] = [$set, $account];
|
||||
@@ -153,10 +155,10 @@ class HomeController extends Controller
|
||||
{
|
||||
// these routes are not relevant for the help pages:
|
||||
$ignore = [
|
||||
// 'logout', 'register', 'bills.rescan', 'attachments.download', 'attachments.preview',
|
||||
// 'budgets.income', 'csv.download-config', 'currency.default', 'export.status', 'export.download',
|
||||
// 'json.', 'help.', 'piggy-banks.addMoney', 'piggy-banks.removeMoney', 'rules.rule.up', 'rules.rule.down',
|
||||
// 'rules.rule-group.up', 'rules.rule-group.down', 'debugbar',
|
||||
// 'logout', 'register', 'bills.rescan', 'attachments.download', 'attachments.preview',
|
||||
// 'budgets.income', 'csv.download-config', 'currency.default', 'export.status', 'export.download',
|
||||
// 'json.', 'help.', 'piggy-banks.addMoney', 'piggy-banks.removeMoney', 'rules.rule.up', 'rules.rule.down',
|
||||
// 'rules.rule-group.up', 'rules.rule-group.down', 'debugbar',
|
||||
];
|
||||
$routes = Route::getRoutes();
|
||||
/** @var \Illuminate\Routing\Route $route */
|
||||
|
@@ -60,11 +60,7 @@ class JsonController extends Controller
|
||||
* Since both this method and the chart use the exact same data, we can suffice
|
||||
* with calling the one method in the bill repository that will get this amount.
|
||||
*/
|
||||
$amount = $repository->getBillsPaidInRange($start, $end); // will be a negative amount.
|
||||
$creditCardDue = $repository->getCreditCardBill($start, $end);
|
||||
if ($creditCardDue >= 0) {
|
||||
$amount = bcadd($amount, $creditCardDue);
|
||||
}
|
||||
$amount = $repository->getBillsPaidInRange($start, $end); // will be a negative amount.
|
||||
$amount = bcmul($amount, '-1');
|
||||
|
||||
$data = ['box' => 'bills-paid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
@@ -79,18 +75,10 @@ class JsonController extends Controller
|
||||
*/
|
||||
public function boxBillsUnpaid(BillRepositoryInterface $repository)
|
||||
{
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$amount = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount.
|
||||
$creditCardDue = $repository->getCreditCardBill($start, $end);
|
||||
|
||||
if ($creditCardDue < 0) {
|
||||
// expenses are negative (bill not yet paid),
|
||||
$creditCardDue = bcmul($creditCardDue, '-1');
|
||||
$amount = bcadd($amount, $creditCardDue);
|
||||
}
|
||||
|
||||
$data = ['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$amount = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount.
|
||||
$data = ['box' => 'bills-unpaid', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
@@ -115,7 +103,7 @@ class JsonController extends Controller
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
|
||||
$accounts = $accountRepository->getAccountsByType(['Default account', 'Asset account', 'Cash account']);
|
||||
$amount = $reportQuery->income($accounts, $start, $end)->sum('journalAmount');
|
||||
|
||||
$data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];
|
||||
@@ -136,7 +124,7 @@ class JsonController extends Controller
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
|
||||
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
|
||||
$accounts = $accountRepository->getAccountsByType(['Default account', 'Asset account', 'Cash account']);
|
||||
|
||||
// works for json too!
|
||||
$cache = new CacheProperties;
|
||||
@@ -192,7 +180,7 @@ class JsonController extends Controller
|
||||
*/
|
||||
public function expenseAccounts(ARI $accountRepository)
|
||||
{
|
||||
$list = $accountRepository->getAccounts(['Expense account', 'Beneficiary account']);
|
||||
$list = $accountRepository->getAccountsByType(['Expense account', 'Beneficiary account']);
|
||||
$return = [];
|
||||
foreach ($list as $entry) {
|
||||
$return[] = $entry->name;
|
||||
@@ -209,7 +197,7 @@ class JsonController extends Controller
|
||||
*/
|
||||
public function revenueAccounts(ARI $accountRepository)
|
||||
{
|
||||
$list = $accountRepository->getAccounts(['Revenue account']);
|
||||
$list = $accountRepository->getAccountsByType(['Revenue account']);
|
||||
$return = [];
|
||||
foreach ($list as $entry) {
|
||||
$return[] = $entry->name;
|
||||
|
@@ -65,7 +65,7 @@ class PiggyBankController extends Controller
|
||||
{
|
||||
|
||||
$periods = config('firefly.piggy_bank_periods');
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccountsByType(['Default account', 'Asset account']));
|
||||
$subTitle = trans('firefly.new_piggy_bank');
|
||||
$subTitleIcon = 'fa-plus';
|
||||
|
||||
@@ -124,7 +124,7 @@ class PiggyBankController extends Controller
|
||||
{
|
||||
|
||||
$periods = config('firefly.piggy_bank_periods');
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||
$accounts = ExpandedForm::makeSelectList($repository->getAccountsByType(['Default account', 'Asset account']));
|
||||
$subTitle = trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
$targetDate = null;
|
||||
|
@@ -16,6 +16,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collection\BalanceLine;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
@@ -182,7 +183,8 @@ class ReportController extends Controller
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$account = $repository->find(intval($attributes['accountId']));
|
||||
$journals = $repository->getExpensesByDestination($account, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||
$types = [TransactionType::WITHDRAWAL, TransactionType::TRANSFER];
|
||||
$journals = $repository->journalsInPeriod(new Collection([$account]), $types, $attributes['startDate'], $attributes['endDate']);
|
||||
$view = view('popup.report.expense-entry', compact('journals', 'account'))->render();
|
||||
|
||||
return $view;
|
||||
@@ -201,10 +203,10 @@ class ReportController extends Controller
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$account = $repository->find(intval($attributes['accountId']));
|
||||
$journals = $repository->getIncomeByDestination($account, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||
$types = [TransactionType::DEPOSIT, TransactionType::TRANSFER];
|
||||
$journals = $repository->journalsInPeriod(new Collection([$account]), $types, $attributes['startDate'], $attributes['endDate']);
|
||||
$view = view('popup.report.income-entry', compact('journals', 'account'))->render();
|
||||
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
@@ -63,7 +63,7 @@ class PreferencesController extends Controller
|
||||
*/
|
||||
public function index(ARI $repository)
|
||||
{
|
||||
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
$accounts = $repository->getAccountsByType(['Default account', 'Asset account']);
|
||||
$viewRangePref = Preferences::get('viewRange', '1M');
|
||||
$viewRange = $viewRangePref->data;
|
||||
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
|
||||
|
@@ -69,7 +69,7 @@ class ReportController extends Controller
|
||||
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
|
||||
|
||||
// does the user have shared accounts?
|
||||
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
$accounts = $repository->getAccountsByType(['Default account', 'Asset account']);
|
||||
// get id's for quick links:
|
||||
$accountIds = [];
|
||||
/** @var Account $account */
|
||||
|
@@ -178,7 +178,7 @@ class RuleGroupController extends Controller
|
||||
public function selectTransactions(AccountRepositoryInterface $repository, RuleGroup $ruleGroup)
|
||||
{
|
||||
// does the user have shared accounts?
|
||||
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
|
||||
$accounts = $repository->getAccountsByType(['Default account', 'Asset account']);
|
||||
$accountList = ExpandedForm::makeSelectList($accounts);
|
||||
$checkedAccounts = array_keys($accountList);
|
||||
$first = session('first')->format('Y-m-d');
|
||||
|
@@ -71,7 +71,7 @@ class SplitController extends Controller
|
||||
|
||||
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
||||
$currencies = ExpandedForm::makeSelectList($currencyRepository->get());
|
||||
$assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccounts(['Default account', 'Asset account']));
|
||||
$assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccountsByType(['Default account', 'Asset account']));
|
||||
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
||||
$preFilled = $this->arrayFromJournal($request, $journal);
|
||||
|
||||
@@ -116,7 +116,7 @@ class SplitController extends Controller
|
||||
$budgetRepository = app(BudgetRepositoryInterface::class);
|
||||
|
||||
$currencies = ExpandedForm::makeSelectList($currencyRepository->get());
|
||||
$assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccounts(['Default account', 'Asset account']));
|
||||
$assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccountsByType(['Default account', 'Asset account']));
|
||||
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
||||
|
||||
return view('split.journals.from-store', compact('currencies', 'assetAccounts', 'budgets', 'preFilled'));
|
||||
|
@@ -72,7 +72,7 @@ class TransactionController extends Controller
|
||||
|
||||
$what = strtolower($what);
|
||||
$uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size')));
|
||||
$assetAccounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||
$assetAccounts = ExpandedForm::makeSelectList($repository->getAccountsByType(['Default account', 'Asset account']));
|
||||
$budgets = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
||||
$piggyBanks = $piggyRepository->getPiggyBanks();
|
||||
/** @var PiggyBank $piggy */
|
||||
@@ -159,7 +159,7 @@ class TransactionController extends Controller
|
||||
/** @var PiggyBankRepositoryInterface $piggyRepository */
|
||||
$piggyRepository = app(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccounts(['Default account', 'Asset account']));
|
||||
$assetAccounts = ExpandedForm::makeSelectList($accountRepository->getAccountsByType(['Default account', 'Asset account']));
|
||||
$budgetList = ExpandedForm::makeSelectListWithEmpty($budgetRepository->getActiveBudgets());
|
||||
$piggyBankList = ExpandedForm::makeSelectListWithEmpty($piggyRepository->getPiggyBanks());
|
||||
$maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize'));
|
||||
@@ -296,7 +296,7 @@ class TransactionController extends Controller
|
||||
$subTitle = trans('firefly.mass_edit_journals');
|
||||
/** @var ARI $accountRepository */
|
||||
$accountRepository = app(ARI::class);
|
||||
$accountList = ExpandedForm::makeSelectList($accountRepository->getAccounts(['Default account', 'Asset account']));
|
||||
$accountList = ExpandedForm::makeSelectList($accountRepository->getAccountsByType(['Default account', 'Asset account']));
|
||||
|
||||
// put previous url in session
|
||||
Session::put('transactions.mass-edit.url', URL::previous());
|
||||
|
Reference in New Issue
Block a user