mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix nullpointers.
This commit is contained in:
commit
2f9724e7ca
@ -137,14 +137,19 @@ class BudgetLimitController extends Controller
|
|||||||
}
|
}
|
||||||
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||||
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||||
|
$amount = (string)$request->get('amount');
|
||||||
$start->startOfDay();
|
$start->startOfDay();
|
||||||
$end->startOfDay();
|
$end->startOfDay();
|
||||||
|
|
||||||
|
if ('' === $amount) {
|
||||||
|
return response()->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
Log::debug(sprintf('Start: %s, end: %s', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
Log::debug(sprintf('Start: %s, end: %s', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||||
|
|
||||||
$limit = $this->blRepository->find($budget, $currency, $start, $end);
|
$limit = $this->blRepository->find($budget, $currency, $start, $end);
|
||||||
if (null !== $limit) {
|
if (null !== $limit) {
|
||||||
$limit->amount = $request->get('amount');
|
$limit->amount = $amount;
|
||||||
$limit->save();
|
$limit->save();
|
||||||
}
|
}
|
||||||
if (null === $limit) {
|
if (null === $limit) {
|
||||||
@ -154,7 +159,7 @@ class BudgetLimitController extends Controller
|
|||||||
'currency_id' => (int)$request->get('transaction_currency_id'),
|
'currency_id' => (int)$request->get('transaction_currency_id'),
|
||||||
'start_date' => $start,
|
'start_date' => $start,
|
||||||
'end_date' => $end,
|
'end_date' => $end,
|
||||||
'amount' => $request->get('amount'),
|
'amount' => $amount,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -176,7 +181,7 @@ class BudgetLimitController extends Controller
|
|||||||
return response()->json($array);
|
return response()->json($array);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route('budgets.index', [$start->format('Y-m-d'), $end->format('Y-m-d')]));
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,7 +192,10 @@ class BudgetLimitController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(Request $request, BudgetLimit $budgetLimit): JsonResponse
|
public function update(Request $request, BudgetLimit $budgetLimit): JsonResponse
|
||||||
{
|
{
|
||||||
$amount = $request->get('amount');
|
$amount = (string)$request->get('amount');
|
||||||
|
if ('' === $amount) {
|
||||||
|
$amount = '0';
|
||||||
|
}
|
||||||
|
|
||||||
$limit = $this->blRepository->update($budgetLimit, ['amount' => $amount]);
|
$limit = $this->blRepository->update($budgetLimit, ['amount' => $amount]);
|
||||||
$array = $limit->toArray();
|
$array = $limit->toArray();
|
||||||
|
@ -65,7 +65,7 @@ class BudgetFormStoreRequest extends FormRequest
|
|||||||
'active' => 'numeric|between:0,1',
|
'active' => 'numeric|between:0,1',
|
||||||
'auto_budget_type' => 'numeric|between:0,2',
|
'auto_budget_type' => 'numeric|between:0,2',
|
||||||
'auto_budget_currency_id' => 'exists:transaction_currencies,id',
|
'auto_budget_currency_id' => 'exists:transaction_currencies,id',
|
||||||
'auto_budget_amount' => 'min:0|max:1000000000',
|
'auto_budget_amount' => 'min:0|max:1000000000|required_if:auto_budget_type,1|required_if:auto_budget_type,2',
|
||||||
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
|
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ class BudgetFormUpdateRequest extends FormRequest
|
|||||||
'active' => 'numeric|between:0,1',
|
'active' => 'numeric|between:0,1',
|
||||||
'auto_budget_type' => 'numeric|between:0,2',
|
'auto_budget_type' => 'numeric|between:0,2',
|
||||||
'auto_budget_currency_id' => 'exists:transaction_currencies,id',
|
'auto_budget_currency_id' => 'exists:transaction_currencies,id',
|
||||||
'auto_budget_amount' => 'min:0|max:1000000000',
|
'auto_budget_amount' => 'min:0|max:1000000000|required_if:auto_budget_type,1|required_if:auto_budget_type,2',
|
||||||
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
|
'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user