mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-23 19:51:24 +00:00
Merge pull request #11391 from firefly-iii/release-1766164682
🤖 Automatically merge the PR into the develop branch.
This commit is contained in:
@@ -80,6 +80,7 @@ class CorrectsAmounts extends Command
|
|||||||
private function correctTransfers(): void
|
private function correctTransfers(): void
|
||||||
{
|
{
|
||||||
Log::debug('Will now correct transfers.');
|
Log::debug('Will now correct transfers.');
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface $repository */
|
/** @var AccountRepositoryInterface $repository */
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
$type = TransactionType::where('type', TransactionTypeEnum::TRANSFER->value)->first();
|
$type = TransactionType::where('type', TransactionTypeEnum::TRANSFER->value)->first();
|
||||||
@@ -88,11 +89,12 @@ class CorrectsAmounts extends Command
|
|||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$repository->setUser($journal->user);
|
$repository->setUser($journal->user);
|
||||||
$primary = Amount::getPrimaryCurrencyByUserGroup($journal->userGroup);
|
$primary = Amount::getPrimaryCurrencyByUserGroup($journal->userGroup);
|
||||||
|
|
||||||
$valid = $this->validateJournal($journal);
|
$valid = $this->validateJournal($journal);
|
||||||
if (false === $valid) {
|
if (false === $valid) {
|
||||||
Log::debug(sprintf('Journal #%d does not need to be fixed or is invalid (see previous messages)', $journal->id));
|
Log::debug(sprintf('Journal #%d does not need to be fixed or is invalid (see previous messages)', $journal->id));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('Journal #%d is ready to be corrected (if necessary).', $journal->id));
|
Log::debug(sprintf('Journal #%d is ready to be corrected (if necessary).', $journal->id));
|
||||||
@@ -107,8 +109,8 @@ class CorrectsAmounts extends Command
|
|||||||
|
|
||||||
if ($sourceCurrency->id === $destCurrency->id) {
|
if ($sourceCurrency->id === $destCurrency->id) {
|
||||||
Log::debug('Both accounts have the same currency. Removing foreign currency info.');
|
Log::debug('Both accounts have the same currency. Removing foreign currency info.');
|
||||||
$source->foreign_currency_id = null;
|
$source->foreign_currency_id = null;
|
||||||
$source->foreign_amount = null;
|
$source->foreign_amount = null;
|
||||||
$source->save();
|
$source->save();
|
||||||
$destination->foreign_currency_id = null;
|
$destination->foreign_currency_id = null;
|
||||||
$destination->foreign_amount = null;
|
$destination->foreign_amount = null;
|
||||||
@@ -271,38 +273,42 @@ class CorrectsAmounts extends Command
|
|||||||
|
|
||||||
private function validateJournal(TransactionJournal $journal): bool
|
private function validateJournal(TransactionJournal $journal): bool
|
||||||
{
|
{
|
||||||
$countSource = $journal->transactions()->where('amount', '<', 0)->count();
|
$countSource = $journal->transactions()->where('amount', '<', 0)->count();
|
||||||
$countDest = $journal->transactions()->where('amount', '>', 0)->count();
|
$countDest = $journal->transactions()->where('amount', '>', 0)->count();
|
||||||
|
|
||||||
if (1 !== $countSource || 1 !== $countDest) {
|
if (1 !== $countSource || 1 !== $countDest) {
|
||||||
$this->friendlyError(sprintf('Transaction journal #%d has bad transaction information. Will delete.', $journal->id));
|
$this->friendlyError(sprintf('Transaction journal #%d has bad transaction information. Will delete.', $journal->id));
|
||||||
$this->deleteJournal($journal);
|
$this->deleteJournal($journal);
|
||||||
Log::error(sprintf('Transaction journal #%d has bad transaction information. Will delete.', $journal->id));
|
Log::error(sprintf('Transaction journal #%d has bad transaction information. Will delete.', $journal->id));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var null|Transaction $source */
|
/** @var null|Transaction $source */
|
||||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||||
|
|
||||||
/** @var null|Transaction $destination */
|
/** @var null|Transaction $destination */
|
||||||
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
$destination = $journal->transactions()->where('amount', '>', 0)->first();
|
||||||
|
|
||||||
if (null === $source || null === $destination) {
|
if (null === $source || null === $destination) {
|
||||||
$this->friendlyError(sprintf('Could not find source OR destination for journal #%d .', $journal->id));
|
$this->friendlyError(sprintf('Could not find source OR destination for journal #%d .', $journal->id));
|
||||||
Log::error(sprintf('Could not find source OR destination for journal #%d .', $journal->id));
|
Log::error(sprintf('Could not find source OR destination for journal #%d .', $journal->id));
|
||||||
$this->deleteJournal($journal);
|
$this->deleteJournal($journal);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (null === $source->foreign_currency_id || null === $destination->foreign_currency_id) {
|
if (null === $source->foreign_currency_id || null === $destination->foreign_currency_id) {
|
||||||
Log::debug('No foreign currency information is present, can safely continue with other transactions.');
|
Log::debug('No foreign currency information is present, can safely continue with other transactions.');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (null === $source->foreign_amount || null === $destination->foreign_amount) {
|
if (null === $source->foreign_amount || null === $destination->foreign_amount) {
|
||||||
$this->friendlyError(sprintf('Transactions of journal #%d have no foreign amount, but have foreign currency info. Will reset this.', $journal->id));
|
$this->friendlyError(sprintf('Transactions of journal #%d have no foreign amount, but have foreign currency info. Will reset this.', $journal->id));
|
||||||
$source->foreign_currency_id = null;
|
$source->foreign_currency_id = null;
|
||||||
$source->save();
|
$source->save();
|
||||||
$destination->foreign_currency_id = null;
|
$destination->foreign_currency_id = null;
|
||||||
$source->save();
|
$source->save();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,8 +317,10 @@ class CorrectsAmounts extends Command
|
|||||||
if (null === $sourceAccount || null === $destAccount) {
|
if (null === $sourceAccount || null === $destAccount) {
|
||||||
$this->friendlyError(sprintf('Could not find accounts for journal #%d,', $journal->id));
|
$this->friendlyError(sprintf('Could not find accounts for journal #%d,', $journal->id));
|
||||||
$this->deleteJournal($journal);
|
$this->deleteJournal($journal);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -668,6 +668,7 @@ class Steam
|
|||||||
{
|
{
|
||||||
$res = $this->getSafeUrl(session()->previousUrl() ?? route('index'), route('index'));
|
$res = $this->getSafeUrl(session()->previousUrl() ?? route('index'), route('index'));
|
||||||
Log::debug(sprintf('getSafePreviousUrl: "%s"', $res));
|
Log::debug(sprintf('getSafePreviousUrl: "%s"', $res));
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ return [
|
|||||||
// see cer.php for exchange rates feature flag.
|
// see cer.php for exchange rates feature flag.
|
||||||
],
|
],
|
||||||
'version' => 'develop/2025-12-19',
|
'version' => 'develop/2025-12-19',
|
||||||
'build_time' => 1766158365,
|
'build_time' => 1766164572,
|
||||||
'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.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user