mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Take page size into account.
This commit is contained in:
parent
e293d69798
commit
98c057c516
@ -194,7 +194,9 @@ class BudgetController extends Controller
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
|
||||
$list = $repository->getWithoutBudget($start, $end);
|
||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$list = $repository->getWithoutBudget($start, $end, $page, $pageSize);
|
||||
$subTitle = trans(
|
||||
'firefly.without_budget_between',
|
||||
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||
@ -235,18 +237,21 @@ class BudgetController extends Controller
|
||||
throw new FireflyException('This budget limit is not part of this budget.');
|
||||
}
|
||||
|
||||
$journals = $repository->getJournals($budget, $repetition, 50);
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$journals = $repository->getJournals($budget, $repetition, $pageSize);
|
||||
|
||||
if (is_null($repetition->id)) {
|
||||
$start = $repository->firstActivity($budget);
|
||||
$end = new Carbon;
|
||||
$set = $budget->limitrepetitions()->orderBy('startdate', 'DESC')->get();
|
||||
$subTitle = e($budget->name);
|
||||
$journals->setPath('/budgets/show/' . $budget->id);
|
||||
} else {
|
||||
$start = $repetition->startdate;
|
||||
$end = $repetition->enddate;
|
||||
$set = new Collection([$repetition]);
|
||||
$subTitle = trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)]);
|
||||
$journals->setPath('/budgets/show/' . $budget->id . '/' . $repetition->id);
|
||||
}
|
||||
|
||||
$spentArray = $repository->spentPerDay($budget, $start, $end);
|
||||
@ -258,7 +263,6 @@ class BudgetController extends Controller
|
||||
$limits->push($entry);
|
||||
}
|
||||
|
||||
$journals->setPath('/budgets/show/' . $budget->id);
|
||||
|
||||
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
{
|
||||
// delete limits with amount 0:
|
||||
BudgetLimit::where('amount', 0)->delete();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -411,7 +412,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
->where('limit_repetitions.startdate', $start->format('Y-m-d 00:00:00'))
|
||||
->where('limit_repetitions.enddate', $end->format('Y-m-d 00:00:00'))
|
||||
->first(['limit_repetitions.*']);
|
||||
if(is_null($data)) {
|
||||
if (is_null($data)) {
|
||||
return new LimitRepetition;
|
||||
}
|
||||
|
||||
@ -540,20 +541,28 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param int $page
|
||||
* @param int $pageSize
|
||||
*
|
||||
* @return Collection
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end): Collection
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end, int $page, int $pageSize = 50): LengthAwarePaginator
|
||||
{
|
||||
return $this->user
|
||||
$offset = ($page - 1) * $pageSize;
|
||||
$query = $this->user
|
||||
->transactionjournals()
|
||||
->expanded()
|
||||
->where('transaction_types.type', TransactionType::WITHDRAWAL)
|
||||
->leftJoin('budget_transaction_journal', 'budget_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->whereNull('budget_transaction_journal.id')
|
||||
->before($end)
|
||||
->after($start)
|
||||
->get(TransactionJournal::QUERYFIELDS);
|
||||
->after($start);
|
||||
|
||||
$count = $query->count();
|
||||
$set = $query->take($pageSize)->offset($offset)->get(TransactionJournal::QUERYFIELDS);
|
||||
$paginator = new LengthAwarePaginator($set, $count, $pageSize, $page);
|
||||
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,10 +204,12 @@ interface BudgetRepositoryInterface
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param int $page
|
||||
* @param int $pageSize
|
||||
*
|
||||
* @return Collection
|
||||
* @return LengthAwarePaginator
|
||||
*/
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end): Collection;
|
||||
public function getWithoutBudget(Carbon $start, Carbon $end, int $page, int $pageSize = 50): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
|
@ -38,7 +38,7 @@
|
||||
<h3 class="box-title">{{ 'transactions'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding">
|
||||
{% include 'list/journals.twig' with {sorting:true} %}
|
||||
{% include 'list/journals' with {sorting:true} %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user