mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 02:52:44 +00:00
More cleanup for budgets.
This commit is contained in:
@@ -68,8 +68,10 @@ class BalanceReportHelper implements BalanceReportHelperInterface
|
|||||||
|
|
||||||
// build a balance header:
|
// build a balance header:
|
||||||
$header = new BalanceHeader;
|
$header = new BalanceHeader;
|
||||||
$budgets = new Collection;// $this->budgetRepository->getBudgetsAndLimitsInRange($start, $end); // TODO BUDGET getBudgets
|
// new Collection;// $this->budgetRepository->getBudgetsAndLimitsInRange($start, $end); // TO DO BUDGET getBudgets
|
||||||
$spentData = new Collection; // $this->budgetRepository->spentPerBudgetPerAccount($budgets, $accounts, $start, $end); TODO BUDGET journalsInPeriod
|
$budgets = $this->budgetRepository->getBudgets();
|
||||||
|
// new Collection; // $this->budgetRepository->spentPerBudgetPerAccount($budgets, $accounts, $start, $end); TO DO BUDGET journalsInPeriod
|
||||||
|
$spentData = $this->budgetRepository->journalsInPeriod($budgets, $accounts, $start, $end);
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$header->addAccount($account);
|
$header->addAccount($account);
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,10 @@ use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
|
|||||||
use FireflyIII\Helpers\Collection\BudgetLine;
|
use FireflyIII\Helpers\Collection\BudgetLine;
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\LimitRepetition;
|
use FireflyIII\Models\LimitRepetition;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BudgetReportHelper
|
* Class BudgetReportHelper
|
||||||
@@ -38,24 +40,21 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
{
|
{
|
||||||
$object = new BudgetCollection;
|
$object = new BudgetCollection;
|
||||||
/** @var BudgetRepositoryInterface $repository */
|
/** @var BudgetRepositoryInterface $repository */
|
||||||
$repository = app(BudgetRepositoryInterface::class);
|
$repository = app(BudgetRepositoryInterface::class);
|
||||||
$set = $repository->getBudgets();
|
$set = $repository->getBudgets();
|
||||||
$allRepetitions = $repository->getAllBudgetLimitRepetitions($start, $end);
|
|
||||||
$allTotalSpent = '0'; //$repository->spentAllPerDayForAccounts($accounts, $start, $end);// TODO BUDGET MASSIVELY STUPID SPECIFIC METHOD
|
|
||||||
|
|
||||||
|
/** @var Budget $budget */
|
||||||
foreach ($set as $budget) {
|
foreach ($set as $budget) {
|
||||||
|
Log::debug('Now at budget #' . $budget->id . ' (' . $budget->name . ')');
|
||||||
$repetitions = $allRepetitions->filter(
|
$repetitions = $budget->limitrepetitions()->before($end)->after($start)->get();
|
||||||
function (LimitRepetition $rep) use ($budget) {
|
|
||||||
return $rep->budget_id == $budget->id;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$totalSpent = $allTotalSpent[$budget->id] ?? [];
|
|
||||||
|
|
||||||
// no repetition(s) for this budget:
|
// no repetition(s) for this budget:
|
||||||
if ($repetitions->count() == 0) {
|
if ($repetitions->count() == 0) {
|
||||||
|
Log::debug('Found zero repetitions.');
|
||||||
|
// spent for budget in time range:
|
||||||
|
$spent = $repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end);
|
||||||
|
|
||||||
$spent = array_sum($totalSpent);
|
// $spent = array_sum($totalSpent);
|
||||||
if ($spent > 0) {
|
if ($spent > 0) {
|
||||||
$budgetLine = new BudgetLine;
|
$budgetLine = new BudgetLine;
|
||||||
$budgetLine->setBudget($budget);
|
$budgetLine->setBudget($budget);
|
||||||
@@ -65,18 +64,16 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Log::debug('Found ' . $repetitions->count() . ' repetitions.');
|
||||||
// one or more repetitions for budget:
|
// one or more repetitions for budget:
|
||||||
/** @var LimitRepetition $repetition */
|
/** @var LimitRepetition $repetition */
|
||||||
foreach ($repetitions as $repetition) {
|
foreach ($repetitions as $repetition) {
|
||||||
|
|
||||||
$budgetLine = new BudgetLine;
|
$budgetLine = new BudgetLine;
|
||||||
$budgetLine->setBudget($budget);
|
$budgetLine->setBudget($budget);
|
||||||
$budgetLine->setRepetition($repetition);
|
$budgetLine->setRepetition($repetition);
|
||||||
$expenses = $this->getSumOfRange($repetition->startdate, $repetition->enddate, $totalSpent);
|
$expenses = $repository->spentInPeriod(new Collection([$budget]), $accounts, $repetition->startdate, $repetition->enddate);
|
||||||
|
Log::debug('Spent in p. [' . $repetition->startdate->format('Y-m-d') . '] to [' . $repetition->enddate->format('Y-m-d') . '] is ' . $expenses);
|
||||||
// 200 en -100 is 100, vergeleken met 0 === 1
|
|
||||||
// 200 en -200 is 0, vergeleken met 0 === 0
|
|
||||||
// 200 en -300 is -100, vergeleken met 0 === -1
|
|
||||||
|
|
||||||
$left = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? bcadd($repetition->amount, $expenses) : '0';
|
$left = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? bcadd($repetition->amount, $expenses) : '0';
|
||||||
$spent = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? $expenses : '0';
|
$spent = bccomp(bcadd($repetition->amount, $expenses), '0') === 1 ? $expenses : '0';
|
||||||
@@ -98,7 +95,12 @@ class BudgetReportHelper implements BudgetReportHelperInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stuff outside of budgets:
|
// stuff outside of budgets:
|
||||||
$noBudget = '0'; //$repository->getWithoutBudgetSum($accounts, $start, $end); // TODO BUDGET journalsInPeriodWithoutBudget
|
$outsideBudget = $repository->journalsInPeriodWithoutBudget($accounts, $start, $end);
|
||||||
|
$noBudget = '0';
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
foreach ($outsideBudget as $journal) {
|
||||||
|
$noBudget = bcadd($noBudget, TransactionJournal::amount($journal));
|
||||||
|
}
|
||||||
$budgetLine = new BudgetLine;
|
$budgetLine = new BudgetLine;
|
||||||
$budgetLine->setOverspent($noBudget);
|
$budgetLine->setOverspent($noBudget);
|
||||||
$budgetLine->setSpent($noBudget);
|
$budgetLine->setSpent($noBudget);
|
||||||
|
@@ -13,6 +13,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
|||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Input;
|
use Input;
|
||||||
|
use Log;
|
||||||
use Navigation;
|
use Navigation;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Response;
|
use Response;
|
||||||
@@ -174,6 +175,8 @@ class BudgetController extends Controller
|
|||||||
$periodStart = $start->formatLocalized($this->monthAndDayFormat);
|
$periodStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||||
$periodEnd = $end->formatLocalized($this->monthAndDayFormat);
|
$periodEnd = $end->formatLocalized($this->monthAndDayFormat);
|
||||||
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
|
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
|
||||||
|
$startAsString = $start->format('Y-m-d');
|
||||||
|
$endAsString = $end->format('Y-m-d');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do some cleanup:
|
* Do some cleanup:
|
||||||
@@ -183,12 +186,28 @@ class BudgetController extends Controller
|
|||||||
// loop the budgets:
|
// loop the budgets:
|
||||||
/** @var Budget $budget */
|
/** @var Budget $budget */
|
||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
$budget->spent = '0';//$repository->balanceInPeriod($budget, $start, $end, $accounts); // TODO BUDGET spentInPeriod
|
$budget->spent = $repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end);
|
||||||
$budget->currentRep = new LimitRepetition(
|
$allRepetitions = $repository->getAllBudgetLimitRepetitions($start, $end);
|
||||||
); // $repository->getCurrentRepetition($budget, $repeatFreq, $start, $end); // TODO BUDGET getBudgetLimitRepetitions
|
$otherRepetitions = new Collection;
|
||||||
$budget->otherRepetitions = new Collection(
|
|
||||||
);//$repository->getValidRepetitions($budget, $start, $end, $budget->currentRep); // TODO BUDGET getBudgetLimitRepetitions
|
/** @var LimitRepetition $repetition */
|
||||||
if (!is_null($budget->currentRep->id)) {
|
foreach ($allRepetitions as $repetition) {
|
||||||
|
if ($repetition->budget_id == $budget->id) {
|
||||||
|
Log::debug('Repetition #' . $repetition->id . ' with budget #' . $repetition->budget_id . ' (current = ' . $budget->id . ')');
|
||||||
|
if ($repetition->budgetLimit->repeat_freq == $repeatFreq
|
||||||
|
&& $repetition->startdate->format('Y-m-d') == $startAsString
|
||||||
|
&& $repetition->enddate->format('Y-m-d') == $endAsString
|
||||||
|
) {
|
||||||
|
// do something
|
||||||
|
$budget->currentRep = $repetition;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$otherRepetitions->push($repetition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$budget->otherRepetitions = $otherRepetitions;
|
||||||
|
|
||||||
|
if (!is_null($budget->currentRep) && !is_null($budget->currentRep->id)) {
|
||||||
$budgeted = bcadd($budgeted, $budget->currentRep->amount);
|
$budgeted = bcadd($budgeted, $budget->currentRep->amount);
|
||||||
}
|
}
|
||||||
$spent = bcadd($spent, $budget->spent);
|
$spent = bcadd($spent, $budget->spent);
|
||||||
@@ -223,7 +242,11 @@ class BudgetController extends Controller
|
|||||||
|
|
||||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||||
$list = new LengthAwarePaginator([], 0, $pageSize); // $repository->getWithoutBudget($start, $end, $page, $pageSize); // TODO BUDGET journalsInPeriodWithoutBudget
|
$offset = ($page - 1) * $pageSize;
|
||||||
|
$journals = $repository->journalsInPeriodWithoutBudget(new Collection, $start, $end);
|
||||||
|
$count = $journals->count();
|
||||||
|
$journals = $journals->slice($offset, $pageSize);
|
||||||
|
$list = new LengthAwarePaginator($journals, $count, $pageSize);
|
||||||
$subTitle = trans(
|
$subTitle = trans(
|
||||||
'firefly.without_budget_between',
|
'firefly.without_budget_between',
|
||||||
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||||
@@ -260,25 +283,30 @@ class BudgetController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(BudgetRepositoryInterface $repository, Budget $budget)
|
public function show(BudgetRepositoryInterface $repository, Budget $budget)
|
||||||
{
|
{
|
||||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
/** @var Carbon $start */
|
||||||
$journals = new LengthAwarePaginator(
|
$start = session('first', Carbon::create()->startOfYear());
|
||||||
[], 0, $pageSize
|
|
||||||
); //$repository->getJournals($budget, new LimitRepetition, $pageSize); // TODO BUDGET journalsInPeriod
|
|
||||||
$start = new Carbon; //$repository->firstActivity($budget); // TODO BUDGET getOldestJournal
|
|
||||||
$end = new Carbon;
|
$end = new Carbon;
|
||||||
|
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||||
|
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||||
|
$offset = ($page - 1) * $pageSize;
|
||||||
|
$journals = $repository->journalsInPeriodWithoutBudget(new Collection, $start, $end);
|
||||||
|
$count = $journals->count();
|
||||||
|
$journals = $journals->slice($offset, $pageSize);
|
||||||
|
$journals = new LengthAwarePaginator($journals, $count, $pageSize);
|
||||||
|
|
||||||
|
$journals->setPath('/budgets/show/' . $budget->id);
|
||||||
|
|
||||||
|
|
||||||
$set = $budget->limitrepetitions()->orderBy('startdate', 'DESC')->get();
|
$set = $budget->limitrepetitions()->orderBy('startdate', 'DESC')->get();
|
||||||
$subTitle = e($budget->name);
|
$subTitle = e($budget->name);
|
||||||
$journals->setPath('/budgets/show/' . $budget->id);
|
$limits = new Collection();
|
||||||
$spentArray = []; //$repository->spentPerDay($budget, $start, $end, new Collection); // TODO BUDGET spentInPeriod
|
|
||||||
$limits = new Collection();
|
|
||||||
|
|
||||||
/** @var LimitRepetition $entry */
|
/** @var LimitRepetition $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$entry->spent = $this->getSumOfRange($entry->startdate, $entry->enddate, $spentArray);
|
$entry->spent = $repository->spentInPeriod(new Collection([$budget]), new Collection, $entry->startdate, $entry->enddate);
|
||||||
$limits->push($entry);
|
$limits->push($entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
|
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,23 +323,24 @@ class BudgetController extends Controller
|
|||||||
if ($repetition->budgetLimit->budget->id != $budget->id) {
|
if ($repetition->budgetLimit->budget->id != $budget->id) {
|
||||||
throw new FireflyException('This budget limit is not part of this budget.');
|
throw new FireflyException('This budget limit is not part of this budget.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
|
||||||
$journals = new LengthAwarePaginator([], 0, $pageSize); // $repository->getJournals($budget, $repetition, $pageSize); // TODO BUDGET journalsInPeriod
|
|
||||||
$start = $repetition->startdate;
|
$start = $repetition->startdate;
|
||||||
$end = $repetition->enddate;
|
$end = $repetition->enddate;
|
||||||
$set = new Collection([$repetition]);
|
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||||
$subTitle = trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)]);
|
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||||
|
$offset = ($page - 1) * $pageSize;
|
||||||
|
$journals = $repository->journalsInPeriodWithoutBudget(new Collection, $start, $end);
|
||||||
|
$count = $journals->count();
|
||||||
|
$journals = $journals->slice($offset, $pageSize);
|
||||||
|
$journals = new LengthAwarePaginator($journals, $count, $pageSize);
|
||||||
|
|
||||||
$journals->setPath('/budgets/show/' . $budget->id . '/' . $repetition->id);
|
$journals->setPath('/budgets/show/' . $budget->id . '/' . $repetition->id);
|
||||||
$spentArray = []; //$repository->spentPerDay($budget, $start, $end, new Collection); // TODO BUDGET spentInPeriod
|
|
||||||
$limits = new Collection();
|
|
||||||
|
|
||||||
/** @var LimitRepetition $entry */
|
|
||||||
foreach ($set as $entry) {
|
|
||||||
$entry->spent = $this->getSumOfRange($entry->startdate, $entry->enddate, $spentArray);
|
|
||||||
$limits->push($entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$subTitle = trans(
|
||||||
|
'firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)]
|
||||||
|
);
|
||||||
|
$repetition->spent = $repository->spentInPeriod(new Collection([$budget]), new Collection, $repetition->startdate, $repetition->enddate);
|
||||||
|
$limits = new Collection([$repetition]);
|
||||||
|
|
||||||
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
|
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
|
||||||
|
|
||||||
|
@@ -14,7 +14,6 @@ namespace FireflyIII\Http\Controllers\Popup;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Collection\BalanceLine;
|
use FireflyIII\Helpers\Collection\BalanceLine;
|
||||||
use FireflyIII\Helpers\Csv\Mapper\Budget;
|
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
@@ -94,15 +93,17 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case ($role === BalanceLine::ROLE_DEFAULTROLE && !is_null($budget->id)):
|
case ($role === BalanceLine::ROLE_DEFAULTROLE && !is_null($budget->id)):
|
||||||
$journals = new Collection;// $budgetRepository->expensesSplit($budget, $account, $attributes['startDate'], $attributes['endDate']);// TODO BUDGET journalsInPeriod
|
$journals = $budgetRepository->journalsInPeriod(
|
||||||
|
new Collection([$budget]), new Collection([$account]), $attributes['startDate'], $attributes['endDate']
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case ($role === BalanceLine::ROLE_DEFAULTROLE && is_null($budget->id)):
|
case ($role === BalanceLine::ROLE_DEFAULTROLE && is_null($budget->id)):
|
||||||
$budget->name = strval(trans('firefly.no_budget'));
|
$budget->name = strval(trans('firefly.no_budget'));
|
||||||
$journals = new Collection;// $budgetRepository->getAllWithoutBudget($account, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']); // TODO BUDGET journalsInPeriodWithoutBudget
|
$journals = $budgetRepository->journalsInPeriodWithoutBudget($attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||||
break;
|
break;
|
||||||
case ($role === BalanceLine::ROLE_DIFFROLE):
|
case ($role === BalanceLine::ROLE_DIFFROLE):
|
||||||
// journals no budget, not corrected by a tag.
|
// journals no budget, not corrected by a tag.
|
||||||
$journals = new Collection; //$budgetRepository->getAllWithoutBudget($account, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']); // TODO BUDGET journalsInPeriodWithoutBudget
|
$journals = $budgetRepository->journalsInPeriodWithoutBudget($attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||||
$budget->name = strval(trans('firefly.leftUnbalanced'));
|
$budget->name = strval(trans('firefly.leftUnbalanced'));
|
||||||
$journals = $journals->filter(
|
$journals = $journals->filter(
|
||||||
function (TransactionJournal $journal) {
|
function (TransactionJournal $journal) {
|
||||||
@@ -138,10 +139,10 @@ class ReportController extends Controller
|
|||||||
$repository = app(BudgetRepositoryInterface::class);
|
$repository = app(BudgetRepositoryInterface::class);
|
||||||
$budget = $repository->find(intval($attributes['budgetId']));
|
$budget = $repository->find(intval($attributes['budgetId']));
|
||||||
if (is_null($budget->id)) {
|
if (is_null($budget->id)) {
|
||||||
$journals = new Collection;// $repository->getWithoutBudgetForAccounts($attributes['accounts'], $attributes['startDate'], $attributes['endDate']); // TODO BUDGET journalsInPeriodWithoutBudget
|
$journals = $repository->journalsInPeriodWithoutBudget($attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||||
} else {
|
} else {
|
||||||
// get all expenses in budget in period:
|
// get all expenses in budget in period:
|
||||||
$journals = new Collection; //$repository->getExpenses($budget, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']); // TODO BUDGET journalsInPeriod
|
$journals = $repository->journalsInPeriod(new Collection([$budget]), $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = view('popup.report.budget-spent-amount', compact('journals', 'budget'))->render();
|
$view = view('popup.report.budget-spent-amount', compact('journals', 'budget'))->render();
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
<?php namespace FireflyIII\Models;
|
<?php namespace FireflyIII\Models;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
@@ -59,6 +61,28 @@ class LimitRepetition extends Model
|
|||||||
return $this->belongsTo('FireflyIII\Models\BudgetLimit');
|
return $this->belongsTo('FireflyIII\Models\BudgetLimit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Builder $query
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function scopeAfter(Builder $query, Carbon $date)
|
||||||
|
{
|
||||||
|
$query->where('limit_repetitions.startdate', '>=', $date->format('Y-m-d 00:00:00'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Builder $query
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function scopeBefore(Builder $query, Carbon $date)
|
||||||
|
{
|
||||||
|
$query->where('limit_repetitions.enddate', '<=', $date->format('Y-m-d 00:00:00'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $value
|
* @param $value
|
||||||
*/
|
*/
|
||||||
|
@@ -338,6 +338,10 @@ class TransactionJournal extends TransactionJournalSupport
|
|||||||
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0);
|
$join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '>', 0);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// order
|
||||||
|
$query->orderBy('transaction_journals.date', 'DESC')->orderBy('transaction_journals.order', 'ASC')->orderBy('transaction_journals.id', 'DESC');
|
||||||
|
|
||||||
$query->groupBy('transaction_journals.id');
|
$query->groupBy('transaction_journals.id');
|
||||||
$query->with(['categories', 'budgets', 'attachments', 'bill','transactions']);
|
$query->with(['categories', 'budgets', 'attachments', 'bill','transactions']);
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@ declare(strict_types = 1);
|
|||||||
namespace FireflyIII\Repositories\Budget;
|
namespace FireflyIII\Repositories\Budget;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use DB;
|
|
||||||
use FireflyIII\Events\BudgetLimitStored;
|
use FireflyIII\Events\BudgetLimitStored;
|
||||||
use FireflyIII\Events\BudgetLimitUpdated;
|
use FireflyIII\Events\BudgetLimitUpdated;
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
@@ -12,21 +11,18 @@ use FireflyIII\Models\BudgetLimit;
|
|||||||
use FireflyIII\Models\LimitRepetition;
|
use FireflyIII\Models\LimitRepetition;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Repositories\Shared\ComponentRepository;
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Query\Builder as QueryBuilder;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Query\JoinClause;
|
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Input;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BudgetRepository
|
* Class BudgetRepository
|
||||||
*
|
*
|
||||||
* @package FireflyIII\Repositories\Budget
|
* @package FireflyIII\Repositories\Budget
|
||||||
*/
|
*/
|
||||||
class BudgetRepository extends ComponentRepository implements BudgetRepositoryInterface
|
class BudgetRepository implements BudgetRepositoryInterface
|
||||||
{
|
{
|
||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
@@ -445,66 +441,66 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param Budget $budget
|
// * @param Budget $budget
|
||||||
// * @param string $repeatFreq
|
// * @param string $repeatFreq
|
||||||
// * @param Carbon $start
|
// * @param Carbon $start
|
||||||
// * @param Carbon $end
|
// * @param Carbon $end
|
||||||
// *
|
// *
|
||||||
// * @return LimitRepetition
|
// * @return LimitRepetition
|
||||||
// */
|
// */
|
||||||
// public function getCurrentRepetition(Budget $budget, string $repeatFreq, Carbon $start, Carbon $end): LimitRepetition
|
// public function getCurrentRepetition(Budget $budget, string $repeatFreq, Carbon $start, Carbon $end): LimitRepetition
|
||||||
// {
|
// {
|
||||||
// $data = $budget->limitrepetitions()
|
// $data = $budget->limitrepetitions()
|
||||||
// ->where('budget_limits.repeat_freq', $repeatFreq)
|
// ->where('budget_limits.repeat_freq', $repeatFreq)
|
||||||
// ->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00'))
|
// ->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00'))
|
||||||
// ->where('limit_repetitions.enddate', $end->format('Y-m-d 00:00:00'))
|
// ->where('limit_repetitions.enddate', $end->format('Y-m-d 00:00:00'))
|
||||||
// ->first(['limit_repetitions.*']);
|
// ->first(['limit_repetitions.*']);
|
||||||
// if (is_null($data)) {
|
// if (is_null($data)) {
|
||||||
// return new LimitRepetition;
|
// return new LimitRepetition;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return $data;
|
// return $data;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Returns all expenses for the given budget and the given accounts, in the given period.
|
// * Returns all expenses for the given budget and the given accounts, in the given period.
|
||||||
// *
|
// *
|
||||||
// * @param Budget $budget
|
// * @param Budget $budget
|
||||||
// * @param Collection $accounts
|
// * @param Collection $accounts
|
||||||
// * @param Carbon $start
|
// * @param Carbon $start
|
||||||
// * @param Carbon $end
|
// * @param Carbon $end
|
||||||
// *
|
// *
|
||||||
// * @return Collection
|
// * @return Collection
|
||||||
// */
|
// */
|
||||||
// public function getExpenses(Budget $budget, Collection $accounts, Carbon $start, Carbon $end):Collection
|
// public function getExpenses(Budget $budget, Collection $accounts, Carbon $start, Carbon $end):Collection
|
||||||
// {
|
// {
|
||||||
// $ids = $accounts->pluck('id')->toArray();
|
// $ids = $accounts->pluck('id')->toArray();
|
||||||
// $set = $budget->transactionjournals()
|
// $set = $budget->transactionjournals()
|
||||||
// ->before($end)
|
// ->before($end)
|
||||||
// ->after($start)
|
// ->after($start)
|
||||||
// ->expanded()
|
// ->expanded()
|
||||||
// ->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
// ->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
||||||
// ->whereIn('source_account.id', $ids)
|
// ->whereIn('source_account.id', $ids)
|
||||||
// ->get(TransactionJournal::queryFields());
|
// ->get(TransactionJournal::queryFields());
|
||||||
//
|
//
|
||||||
// return $set;
|
// return $set;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param Budget $budget
|
// * @param Budget $budget
|
||||||
// *
|
// *
|
||||||
// * @return Carbon
|
// * @return Carbon
|
||||||
// */
|
// */
|
||||||
// public function getFirstBudgetLimitDate(Budget $budget): Carbon
|
// public function getFirstBudgetLimitDate(Budget $budget): Carbon
|
||||||
// {
|
// {
|
||||||
// $limit = $budget->budgetlimits()->orderBy('startdate', 'ASC')->first();
|
// $limit = $budget->budgetlimits()->orderBy('startdate', 'ASC')->first();
|
||||||
// if ($limit) {
|
// if ($limit) {
|
||||||
// return $limit->startdate;
|
// return $limit->startdate;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return Carbon::now()->startOfYear();
|
// return Carbon::now()->startOfYear();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection
|
* @return Collection
|
||||||
@@ -523,315 +519,428 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
|||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Returns all the transaction journals for a limit, possibly limited by a limit repetition.
|
// * Returns all the transaction journals for a limit, possibly limited by a limit repetition.
|
||||||
// *
|
// *
|
||||||
// * @param Budget $budget
|
// * @param Budget $budget
|
||||||
// * @param LimitRepetition $repetition
|
// * @param LimitRepetition $repetition
|
||||||
// * @param int $take
|
// * @param int $take
|
||||||
// *
|
// *
|
||||||
// * @return LengthAwarePaginator
|
// * @return LengthAwarePaginator
|
||||||
// */
|
// */
|
||||||
// public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50): LengthAwarePaginator
|
// public function getJournals(Budget $budget, LimitRepetition $repetition = null, int $take = 50): LengthAwarePaginator
|
||||||
// {
|
// {
|
||||||
// $offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0;
|
// $offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0;
|
||||||
// $setQuery = $budget->transactionjournals()->expanded()
|
// $setQuery = $budget->transactionjournals()->expanded()
|
||||||
// ->take($take)->offset($offset)
|
// ->take($take)->offset($offset)
|
||||||
// ->orderBy('transaction_journals.date', 'DESC')
|
// ->orderBy('transaction_journals.date', 'DESC')
|
||||||
// ->orderBy('transaction_journals.order', 'ASC')
|
// ->orderBy('transaction_journals.order', 'ASC')
|
||||||
// ->orderBy('transaction_journals.id', 'DESC');
|
// ->orderBy('transaction_journals.id', 'DESC');
|
||||||
// $countQuery = $budget->transactionjournals();
|
// $countQuery = $budget->transactionjournals();
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// if (!is_null($repetition->id)) {
|
// if (!is_null($repetition->id)) {
|
||||||
// $setQuery->after($repetition->startdate)->before($repetition->enddate);
|
// $setQuery->after($repetition->startdate)->before($repetition->enddate);
|
||||||
// $countQuery->after($repetition->startdate)->before($repetition->enddate);
|
// $countQuery->after($repetition->startdate)->before($repetition->enddate);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// $set = $setQuery->get(TransactionJournal::queryFields());
|
// $set = $setQuery->get(TransactionJournal::queryFields());
|
||||||
// $count = $countQuery->count();
|
// $count = $countQuery->count();
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// $paginator = new LengthAwarePaginator($set, $count, $take, $offset);
|
// $paginator = new LengthAwarePaginator($set, $count, $take, $offset);
|
||||||
//
|
//
|
||||||
// return $paginator;
|
// return $paginator;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Returns a list of budget limits that are valid in the current given range.
|
// * Returns a list of budget limits that are valid in the current given range.
|
||||||
// * $ignore is optional. Send an empty limit rep.
|
// * $ignore is optional. Send an empty limit rep.
|
||||||
// *
|
// *
|
||||||
// * @param Budget $budget
|
// * @param Budget $budget
|
||||||
// * @param Carbon $start
|
// * @param Carbon $start
|
||||||
// * @param Carbon $end
|
// * @param Carbon $end
|
||||||
// * @param LimitRepetition $ignore
|
// * @param LimitRepetition $ignore
|
||||||
// *
|
// *
|
||||||
// * @return Collection
|
// * @return Collection
|
||||||
// */
|
// */
|
||||||
// public function getValidRepetitions(Budget $budget, Carbon $start, Carbon $end, LimitRepetition $ignore) : Collection
|
// public function getValidRepetitions(Budget $budget, Carbon $start, Carbon $end, LimitRepetition $ignore) : Collection
|
||||||
// {
|
// {
|
||||||
// $query = $budget->limitrepetitions()
|
// $query = $budget->limitrepetitions()
|
||||||
// // starts before start time, and the end also after start time.
|
// // starts before start time, and the end also after start time.
|
||||||
// ->where('limit_repetitions.enddate', '>=', $start->format('Y-m-d 00:00:00'))
|
// ->where('limit_repetitions.enddate', '>=', $start->format('Y-m-d 00:00:00'))
|
||||||
// ->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00'));
|
// ->where('limit_repetitions.startdate', '<=', $end->format('Y-m-d 00:00:00'));
|
||||||
// if (!is_null($ignore->id)) {
|
// if (!is_null($ignore->id)) {
|
||||||
// $query->where('limit_repetitions.id', '!=', $ignore->id);
|
// $query->where('limit_repetitions.id', '!=', $ignore->id);
|
||||||
// }
|
// }
|
||||||
// $data = $query->get(['limit_repetitions.*']);
|
// $data = $query->get(['limit_repetitions.*']);
|
||||||
//
|
//
|
||||||
// return $data;
|
// return $data;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param Carbon $start
|
// * @param Carbon $start
|
||||||
// * @param Carbon $end
|
// * @param Carbon $end
|
||||||
// * @param int $page
|
// * @param int $page
|
||||||
// * @param int $pageSize
|
// * @param int $pageSize
|
||||||
// *
|
// *
|
||||||
// * @return LengthAwarePaginator
|
// * @return LengthAwarePaginator
|
||||||
// */
|
// */
|
||||||
// public function getWithoutBudget(Carbon $start, Carbon $end, int $page, int $pageSize = 50): LengthAwarePaginator
|
// public function getWithoutBudget(Carbon $start, Carbon $end, int $page, int $pageSize = 50): LengthAwarePaginator
|
||||||
// {
|
// {
|
||||||
// $offset = ($page - 1) * $pageSize;
|
// $offset = ($page - 1) * $pageSize;
|
||||||
// $query = $this->user
|
// $query = $this->user
|
||||||
// ->transactionjournals()
|
// ->transactionjournals()
|
||||||
// ->expanded()
|
// ->expanded()
|
||||||
// ->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
// ->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
||||||
// ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
// ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
// ->whereNull('budget_transaction_journal.id')
|
// ->whereNull('budget_transaction_journal.id')
|
||||||
// ->before($end)
|
// ->before($end)
|
||||||
// ->after($start);
|
// ->after($start);
|
||||||
//
|
//
|
||||||
// $count = $query->count();
|
// $count = $query->count();
|
||||||
// $set = $query->take($pageSize)->offset($offset)->get(TransactionJournal::queryFields());
|
// $set = $query->take($pageSize)->offset($offset)->get(TransactionJournal::queryFields());
|
||||||
// $paginator = new LengthAwarePaginator($set, $count, $pageSize, $page);
|
// $paginator = new LengthAwarePaginator($set, $count, $pageSize, $page);
|
||||||
//
|
//
|
||||||
// return $paginator;
|
// return $paginator;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param Collection $accounts
|
// * @param Collection $accounts
|
||||||
// * @param Carbon $start
|
// * @param Carbon $start
|
||||||
// * @param Carbon $end
|
// * @param Carbon $end
|
||||||
// *
|
// *
|
||||||
// * @return Collection
|
// * @return Collection
|
||||||
// */
|
// */
|
||||||
// public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end): Collection
|
// public function getWithoutBudgetForAccounts(Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||||
// {
|
// {
|
||||||
// $ids = $accounts->pluck('id')->toArray();
|
// $ids = $accounts->pluck('id')->toArray();
|
||||||
//
|
//
|
||||||
// return $this->user
|
// return $this->user
|
||||||
// ->transactionjournals()
|
// ->transactionjournals()
|
||||||
// ->expanded()
|
// ->expanded()
|
||||||
// ->whereIn('source_account.id', $ids)
|
// ->whereIn('source_account.id', $ids)
|
||||||
// ->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
// ->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
||||||
// ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
// ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
// ->whereNull('budget_transaction_journal.id')
|
// ->whereNull('budget_transaction_journal.id')
|
||||||
// ->before($end)
|
// ->before($end)
|
||||||
// ->after($start)
|
// ->after($start)
|
||||||
// ->get(TransactionJournal::queryFields());
|
// ->get(TransactionJournal::queryFields());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param Collection $accounts
|
// * @param Collection $accounts
|
||||||
// * @param Carbon $start
|
// * @param Carbon $start
|
||||||
// * @param Carbon $end
|
// * @param Carbon $end
|
||||||
// *
|
// *
|
||||||
// * @return string
|
// * @return string
|
||||||
// */
|
// */
|
||||||
// public function getWithoutBudgetSum(Collection $accounts, Carbon $start, Carbon $end): string
|
// public function getWithoutBudgetSum(Collection $accounts, Carbon $start, Carbon $end): string
|
||||||
// {
|
// {
|
||||||
// $ids = $accounts->pluck('id')->toArray();
|
// $ids = $accounts->pluck('id')->toArray();
|
||||||
// $entry = $this->user
|
// $entry = $this->user
|
||||||
// ->transactionjournals()
|
// ->transactionjournals()
|
||||||
// ->whereNotIn(
|
// ->whereNotIn(
|
||||||
// 'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) {
|
// 'transaction_journals.id', function (QueryBuilder $query) use ($start, $end) {
|
||||||
// $query
|
// $query
|
||||||
// ->select('transaction_journals.id')
|
// ->select('transaction_journals.id')
|
||||||
// ->from('transaction_journals')
|
// ->from('transaction_journals')
|
||||||
// ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
// ->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
// ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
// ->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
||||||
// ->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'))
|
// ->where('transaction_journals.date', '<=', $end->format('Y-m-d 00:00:00'))
|
||||||
// ->whereNotNull('budget_transaction_journal.budget_id');
|
// ->whereNotNull('budget_transaction_journal.budget_id');
|
||||||
// }
|
// }
|
||||||
// )
|
// )
|
||||||
// ->after($start)
|
// ->after($start)
|
||||||
// ->before($end)
|
// ->before($end)
|
||||||
// ->leftJoin(
|
// ->leftJoin(
|
||||||
// 'transactions', function (JoinClause $join) {
|
// 'transactions', function (JoinClause $join) {
|
||||||
// $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0);
|
// $join->on('transactions.transaction_journal_id', '=', 'transaction_journals.id')->where('transactions.amount', '<', 0);
|
||||||
// }
|
// }
|
||||||
// )
|
// )
|
||||||
// ->whereIn('transactions.account_id', $ids)
|
// ->whereIn('transactions.account_id', $ids)
|
||||||
// //->having('transaction_count', '=', 1) TODO check if this still works
|
// //->having('transaction_count', '=', 1) TODO check if this still works
|
||||||
// ->transactionTypes([TransactionType::WITHDRAWAL])
|
// ->transactionTypes([TransactionType::WITHDRAWAL])
|
||||||
// ->first(
|
// ->first(
|
||||||
// [
|
// [
|
||||||
// DB::raw('SUM(`transactions`.`amount`) as `journalAmount`'),
|
// DB::raw('SUM(`transactions`.`amount`) as `journalAmount`'),
|
||||||
// DB::raw('COUNT(`transactions`.`id`) as `transaction_count`'),
|
// DB::raw('COUNT(`transactions`.`id`) as `transaction_count`'),
|
||||||
// ]
|
// ]
|
||||||
// );
|
// );
|
||||||
// if (is_null($entry)) {
|
// if (is_null($entry)) {
|
||||||
// return '0';
|
// return '0';
|
||||||
// }
|
// }
|
||||||
// if (is_null($entry->journalAmount)) {
|
// if (is_null($entry->journalAmount)) {
|
||||||
// return '0';
|
// return '0';
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return $entry->journalAmount;
|
// return $entry->journalAmount;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Returns an array with the following key:value pairs:
|
// * Returns an array with the following key:value pairs:
|
||||||
// *
|
// *
|
||||||
// * yyyy-mm-dd:<array>
|
// * yyyy-mm-dd:<array>
|
||||||
// *
|
// *
|
||||||
// * That array contains:
|
// * That array contains:
|
||||||
// *
|
// *
|
||||||
// * budgetid:<amount>
|
// * budgetid:<amount>
|
||||||
// *
|
// *
|
||||||
// * Where yyyy-mm-dd is the date and <amount> is the money spent using WITHDRAWALS in the $budget
|
// * Where yyyy-mm-dd is the date and <amount> is the money spent using WITHDRAWALS in the $budget
|
||||||
// * from the given users accounts..
|
// * from the given users accounts..
|
||||||
// *
|
// *
|
||||||
// * @param Collection $accounts
|
// * @param Collection $accounts
|
||||||
// * @param Carbon $start
|
// * @param Carbon $start
|
||||||
// * @param Carbon $end
|
// * @param Carbon $end
|
||||||
// *
|
// *
|
||||||
// * @return array
|
// * @return array
|
||||||
// */
|
// */
|
||||||
// public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end): array
|
// public function spentAllPerDayForAccounts(Collection $accounts, Carbon $start, Carbon $end): array
|
||||||
// {
|
// {
|
||||||
// $ids = $accounts->pluck('id')->toArray();
|
// $ids = $accounts->pluck('id')->toArray();
|
||||||
// /** @var Collection $query */
|
// /** @var Collection $query */
|
||||||
// $query = $this->user->transactionJournals()
|
// $query = $this->user->transactionJournals()
|
||||||
// ->transactionTypes([TransactionType::WITHDRAWAL])
|
// ->transactionTypes([TransactionType::WITHDRAWAL])
|
||||||
// ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
// ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
// ->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
|
// ->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
|
||||||
// ->whereIn('transactions.account_id', $ids)
|
// ->whereIn('transactions.account_id', $ids)
|
||||||
// ->where('transactions.amount', '<', 0)
|
// ->where('transactions.amount', '<', 0)
|
||||||
// ->before($end)
|
// ->before($end)
|
||||||
// ->after($start)
|
// ->after($start)
|
||||||
// ->groupBy('budget_id')
|
// ->groupBy('budget_id')
|
||||||
// ->groupBy('dateFormatted')
|
// ->groupBy('dateFormatted')
|
||||||
// ->get(
|
// ->get(
|
||||||
// ['transaction_journals.date as dateFormatted', 'budget_transaction_journal.budget_id',
|
// ['transaction_journals.date as dateFormatted', 'budget_transaction_journal.budget_id',
|
||||||
// DB::raw('SUM(`transactions`.`amount`) AS `sum`')]
|
// DB::raw('SUM(`transactions`.`amount`) AS `sum`')]
|
||||||
// );
|
// );
|
||||||
//
|
//
|
||||||
// $return = [];
|
// $return = [];
|
||||||
// foreach ($query->toArray() as $entry) {
|
// foreach ($query->toArray() as $entry) {
|
||||||
// $budgetId = $entry['budget_id'];
|
// $budgetId = $entry['budget_id'];
|
||||||
// if (!isset($return[$budgetId])) {
|
// if (!isset($return[$budgetId])) {
|
||||||
// $return[$budgetId] = [];
|
// $return[$budgetId] = [];
|
||||||
// }
|
// }
|
||||||
// $return[$budgetId][$entry['dateFormatted']] = $entry['sum'];
|
// $return[$budgetId][$entry['dateFormatted']] = $entry['sum'];
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return $return;
|
// return $return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Returns a list of expenses (in the field "spent", grouped per budget per account.
|
// * Returns a list of expenses (in the field "spent", grouped per budget per account.
|
||||||
// *
|
// *
|
||||||
// * @param Collection $budgets
|
// * @param Collection $budgets
|
||||||
// * @param Collection $accounts
|
// * @param Collection $accounts
|
||||||
// * @param Carbon $start
|
// * @param Carbon $start
|
||||||
// * @param Carbon $end
|
// * @param Carbon $end
|
||||||
// *
|
// *
|
||||||
// * @return Collection
|
// * @return Collection
|
||||||
// */
|
// */
|
||||||
// public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): Collection
|
// public function spentPerBudgetPerAccount(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||||
// {
|
// {
|
||||||
// $accountIds = $accounts->pluck('id')->toArray();
|
// $accountIds = $accounts->pluck('id')->toArray();
|
||||||
// $budgetIds = $budgets->pluck('id')->toArray();
|
// $budgetIds = $budgets->pluck('id')->toArray();
|
||||||
// $set = $this->user->transactionjournals()
|
// $set = $this->user->transactionjournals()
|
||||||
// ->leftJoin(
|
// ->leftJoin(
|
||||||
// 'transactions AS t_from', function (JoinClause $join) {
|
// 'transactions AS t_from', function (JoinClause $join) {
|
||||||
// $join->on('transaction_journals.id', '=', 't_from.transaction_journal_id')->where('t_from.amount', '<', 0);
|
// $join->on('transaction_journals.id', '=', 't_from.transaction_journal_id')->where('t_from.amount', '<', 0);
|
||||||
// }
|
// }
|
||||||
// )
|
// )
|
||||||
// ->leftJoin(
|
// ->leftJoin(
|
||||||
// 'transactions AS t_to', function (JoinClause $join) {
|
// 'transactions AS t_to', function (JoinClause $join) {
|
||||||
// $join->on('transaction_journals.id', '=', 't_to.transaction_journal_id')->where('t_to.amount', '>', 0);
|
// $join->on('transaction_journals.id', '=', 't_to.transaction_journal_id')->where('t_to.amount', '>', 0);
|
||||||
// }
|
// }
|
||||||
// )
|
// )
|
||||||
// ->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
|
// ->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
|
||||||
// ->whereIn('t_from.account_id', $accountIds)
|
// ->whereIn('t_from.account_id', $accountIds)
|
||||||
// ->whereNotIn('t_to.account_id', $accountIds)
|
// ->whereNotIn('t_to.account_id', $accountIds)
|
||||||
// ->where(
|
// ->where(
|
||||||
// function (Builder $q) use ($budgetIds) {
|
// function (Builder $q) use ($budgetIds) {
|
||||||
// $q->whereIn('budget_transaction_journal.budget_id', $budgetIds);
|
// $q->whereIn('budget_transaction_journal.budget_id', $budgetIds);
|
||||||
// $q->orWhereNull('budget_transaction_journal.budget_id');
|
// $q->orWhereNull('budget_transaction_journal.budget_id');
|
||||||
// }
|
// }
|
||||||
// )
|
// )
|
||||||
// ->after($start)
|
// ->after($start)
|
||||||
// ->before($end)
|
// ->before($end)
|
||||||
// ->groupBy('t_from.account_id')
|
// ->groupBy('t_from.account_id')
|
||||||
// ->groupBy('budget_transaction_journal.budget_id')
|
// ->groupBy('budget_transaction_journal.budget_id')
|
||||||
// ->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])// opening balance is not an expense.
|
// ->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])// opening balance is not an expense.
|
||||||
// ->get(
|
// ->get(
|
||||||
// [
|
// [
|
||||||
// 't_from.account_id', 'budget_transaction_journal.budget_id',
|
// 't_from.account_id', 'budget_transaction_journal.budget_id',
|
||||||
// DB::raw('SUM(`t_from`.`amount`) AS `spent`'),
|
// DB::raw('SUM(`t_from`.`amount`) AS `spent`'),
|
||||||
// ]
|
// ]
|
||||||
// );
|
// );
|
||||||
//
|
//
|
||||||
// return $set;
|
// return $set;
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Returns an array with the following key:value pairs:
|
// * Returns an array with the following key:value pairs:
|
||||||
// *
|
// *
|
||||||
// * yyyy-mm-dd:<amount>
|
// * yyyy-mm-dd:<amount>
|
||||||
// *
|
// *
|
||||||
// * Where yyyy-mm-dd is the date and <amount> is the money spent using DEPOSITS in the $budget
|
// * Where yyyy-mm-dd is the date and <amount> is the money spent using DEPOSITS in the $budget
|
||||||
// * from all the users accounts.
|
// * from all the users accounts.
|
||||||
// *
|
// *
|
||||||
// * @param Budget $budget
|
// * @param Budget $budget
|
||||||
// * @param Carbon $start
|
// * @param Carbon $start
|
||||||
// * @param Carbon $end
|
// * @param Carbon $end
|
||||||
// * @param Collection $accounts
|
// * @param Collection $accounts
|
||||||
// *
|
// *
|
||||||
// * @return array
|
// * @return array
|
||||||
// */
|
// */
|
||||||
// public function spentPerDay(Budget $budget, Carbon $start, Carbon $end, Collection $accounts): array
|
// public function spentPerDay(Budget $budget, Carbon $start, Carbon $end, Collection $accounts): array
|
||||||
// {
|
// {
|
||||||
// /** @var Collection $query */
|
// /** @var Collection $query */
|
||||||
// $query = $budget->transactionjournals()
|
// $query = $budget->transactionjournals()
|
||||||
// ->transactionTypes([TransactionType::WITHDRAWAL])
|
// ->transactionTypes([TransactionType::WITHDRAWAL])
|
||||||
// ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
// ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
// ->where('transactions.amount', '<', 0)
|
// ->where('transactions.amount', '<', 0)
|
||||||
// ->before($end)
|
// ->before($end)
|
||||||
// ->after($start)
|
// ->after($start)
|
||||||
// ->groupBy('dateFormatted')->get(['transaction_journals.date as dateFormatted', DB::raw('SUM(`transactions`.`amount`) AS `sum`')]);
|
// ->groupBy('dateFormatted')->get(['transaction_journals.date as dateFormatted', DB::raw('SUM(`transactions`.`amount`) AS `sum`')]);
|
||||||
//
|
//
|
||||||
// $return = [];
|
// $return = [];
|
||||||
// foreach ($query->toArray() as $entry) {
|
// foreach ($query->toArray() as $entry) {
|
||||||
// $return[$entry['dateFormatted']] = $entry['sum'];
|
// $return[$entry['dateFormatted']] = $entry['sum'];
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // also search transactions:
|
// // also search transactions:
|
||||||
// $query = $budget->transactions()
|
// $query = $budget->transactions()
|
||||||
// ->transactionTypes([TransactionType::WITHDRAWAL])
|
// ->transactionTypes([TransactionType::WITHDRAWAL])
|
||||||
// ->where('transactions.amount', '<', 0)
|
// ->where('transactions.amount', '<', 0)
|
||||||
// ->before($end)
|
// ->before($end)
|
||||||
// ->after($start)
|
// ->after($start)
|
||||||
// ->groupBy('dateFormatted')->get(['transaction_journals.date as dateFormatted', DB::raw('SUM(`transactions`.`amount`) AS `sum`')]);
|
// ->groupBy('dateFormatted')->get(['transaction_journals.date as dateFormatted', DB::raw('SUM(`transactions`.`amount`) AS `sum`')]);
|
||||||
// foreach ($query as $newEntry) {
|
// foreach ($query as $newEntry) {
|
||||||
// // add to return array.
|
// // add to return array.
|
||||||
// $date = $newEntry['dateFormatted'];
|
// $date = $newEntry['dateFormatted'];
|
||||||
// if (isset($return[$date])) {
|
// if (isset($return[$date])) {
|
||||||
// $return[$date] = bcadd($newEntry['sum'], $return[$date]);
|
// $return[$date] = bcadd($newEntry['sum'], $return[$date]);
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// $return[$date] = $newEntry['sum'];
|
// $return[$date] = $newEntry['sum'];
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return $return;
|
// return $return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $budgets
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function journalsInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||||
|
{
|
||||||
|
$return = new Collection;
|
||||||
|
$accountIds = [];
|
||||||
|
if ($accounts->count() > 0) {
|
||||||
|
$accountIds = $accounts->pluck('id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
// first get all journals for all budget(s):
|
||||||
|
$journalQuery = $this->user->transactionjournals()
|
||||||
|
->expanded()
|
||||||
|
->before($end)
|
||||||
|
->after($start)
|
||||||
|
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
|
->whereIn('budget_transaction_journal.budget_id', $budgets->pluck('id')->toArray());
|
||||||
|
// add account id's, if relevant:
|
||||||
|
if (count($accountIds) > 0) {
|
||||||
|
$journalQuery->leftJoin('transactions as source', 'source.transaction_journal_id', '=', 'transaction_journals.id');
|
||||||
|
$journalQuery->whereIn('source.account_id', $accountIds);
|
||||||
|
}
|
||||||
|
// get them:
|
||||||
|
$journals = $journalQuery->get(TransactionJournal::queryFields());
|
||||||
|
Log::debug('journalsInPeriod journal count is ' . $journals->count());
|
||||||
|
|
||||||
|
// then get transactions themselves.
|
||||||
|
$transactionQuery = $this->user->transactionjournals()
|
||||||
|
->expanded()
|
||||||
|
->before($end)
|
||||||
|
->after($start)
|
||||||
|
->leftJoin('transactions as related', 'related.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
|
->leftJoin('budget_transaction', 'budget_transaction.transaction_id', '=', 'related.id')
|
||||||
|
->whereIn('budget_transaction.budget_id', $budgets->pluck('id')->toArray());
|
||||||
|
|
||||||
|
if (count($accountIds) > 0) {
|
||||||
|
$transactionQuery->leftJoin('transactions as source', 'source.transaction_journal_id', '=', 'transaction_journals.id');
|
||||||
|
$transactionQuery->whereIn('source.account_id', $accountIds);
|
||||||
|
}
|
||||||
|
$transactions = $transactionQuery->get(TransactionJournal::queryFields());
|
||||||
|
|
||||||
|
// return complete set:
|
||||||
|
$return = $return->merge($transactions);
|
||||||
|
$return = $return->merge($journals);
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function journalsInPeriodWithoutBudget(Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||||
|
{
|
||||||
|
/** @var Collection $set */
|
||||||
|
$set = $this->user
|
||||||
|
->transactionjournals()
|
||||||
|
->expanded()
|
||||||
|
->transactionTypes([TransactionType::WITHDRAWAL])
|
||||||
|
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
|
->whereNull('budget_transaction_journal.id')
|
||||||
|
->before($end)
|
||||||
|
->after($start)->with(
|
||||||
|
[
|
||||||
|
'transactions' => function (HasMany $query) {
|
||||||
|
$query->where('transactions.amount', '<', 0);
|
||||||
|
},
|
||||||
|
'transactions.budgets',
|
||||||
|
]
|
||||||
|
)->get(TransactionJournal::queryFields());
|
||||||
|
|
||||||
|
$set = $set->filter(
|
||||||
|
function (TransactionJournal $journal) {
|
||||||
|
foreach ($journal->transactions as $t) {
|
||||||
|
if ($t->budgets->count() === 0) {
|
||||||
|
return $journal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return $set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $budgets
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end) : string
|
||||||
|
{
|
||||||
|
$set = $this->journalsInPeriod($budgets, $accounts, $start, $end);
|
||||||
|
Log::debug('spentInPeriod set count is ' . $set->count());
|
||||||
|
$sum = '0';
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
foreach ($set as $journal) {
|
||||||
|
$sum = bcadd($sum, TransactionJournal::amount($journal));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sum;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
@@ -16,6 +16,13 @@ use Illuminate\Support\Collection;
|
|||||||
interface BudgetRepositoryInterface
|
interface BudgetRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Budget $budget
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function destroy(Budget $budget): bool;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// *
|
// *
|
||||||
// * Same as ::spentInPeriod but corrects journals for a set of accounts
|
// * Same as ::spentInPeriod but corrects journals for a set of accounts
|
||||||
@@ -35,11 +42,13 @@ interface BudgetRepositoryInterface
|
|||||||
// public function cleanupBudgets(): bool;
|
// public function cleanupBudgets(): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Budget $budget
|
* Find a budget.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @param int $budgetId
|
||||||
|
*
|
||||||
|
* @return Budget
|
||||||
*/
|
*/
|
||||||
public function destroy(Budget $budget): bool;
|
public function find(int $budgetId): Budget;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param Budget $budget
|
// * @param Budget $budget
|
||||||
@@ -52,13 +61,9 @@ interface BudgetRepositoryInterface
|
|||||||
// public function expensesSplit(Budget $budget, Account $account, Carbon $start, Carbon $end): Collection;
|
// public function expensesSplit(Budget $budget, Account $account, Carbon $start, Carbon $end): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a budget.
|
* @return Collection
|
||||||
*
|
|
||||||
* @param int $budgetId
|
|
||||||
*
|
|
||||||
* @return Budget
|
|
||||||
*/
|
*/
|
||||||
public function find(int $budgetId): Budget;
|
public function getActiveBudgets(): Collection;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param Budget $budget
|
// * @param Budget $budget
|
||||||
@@ -67,11 +72,6 @@ interface BudgetRepositoryInterface
|
|||||||
// */
|
// */
|
||||||
// public function firstActivity(Budget $budget): Carbon;
|
// public function firstActivity(Budget $budget): Carbon;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getActiveBudgets(): Collection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
@@ -80,6 +80,11 @@ interface BudgetRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end): Collection;
|
public function getAllBudgetLimitRepetitions(Carbon $start, Carbon $end): Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getBudgets(): Collection;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param Account $account
|
// * @param Account $account
|
||||||
// * @param Collection $accounts
|
// * @param Collection $accounts
|
||||||
@@ -104,7 +109,7 @@ interface BudgetRepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getBudgets(): Collection;
|
public function getInactiveBudgets(): Collection;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Returns an array with every budget in it and the expenses for each budget
|
// * Returns an array with every budget in it and the expenses for each budget
|
||||||
@@ -186,9 +191,33 @@ interface BudgetRepositoryInterface
|
|||||||
// public function getFirstBudgetLimitDate(Budget $budget):Carbon;
|
// public function getFirstBudgetLimitDate(Budget $budget):Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Collection $budgets
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getInactiveBudgets(): Collection;
|
public function journalsInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function journalsInPeriodWithoutBudget(Collection $accounts, Carbon $start, Carbon $end): Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $budgets
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end) : string;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Returns all the transaction journals for a limit, possibly limited by a limit repetition.
|
// * Returns all the transaction journals for a limit, possibly limited by a limit repetition.
|
||||||
|
@@ -132,8 +132,8 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
if (count($types) > 0) {
|
if (count($types) > 0) {
|
||||||
$query->transactionTypes($types);
|
$query->transactionTypes($types);
|
||||||
}
|
}
|
||||||
|
$count = $this->user->transactionJournals()->transactionTypes($types)->count();
|
||||||
$count = $query->count();
|
Log::debug('getJournals() count: ' . $count);
|
||||||
$set = $query->take($pageSize)->offset($offset)->get(TransactionJournal::queryFields());
|
$set = $query->take($pageSize)->offset($offset)->get(TransactionJournal::queryFields());
|
||||||
$journals = new LengthAwarePaginator($set, $count, $pageSize, $page);
|
$journals = new LengthAwarePaginator($set, $count, $pageSize, $page);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user