Show total amounts for the whole group and for each ticket.

This commit is contained in:
Bradley M. Kuhn 2020-04-09 09:32:58 -07:00
parent 01decbbd55
commit df7362f6b9

View file

@ -87,6 +87,8 @@ if (@ticketSpecs <= 0) {
}
my %payments;
print "Total tickets ready for payment is: ", scalar(@ticketSpecs), "\n\n";
foreach my $ticketSpec (@ticketSpecs) {
my $paymentMethod = FindMostRecentPaymentMethodForTicket($ticketSpec);
print STDERR "$ticketSpec has payment method of $paymentMethod\n" if ($VERBOSE > 6);
@ -96,9 +98,22 @@ foreach my $ticketSpec (@ticketSpecs) {
}
push(@{$payments{$paymentMethod}}, $ticketSpec);
}
print "#" x 70, "\n";
foreach my $paymentMethod (sort { $a cmp $b } keys %payments) {
print "$paymentMethod: Count: ", scalar(@{$payments{$paymentMethod}}), "\n";
print " Tickets: ", join(", ", map { s%^\s*ticket\s*/\s*%%; $_; } @{$payments{$paymentMethod}}), "\n";
print " Tickets: ", join(" ", map { s%^\s*ticket\s*/\s*%%; $_; } @{$payments{$paymentMethod}}), "\n";
}
if ($SHOW_AMOUNTS) {
print "Unable to find amounts for all tickets\n" if (scalar(@ticketSpecs) != scalar(keys %AMOUNTS));
my $total = 0.00;
my $totalOk = 1;
foreach my $tix (sort { $a <=> $b} (keys %AMOUNTS)) {
my $val = $AMOUNTS{$tix};
print "$tix: $AMOUNTS{$tix}\n";
$val =~ s/\$//g; $val =~ s/,//g; $val =~ s/\s//g;
if ($val =~ /^[\d\.]+$/) { $total += $val; } else { $totalOk = 0; }
}
print "\nTOTAL AMOUNT: $total\n" if $totalOk;
}
###############################################################################
#