mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fixed a bug in the budget controller.
This commit is contained in:
parent
8b085af6a1
commit
0faef542c1
@ -22,6 +22,9 @@ use URL;
|
|||||||
class BudgetController extends Controller
|
class BudgetController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
View::share('title', 'Budgets');
|
View::share('title', 'Budgets');
|
||||||
@ -32,7 +35,6 @@ class BudgetController extends Controller
|
|||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function amount(Budget $budget, BudgetRepositoryInterface $repository)
|
public function amount(Budget $budget, BudgetRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
|
@ -120,10 +120,12 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function updateLimitAmount(Budget $budget, Carbon $date, $amount)
|
public function updateLimitAmount(Budget $budget, Carbon $date, $amount)
|
||||||
{
|
{
|
||||||
|
// there should be a budget limit for this startdate:
|
||||||
/** @var BudgetLimit $limit */
|
/** @var BudgetLimit $limit */
|
||||||
$limit = $budget->limitrepetitions()->where('limit_repetitions.startdate', $date)->first(['limit_repetitions.*']);
|
$limit = $budget->budgetlimits()->where('budget_limits.startdate', $date)->first(['budget_limits.*']);
|
||||||
|
|
||||||
if (!$limit) {
|
if (!$limit) {
|
||||||
// create one!
|
// if not, create one!
|
||||||
$limit = new BudgetLimit;
|
$limit = new BudgetLimit;
|
||||||
$limit->budget()->associate($budget);
|
$limit->budget()->associate($budget);
|
||||||
$limit->startdate = $date;
|
$limit->startdate = $date;
|
||||||
@ -131,6 +133,10 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
$limit->repeat_freq = 'monthly';
|
$limit->repeat_freq = 'monthly';
|
||||||
$limit->repeats = 0;
|
$limit->repeats = 0;
|
||||||
$limit->save();
|
$limit->save();
|
||||||
|
|
||||||
|
// likewise, there should be a limit repetition to match the end date
|
||||||
|
// (which is always the end of the month) but that is caught by an event.
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ($amount > 0) {
|
if ($amount > 0) {
|
||||||
$limit->amount = $amount;
|
$limit->amount = $amount;
|
||||||
|
Loading…
Reference in New Issue
Block a user