mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Big refactor to remove the deprecated transaction collector.
This commit is contained in:
@@ -136,7 +136,7 @@ class CreateController extends Controller
|
||||
|
||||
// update preferences if necessary:
|
||||
$frontPage = app('preferences')->get('frontPageAccounts', [])->data;
|
||||
if (AccountType::ASSET === $account->accountType->type && \count($frontPage) > 0) {
|
||||
if (AccountType::ASSET === $account->accountType->type && count($frontPage) > 0) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$frontPage[] = $account->id;
|
||||
app('preferences')->set('frontPageAccounts', $frontPage);
|
||||
|
@@ -26,7 +26,6 @@ namespace FireflyIII\Http\Controllers\Account;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@@ -126,7 +125,7 @@ class ShowController extends Controller
|
||||
$collector
|
||||
->setAccounts(new Collection([$account]))
|
||||
->setLimit($pageSize)
|
||||
->setPage($page)
|
||||
->setPage($page)->withAccountInformation()
|
||||
->setRange($start, $end);
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));
|
||||
@@ -170,17 +169,17 @@ class ShowController extends Controller
|
||||
}
|
||||
$subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$periods = new Collection;
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath(route('accounts.show.all', [$account->id]));
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation();
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('accounts.show.all', [$account->id]));
|
||||
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
$showAll = true;
|
||||
|
||||
return view(
|
||||
'accounts.show',
|
||||
compact('account', 'showAll', 'isLiability', 'currency', 'today', 'chartUri', 'periods', 'subTitleIcon', 'transactions', 'subTitle', 'start', 'end')
|
||||
compact('account', 'showAll', 'isLiability', 'currency', 'today', 'chartUri', 'periods', 'subTitleIcon', 'groups', 'subTitle', 'start', 'end')
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -356,7 +356,7 @@ class BillController extends Controller
|
||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||
$this->attachments->saveAttachmentsForModel($bill, $files);
|
||||
|
||||
if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ class BillController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($bill, $files);
|
||||
|
||||
// flash messages
|
||||
if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
|
||||
}
|
||||
$redirect = redirect($this->getPreviousUri('bills.edit.uri'));
|
||||
|
@@ -25,7 +25,7 @@ namespace FireflyIII\Http\Controllers\Budget;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\BudgetIncomeRequest;
|
||||
use FireflyIII\Models\Budget;
|
||||
@@ -71,9 +71,9 @@ class AmountController extends Controller
|
||||
/**
|
||||
* Set the amount for a single budget in a specific period. Shows a waring when its a lot.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -147,6 +147,7 @@ class AmountController extends Controller
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* TODO remove this feature
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
@@ -164,10 +165,10 @@ class AmountController extends Controller
|
||||
Log::debug(sprintf('Average is %s, so total available is %s because days is %d.', $average, $available, $daysInPeriod));
|
||||
|
||||
// amount earned in this period:
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($searchBegin, $searchEnd)->setTypes([TransactionType::DEPOSIT])->withOpposingAccount();
|
||||
$earned = (string)$collector->getTransactions()->sum('transaction_amount');
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($searchBegin, $searchEnd)->setTypes([TransactionType::DEPOSIT]);
|
||||
$earned = $collector->getSum();
|
||||
// Total amount earned divided by the number of days in the whole search period is the average amount earned per day.
|
||||
// This is multiplied by the number of days in the current period, showing you the average.
|
||||
$earnedAverage = bcmul(bcdiv($earned, (string)$daysInSearchPeriod), (string)$daysInPeriod);
|
||||
@@ -175,10 +176,10 @@ class AmountController extends Controller
|
||||
Log::debug(sprintf('Earned is %s, earned average is %s', $earned, $earnedAverage));
|
||||
|
||||
// amount spent in period
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($searchBegin, $searchEnd)->setTypes([TransactionType::WITHDRAWAL])->withOpposingAccount();
|
||||
$spent = (string)$collector->getTransactions()->sum('transaction_amount');
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($searchBegin, $searchEnd)->setTypes([TransactionType::WITHDRAWAL]);
|
||||
$spent = $collector->getSum();
|
||||
$spentAverage = app('steam')->positive(bcmul(bcdiv($spent, (string)$daysInSearchPeriod), (string)$daysInPeriod));
|
||||
|
||||
Log::debug(sprintf('Spent is %s, spent average is %s', $earned, $earnedAverage));
|
||||
@@ -227,8 +228,8 @@ class AmountController extends Controller
|
||||
* Shows the form to update available budget.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
|
@@ -26,7 +26,7 @@ namespace FireflyIII\Http\Controllers\Budget;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
@@ -66,7 +66,7 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show transactions without a budget.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
@@ -86,20 +86,20 @@ class ShowController extends Controller
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
|
||||
->withoutBudget()->withOpposingAccount();
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath(route('budgets.no-budget'));
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
|
||||
->withoutBudget()->withAccountInformation();
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('budgets.no-budget'));
|
||||
|
||||
return view('budgets.no-budget', compact('transactions', 'subTitle', 'periods', 'start', 'end'));
|
||||
return view('budgets.no-budget', compact('groups', 'subTitle', 'periods', 'start', 'end'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows ALL transactions without a budget.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @param JournalRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
@@ -115,14 +115,14 @@ class ShowController extends Controller
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
|
||||
->withoutBudget()->withOpposingAccount();
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath(route('budgets.no-budget'));
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)
|
||||
->withoutBudget()->withAccountInformation();
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('budgets.no-budget'));
|
||||
|
||||
return view('budgets.no-budget', compact('transactions', 'subTitle', 'start', 'end'));
|
||||
return view('budgets.no-budget', compact('groups', 'subTitle', 'start', 'end'));
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ class ShowController extends Controller
|
||||
* Show a single budget.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
@@ -145,22 +145,22 @@ class ShowController extends Controller
|
||||
$repetition = null;
|
||||
|
||||
// collector:
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath(route('budgets.show', [$budget->id]));
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('budgets.show', [$budget->id]));
|
||||
|
||||
$subTitle = (string)trans('firefly.all_journals_for_budget', ['name' => $budget->name]);
|
||||
|
||||
return view('budgets.show', compact('limits', 'budget', 'repetition', 'transactions', 'subTitle'));
|
||||
return view('budgets.show', compact('limits', 'budget', 'repetition', 'groups', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a single budget by a budget limit.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
@@ -184,17 +184,18 @@ class ShowController extends Controller
|
||||
);
|
||||
|
||||
// collector:
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($budgetLimit->start_date, $budgetLimit->end_date)
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date)
|
||||
->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
|
||||
/** @var Carbon $start */
|
||||
$start = session('first', Carbon::now()->startOfYear());
|
||||
$end = new Carbon;
|
||||
$limits = $this->getLimits($budget, $start, $end);
|
||||
|
||||
return view('budgets.show', compact('limits', 'budget', 'budgetLimit', 'transactions', 'subTitle'));
|
||||
return view('budgets.show', compact('limits', 'budget', 'budgetLimit', 'groups', 'subTitle'));
|
||||
}
|
||||
}
|
||||
|
@@ -25,8 +25,7 @@ namespace FireflyIII\Http\Controllers\Category;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
@@ -66,7 +65,7 @@ class NoCategoryController extends Controller
|
||||
/**
|
||||
* Show transactions without a category.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
@@ -90,15 +89,15 @@ class NoCategoryController extends Controller
|
||||
Log::debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));
|
||||
Log::debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount()
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)
|
||||
->setLimit($pageSize)->setPage($page)->withoutCategory()
|
||||
->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
|
||||
$collector->removeFilter(InternalTransferFilter::class);
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath(route('categories.no-category'));
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('categories.no-category'));
|
||||
|
||||
return view('categories.no-category', compact('transactions', 'subTitle', 'periods', 'start', 'end'));
|
||||
return view('categories.no-category', compact('groups', 'subTitle', 'periods', 'start', 'end'));
|
||||
}
|
||||
|
||||
|
||||
@@ -125,14 +124,13 @@ class NoCategoryController extends Controller
|
||||
Log::debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));
|
||||
Log::debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount()
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()
|
||||
->setTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER]);
|
||||
$collector->removeFilter(InternalTransferFilter::class);
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath(route('categories.no-category.all'));
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('categories.no-category.all'));
|
||||
|
||||
return view('categories.no-category', compact('transactions', 'subTitle', 'periods', 'start', 'end'));
|
||||
return view('categories.no-category', compact('groups', 'subTitle', 'periods', 'start', 'end'));
|
||||
}
|
||||
}
|
||||
|
@@ -24,8 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Category;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
@@ -69,8 +68,8 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show a single category.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
@@ -94,23 +93,24 @@ class ShowController extends Controller
|
||||
'end' => $end->formatLocalized($this->monthAndDayFormat),]
|
||||
);
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)
|
||||
->withAccountInformation()
|
||||
->setCategory($category)->withBudgetInformation()->withCategoryInformation();
|
||||
$collector->removeFilter(InternalTransferFilter::class);
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath($path);
|
||||
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath($path);
|
||||
|
||||
Log::debug('End of show()');
|
||||
|
||||
return view('categories.show', compact('category', 'transactions', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
|
||||
return view('categories.show', compact('category', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all transactions within a category.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
@@ -133,14 +133,15 @@ class ShowController extends Controller
|
||||
$path = route('categories.show.all', [$category->id]);
|
||||
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)
|
||||
->withAccountInformation()
|
||||
->setCategory($category)->withBudgetInformation()->withCategoryInformation();
|
||||
$collector->removeFilter(InternalTransferFilter::class);
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath($path);
|
||||
|
||||
return view('categories.show', compact('category', 'transactions', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath($path);
|
||||
|
||||
return view('categories.show', compact('category', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
|
||||
}
|
||||
}
|
||||
|
@@ -24,11 +24,10 @@ namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@@ -147,7 +146,7 @@ class AccountController extends Controller
|
||||
|
||||
// loop all found currencies and build the data array for the chart.
|
||||
/**
|
||||
* @var int $currencyId
|
||||
* @var int $currencyId
|
||||
* @var TransactionCurrency $currency
|
||||
*/
|
||||
foreach ($currencies as $currencyId => $currency) {
|
||||
@@ -174,13 +173,28 @@ class AccountController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expenses per budget for all time, as shown on account overview.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function expenseBudgetAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
|
||||
{
|
||||
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now();
|
||||
|
||||
return $this->expenseBudget($account, $start, $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expenses per budget, as shown on account overview.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -194,30 +208,28 @@ class AccountController extends Controller
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withBudgetInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
||||
$transactions = $collector->getTransactions();
|
||||
$chartData = [];
|
||||
$result = [];
|
||||
$budgetIds = [];
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$jrnlBudgetId = (int)$transaction->transaction_journal_budget_id;
|
||||
$transBudgetId = (int)$transaction->transaction_budget_id;
|
||||
$currencyName = $transaction->transaction_currency_name;
|
||||
$budgetId = max($jrnlBudgetId, $transBudgetId);
|
||||
$combi = $budgetId . $currencyName;
|
||||
$budgetIds[] = $budgetId;
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$chartData = [];
|
||||
$result = [];
|
||||
$budgetIds = [];
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$currencyName = $journal['currency_name'];
|
||||
$budgetId = (int)$journal['budget_id'];
|
||||
$combi = $budgetId . $currencyName;
|
||||
$budgetIds[] = $budgetId;
|
||||
if (!isset($result[$combi])) {
|
||||
$result[$combi] = [
|
||||
'total' => '0',
|
||||
'budget_id' => $budgetId,
|
||||
'currency' => $currencyName,
|
||||
'currency_symbol' => $transaction->transaction_currency_symbol,
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
}
|
||||
$result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
|
||||
$result[$combi]['total'] = bcadd($journal['amount'], $result[$combi]['total']);
|
||||
}
|
||||
|
||||
$names = $this->getBudgetNames($budgetIds);
|
||||
@@ -236,28 +248,27 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Expenses per budget for all time, as shown on account overview.
|
||||
* Expenses grouped by category for account.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
* @param Account $account
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function expenseBudgetAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
|
||||
public function expenseCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
|
||||
{
|
||||
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now();
|
||||
|
||||
return $this->expenseBudget($account, $start, $end);
|
||||
return $this->expenseCategory($account, $start, $end);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expenses per category for one single account.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -272,20 +283,18 @@ class AccountController extends Controller
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::WITHDRAWAL]);
|
||||
$transactions = $collector->getTransactions();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
$categoryIds = [];
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
$categoryIds = [];
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$jrnlCatId = (int)$transaction->transaction_journal_category_id;
|
||||
$transCatId = (int)$transaction->transaction_category_id;
|
||||
$currencyName = $transaction->transaction_currency_name;
|
||||
$categoryId = max($jrnlCatId, $transCatId);
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$currencyName = $journal['currency_name'];
|
||||
$categoryId = $journal['category_id'];
|
||||
$combi = $categoryId . $currencyName;
|
||||
$categoryIds[] = $categoryId;
|
||||
if (!isset($result[$combi])) {
|
||||
@@ -293,10 +302,10 @@ class AccountController extends Controller
|
||||
'total' => '0',
|
||||
'category_id' => $categoryId,
|
||||
'currency' => $currencyName,
|
||||
'currency_symbol' => $transaction->transaction_currency_symbol,
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
}
|
||||
$result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
|
||||
$result[$combi]['total'] = bcadd($journal['amount'], $result[$combi]['total']);
|
||||
}
|
||||
|
||||
$names = $this->getCategoryNames($categoryIds);
|
||||
@@ -314,23 +323,6 @@ class AccountController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expenses grouped by category for account.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function expenseCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
|
||||
{
|
||||
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now();
|
||||
|
||||
return $this->expenseCategory($account, $start, $end);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shows the balances for all the user's frontpage accounts.
|
||||
*
|
||||
@@ -348,7 +340,7 @@ class AccountController extends Controller
|
||||
|
||||
|
||||
Log::debug('Frontpage preference set is ', $frontPage->data);
|
||||
if (0 === \count($frontPage->data)) {
|
||||
if (0 === count($frontPage->data)) {
|
||||
$frontPage->data = $defaultSet;
|
||||
Log::debug('frontpage set is empty!');
|
||||
$frontPage->save();
|
||||
@@ -358,13 +350,28 @@ class AccountController extends Controller
|
||||
return response()->json($this->accountBalanceChart($accounts, $start, $end));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the income grouped by category for an account, in all time.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function incomeCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
|
||||
{
|
||||
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now();
|
||||
|
||||
return $this->incomeCategory($account, $start, $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows all income per account for each category.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -380,19 +387,18 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
// grab all journals:
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::DEPOSIT]);
|
||||
$transactions = $collector->getTransactions();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
$categoryIds = [];
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$jrnlCatId = (int)$transaction->transaction_journal_category_id;
|
||||
$transCatId = (int)$transaction->transaction_category_id;
|
||||
$categoryId = max($jrnlCatId, $transCatId);
|
||||
$currencyName = $transaction->transaction_currency_name;
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
$categoryIds = [];
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$categoryId = $journal['category_id'];
|
||||
$currencyName = $journal['currency_name'];
|
||||
$combi = $categoryId . $currencyName;
|
||||
$categoryIds[] = $categoryId;
|
||||
if (!isset($result[$combi])) {
|
||||
@@ -400,10 +406,10 @@ class AccountController extends Controller
|
||||
'total' => '0',
|
||||
'category_id' => $categoryId,
|
||||
'currency' => $currencyName,
|
||||
'currency_symbol' => $transaction->transaction_currency_symbol,
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
];
|
||||
}
|
||||
$result[$combi]['total'] = bcadd($transaction->transaction_amount, $result[$combi]['total']);
|
||||
$result[$combi]['total'] = bcadd($journal['amount'], $result[$combi]['total']);
|
||||
}
|
||||
|
||||
$names = $this->getCategoryNames($categoryIds);
|
||||
@@ -419,32 +425,15 @@ class AccountController extends Controller
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the income grouped by category for an account, in all time.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Account $account
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function incomeCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
|
||||
{
|
||||
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$end = Carbon::now();
|
||||
|
||||
return $this->incomeCategory($account, $start, $end);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shows overview of account during a single period.
|
||||
*
|
||||
* TODO this chart is not multi-currency aware.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $start
|
||||
*
|
||||
* @param Carbon $end
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
@@ -502,8 +491,8 @@ class AccountController extends Controller
|
||||
*
|
||||
* TODO this chart is not multi-currency aware.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return JsonResponse
|
||||
@@ -579,7 +568,7 @@ class AccountController extends Controller
|
||||
|
||||
// loop all found currencies and build the data array for the chart.
|
||||
/**
|
||||
* @var int $currencyId
|
||||
* @var int $currencyId
|
||||
* @var TransactionCurrency $currency
|
||||
*/
|
||||
foreach ($currencies as $currencyId => $currency) {
|
||||
|
@@ -24,15 +24,13 @@ namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class BillController.
|
||||
@@ -99,12 +97,11 @@ class BillController extends Controller
|
||||
/**
|
||||
* Shows overview for a single bill.
|
||||
*
|
||||
* @param TransactionCollectorInterface $collector
|
||||
* @param Bill $bill
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function single(TransactionCollectorInterface $collector, Bill $bill): JsonResponse
|
||||
public function single(Bill $bill): JsonResponse
|
||||
{
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty('chart.bill.single');
|
||||
@@ -113,23 +110,18 @@ class BillController extends Controller
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$results = $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->getTransactions();
|
||||
// TODO remove me
|
||||
/** @var Collection $results */
|
||||
$results = $results->sortBy(
|
||||
function (Transaction $transaction) {
|
||||
return $transaction->date->format('U');
|
||||
}
|
||||
);
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$journals = $collector->setBill($bill)->getExtractedJournals();
|
||||
|
||||
$chartData = [
|
||||
['type' => 'bar', 'label' => (string)trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []],
|
||||
['type' => 'bar', 'label' => (string)trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []],
|
||||
['type' => 'line', 'label' => (string)trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'entries' => []],
|
||||
];
|
||||
|
||||
/** @var Transaction $entry */
|
||||
foreach ($results as $entry) {
|
||||
$date = $entry->date->formatLocalized((string)trans('config.month_and_day'));
|
||||
foreach ($journals as $journal) {
|
||||
$date = $journal['date']->formatLocalized((string)trans('config.month_and_day'));
|
||||
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
|
||||
$chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill
|
||||
|
||||
@@ -137,7 +129,7 @@ class BillController extends Controller
|
||||
if (!isset($chartData[2]['entries'][$date])) {
|
||||
$chartData[2]['entries'][$date] = '0';
|
||||
}
|
||||
$amount = bcmul($entry->transaction_amount, '-1');
|
||||
$amount = bcmul($journal['amount'], '-1');
|
||||
$chartData[2]['entries'][$date] = bcadd($chartData[2]['entries'][$date], $amount); // amount of journal
|
||||
}
|
||||
|
||||
|
@@ -25,11 +25,10 @@ namespace FireflyIII\Http\Controllers\Chart;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
@@ -128,7 +127,7 @@ class BudgetController extends Controller
|
||||
*
|
||||
* TODO this chart is not multi-currency aware.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*
|
||||
* @return JsonResponse
|
||||
@@ -177,7 +176,7 @@ class BudgetController extends Controller
|
||||
*
|
||||
* TODO this chart is not multi-currency aware.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit|null $budgetLimit
|
||||
*
|
||||
* @return JsonResponse
|
||||
@@ -195,21 +194,20 @@ class BudgetController extends Controller
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setBudget($budget);
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setBudget($budget);
|
||||
if (null !== $budgetLimit) {
|
||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
|
||||
}
|
||||
|
||||
$transactions = $collector->getTransactions();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$assetId = (int)$transaction->account_id;
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
foreach ($journals as $journal) {
|
||||
$assetId = (int)$journal['destination_account_id'];
|
||||
$result[$assetId] = $result[$assetId] ?? '0';
|
||||
$result[$assetId] = bcadd($transaction->transaction_amount, $result[$assetId]);
|
||||
$result[$assetId] = bcadd($journal['amount'], $result[$assetId]);
|
||||
}
|
||||
|
||||
$names = $this->getAccountNames(array_keys($result));
|
||||
@@ -229,7 +227,7 @@ class BudgetController extends Controller
|
||||
*
|
||||
* TODO this chart is not multi-currency aware.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit|null $budgetLimit
|
||||
*
|
||||
* @return JsonResponse
|
||||
@@ -247,23 +245,20 @@ class BudgetController extends Controller
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setBudget($budget)->withCategoryInformation();
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setBudget($budget)->withCategoryInformation();
|
||||
if (null !== $budgetLimit) {
|
||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
|
||||
}
|
||||
|
||||
$transactions = $collector->getTransactions();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$jrnlCatId = (int)$transaction->transaction_journal_category_id;
|
||||
$transCatId = (int)$transaction->transaction_category_id;
|
||||
$categoryId = max($jrnlCatId, $transCatId);
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
foreach ($journals as $journal) {
|
||||
$categoryId = (int)$journal['category_id'];
|
||||
$result[$categoryId] = $result[$categoryId] ?? '0';
|
||||
$result[$categoryId] = bcadd($transaction->transaction_amount, $result[$categoryId]);
|
||||
$result[$categoryId] = bcadd($journal['amount'], $result[$categoryId]);
|
||||
}
|
||||
|
||||
$names = $this->getCategoryNames(array_keys($result));
|
||||
@@ -282,7 +277,7 @@ class BudgetController extends Controller
|
||||
*
|
||||
* TODO this chart is not multi-currency aware.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit|null $budgetLimit
|
||||
*
|
||||
* @return JsonResponse
|
||||
@@ -300,21 +295,22 @@ class BudgetController extends Controller
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withOpposingAccount();
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withAccountInformation();
|
||||
if (null !== $budgetLimit) {
|
||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
|
||||
}
|
||||
|
||||
$transactions = $collector->getTransactions();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$opposingId = (int)$transaction->opposing_account_id;
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$result = [];
|
||||
$chartData = [];
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$opposingId = (int)$journal['destination_account_id'];
|
||||
$result[$opposingId] = $result[$opposingId] ?? '0';
|
||||
$result[$opposingId] = bcadd($transaction->transaction_amount, $result[$opposingId]);
|
||||
$result[$opposingId] = bcadd($journal['amount'], $result[$opposingId]);
|
||||
}
|
||||
|
||||
$names = $this->getAccountNames(array_keys($result));
|
||||
@@ -392,9 +388,9 @@ class BudgetController extends Controller
|
||||
*
|
||||
* TODO this chart is not multi-currency aware.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return JsonResponse
|
||||
@@ -441,8 +437,8 @@ class BudgetController extends Controller
|
||||
* TODO this chart is not multi-currency aware.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
|
@@ -201,7 +201,7 @@ class BudgetReportController extends Controller
|
||||
$chartData[$budget->id]['entries'][$label] = bcmul($currentExpenses, '-1');
|
||||
$chartData[$budget->id . '-sum']['entries'][$label] = bcmul($sumOfExpenses[$budget->id], '-1');
|
||||
|
||||
if (\count($budgetLimits) > 0) {
|
||||
if (count($budgetLimits) > 0) {
|
||||
$budgetLimitId = $budgetLimits->first()->id;
|
||||
$leftOfLimits[$budgetLimitId] = $leftOfLimits[$budgetLimitId] ?? (string)$budgetLimits->sum('amount');
|
||||
$leftOfLimits[$budgetLimitId] = bcadd($leftOfLimits[$budgetLimitId], $currentExpenses);
|
||||
|
@@ -188,7 +188,7 @@ class ExpenseReportController extends Controller
|
||||
$newSet[$key] = $chartData[$key];
|
||||
}
|
||||
}
|
||||
if (0 === \count($newSet)) {
|
||||
if (0 === count($newSet)) {
|
||||
$newSet = $chartData; // @codeCoverageIgnore
|
||||
}
|
||||
$data = $this->generator->multiSet($newSet);
|
||||
|
@@ -200,7 +200,7 @@ class TagReportController extends Controller
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
//return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||
@@ -254,7 +254,7 @@ class TagReportController extends Controller
|
||||
$labelOut = $tag->id . '-out';
|
||||
$labelSumIn = $tag->id . '-total-in';
|
||||
$labelSumOut = $tag->id . '-total-out';
|
||||
$currentIncome = $income[$tag->id] ?? '0';
|
||||
$currentIncome = bcmul($income[$tag->id] ?? '0','-1');
|
||||
$currentExpense = $expenses[$tag->id] ?? '0';
|
||||
|
||||
// add to sum:
|
||||
@@ -272,6 +272,8 @@ class TagReportController extends Controller
|
||||
/** @var Carbon $currentStart */
|
||||
$currentStart = clone $currentEnd;
|
||||
$currentStart->addDay();
|
||||
$currentStart->startOfDay();
|
||||
|
||||
}
|
||||
// remove all empty entries to prevent cluttering:
|
||||
$newSet = [];
|
||||
@@ -280,7 +282,7 @@ class TagReportController extends Controller
|
||||
$newSet[$key] = $chartData[$key];
|
||||
}
|
||||
}
|
||||
if (0 === \count($newSet)) {
|
||||
if (0 === count($newSet)) {
|
||||
$newSet = $chartData; // @codeCoverageIgnore
|
||||
}
|
||||
$data = $this->generator->multiSet($newSet);
|
||||
|
@@ -23,7 +23,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Json;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@@ -98,12 +98,10 @@ class AutoCompleteController extends Controller
|
||||
/**
|
||||
* List of all journals.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param TransactionCollectorInterface $collector
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function allTransactionJournals(Request $request, TransactionCollectorInterface $collector): JsonResponse
|
||||
public function allTransactionJournals(Request $request): JsonResponse
|
||||
{
|
||||
$search = (string)$request->get('search');
|
||||
$cache = new CacheProperties;
|
||||
@@ -115,8 +113,22 @@ class AutoCompleteController extends Controller
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
// find everything:
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setLimit(250)->setPage(1);
|
||||
$return = array_values(array_unique($collector->getTransactions()->pluck('description')->toArray()));
|
||||
|
||||
$journals = $collector->getExtractedJournals();
|
||||
$return = [];
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
if (strlen($journal['group_title']) > 0) {
|
||||
$return[] = $journal['group_title'];
|
||||
}
|
||||
if (strlen($journal['description']) > 0) {
|
||||
$return[] = $journal['description'];
|
||||
}
|
||||
}
|
||||
$return = array_unique($return);
|
||||
|
||||
if ('' !== $search) {
|
||||
$return = array_values(
|
||||
@@ -136,7 +148,7 @@ class AutoCompleteController extends Controller
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param string $subject
|
||||
* @param string $subject
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -250,13 +262,12 @@ class AutoCompleteController extends Controller
|
||||
/**
|
||||
* List of journals with their ID.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param TransactionCollectorInterface $collector
|
||||
* @param TransactionJournal $except
|
||||
* @param Request $request
|
||||
* @param TransactionJournal $except
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function journalsWithId(Request $request, TransactionCollectorInterface $collector, TransactionJournal $except): JsonResponse
|
||||
public function journalsWithId(Request $request, TransactionJournal $except): JsonResponse
|
||||
{
|
||||
$search = (string)$request->get('search');
|
||||
$cache = new CacheProperties;
|
||||
@@ -268,15 +279,17 @@ class AutoCompleteController extends Controller
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
// find everything:
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setLimit(400)->setPage(1);
|
||||
$set = $collector->getTransactions()->pluck('description', 'journal_id')->toArray();
|
||||
$set = $collector->getExtractedJournals();
|
||||
$return = [];
|
||||
foreach ($set as $id => $description) {
|
||||
$id = (int)$id;
|
||||
foreach ($set as $journal) {
|
||||
$id = (int)$journal['transaction_journal_id'];
|
||||
if ($id !== $except->id) {
|
||||
$return[] = [
|
||||
'id' => $id,
|
||||
'name' => $id . ': ' . $description,
|
||||
'name' => $id . ': ' . $journal['description'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -327,13 +340,12 @@ class AutoCompleteController extends Controller
|
||||
/**
|
||||
* List of journals by type.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param TransactionCollectorInterface $collector
|
||||
* @param string $what
|
||||
* @param Request $request
|
||||
* @param string $what
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function transactionJournals(Request $request, TransactionCollectorInterface $collector, string $what): JsonResponse
|
||||
public function transactionJournals(Request $request, string $what): JsonResponse
|
||||
{
|
||||
$search = (string)$request->get('search');
|
||||
$cache = new CacheProperties;
|
||||
@@ -348,8 +360,15 @@ class AutoCompleteController extends Controller
|
||||
$type = config('firefly.transactionTypesByWhat.' . $what);
|
||||
$types = [$type];
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes($types)->setLimit(250)->setPage(1);
|
||||
$return = array_unique($collector->getTransactions()->pluck('description')->toArray());
|
||||
$result = $collector->getExtractedJournals();
|
||||
$return = [];
|
||||
foreach ($result as $journal) {
|
||||
$return[] = $journal['description'];
|
||||
}
|
||||
$return = array_unique($return);
|
||||
sort($return);
|
||||
|
||||
if ('' !== $search) {
|
||||
|
@@ -23,12 +23,11 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Json;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Helpers\Report\NetWorthInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@@ -134,35 +133,33 @@ class BoxController extends Controller
|
||||
$sums = [];
|
||||
|
||||
// collect income of user:
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)
|
||||
->setTypes([TransactionType::DEPOSIT])
|
||||
->withOpposingAccount();
|
||||
$set = $collector->getTransactions();
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
$currencyId = (int)$transaction->transaction_currency_id;
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)
|
||||
->setTypes([TransactionType::DEPOSIT]);
|
||||
$set = $collector->getExtractedJournals();
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
|
||||
$incomes[$currencyId] = bcadd($incomes[$currencyId], $transaction->transaction_amount);
|
||||
$incomes[$currencyId] = bcadd($incomes[$currencyId], $journal['amount']);
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? '0';
|
||||
$sums[$currencyId] = bcadd($sums[$currencyId], $transaction->transaction_amount);
|
||||
$sums[$currencyId] = bcadd($sums[$currencyId], $journal['amount']);
|
||||
}
|
||||
|
||||
// collect expenses
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)
|
||||
->setTypes([TransactionType::WITHDRAWAL])
|
||||
->withOpposingAccount();
|
||||
$set = $collector->getTransactions();
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
$currencyId = (int)$transaction->transaction_currency_id;
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)
|
||||
->setTypes([TransactionType::WITHDRAWAL]);
|
||||
$set = $collector->getExtractedJournals();
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$expenses[$currencyId] = $expenses[$currencyId] ?? '0';
|
||||
$expenses[$currencyId] = bcadd($expenses[$currencyId], $transaction->transaction_amount);
|
||||
$expenses[$currencyId] = bcadd($expenses[$currencyId], $journal['amount']);
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? '0';
|
||||
$sums[$currencyId] = bcadd($sums[$currencyId], $transaction->transaction_amount);
|
||||
$sums[$currencyId] = bcadd($sums[$currencyId], $journal['amount']);
|
||||
}
|
||||
|
||||
// format amounts:
|
||||
@@ -173,7 +170,7 @@ class BoxController extends Controller
|
||||
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
|
||||
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
|
||||
}
|
||||
if (0 === \count($sums)) {
|
||||
if (0 === count($sums)) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$sums[$currency->id] = app('amount')->formatAnything($currency, '0', false);
|
||||
$incomes[$currency->id] = app('amount')->formatAnything($currency, '0', false);
|
||||
@@ -184,7 +181,7 @@ class BoxController extends Controller
|
||||
'incomes' => $incomes,
|
||||
'expenses' => $expenses,
|
||||
'sums' => $sums,
|
||||
'size' => \count($sums),
|
||||
'size' => count($sums),
|
||||
];
|
||||
|
||||
|
||||
|
@@ -64,7 +64,7 @@ class FrontpageController extends Controller
|
||||
}
|
||||
}
|
||||
$html = '';
|
||||
if (\count($info) > 0) {
|
||||
if (count($info) > 0) {
|
||||
try {
|
||||
$html = view('json.piggy-banks', compact('info'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
|
@@ -47,7 +47,7 @@ class IntroController
|
||||
$specificPage = $specificPage ?? '';
|
||||
$steps = $this->getBasicSteps($route);
|
||||
$specificSteps = $this->getSpecificSteps($route, $specificPage);
|
||||
if (0 === \count($specificSteps)) {
|
||||
if (0 === count($specificSteps)) {
|
||||
Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage));
|
||||
|
||||
return response()->json($steps);
|
||||
@@ -55,7 +55,7 @@ class IntroController
|
||||
if ($this->hasOutroStep($route)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
// save last step:
|
||||
$lastStep = $steps[\count($steps) - 1];
|
||||
$lastStep = $steps[count($steps) - 1];
|
||||
// remove last step:
|
||||
array_pop($steps);
|
||||
// merge arrays and add last step again
|
||||
|
@@ -26,7 +26,7 @@ namespace FireflyIII\Http\Controllers\Json;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@@ -44,7 +44,7 @@ use Throwable;
|
||||
/**
|
||||
*
|
||||
* Class ReconcileController
|
||||
*
|
||||
* TODO needs a full rewrite
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class ReconcileController extends Controller
|
||||
@@ -84,8 +84,8 @@ class ReconcileController extends Controller
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -189,8 +189,8 @@ class ReconcileController extends Controller
|
||||
* Returns a list of transactions in a modal.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
@@ -220,14 +220,15 @@ class ReconcileController extends Controller
|
||||
$selectionEnd->addDays(3);
|
||||
|
||||
// grab transactions:
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setAccounts(new Collection([$account]))
|
||||
->setRange($selectionStart, $selectionEnd)->withBudgetInformation()->withOpposingAccount()->withCategoryInformation();
|
||||
$transactions = $collector->getTransactions();
|
||||
->setRange($selectionStart, $selectionEnd)->withBudgetInformation()->withCategoryInformation();
|
||||
$groups = $collector->getGroups();
|
||||
try {
|
||||
$html = view(
|
||||
'accounts.reconcile.transactions', compact('account', 'transactions', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd')
|
||||
'accounts.reconcile.transactions', compact('account', 'groups', 'currency', 'start', 'end', 'selectionStart', 'selectionEnd')
|
||||
)->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
|
@@ -72,7 +72,7 @@ class PreferencesController extends Controller
|
||||
|
||||
// an important fallback is that the frontPageAccount array gets refilled automatically
|
||||
// when it turns up empty.
|
||||
if (0 === \count($frontPageAccounts->data)) {
|
||||
if (0 === count($frontPageAccounts->data)) {
|
||||
$frontPageAccounts = $accountIds;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ class PreferencesController extends Controller
|
||||
{
|
||||
// front page accounts
|
||||
$frontPageAccounts = [];
|
||||
if (\is_array($request->get('frontPageAccounts')) && \count($request->get('frontPageAccounts')) > 0) {
|
||||
if (\is_array($request->get('frontPageAccounts')) && count($request->get('frontPageAccounts')) > 0) {
|
||||
foreach ($request->get('frontPageAccounts') as $id) {
|
||||
$frontPageAccounts[] = (int)$id;
|
||||
}
|
||||
|
@@ -88,8 +88,8 @@ class CreateController extends Controller
|
||||
$oldActions = $this->getPreviousActions($request);
|
||||
}
|
||||
|
||||
$triggerCount = \count($oldTriggers);
|
||||
$actionCount = \count($oldActions);
|
||||
$triggerCount = count($oldTriggers);
|
||||
$actionCount = count($oldActions);
|
||||
$subTitleIcon = 'fa-clone';
|
||||
|
||||
// title depends on whether or not there is a rule group:
|
||||
@@ -140,8 +140,8 @@ class CreateController extends Controller
|
||||
$oldTriggers = $this->getTriggersForBill($bill);
|
||||
$oldActions = $this->getActionsForBill($bill);
|
||||
|
||||
$triggerCount = \count($oldTriggers);
|
||||
$actionCount = \count($oldActions);
|
||||
$triggerCount = count($oldTriggers);
|
||||
$actionCount = count($oldActions);
|
||||
$subTitleIcon = 'fa-clone';
|
||||
|
||||
// title depends on whether or not there is a rule group:
|
||||
|
@@ -79,19 +79,19 @@ class EditController extends Controller
|
||||
$oldActions = [];
|
||||
$oldTriggers = [];
|
||||
// has old input?
|
||||
if (\count($request->old()) > 0) {
|
||||
if (count($request->old()) > 0) {
|
||||
$oldTriggers = $this->getPreviousTriggers($request);
|
||||
$triggerCount = \count($oldTriggers);
|
||||
$triggerCount = count($oldTriggers);
|
||||
$oldActions = $this->getPreviousActions($request);
|
||||
$actionCount = \count($oldActions);
|
||||
$actionCount = count($oldActions);
|
||||
}
|
||||
|
||||
// overrule old input when it has no rule data:
|
||||
if (0 === $triggerCount && 0 === $actionCount) {
|
||||
$oldTriggers = $this->getCurrentTriggers($rule);
|
||||
$triggerCount = \count($oldTriggers);
|
||||
$triggerCount = count($oldTriggers);
|
||||
$oldActions = $this->getCurrentActions($rule);
|
||||
$actionCount = \count($oldActions);
|
||||
$actionCount = count($oldActions);
|
||||
}
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
|
@@ -145,7 +145,7 @@ class SelectController extends Controller
|
||||
// build trigger array from response
|
||||
$triggers = $this->getValidTriggerList($request);
|
||||
|
||||
if (0 === \count($triggers)) {
|
||||
if (0 === count($triggers)) {
|
||||
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ class SelectController extends Controller
|
||||
{
|
||||
$triggers = $rule->ruleTriggers;
|
||||
|
||||
if (0 === \count($triggers)) {
|
||||
if (0 === count($triggers)) {
|
||||
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@@ -24,8 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Requests\TagFormRequest;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
@@ -171,8 +170,8 @@ class TagController extends Controller
|
||||
/**
|
||||
* Show a single tag.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Tag $tag
|
||||
* @param Request $request
|
||||
* @param Tag $tag
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
@@ -196,23 +195,23 @@ class TagController extends Controller
|
||||
$periods = $this->getTagPeriodOverview($tag, $start);
|
||||
$path = route('tags.show', [$tag->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
|
||||
->setTag($tag)->withBudgetInformation()->withCategoryInformation()->removeFilter(InternalTransferFilter::class);
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath($path);
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withAccountInformation()
|
||||
->setTag($tag)->withBudgetInformation()->withCategoryInformation();
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath($path);
|
||||
$sums = $this->repository->sumsOfTag($tag, $start, $end);
|
||||
|
||||
return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'transactions', 'start', 'end'));
|
||||
return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a single tag over all time.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Tag $tag
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*
|
||||
@@ -230,15 +229,15 @@ class TagController extends Controller
|
||||
$start = $this->repository->firstUseDate($tag) ?? new Carbon;
|
||||
$end = new Carbon;
|
||||
$path = route('tags.show', [$tag->id, 'all']);
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
|
||||
->setTag($tag)->withBudgetInformation()->withCategoryInformation()->removeFilter(InternalTransferFilter::class);
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath($path);
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withAccountInformation()
|
||||
->setTag($tag)->withBudgetInformation()->withCategoryInformation();
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath($path);
|
||||
$sums = $this->repository->sumsOfTag($tag, $start, $end);
|
||||
|
||||
return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'transactions', 'start', 'end'));
|
||||
return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,7 +275,7 @@ class TagController extends Controller
|
||||
* Update a tag.
|
||||
*
|
||||
* @param TagFormRequest $request
|
||||
* @param Tag $tag
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
|
@@ -27,7 +27,7 @@ namespace FireflyIII\Http\Controllers\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Support\Http\Controllers\ModelInformation;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Controllers\PeriodOverview;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -37,20 +37,21 @@ use Illuminate\Http\Request;
|
||||
class IndexController extends Controller
|
||||
{
|
||||
use PeriodOverview;
|
||||
|
||||
/**
|
||||
* Index for a range of transactions.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $transactionType
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index(Request $request, string $transactionType, Carbon $start = null, Carbon $end = null)
|
||||
public function index(Request $request, string $objectType, Carbon $start = null, Carbon $end = null)
|
||||
{
|
||||
$subTitleIcon = config('firefly.transactionIconsByType.' . $transactionType);
|
||||
$types = config('firefly.transactionTypesByType.' . $transactionType);
|
||||
$subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
|
||||
$types = config('firefly.transactionTypesByType.' . $objectType);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
if (null === $start) {
|
||||
@@ -65,13 +66,12 @@ class IndexController extends Controller
|
||||
[$start, $end] = [$end, $start];
|
||||
}
|
||||
|
||||
$path = route('transactions.index', [$transactionType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
|
||||
$startStr = $start->formatLocalized($this->monthAndDayFormat);
|
||||
$endStr = $end->formatLocalized($this->monthAndDayFormat);
|
||||
$subTitle = (string)trans(sprintf('firefly.title_%s_between',$transactionType), ['start' => $startStr, 'end' => $endStr]);
|
||||
|
||||
$periods = $this->getTransactionPeriodOverview($transactionType, $end);
|
||||
$subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
|
||||
$periods = $this->getTransactionPeriodOverview($objectType, $end);
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
@@ -86,6 +86,42 @@ class IndexController extends Controller
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath($path);
|
||||
|
||||
return view('transactions.index', compact('subTitle', 'transactionType', 'subTitleIcon', 'groups', 'periods', 'start', 'end'));
|
||||
return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'periods', 'start', 'end'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Index for ALL transactions.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function indexAll(Request $request, string $objectType)
|
||||
{
|
||||
/** @var JournalRepositoryInterface $repository */
|
||||
$repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
|
||||
$subTitleIcon = config('firefly.transactionIconsByWhat.' . $objectType);
|
||||
$types = config('firefly.transactionTypesByWhat.' . $objectType);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$path = route('transactions.index.all', [$objectType]);
|
||||
$first = $repository->firstNull();
|
||||
$start = null === $first ? new Carbon : $first->date;
|
||||
$end = new Carbon;
|
||||
$subTitle = (string)trans('firefly.all_' . $objectType);
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setRange($start, $end)
|
||||
->setTypes($types)->setLimit($pageSize)->setPage($page)->withAccountInformation()
|
||||
->withBudgetInformation()->withCategoryInformation();
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath($path);
|
||||
|
||||
return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'start', 'end'));
|
||||
}
|
||||
}
|
@@ -393,11 +393,11 @@ class SingleController extends Controller
|
||||
|
||||
// store the journal only, flash the rest.
|
||||
Log::debug(sprintf('Count of error messages is %d', $this->attachments->getErrors()->count()));
|
||||
if (\count($this->attachments->getErrors()->get('attachments')) > 0) {
|
||||
if (count($this->attachments->getErrors()->get('attachments')) > 0) {
|
||||
session()->flash('error', $this->attachments->getErrors()->get('attachments'));
|
||||
}
|
||||
// flash messages
|
||||
if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
session()->flash('info', $this->attachments->getMessages()->get('attachments'));
|
||||
}
|
||||
|
||||
@@ -460,10 +460,10 @@ class SingleController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($journal, $files);
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
if (\count($this->attachments->getErrors()->get('attachments')) > 0) {
|
||||
if (count($this->attachments->getErrors()->get('attachments')) > 0) {
|
||||
session()->flash('error', $this->attachments->getErrors()->get('attachments'));
|
||||
}
|
||||
if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
session()->flash('info', $this->attachments->getMessages()->get('attachments'));
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@@ -152,7 +152,7 @@ class SplitController extends Controller
|
||||
|
||||
// flash messages
|
||||
// @codeCoverageIgnoreStart
|
||||
if (\count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
session()->flash('info', $this->attachments->getMessages()->get('attachments'));
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@@ -25,19 +25,12 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\CountAttachmentsFilter;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Helpers\Filter\SplitIndicatorFilter;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Controllers\ModelInformation;
|
||||
use FireflyIII\Support\Http\Controllers\PeriodOverview;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -72,40 +65,6 @@ class TransactionController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Index for ALL transactions.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $what
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function indexAll(Request $request, string $what)
|
||||
{
|
||||
throw new FireflyException('Do not use me.');
|
||||
$subTitleIcon = config('firefly.transactionIconsByWhat.' . $what);
|
||||
$types = config('firefly.transactionTypesByWhat.' . $what);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$path = route('transactions.index.all', [$what]);
|
||||
$first = $this->repository->firstNull();
|
||||
$start = null === $first ? new Carbon : $first->date;
|
||||
$end = new Carbon;
|
||||
$subTitle = (string)trans('firefly.all_' . $what);
|
||||
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)
|
||||
->setTypes($types)->setLimit($pageSize)->setPage($page)->withOpposingAccount()
|
||||
->withBudgetInformation()->withCategoryInformation();
|
||||
$collector->removeFilter(InternalTransferFilter::class);
|
||||
$collector->addFilter(SplitIndicatorFilter::class);
|
||||
$collector->addFilter(CountAttachmentsFilter::class);
|
||||
$transactions = $collector->getPaginatedTransactions();
|
||||
$transactions->setPath($path);
|
||||
|
||||
return view('transactions.index', compact('subTitle', 'what', 'subTitleIcon', 'transactions', 'start', 'end'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Do a reconciliation.
|
||||
@@ -141,7 +100,7 @@ class TransactionController extends Controller
|
||||
{
|
||||
$ids = $request->get('items');
|
||||
$date = new Carbon($request->get('date'));
|
||||
if (\count($ids) > 0) {
|
||||
if (count($ids) > 0) {
|
||||
$order = 0;
|
||||
$ids = array_unique($ids);
|
||||
foreach ($ids as $id) {
|
||||
|
@@ -130,7 +130,7 @@ class ReportFormRequest extends Request
|
||||
$date = new Carbon;
|
||||
$range = $this->get('daterange');
|
||||
$parts = explode(' - ', (string)$range);
|
||||
if (2 === \count($parts)) {
|
||||
if (2 === count($parts)) {
|
||||
try {
|
||||
$date = new Carbon($parts[1]);
|
||||
// @codeCoverageIgnoreStart
|
||||
@@ -181,7 +181,7 @@ class ReportFormRequest extends Request
|
||||
$date = new Carbon;
|
||||
$range = $this->get('daterange');
|
||||
$parts = explode(' - ', (string)$range);
|
||||
if (2 === \count($parts)) {
|
||||
if (2 === count($parts)) {
|
||||
try {
|
||||
$date = new Carbon($parts[0]);
|
||||
// @codeCoverageIgnoreStart
|
||||
|
Reference in New Issue
Block a user