Use amount object directly internally,

instead of relying on operator overloading, but keep the ones where direct use
would result in overly messy code.
This commit is contained in:
Juerd Waalboer 2021-12-03 03:14:26 +01:00
parent 58f49cbffb
commit 1661661ffd
3 changed files with 17 additions and 13 deletions

View file

@ -52,9 +52,12 @@ sub update {
$new = $old + $delta;
my $since = $a[3] // "";
$since = "+\@" . now() if $new > 0 and (!$since or $old <= 0);
$since = "-\@" . now() if $new < 0 and (!$since or $old >= 0);
$since = "0\@" . now() if $new == 0 and (!$since or $old != 0);
my $newc = $new->cents;
my $oldc = $old->cents;
$since = "+\@" . now() if $newc > 0 and (!$since or $oldc <= 0);
$since = "-\@" . now() if $newc < 0 and (!$since or $oldc >= 0);
$since = "0\@" . now() if $newc == 0 and (!$since or $oldc != 0);
printf {$out} "%-16s %9s %s %s\n", (
$username, $new->string("+"), now(), $since