mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
This commit is contained in:
@@ -59,18 +59,22 @@ class ReportSum extends Command
|
|||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
foreach ($userRepository->all() as $user) {
|
foreach ($userRepository->all() as $user) {
|
||||||
$sum = (string)$user->transactions()->selectRaw('SUM(amount) + SUM(foreign_amount) as total')->value('total');
|
$sum = (string) $user->transactions()->selectRaw('SUM(amount) as total')->value('total');
|
||||||
if (!is_numeric($sum)) {
|
$foreign = (string) $user->transactions()->selectRaw('SUM(foreign_amount) as total')->value('total');
|
||||||
$message = sprintf('Error: Transactions for user #%d (%s) have an invalid sum ("%s").', $user->id, $user->email, $sum);
|
$sum = '' === $sum ? '0' : $sum;
|
||||||
|
$foreign = '' === $foreign ? '0' : $foreign;
|
||||||
|
$total = bcadd($sum, $foreign);
|
||||||
|
if (!is_numeric($total)) {
|
||||||
|
$message = sprintf('Error: Transactions for user #%d (%s) have an invalid sum ("%s").', $user->id, $user->email, $total);
|
||||||
$this->friendlyError($message);
|
$this->friendlyError($message);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (0 !== bccomp($sum, '0')) {
|
if (0 !== bccomp($total, '0')) {
|
||||||
$message = sprintf('Error: Transactions for user #%d (%s) are off by %s!', $user->id, $user->email, $sum);
|
$message = sprintf('Error: Transactions for user #%d (%s) are off by %s!', $user->id, $user->email, $total);
|
||||||
$this->friendlyError($message);
|
$this->friendlyError($message);
|
||||||
}
|
}
|
||||||
if (0 === bccomp($sum, '0')) {
|
if (0 === bccomp($total, '0')) {
|
||||||
$this->friendlyPositive(sprintf('Amount integrity OK for user #%d', $user->id));
|
$this->friendlyPositive(sprintf('Amount integrity OK for user #%d', $user->id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user