mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Verify currency data routine.
This commit is contained in:
parent
5329e026dc
commit
0e929602a8
@ -74,6 +74,7 @@ class UpgradeDatabase extends Command
|
|||||||
$this->updateAccountCurrencies();
|
$this->updateAccountCurrencies();
|
||||||
$this->updateJournalCurrencies();
|
$this->updateJournalCurrencies();
|
||||||
$this->currencyInfoToTransactions();
|
$this->currencyInfoToTransactions();
|
||||||
|
$this->verifyCurrencyInfo();
|
||||||
$this->info('Firefly III database is up to date.');
|
$this->info('Firefly III database is up to date.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,4 +387,25 @@ class UpgradeDatabase extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function verifyCurrencyInfo()
|
||||||
|
{
|
||||||
|
$count = 0;
|
||||||
|
$transactions = Transaction::get();
|
||||||
|
/** @var Transaction $transaction */
|
||||||
|
foreach ($transactions as $transaction) {
|
||||||
|
$currencyId = intval($transaction->transaction_currency_id);
|
||||||
|
$foreignId = intval($transaction->foreign_currency_id);
|
||||||
|
if ($currencyId === $foreignId) {
|
||||||
|
$transaction->foreign_currency_id = null;
|
||||||
|
$transaction->foreign_amount = null;
|
||||||
|
$transaction->save();
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->line(sprintf('Updated currency information for %d transactions', $count));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user