mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-15 06:08:16 +00:00
Various nestor-related fixes.
This commit is contained in:
@@ -143,13 +143,13 @@ class BudgetLimitController extends Controller
|
||||
// first search for existing one and update it if necessary.
|
||||
$currency = $this->currencyRepos->find((int) $request->get('transaction_currency_id'));
|
||||
$budget = $this->repository->find((int) $request->get('budget_id'));
|
||||
if (null === $currency || null === $budget) {
|
||||
if (!$currency instanceof TransactionCurrency || !$budget instanceof Budget) {
|
||||
throw new FireflyException('No valid currency or budget.');
|
||||
}
|
||||
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||
|
||||
if (null === $start || null === $end) {
|
||||
if (!$start instanceof Carbon || !$end instanceof Carbon) {
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ class BudgetLimitController extends Controller
|
||||
|
||||
// sanity check on amount:
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
if (null !== $limit) {
|
||||
if ($limit instanceof BudgetLimit) {
|
||||
$this->blRepository->destroyBudgetLimit($limit);
|
||||
}
|
||||
|
||||
@@ -181,11 +181,11 @@ class BudgetLimitController extends Controller
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
|
||||
if (null !== $limit) {
|
||||
if ($limit instanceof BudgetLimit) {
|
||||
$limit->amount = $amount;
|
||||
$limit->save();
|
||||
}
|
||||
if (null === $limit) {
|
||||
if (!$limit instanceof BudgetLimit) {
|
||||
$limit = $this->blRepository->store(
|
||||
[
|
||||
'budget_id' => $request->get('budget_id'),
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Budget;
|
||||
|
||||
use FireflyIII\Models\AutoBudget;
|
||||
use FireflyIII\Enums\AutoBudgetType;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
@@ -95,7 +96,7 @@ class EditController extends Controller
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $budget->active,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $this->defaultCurrency->id,
|
||||
];
|
||||
if (null !== $autoBudget) {
|
||||
if ($autoBudget instanceof AutoBudget) {
|
||||
$amount = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount;
|
||||
if (is_array($amount)) {
|
||||
$amount = '0';
|
||||
|
||||
@@ -316,7 +316,7 @@ class IndexController extends Controller
|
||||
foreach ($budgetIds as $index => $budgetId) {
|
||||
$budgetId = (int) $budgetId;
|
||||
$budget = $repository->find($budgetId);
|
||||
if (null !== $budget) {
|
||||
if ($budget instanceof Budget) {
|
||||
app('log')->debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1));
|
||||
$repository->setBudgetOrder($budget, $index + 1);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Budget;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -90,7 +91,7 @@ class ShowController extends Controller
|
||||
|
||||
// get first journal ever to set off the budget period overview.
|
||||
$first = $this->journalRepos->firstNull();
|
||||
$firstDate = null !== $first ? $first->date : $start;
|
||||
$firstDate = $first instanceof TransactionJournal ? $first->date : $start;
|
||||
$periods = $this->getNoBudgetPeriodOverview($firstDate, $end);
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
@@ -115,7 +116,7 @@ class ShowController extends Controller
|
||||
{
|
||||
$subTitle = (string) trans('firefly.all_journals_without_budget');
|
||||
$first = $this->journalRepos->firstNull();
|
||||
$start = null === $first ? new Carbon() : $first->date;
|
||||
$start = $first instanceof TransactionJournal ? $first->date : new Carbon();
|
||||
$end = today(config('app.timezone'));
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
|
||||
Reference in New Issue
Block a user