mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix available budgets.
This commit is contained in:
parent
62f4da6063
commit
d37304fa68
@ -46,7 +46,7 @@ class AvailableBudgetObserver
|
||||
private function updateNativeAmount(AvailableBudget $availableBudget): void
|
||||
{
|
||||
if (!Amount::convertToNative($availableBudget->user)) {
|
||||
Log::debug('Do not update native available amount of the available budget.');
|
||||
//Log::debug('Do not update native available amount of the available budget.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class BudgetLimitObserver
|
||||
private function updateNativeAmount(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
if (!Amount::convertToNative($budgetLimit->budget->user)) {
|
||||
Log::debug('Do not update native amount of the budget limit.');
|
||||
//Log::debug('Do not update native amount of the budget limit.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
@ -66,10 +67,10 @@ class AvailableBudget extends Model
|
||||
$availableBudgetId = (int) $value;
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
|
||||
/** @var null|AvailableBudget $availableBudget */
|
||||
$availableBudget = $user->availableBudgets()->find($availableBudgetId);
|
||||
$availableBudget = $user->availableBudgets()->find($availableBudgetId);
|
||||
if (null !== $availableBudget) {
|
||||
return $availableBudget;
|
||||
}
|
||||
@ -91,14 +92,29 @@ class AvailableBudget extends Model
|
||||
protected function amount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (string) $value,
|
||||
get: static fn($value) => (string) $value,
|
||||
);
|
||||
}
|
||||
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (int) $value,
|
||||
get: static fn($value) => (int) $value,
|
||||
);
|
||||
}
|
||||
protected function startDate(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn (string $value) => Carbon::parse($value),
|
||||
set: fn (Carbon $value) => $value->format('Y-m-d'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function endDate(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn (string $value) => Carbon::parse($value),
|
||||
set: fn (Carbon $value) => $value->format('Y-m-d'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
);
|
||||
}
|
||||
$result = $query->get(['available_budgets.*']);
|
||||
Log::debug(sprintf('Found %d available budgets between %s and %s', $result->count(), $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
Log::debug(sprintf('Found %d available budgets between %s and %s', $result->count(), $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -215,9 +215,9 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
$availableBudget = new AvailableBudget();
|
||||
$availableBudget->user()->associate($this->user);
|
||||
$availableBudget->transactionCurrency()->associate($currency);
|
||||
$availableBudget->start_date = $start->startOfDay()->format('Y-m-d'); // @phpstan-ignore-line
|
||||
$availableBudget->start_date = $start->startOfDay();
|
||||
$availableBudget->start_date_tz = $start->format('e');
|
||||
$availableBudget->end_date = $end->endOfDay()->format('Y-m-d'); // @phpstan-ignore-line
|
||||
$availableBudget->end_date = $end->endOfDay();
|
||||
$availableBudget->end_date_tz = $end->format('e');
|
||||
}
|
||||
$availableBudget->amount = $amount;
|
||||
@ -250,9 +250,9 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
'user_group_id' => $this->user->user_group_id,
|
||||
'transaction_currency_id' => $data['currency_id'],
|
||||
'amount' => $data['amount'],
|
||||
'start_date' => $start->format('Y-m-d'),
|
||||
'start_date' => $start,
|
||||
'start_date_tz' => $start->format('e'),
|
||||
'end_date' => $end->format('Y-m-d'),
|
||||
'end_date' => $end,
|
||||
'end_date_tz' => $end->format('e'),
|
||||
]
|
||||
);
|
||||
@ -274,7 +274,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
$start = $data['start'];
|
||||
if ($start instanceof Carbon) {
|
||||
$start = $data['start']->startOfDay();
|
||||
$availableBudget->start_date = $start->format('Y-m-d');
|
||||
$availableBudget->start_date = $start;
|
||||
$availableBudget->start_date_tz = $start->format('e');
|
||||
$availableBudget->save();
|
||||
}
|
||||
@ -284,7 +284,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
$end = $data['end'];
|
||||
if ($end instanceof Carbon) {
|
||||
$end = $data['end']->endOfDay();
|
||||
$availableBudget->end_date = $end->format('Y-m-d');
|
||||
$availableBudget->end_date = $end;
|
||||
$availableBudget->end_date_tz = $end->format('e');
|
||||
$availableBudget->save();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
"postcss": "^8.4.47",
|
||||
"uiv": "^1.4",
|
||||
"vue": "^2.7",
|
||||
"vue-i18n": "^8",
|
||||
"vue-i18n": "^11",
|
||||
"vue-loader": "^15",
|
||||
"vue-template-compiler": "^2.7"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user