Compare commits

..

5 Commits

Author SHA1 Message Date
github-actions[bot]
be87a24b8f Merge pull request #11517 from firefly-iii/release-1768334732
🤖 Automatically merge the PR into the develop branch.
2026-01-13 21:05:40 +01:00
JC5
f6032d5502 🤖 Auto commit for release 'develop' on 2026-01-13 2026-01-13 21:05:32 +01:00
James Cole
7dcfb68fca Fix parse issue. 2026-01-13 20:59:54 +01:00
James Cole
419c796eac Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2026-01-13 20:54:44 +01:00
James Cole
1d5733adba Experimental command 2026-01-13 20:54:31 +01:00
3 changed files with 94 additions and 3 deletions

View File

@@ -0,0 +1,91 @@
<?php
declare(strict_types=1);
/*
* ExplainAvailableBudget.php
* Copyright (c) 2026 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace FireflyIII\Console\Commands\Explain;
use Carbon\Carbon;
use Carbon\Exceptions\InvalidFormatException;
use FireflyIII\Console\Commands\VerifiesAccessToken;
use FireflyIII\Support\Facades\Navigation;
use FireflyIII\Support\Facades\Preferences;
use Illuminate\Console\Command;
class ExplainAvailableBudget extends Command
{
use VerifiesAccessToken;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'explain:available-budget
{--date=now : A date formatted YYYY-MM-DD or the word "now"}
{--user=1 : The user ID.}
{--token= : The user\'s access token.}
';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Explains why the available budget amount is what it is.';
/**
* Execute the console command.
*/
public function handle(): int
{
$date = $this->getDate((string) $this->option('date'));
$range = Preferences::getForUser($this->getUser(), 'viewRange', '1M')->data ?? '1M';
$title = Navigation::periodShow($date, $range);
$this->line('This command explains why the "available" budget bar at the top of your /budget bar means.');
$this->line(sprintf(
'You submitted date %s and your settings show a %s period, so this explanation concerns the period "%s".',
$date->format('Y-m-d'),
$range,
$title
));
return Command::SUCCESS;
}
private function getDate(string $param): Carbon
{
if ('now' === $param) {
return today();
}
try {
$date = Carbon::parse($param);
} catch (InvalidFormatException) {
$this->warn('Invalid date given. Fall back to today\'s date.');
return today();
}
return $date;
}
}

View File

@@ -103,7 +103,7 @@ class AvailableBudget extends Model
protected function endDate(): Attribute
{
return Attribute::make(
get: Carbon::parse(...),
get: static fn (string $value): Carbon => Carbon::parse($value),
set: static fn (Carbon $value): string => $value->format('Y-m-d'),
);
}
@@ -111,7 +111,7 @@ class AvailableBudget extends Model
protected function startDate(): Attribute
{
return Attribute::make(
get: Carbon::parse(...),
get: static fn (string $value): Carbon => Carbon::parse($value),
set: static fn (Carbon $value): string => $value->format('Y-m-d'),
);
}

View File

@@ -79,7 +79,7 @@ return [
// see cer.php for exchange rates feature flag.
],
'version' => 'develop/2026-01-13',
'build_time' => 1768333193,
'build_time' => 1768334619,
'api_version' => '2.1.0', // field is no longer used.
'db_version' => 28, // field is no longer used.