X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fsqlradacct_hour.pm;h=206bea0d05abb88aa8ead89325dd9f755f468905;hb=121510b6337b7f75f25d583730a65f3fc63bbfbe;hp=2f9d833d0eebd991793922c8ec145bef84f97aec;hpb=fe9ea9183e8a16616d6d04a7b5c7498d28e78248;p=freeside.git diff --git a/FS/FS/part_pkg/sqlradacct_hour.pm b/FS/FS/part_pkg/sqlradacct_hour.pm index 2f9d833d0..206bea0d0 100644 --- a/FS/FS/part_pkg/sqlradacct_hour.pm +++ b/FS/FS/part_pkg/sqlradacct_hour.pm @@ -105,7 +105,18 @@ sub calc_recur { 'AcctOutputOctets' ) / BU; - my $total = $input + $output - $self->option('recur_included_total'); + my $included_total = $self->option('recur_included_total') || 0; + my $addoncharge = 0; + foreach my $cust_pkg_usageprice ($cust_pkg->cust_pkg_usageprice) { + my $part_pkg_usageprice = $cust_pkg_usageprice->part_pkg_usageprice; + $included_total += $cust_pkg_usageprice->quantity * $part_pkg_usageprice->amount; + $addoncharge += $cust_pkg_usageprice->price; + } + my $raw_total = $input + $output; + push(@$details,sprintf( "%.3f %ss included, %.3f %ss used", $included_total, BA, $raw_total, BA )) + if $included_total; + + my $total = $input + $output - $included_total; $total = 0 if $total < 0; $input = $input - $self->option('recur_included_input'); $input = 0 if $input < 0; @@ -138,22 +149,22 @@ sub calc_recur { if ( $self->option('recur_total_charge') > 0 ) { push @$details, - sprintf( "Last month's data %.1f %ss: %s", $total, BA, $totalcharge ); + sprintf( "Last month's data %.3f %ss: %s", $total, BA, $totalcharge ); } if ( $self->option('recur_input_charge') > 0 ) { push @$details, - sprintf( "Last month's download %.1f %ss: %s", $input, BA, $inputcharge ); + sprintf( "Last month's download %.3f %ss: %s", $input, BA, $inputcharge ); } if ( $self->option('recur_output_charge') > 0 ) { push @$details, - sprintf( "Last month's upload %.1f %ss: %s", $output, BA, $outputcharge ); + sprintf( "Last month's upload %.3f %ss: %s", $output, BA, $outputcharge ); } if ( $self->option('recur_hourly_charge') > 0 ) { push @$details, "Last month\'s time ". sprintf('%.1f', $hours). " hours: $hourscharge"; } - my $charges = $hourscharge + $inputcharge + $outputcharge + $totalcharge; + my $charges = $hourscharge + $inputcharge + $outputcharge + $totalcharge + $addoncharge; if ( $self->option('global_cap') && $charges > $self->option('global_cap') ) { $charges = $self->option('global_cap'); push @$details, "Usage charges capped at: $charges";