=================================================================== RCS file: /cvs/RT/Invoicing/rt_invoices.pl,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- RT/Invoicing/rt_invoices.pl 2011/05/03 05:41:11 1.30 +++ RT/Invoicing/rt_invoices.pl 2011/05/07 02:03:55 1.31 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $AFresh1: rt_invoices.pl,v 1.29 2011/05/03 04:38:56 andrew Exp $ +# $AFresh1: rt_invoices.pl,v 1.30 2011/05/03 04:41:11 andrew Exp $ ######################################################################## # Copyright (c) 2011 Andrew Fresh # @@ -101,30 +101,28 @@ foreach my $fee ( @{ $project->{fees} } ) { my $hours = hours_for_date( $cust->{invoice}, $fee->{date} ); - my $h_type - = exists $hours->{ $fee->{type} } - ? $fee->{type} - : 'default'; + my $type = exists $hours->{ $fee->{type} } + && $hours->{ $fee->{type} } > 0 ? $type : 'default'; - next unless exists $hours->{$h_type} && $hours->{$h_type} > 0; + next unless exists $hours->{$type} && $hours->{$type} > 0; my $discount_time = 0; - if ( $hours->{$h_type} > $fee->{count} ) { - $hours->{$h_type} -= $fee->{count}; + if ( $hours->{$type} > $fee->{count} ) { + $hours->{$type} -= $fee->{count}; $discount_time = $fee->{count}; } else { - $discount_time = $hours->{$h_type}; - $hours->{$h_type} = 0; + $discount_time = $hours->{$type}; + $hours->{$type} = 0; } if ($discount_time) { $cust->{invoice}->{discount}->{amount} += round( $discount_time * $fee->{rate} ); - $cust->{invoice}->{discount}->{hours}{$h_type} += $discount_time; + $cust->{invoice}->{discount}->{hours}{$type} += $discount_time; - $h_type = '' if $h_type eq 'default'; - $fee->{detail} = "$discount_time $h_type Hours Discounted"; + $type = '' if $type eq 'default'; + $fee->{detail} = "$discount_time $type Hours Discounted"; } }