Gave method old name back.

This commit is contained in:
James Cole
2017-01-05 09:08:35 +01:00
parent 8e8b011587
commit 2d8ca363db
6 changed files with 13 additions and 13 deletions

View File

@@ -158,7 +158,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
foreach ($accounts as $account) { foreach ($accounts as $account) {
$balanceEntry = new BalanceEntry; $balanceEntry = new BalanceEntry;
$balanceEntry->setAccount($account); $balanceEntry->setAccount($account);
$spent = $this->budgetRepository->spentInPeriodCollector(new Collection([$budgetLimit->budget]), new Collection([$account]), $budgetLimit->start_date, $budgetLimit->end_date); $spent = $this->budgetRepository->spentInPeriod(new Collection([$budgetLimit->budget]), new Collection([$account]), $budgetLimit->start_date, $budgetLimit->end_date);
$balanceEntry->setSpent($spent); $balanceEntry->setSpent($spent);
$line->addBalanceEntry($balanceEntry); $line->addBalanceEntry($balanceEntry);
} }

View File

@@ -59,7 +59,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
foreach ($set as $budget) { foreach ($set as $budget) {
$budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end); $budgetLimits = $this->repository->getBudgetLimits($budget, $start, $end);
if ($budgetLimits->count() == 0) { // no budget limit(s) for this budget if ($budgetLimits->count() == 0) { // no budget limit(s) for this budget
$spent = $this->repository->spentInPeriodCollector(new Collection([$budget]), $accounts, $start, $end);// spent for budget in time range $spent = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end);// spent for budget in time range
if ($spent > 0) { if ($spent > 0) {
$budgetLine = new BudgetLine; $budgetLine = new BudgetLine;
$budgetLine->setBudget($budget)->setOverspent($spent); $budgetLine->setBudget($budget)->setOverspent($spent);
@@ -104,7 +104,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
$set = new Collection; $set = new Collection;
/** @var Budget $budget */ /** @var Budget $budget */
foreach ($budgets as $budget) { foreach ($budgets as $budget) {
$total = $repository->spentInPeriodCollector(new Collection([$budget]), $accounts, $start, $end); $total = $repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end);
if (bccomp($total, '0') === -1) { if (bccomp($total, '0') === -1) {
$set->push($budget); $set->push($budget);
} }
@@ -128,7 +128,7 @@ class BudgetReportHelper implements BudgetReportHelperInterface
private function calculateExpenses(Budget $budget, BudgetLimit $budgetLimit, Collection $accounts): array private function calculateExpenses(Budget $budget, BudgetLimit $budgetLimit, Collection $accounts): array
{ {
$array = []; $array = [];
$expenses = $this->repository->spentInPeriodCollector(new Collection([$budget]), $accounts, $budgetLimit->start_date, $budgetLimit->end_date); $expenses = $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $budgetLimit->start_date, $budgetLimit->end_date);
$array['left'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? bcadd($budgetLimit->amount, $expenses) : '0'; $array['left'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? bcadd($budgetLimit->amount, $expenses) : '0';
$array['spent'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? $expenses : '0'; $array['spent'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? $expenses : '0';
$array['overspent'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? '0' : bcadd($expenses, $budgetLimit->amount); $array['overspent'] = bccomp(bcadd($budgetLimit->amount, $expenses), '0') === 1 ? '0' : bcadd($expenses, $budgetLimit->amount);

View File

@@ -268,7 +268,7 @@ class BudgetController extends Controller
/** @var BudgetLimit $entry */ /** @var BudgetLimit $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
$entry->spent = $repository->spentInPeriodCollector(new Collection([$budget]), $accounts, $entry->start_date, $entry->end_date); $entry->spent = $repository->spentInPeriod(new Collection([$budget]), $accounts, $entry->start_date, $entry->end_date);
$limits->push($entry); $limits->push($entry);
} }
@@ -313,7 +313,7 @@ class BudgetController extends Controller
$journals->setPath('/budgets/show/' . $budget->id . '/' . $budgetLimit->id); $journals->setPath('/budgets/show/' . $budget->id . '/' . $budgetLimit->id);
$budgetLimit->spent = $repository->spentInPeriodCollector(new Collection([$budget]), $accounts, $budgetLimit->start_date, $budgetLimit->end_date); $budgetLimit->spent = $repository->spentInPeriod(new Collection([$budget]), $accounts, $budgetLimit->start_date, $budgetLimit->end_date);
$limits = new Collection([$budgetLimit]); $limits = new Collection([$budgetLimit]);
return view('budgets.show', compact('limits', 'budget', 'budgetLimit', 'journals', 'subTitle')); return view('budgets.show', compact('limits', 'budget', 'budgetLimit', 'journals', 'subTitle'));
@@ -405,7 +405,7 @@ class BudgetController extends Controller
foreach ($budgets as $budget) { foreach ($budgets as $budget) {
$budgetId = $budget->id; $budgetId = $budget->id;
$return[$budgetId] = [ $return[$budgetId] = [
'spent' => $this->repository->spentInPeriodCollector(new Collection([$budget]), $accounts, $start, $end), 'spent' => $this->repository->spentInPeriod(new Collection([$budget]), $accounts, $start, $end),
'budgeted' => '0', 'budgeted' => '0',
'currentRep' => false, 'currentRep' => false,
]; ];

View File

@@ -95,7 +95,7 @@ class BudgetController extends Controller
$currentEnd = Navigation::endOfPeriod($first, $range); $currentEnd = Navigation::endOfPeriod($first, $range);
// sub another day because reasons. // sub another day because reasons.
$currentEnd->subDay(); $currentEnd->subDay();
$spent = $this->repository->spentInPeriodCollector($budgetCollection, new Collection, $currentStart, $currentEnd); $spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $currentStart, $currentEnd);
$format = Navigation::periodShow($first, $range); $format = Navigation::periodShow($first, $range);
$entries[$format] = bcmul($spent, '-1'); $entries[$format] = bcmul($spent, '-1');
$first = Navigation::addPeriod($first, $range, 0); $first = Navigation::addPeriod($first, $range, 0);
@@ -140,7 +140,7 @@ class BudgetController extends Controller
$amount = $budgetLimit->amount; $amount = $budgetLimit->amount;
$budgetCollection = new Collection([$budget]); $budgetCollection = new Collection([$budget]);
while ($start <= $end) { while ($start <= $end) {
$spent = $this->repository->spentInPeriodCollector($budgetCollection, new Collection, $start, $start); $spent = $this->repository->spentInPeriod($budgetCollection, new Collection, $start, $start);
$amount = bcadd($amount, $spent); $amount = bcadd($amount, $spent);
$format = $start->formatLocalized(strval(trans('config.month_and_day'))); $format = $start->formatLocalized(strval(trans('config.month_and_day')));
$entries[$format] = $amount; $entries[$format] = $amount;
@@ -329,7 +329,7 @@ class BudgetController extends Controller
{ {
$return = []; $return = [];
if ($limits->count() === 0) { if ($limits->count() === 0) {
$spent = $this->repository->spentInPeriodCollector(new Collection([$budget]), new Collection, $start, $end); $spent = $this->repository->spentInPeriod(new Collection([$budget]), new Collection, $start, $end);
if (bccomp($spent, '0') !== 0) { if (bccomp($spent, '0') !== 0) {
$return[$budget->name]['spent'] = bcmul($spent, '-1'); $return[$budget->name]['spent'] = bcmul($spent, '-1');
$return[$budget->name]['left'] = 0; $return[$budget->name]['left'] = 0;
@@ -375,7 +375,7 @@ class BudgetController extends Controller
$name = $budget->name; $name = $budget->name;
/** @var BudgetLimit $budgetLimit */ /** @var BudgetLimit $budgetLimit */
foreach ($limits as $budgetLimit) { foreach ($limits as $budgetLimit) {
$expenses = $this->repository->spentInPeriodCollector(new Collection([$budget]), new Collection, $budgetLimit->start_date, $budgetLimit->end_date); $expenses = $this->repository->spentInPeriod(new Collection([$budget]), new Collection, $budgetLimit->start_date, $budgetLimit->end_date);
if ($limits->count() > 1) { if ($limits->count() > 1) {
$name = $budget->name . ' ' . trans( $name = $budget->name . ' ' . trans(

View File

@@ -441,7 +441,7 @@ class BudgetRepository implements BudgetRepositoryInterface
* *
* @return string * @return string
*/ */
public function spentInPeriodCollector(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string
{ {
/** @var JournalCollectorInterface $collector */ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class, [$this->user]); $collector = app(JournalCollectorInterface::class, [$this->user]);

View File

@@ -157,7 +157,7 @@ interface BudgetRepositoryInterface
* *
* @return string * @return string
*/ */
public function spentInPeriodCollector(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string; public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string;
/** /**
* @param Collection $accounts * @param Collection $accounts