
This somehow escaped change with the introduction of RevBank::Amount in v3.2 in 2021, which only now became relevant due to the recent change in v6.1.0 which turns invalid account balances into a feature.
26 lines
688 B
Perl
26 lines
688 B
Perl
#!perl
|
|
|
|
HELP "grandtotal" => "Summary of all accounts";
|
|
|
|
sub command :Tab(grandtotal) ($self, $cart, $command, @) {
|
|
return NEXT if $command ne 'grandtotal';
|
|
|
|
my $pos = 0;
|
|
my $neg = 0;
|
|
|
|
for my $line (slurp 'revbank.accounts') {
|
|
my ($username, $balance) = split " ", $line;
|
|
next if RevBank::Users::is_special($username);
|
|
|
|
my $credit = RevBank::Amount->parse_string($balance) or next;
|
|
$neg += $credit if $credit < 0;
|
|
$pos += $credit if $credit > 0;
|
|
}
|
|
|
|
printf "Total positive: %8s\n", $pos;
|
|
printf "Total negative: \e[31;1m%8s\e[0m\n", $neg;
|
|
printf "GRAND TOTAL: \e[1m%8s\e[0m\n", $pos + $neg;
|
|
|
|
return ACCEPT;
|
|
}
|
|
|