This commit is contained in:
James Cole 2023-06-12 06:24:30 +02:00
parent ed36604050
commit ff765d4687
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
4 changed files with 14 additions and 1 deletions

View File

@ -51,6 +51,14 @@ class FixUnevenAmount extends Command
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
/** @var stdClass $entry */
foreach ($journals as $entry) {
$sum = (string)$entry->the_sum;
if (!is_numeric($sum)) {
$message = sprintf('Journal #%d has an invalid sum ("%s"). No sure what to do.', $entry->transaction_journal_id, $entry->the_sum);
$this->warn($message);
app('log')->warning($message);
$count++;
continue;
}
if (0 !== bccomp((string)$entry->the_sum, '0')) {
$message = sprintf('Sum of journal #%d is %s instead of zero.', $entry->transaction_journal_id, $entry->the_sum);
$this->warn($message);

View File

@ -60,7 +60,6 @@ class ReportIntegrity extends Command
'firefly-iii:create-group-memberships',
'firefly-iii:report-empty-objects',
'firefly-iii:report-sum',
'firefly-iii:restore-oauth-keys',
'firefly-iii:upgrade-group-information',
];
foreach ($commands as $command) {

View File

@ -58,6 +58,11 @@ class ReportSum extends Command
/** @var User $user */
foreach ($userRepository->all() as $user) {
$sum = (string)$user->transactions()->sum('amount');
if (!is_numeric($sum)) {
$message = sprintf('Error: Transactions for user #%d (%s) have an invalid sum ("%s").', $user->id, $user->email, $sum);
$this->error($message);
continue;
}
if (0 !== bccomp($sum, '0')) {
$message = sprintf('Error: Transactions for user #%d (%s) are off by %s!', $user->id, $user->email, $sum);
$this->error($message);

View File

@ -65,6 +65,7 @@ class UpgradeDatabase extends Command
'firefly-iii:upgrade-liabilities',
'firefly-iii:liabilities-600',
'firefly-iii:budget-limit-periods',
'firefly-iii:restore-oauth-keys',
];
$args = [];
if ($this->option('force')) {