summaryrefslogtreecommitdiff
path: root/FS/FS/part_pkg
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-09-10 21:33:37 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-09-14 23:05:54 -0500
commit205cf3b843285a5858f1d6387386381564a5deca (patch)
tree2bf54867b4a4105c610147d3f28cfab99b0d3a31 /FS/FS/part_pkg
parentb78bb7aeaa27daab707106217b33e4096e985262 (diff)
RT#33410: Package GB add-ons
Diffstat (limited to 'FS/FS/part_pkg')
-rw-r--r--FS/FS/part_pkg/sqlradacct_hour.pm15
1 files changed, 13 insertions, 2 deletions
diff --git a/FS/FS/part_pkg/sqlradacct_hour.pm b/FS/FS/part_pkg/sqlradacct_hour.pm
index 79e64fb..206bea0 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;
@@ -153,7 +164,7 @@ sub calc_recur {
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";