version 1.37, 2011/05/26 02:09:36 |
version 1.38, 2011/06/21 01:20:28 |
|
|
#!/usr/bin/perl |
#!/usr/bin/perl |
# $AFresh1: rt_invoices.pl,v 1.36 2011/05/18 19:03:17 andrew Exp $ |
# $AFresh1: rt_invoices.pl,v 1.37 2011/05/26 01:09:36 andrew Exp $ |
######################################################################## |
######################################################################## |
# Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com> |
# Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com> |
# |
# |
|
|
foreach my $fee ( @{ $project->{fees} } ) { |
foreach my $fee ( @{ $project->{fees} } ) { |
my $hours = hours_for_date( $cust->{invoice}, $fee->{date} ); |
my $hours = hours_for_date( $cust->{invoice}, $fee->{date} ); |
|
|
my $type = 'unknown'; |
my $type = 'unknown'; |
while ( $type && $type ne 'default' ) { |
my $count = $fee->{count}; |
|
while ( $type && $count > 0 && $type ne 'default' ) { |
$type = exists $hours->{ $fee->{type} } |
$type = exists $hours->{ $fee->{type} } |
&& $hours->{ $fee->{type} } > 0 ? $fee->{type} : 'default'; |
&& $hours->{ $fee->{type} } > 0 ? $fee->{type} : 'default'; |
|
|
next unless exists $hours->{$type} && $hours->{$type} > 0; |
next unless exists $hours->{$type} && $hours->{$type} > 0; |
|
|
my $discount_time = 0; |
my $discount_time = 0; |
if ( $hours->{$type} > $fee->{count} ) { |
if ( $hours->{$type} > $count ) { |
$hours->{$type} -= $fee->{count}; |
$hours->{$type} -= $count; |
$discount_time = $fee->{count}; |
$discount_time = $count; |
} |
} |
else { |
else { |
$discount_time = $hours->{$type}; |
$discount_time = $hours->{$type}; |
|
|
+= $discount_time; |
+= $discount_time; |
|
|
$type = '' if $type eq 'default'; |
$type = '' if $type eq 'default'; |
|
$count -= $discount_time; |
$fee->{detail} .= " $discount_time $type Hours Discounted"; |
$fee->{detail} .= " $discount_time $type Hours Discounted"; |
} |
} |
|
|
last if $discount_time == $fee->{count}; |
|
} |
} |
} |
} |
|
|