Expense report favors Conferences first,

then takes Travel as if it were an Other category only after categories
have been handled.
This commit is contained in:
Bradley M. Kuhn 2012-11-25 12:19:44 -05:00
parent 3e634b6d45
commit 4318c11fd9

View file

@ -291,20 +291,21 @@ foreach my $line (<FILE>) {
die "Weird account found, $account, with amount of $amount in expenses command\n" die "Weird account found, $account, with amount of $amount in expenses command\n"
unless $account =~ /^\s*Expenses:/; unless $account =~ /^\s*Expenses:/;
if ($account =~ /Travel/) { my $taken = 0;
$expenseGroups{'TRAVEL'}{total} += $amount; # Note: Prioritize to put things under conference expenses if they were for a conference.
$expenseGroups{'TRAVEL'}{output} .= " $line"; foreach my $type ('CONFERENCES', keys %expenseGroups) {
} else { last if $taken;
my $taken = 0; next if $type eq 'TRAVEL' or $type eq 'OTHER';
foreach my $type (keys %expenseGroups) { next unless $line =~ /$expenseGroups{$type}{regex}/;
last if $taken; $taken = 1;
next if $type eq 'TRAVEL' or $type eq 'OTHER'; $expenseGroups{$type}{total} += $amount;
next unless $line =~ /$expenseGroups{$type}{regex}/; $expenseGroups{$type}{output} .= " $line";
$taken = 1; }
$expenseGroups{$type}{total} += $amount; if (not $taken) {
$expenseGroups{$type}{output} .= " $line"; if ($account =~ /Travel/) {
} $expenseGroups{'TRAVEL'}{total} += $amount;
if (not $taken) { $expenseGroups{'TRAVEL'}{output} .= " $line";
} else {
$expenseGroups{'OTHER'}{total} += $amount; $expenseGroups{'OTHER'}{total} += $amount;
$expenseGroups{'OTHER'}{output} .= " $line"; $expenseGroups{'OTHER'}{output} .= " $line";
} }