Updates to budgets.

This commit is contained in:
James Cole
2016-04-28 10:59:36 +02:00
parent 19d7e27fa9
commit b47a140c2f
20 changed files with 510 additions and 182 deletions

View File

@@ -47,9 +47,18 @@ class BudgetController extends Controller
public function amount(BudgetRepositoryInterface $repository, Budget $budget)
{
$amount = intval(Input::get('amount'));
/** @var Carbon $date */
$date = session('start', Carbon::now()->startOfMonth());
$limitRepetition = $repository->updateLimitAmount($budget, $date, $amount);
/** @var Carbon $start */
$start = session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
$end = session('end', Carbon::now()->endOfMonth());
$viewRange = Preferences::get('viewRange', '1M')->data;
// is custom view range?
if (session('is_custom_range') === true) {
$viewRange = 'custom';
}
$limitRepetition = $repository->updateLimitAmount($budget, $start, $end, $viewRange, $amount);
if ($amount == 0) {
$limitRepetition = null;
}
@@ -160,14 +169,6 @@ class BudgetController extends Controller
$periodEnd = $end->formatLocalized($this->monthAndDayFormat);
$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);
/**
* Warn user if necessary
*/
$userWarning = '';
if (session('is_custom_range', false) === true) {
$userWarning = strval(trans('firefly.warn_range_' . $repeatFreq));
}
/**
* Do some cleanup:
*/
@@ -195,7 +196,7 @@ class BudgetController extends Controller
'budgetMaximum', 'periodStart', 'periodEnd',
'period', 'range', 'budgetIncomeTotal',
'defaultCurrency', 'inactive', 'budgets',
'spent', 'budgeted', 'userWarning'
'spent', 'budgeted'
)
);
}