🤖 Auto commit for release 'develop' on 2025-11-17

This commit is contained in:
JC5
2025-11-17 19:08:12 +01:00
parent 4a901a1b42
commit 69b46af245
4 changed files with 68 additions and 66 deletions

View File

@@ -173,7 +173,7 @@ class EditController extends Controller
*/ */
public function update(RecurrenceFormRequest $request, Recurrence $recurrence) public function update(RecurrenceFormRequest $request, Recurrence $recurrence)
{ {
$data = $request->getAll(); $data = $request->getAll();
$recurrence = $this->repository->update($recurrence, $data); $recurrence = $this->repository->update($recurrence, $data);
$request->session()->flash('success', (string) trans('firefly.updated_recurrence', ['title' => $recurrence->title])); $request->session()->flash('success', (string) trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
@@ -181,7 +181,7 @@ class EditController extends Controller
// store new attachment(s): // store new attachment(s):
/** @var null|array $files */ /** @var null|array $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null; $files = $request->hasFile('attachments') ? $request->file('attachments') : null;
if (null !== $files && !auth()->user()->hasRole('demo')) { if (null !== $files && !auth()->user()->hasRole('demo')) {
$this->attachments->saveAttachmentsForModel($recurrence, $files); $this->attachments->saveAttachmentsForModel($recurrence, $files);
} }
@@ -194,7 +194,7 @@ class EditController extends Controller
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); $request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
} }
app('preferences')->mark(); app('preferences')->mark();
$redirect = redirect($this->getPreviousUrl('recurrences.edit.url')); $redirect = redirect($this->getPreviousUrl('recurrences.edit.url'));
if (1 === (int) $request->get('return_to_edit')) { if (1 === (int) $request->get('return_to_edit')) {
// set value so edit routine will not overwrite URL: // set value so edit routine will not overwrite URL:
$request->session()->put('recurrences.edit.fromUpdate', true); $request->session()->put('recurrences.edit.fromUpdate', true);

View File

@@ -51,11 +51,12 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use function Safe\json_decode; use function Safe\json_decode;
class RecurringEnrichment implements EnrichmentInterface class RecurringEnrichment implements EnrichmentInterface
{ {
private array $accounts = []; private array $accounts = [];
private Collection $collection; private Collection $collection;
// private array $transactionTypeIds = []; // private array $transactionTypeIds = [];
// private array $transactionTypes = []; // private array $transactionTypes = [];
@@ -99,7 +100,7 @@ class RecurringEnrichment implements EnrichmentInterface
return $this->collection; return $this->collection;
} }
public function enrichSingle(array | Model $model): array | Model public function enrichSingle(array|Model $model): array|Model
{ {
Log::debug(__METHOD__); Log::debug(__METHOD__);
$collection = new Collection()->push($model); $collection = new Collection()->push($model);
@@ -133,7 +134,7 @@ class RecurringEnrichment implements EnrichmentInterface
return (string)trans('firefly.recurring_monthly', ['dayOfMonth' => $repetition->repetition_moment, 'skip' => $repetition->repetition_skip - 1], $this->language); return (string)trans('firefly.recurring_monthly', ['dayOfMonth' => $repetition->repetition_moment, 'skip' => $repetition->repetition_skip - 1], $this->language);
} }
if ('ndom' === $repetition->repetition_type) { if ('ndom' === $repetition->repetition_type) {
$parts = explode(',', $repetition->repetition_moment); $parts = explode(',', $repetition->repetition_moment);
// first part is number of week, second is weekday. // first part is number of week, second is weekday.
$dayOfWeek = trans(sprintf('config.dow_%s', $parts[1]), [], $this->language); $dayOfWeek = trans(sprintf('config.dow_%s', $parts[1]), [], $this->language);
if ($repetition->repetition_skip > 0) { if ($repetition->repetition_skip > 0) {
@@ -150,7 +151,7 @@ class RecurringEnrichment implements EnrichmentInterface
} }
// $diffInYears = (int)$today->diffInYears($repDate, true); // $diffInYears = (int)$today->diffInYears($repDate, true);
// $repDate->addYears($diffInYears); // technically not necessary. // $repDate->addYears($diffInYears); // technically not necessary.
$string = $repDate->isoFormat((string)trans('config.month_and_day_no_year_js')); $string = $repDate->isoFormat((string)trans('config.month_and_day_no_year_js'));
return (string)trans('firefly.recurring_yearly', ['date' => $string], $this->language); return (string)trans('firefly.recurring_yearly', ['date' => $string], $this->language);
} }
@@ -173,8 +174,8 @@ class RecurringEnrichment implements EnrichmentInterface
private function appendCollectedData(): void private function appendCollectedData(): void
{ {
$this->collection = $this->collection->map(function (Recurrence $item): Recurrence { $this->collection = $this->collection->map(function (Recurrence $item): Recurrence {
$id = (int)$item->id; $id = (int)$item->id;
$meta = [ $meta = [
'notes' => $this->notes[$id] ?? null, 'notes' => $this->notes[$id] ?? null,
'repetitions' => array_values($this->repetitions[$id] ?? []), 'repetitions' => array_values($this->repetitions[$id] ?? []),
'transactions' => $this->processTransactions(array_values($this->transactions[$id] ?? [])), 'transactions' => $this->processTransactions(array_values($this->transactions[$id] ?? [])),
@@ -300,9 +301,10 @@ class RecurringEnrichment implements EnrichmentInterface
private function collectNotes(): void private function collectNotes(): void
{ {
$notes = Note::query()->whereIn('noteable_id', $this->ids) $notes = Note::query()->whereIn('noteable_id', $this->ids)
->whereNotNull('notes.text') ->whereNotNull('notes.text')
->where('notes.text', '!=', '') ->where('notes.text', '!=', '')
->where('noteable_type', Recurrence::class)->get(['notes.id', 'notes.noteable_id', 'notes.text'])->toArray(); ->where('noteable_type', Recurrence::class)->get(['notes.id', 'notes.noteable_id', 'notes.text'])->toArray()
;
foreach ($notes as $note) { foreach ($notes as $note) {
$notableId = (int)$note['noteable_id']; $notableId = (int)$note['noteable_id'];
$this->notes[$notableId] = (string)$note['text']; $this->notes[$notableId] = (string)$note['text'];
@@ -334,21 +336,21 @@ class RecurringEnrichment implements EnrichmentInterface
Log::debug('Start of enrichment: collectRepetitions()'); Log::debug('Start of enrichment: collectRepetitions()');
$repository = app(RecurringRepositoryInterface::class); $repository = app(RecurringRepositoryInterface::class);
$repository->setUserGroup($this->userGroup); $repository->setUserGroup($this->userGroup);
$set = RecurrenceRepetition::whereIn('recurrence_id', $this->ids)->get(); $set = RecurrenceRepetition::whereIn('recurrence_id', $this->ids)->get();
/** @var RecurrenceRepetition $repetition */ /** @var RecurrenceRepetition $repetition */
foreach ($set as $repetition) { foreach ($set as $repetition) {
$recurrence = $this->collection->filter(fn(Recurrence $item): bool => (int)$item->id === (int)$repetition->recurrence_id)->first(); $recurrence = $this->collection->filter(fn (Recurrence $item): bool => (int)$item->id === (int)$repetition->recurrence_id)->first();
$fromDate = clone($recurrence->latest_date ?? $recurrence->first_date); $fromDate = clone ($recurrence->latest_date ?? $recurrence->first_date);
$recurrenceId = (int)$repetition->recurrence_id; $recurrenceId = (int)$repetition->recurrence_id;
$repId = (int)$repetition->id; $repId = (int)$repetition->id;
$this->repetitions[$recurrenceId] ??= []; $this->repetitions[$recurrenceId] ??= [];
Log::debug(sprintf('Collected repetition #%d of recurrence #%d.', $repId, $recurrenceId)); Log::debug(sprintf('Collected repetition #%d of recurrence #%d.', $repId, $recurrenceId));
// get the (future) occurrences for this specific type of repetition: // get the (future) occurrences for this specific type of repetition:
$amount = 'daily' === $repetition->repetition_type ? 9 : 5; $amount = 'daily' === $repetition->repetition_type ? 9 : 5;
$set = $repository->getXOccurrencesSince($repetition, $fromDate, now(config('app.timezone')), $amount); $set = $repository->getXOccurrencesSince($repetition, $fromDate, now(config('app.timezone')), $amount);
$occurrences = []; $occurrences = [];
/** @var Carbon $carbon */ /** @var Carbon $carbon */
foreach ($set as $carbon) { foreach ($set as $carbon) {
@@ -371,11 +373,11 @@ class RecurringEnrichment implements EnrichmentInterface
private function collectTransactionMetaData(): void private function collectTransactionMetaData(): void
{ {
$rtIds = []; $rtIds = [];
foreach ($this->ids as $recurrenceId) { foreach ($this->ids as $recurrenceId) {
$rtIds = array_merge($rtIds, array_keys($this->transactions[$recurrenceId])); $rtIds = array_merge($rtIds, array_keys($this->transactions[$recurrenceId]));
} }
$meta = RecurrenceTransactionMeta::whereNull('deleted_at')->whereIn('rt_id', $rtIds)->get(); $meta = RecurrenceTransactionMeta::whereNull('deleted_at')->whereIn('rt_id', $rtIds)->get();
// other meta-data to be collected: // other meta-data to be collected:
$billIds = []; $billIds = [];
$piggyBankIds = []; $piggyBankIds = [];
@@ -387,9 +389,9 @@ class RecurringEnrichment implements EnrichmentInterface
$transactionId = (int)$entry->rt_id; $transactionId = (int)$entry->rt_id;
// this should refer to another array, were rtIds can be used to find the recurrence. // this should refer to another array, were rtIds can be used to find the recurrence.
$recurrenceId = $this->recurrenceByTransaction[$transactionId] ?? 0; $recurrenceId = $this->recurrenceByTransaction[$transactionId] ?? 0;
Log::debug(sprintf('Collecting meta data entry #%d for recurrence transaction #%d, for recurrence #%d ', $id, $transactionId, $recurrenceId)); Log::debug(sprintf('Collecting meta data entry #%d for recurrence transaction #%d, for recurrence #%d ', $id, $transactionId, $recurrenceId));
$name = (string)($entry->name ?? ''); $name = (string)($entry->name ?? '');
if (0 === $recurrenceId) { if (0 === $recurrenceId) {
Log::error(sprintf('Could not find recurrence ID for recurrence transaction ID #%d', $transactionId)); Log::error(sprintf('Could not find recurrence ID for recurrence transaction ID #%d', $transactionId));
@@ -489,12 +491,12 @@ class RecurringEnrichment implements EnrichmentInterface
/** @var RecurrenceTransaction $transaction */ /** @var RecurrenceTransaction $transaction */
foreach ($set as $transaction) { foreach ($set as $transaction) {
$recurrenceId = (int)$transaction->recurrence_id; $recurrenceId = (int)$transaction->recurrence_id;
$transactionId = (int)$transaction->id; $transactionId = (int)$transaction->id;
$this->recurrenceByTransaction[$transactionId] = $recurrenceId; $this->recurrenceByTransaction[$transactionId] = $recurrenceId;
$this->transactions[$recurrenceId] ??= []; $this->transactions[$recurrenceId] ??= [];
$amount = $transaction->amount; $amount = $transaction->amount;
$foreignAmount = $transaction->foreign_amount; $foreignAmount = $transaction->foreign_amount;
Log::debug(sprintf('Collected transaction #%d of recurrence #%d', $transactionId, $recurrenceId)); Log::debug(sprintf('Collected transaction #%d of recurrence #%d', $transactionId, $recurrenceId));
$this->transactions[$recurrenceId][$transactionId] = [ $this->transactions[$recurrenceId][$transactionId] = [
@@ -521,9 +523,9 @@ class RecurringEnrichment implements EnrichmentInterface
]; ];
// collect all kinds of meta-data to be collected later. // collect all kinds of meta-data to be collected later.
$this->currencyIds[$transactionId] = (int)$transaction->transaction_currency_id; $this->currencyIds[$transactionId] = (int)$transaction->transaction_currency_id;
$this->sourceAccountIds[$transactionId] = (int)$transaction->source_id; $this->sourceAccountIds[$transactionId] = (int)$transaction->source_id;
$this->destinationAccountIds[$transactionId] = (int)$transaction->destination_id; $this->destinationAccountIds[$transactionId] = (int)$transaction->destination_id;
if (null !== $transaction->foreign_currency_id) { if (null !== $transaction->foreign_currency_id) {
$this->foreignCurrencyIds[$transactionId] = (int)$transaction->foreign_currency_id; $this->foreignCurrencyIds[$transactionId] = (int)$transaction->foreign_currency_id;
} }
@@ -533,8 +535,8 @@ class RecurringEnrichment implements EnrichmentInterface
private function getLanguage(): void private function getLanguage(): void
{ {
/** @var Preference $preference */ /** @var Preference $preference */
$preference = Preferences::getForUser($this->user, 'language', config('firefly.default_language', 'en_US')); $preference = Preferences::getForUser($this->user, 'language', config('firefly.default_language', 'en_US'));
$language = $preference->data; $language = $preference->data;
if (is_array($language)) { if (is_array($language)) {
$language = 'en_US'; $language = 'en_US';
} }
@@ -547,9 +549,9 @@ class RecurringEnrichment implements EnrichmentInterface
$return = []; $return = [];
$converter = new ExchangeRateConverter(); $converter = new ExchangeRateConverter();
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
$currencyId = $transaction['transaction_currency_id']; $currencyId = $transaction['transaction_currency_id'];
$pcAmount = null; $pcAmount = null;
$pcForeignAmount = null; $pcForeignAmount = null;
// set the same amount in the primary currency, if both are the same anyway. // set the same amount in the primary currency, if both are the same anyway.
if ($this->convertToPrimary && $currencyId === (int)$this->primaryCurrency->id) { if ($this->convertToPrimary && $currencyId === (int)$this->primaryCurrency->id) {
$pcAmount = $transaction['amount']; $pcAmount = $transaction['amount'];
@@ -565,26 +567,26 @@ class RecurringEnrichment implements EnrichmentInterface
} }
} }
$transaction['pc_amount'] = $pcAmount; $transaction['pc_amount'] = $pcAmount;
$transaction['pc_foreign_amount'] = $pcForeignAmount; $transaction['pc_foreign_amount'] = $pcForeignAmount;
$sourceId = $transaction['source_id']; $sourceId = $transaction['source_id'];
$transaction['source_name'] = $this->accounts[$sourceId]->name; $transaction['source_name'] = $this->accounts[$sourceId]->name;
$transaction['source_iban'] = $this->accounts[$sourceId]->iban; $transaction['source_iban'] = $this->accounts[$sourceId]->iban;
$transaction['source_type'] = $this->accounts[$sourceId]->accountType->type; $transaction['source_type'] = $this->accounts[$sourceId]->accountType->type;
$transaction['source_id'] = (string)$transaction['source_id']; $transaction['source_id'] = (string)$transaction['source_id'];
$destId = $transaction['destination_id']; $destId = $transaction['destination_id'];
$transaction['destination_name'] = $this->accounts[$destId]->name; $transaction['destination_name'] = $this->accounts[$destId]->name;
$transaction['destination_iban'] = $this->accounts[$destId]->iban; $transaction['destination_iban'] = $this->accounts[$destId]->iban;
$transaction['destination_type'] = $this->accounts[$destId]->accountType->type; $transaction['destination_type'] = $this->accounts[$destId]->accountType->type;
$transaction['destination_id'] = (string)$transaction['destination_id']; $transaction['destination_id'] = (string)$transaction['destination_id'];
$transaction['currency_id'] = (string)$currencyId; $transaction['currency_id'] = (string)$currencyId;
$transaction['currency_name'] = $this->currencies[$currencyId]->name; $transaction['currency_name'] = $this->currencies[$currencyId]->name;
$transaction['currency_code'] = $this->currencies[$currencyId]->code; $transaction['currency_code'] = $this->currencies[$currencyId]->code;
$transaction['currency_symbol'] = $this->currencies[$currencyId]->symbol; $transaction['currency_symbol'] = $this->currencies[$currencyId]->symbol;
$transaction['currency_decimal_places'] = $this->currencies[$currencyId]->decimal_places; $transaction['currency_decimal_places'] = $this->currencies[$currencyId]->decimal_places;
$transaction['primary_currency_id'] = (string)$this->primaryCurrency->id; $transaction['primary_currency_id'] = (string)$this->primaryCurrency->id;
$transaction['primary_currency_name'] = $this->primaryCurrency->name; $transaction['primary_currency_name'] = $this->primaryCurrency->name;
@@ -606,7 +608,7 @@ class RecurringEnrichment implements EnrichmentInterface
$transaction['foreign_currency_decimal_places'] = $this->currencies[$currencyId]->decimal_places; $transaction['foreign_currency_decimal_places'] = $this->currencies[$currencyId]->decimal_places;
} }
unset($transaction['transaction_currency_id']); unset($transaction['transaction_currency_id']);
$return[] = $transaction; $return[] = $transaction;
} }
return $return; return $return;

View File

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

18
package-lock.json generated
View File

@@ -4075,9 +4075,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/baseline-browser-mapping": { "node_modules/baseline-browser-mapping": {
"version": "2.8.28", "version": "2.8.29",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.28.tgz", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.29.tgz",
"integrity": "sha512-gYjt7OIqdM0PcttNYP2aVrr2G0bMALkBaoehD4BuRGjAOtipg0b6wHg1yNL+s5zSnLZZrGHOw4IrND8CD+3oIQ==", "integrity": "sha512-sXdt2elaVnhpDNRDz+1BDx1JQoJRuNk7oVlAlbGiFkLikHCAQiccexF/9e91zVi6RCgqspl04aP+6Cnl9zRLrA==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"bin": { "bin": {
@@ -5365,9 +5365,9 @@
} }
}, },
"node_modules/csstype": { "node_modules/csstype": {
"version": "3.2.2", "version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.2.tgz", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
"integrity": "sha512-D80T+tiqkd/8B0xNlbstWDG4x6aqVfO52+OlSUNIdkTvmNw0uQpJLeos2J/2XvpyidAFuTPmpad+tUxLndwj6g==", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
@@ -6443,9 +6443,9 @@
} }
}, },
"node_modules/form-data": { "node_modules/form-data": {
"version": "4.0.4", "version": "4.0.5",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {