mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-30 18:11:45 +00:00
Compare commits
8 Commits
3c904c9017
...
develop-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76899389b8 | ||
|
|
e83fe023d2 | ||
|
|
1dd098a283 | ||
|
|
52164689d4 | ||
|
|
034b14eb0b | ||
|
|
8722d264dc | ||
|
|
3603ef1cc7 | ||
|
|
7abd30f4dd |
@@ -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')) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user