Compare commits

...

8 Commits

Author SHA1 Message Date
github-actions[bot]
76899389b8 Merge pull request #11291 from firefly-iii/release-1764180754
🤖 Automatically merge the PR into the develop branch.
2025-11-26 19:12:42 +01:00
JC5
e83fe023d2 🤖 Auto commit for release 'develop' on 2025-11-26 2025-11-26 19:12:34 +01:00
James Cole
1dd098a283 Fix #11284 2025-11-26 19:06:58 +01:00
James Cole
52164689d4 Switch to 1M when it's MTD. 2025-11-26 19:05:46 +01:00
github-actions[bot]
034b14eb0b Merge pull request #11290 from firefly-iii/release-1764179030
🤖 Automatically merge the PR into the develop branch.
2025-11-26 18:43:56 +01:00
JC5
8722d264dc 🤖 Auto commit for release 'develop' on 2025-11-26 2025-11-26 18:43:50 +01:00
James Cole
3603ef1cc7 Fix #11288 2025-11-26 18:39:05 +01:00
James Cole
7abd30f4dd Attempted fix with sanity check for #11284 2025-11-26 18:35:56 +01:00
5 changed files with 72 additions and 38 deletions

View File

@@ -75,6 +75,9 @@ class CreateController extends Controller
$subTitleIcon = 'fa-plus';
$request->old('_token');
$preFilled = $request->old();
if (!array_key_exists('transaction_currency_id', $preFilled)) {
$preFilled['transaction_currency_id'] = $this->primaryCurrency->id;
}
// put previous url in session if not redirect from store (not "create another").
if (true !== session('piggy-banks.create.fromStore')) {

View File

@@ -206,7 +206,13 @@ class Navigation
public function endOfPeriod(Carbon $end, string $repeatFreq): Carbon
{
$currentEnd = clone $end;
// Log::debug(sprintf('Now in endOfPeriod("%s", "%s").', $currentEnd->toIso8601String(), $repeatFreq));
if ('MTD' === $repeatFreq && $end->isFuture()) {
// fall back to a monthly schedule if the requested period is MTD.
Log::debug('endOfPeriod() requests "MTD", set it to "1M" instead.');
$repeatFreq = '1M';
}
$functionMap = [
'1D' => 'endOfDay',
@@ -248,12 +254,28 @@ class Navigation
Log::debug(sprintf('Diff in days is %d', $diffInDays));
$currentEnd->addDays($diffInDays);
// add sanity check.
if ($currentEnd->lt($end)) {
throw new FireflyException(sprintf('[a] endOfPeriod(%s, %s) failed, because it resulted in %s.', $end->toW3cString(), $repeatFreq, $currentEnd->toW3cString()));
}
return $currentEnd;
}
if ('MTD' === $repeatFreq) {
$today = today();
if ($today->isSameMonth($end)) {
return $today->endOfDay()->milli(0);
$res = $today->endOfDay()->milli(0);
// add sanity check.
if ($res->lt($end)) {
throw new FireflyException(sprintf('[b] endOfPeriod(%s, %s) failed, because it resulted in %s.', $end->toW3cString(), $repeatFreq, $res->toW3cString()));
}
return $res;
}
// add sanity check.
if ($currentEnd->lt($end)) {
throw new FireflyException(sprintf('[c] endOfPeriod(%s, %s) failed, because it resulted in %s.', $end->toW3cString(), $repeatFreq, $currentEnd->toW3cString()));
}
return $end->endOfMonth();
@@ -270,6 +292,11 @@ class Navigation
default => null,
};
if (null !== $result) {
// add sanity check.
if ($currentEnd->lt($end)) {
throw new FireflyException(sprintf('[d] endOfPeriod(%s, %s) failed, because it resulted in %s.', $end->toW3cString(), $repeatFreq, $currentEnd->toW3cString()));
}
return $result;
}
unset($result);
@@ -277,6 +304,11 @@ class Navigation
if (!array_key_exists($repeatFreq, $functionMap)) {
Log::error(sprintf('Cannot do endOfPeriod for $repeat_freq "%s"', $repeatFreq));
// add sanity check.
if ($currentEnd->lt($end)) {
throw new FireflyException(sprintf('[e] endOfPeriod(%s, %s) failed, because it resulted in %s.', $end->toW3cString(), $repeatFreq, $currentEnd->toW3cString()));
}
return $end;
}
$function = $functionMap[$repeatFreq];
@@ -288,6 +320,11 @@ class Navigation
}
$currentEnd->endOfDay()->milli(0);
// add sanity check.
if ($currentEnd->lt($end)) {
throw new FireflyException(sprintf('[f] endOfPeriod(%s, %s) failed, because it resulted in %s.', $end->toW3cString(), $repeatFreq, $currentEnd->toW3cString()));
}
return $currentEnd;
}
$currentEnd->{$function}(); // @phpstan-ignore-line
@@ -297,6 +334,11 @@ class Navigation
}
// Log::debug(sprintf('Final result: %s', $currentEnd->toIso8601String()));
// add sanity check.
if ($currentEnd->lt($end)) {
throw new FireflyException(sprintf('[g] endOfPeriod(%s, %s) failed, because it resulted in %s.', $end->toW3cString(), $repeatFreq, $currentEnd->toW3cString()));
}
return $currentEnd;
}
@@ -413,26 +455,26 @@ class Navigation
{
$date = clone $theDate;
$formatMap = [
'1D' => (string)trans('config.specific_day_js'),
'daily' => (string)trans('config.specific_day_js'),
'custom' => (string)trans('config.specific_day_js'),
'1W' => (string)trans('config.week_in_year_js'),
'week' => (string)trans('config.week_in_year_js'),
'weekly' => (string)trans('config.week_in_year_js'),
'1M' => (string)trans('config.month_js'),
'MTD' => (string)trans('config.month_js'),
'month' => (string)trans('config.month_js'),
'monthly' => (string)trans('config.month_js'),
'1Y' => (string)trans('config.year_js'),
'YTD' => (string)trans('config.year_js'),
'year' => (string)trans('config.year_js'),
'yearly' => (string)trans('config.year_js'),
'6M' => (string)trans('config.half_year_js'),
'last7' => (string)trans('config.specific_day_js'),
'last30' => (string)trans('config.month_js'),
'last90' => (string)trans('config.month_js'),
'last365' => (string)trans('config.year_js'),
'QTD' => (string)trans('config.month_js'),
'1D' => (string)trans('config.specific_day_js'),
'daily' => (string)trans('config.specific_day_js'),
'custom' => (string)trans('config.specific_day_js'),
'1W' => (string)trans('config.week_in_year_js'),
'week' => (string)trans('config.week_in_year_js'),
'weekly' => (string)trans('config.week_in_year_js'),
'1M' => (string)trans('config.month_js'),
'MTD' => (string)trans('config.month_js'),
'month' => (string)trans('config.month_js'),
'monthly' => (string)trans('config.month_js'),
'1Y' => (string)trans('config.year_js'),
'YTD' => (string)trans('config.year_js'),
'year' => (string)trans('config.year_js'),
'yearly' => (string)trans('config.year_js'),
'6M' => (string)trans('config.half_year_js'),
'last7' => (string)trans('config.specific_day_js'),
'last30' => (string)trans('config.month_js'),
'last90' => (string)trans('config.month_js'),
'last365' => (string)trans('config.year_js'),
'QTD' => (string)trans('config.month_js'),
];
if (array_key_exists($repeatFrequency, $formatMap)) {

View File

@@ -35,7 +35,6 @@ use Illuminate\Support\Facades\Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Spatie\Period\Boundaries;
use Spatie\Period\Exceptions\InvalidPeriod;
use Spatie\Period\Period;
use Spatie\Period\Precision;
@@ -201,20 +200,10 @@ trait RecalculatesAvailableBudgetsTrait
Log::debug('Found 1 AB, will update.');
$this->calculateAmount($availableBudget);
}
if (null === $availableBudget) {
Log::debug('No AB found, will create.');
// if not exists:
try {
$currentPeriod = Period::make($current, $currentEnd, precision: Precision::DAY(), boundaries: Boundaries::EXCLUDE_NONE());
} catch (InvalidPeriod $e) {
Log::error('Tried to make invalid period.');
Log::error($e->getMessage());
continue;
}
$daily = $this->getDailyAmount($budgetLimit);
$amount = bcmul((string)$daily, (string)$currentPeriod->length(), 12);
if (null === $availableBudget && $currentEnd->gte($current)) {
$currentPeriod = Period::make($current, $currentEnd, precision: Precision::DAY(), boundaries: Boundaries::EXCLUDE_NONE());
$daily = $this->getDailyAmount($budgetLimit);
$amount = bcmul((string)$daily, (string)$currentPeriod->length(), 12);
// no need to calculate if period is equal.
if ($currentPeriod->equals($limitPeriod)) {

View File

@@ -79,7 +79,7 @@ return [
// see cer.php for exchange rates feature flag.
],
'version' => 'develop/2025-11-26',
'build_time' => 1764136346,
'build_time' => 1764180641,
'api_version' => '2.1.0', // field is no longer used.
'db_version' => 28, // field is no longer used.

View File

@@ -17,7 +17,7 @@
<div class="box-body">
{{ ExpandedForm.text('name') }}
{{ ExpandedForm.amountNoCurrency('target_amount') }}
{{ CurrencyForm.currencyList('transaction_currency_id', null, {helpText:'piggy_default_currency'|_}) }}
{{ CurrencyForm.currencyList('transaction_currency_id', preFilled.transaction_currency_id, {helpText:'piggy_default_currency'|_}) }}
{{ AccountForm.assetLiabilityMultiAccountList('accounts', preFilled.accounts, {label: 'saveOnAccounts'|_, helpText: 'piggy_account_currency_match'|_ }) }}
</div>