'type' => 'checkbox',
},
+ 'usage_section' => { 'name' => 'Section in which to place separate usage charges',
+ },
+
+ 'summarize_usage' => { 'name' => 'Include usage summary with recurring charges when usage is in separate section',
+ 'type' => 'checkbox',
+ },
+
#XXX also have option for an external db
# 'cdr_location' => { 'name' => 'CDR database location'
# 'type' => 'select',
disable_src
domestic_prefix international_prefix
use_amaflags use_disposition output_format
- separate_usage
+ separate_usage summarize_usage usage_section
)
],
'weight' => 40,
my( $rate_region, $regionnum );
my $pretty_destnum;
my $charge = '';
+ my $classnum = '';
my @call_details = ();
if ( $self->option('rating_method') eq 'prefix'
|| ! $self->option('rating_method')
$rate_region->regionname,
);
+ $classnum = $rate_detail->classnum;
+
}
if ( $charge > 0 ) {
+ #just use FS::cust_bill_pkg_detail objects?
my $call_details;
if ( $self->option('rating_method') eq 'upstream_simple' ) {
- $call_details = [ 'C', $call_details[0] ];
+ $call_details = [ 'C', $call_details[0], $charge, $classnum ];
}else{
$csv->combine(@call_details);
- $call_details = [ 'C', $csv->string ];
+ $call_details = [ 'C', $csv->string, $charge, $classnum ];
}
warn " adding details on charge to invoice: [ ".
join(', ', @{$call_details} ). " ]"
return []
unless $charges; # unless @details?
- my $cust_bill_pkg = new FS::cust_bill_pkg {
+ my @cust_bill_pkg = ();
+
+ my $want_summary = $self->option('summarize_usage', 'Hush!') &&
+ $self->option('usage_section', 'Hush!');
+
+ push @cust_bill_pkg, new FS::cust_bill_pkg {
'pkgnum' => $cust_pkg->pkgnum,
'setup' => 0,
'unitsetup' => 0,
'sdate' => $$sdate,
'edate' => $cust_pkg->bill, # already fiddled
'itemdesc' => 'Usage charges', # configurable?
- 'details' => \@details,
+ 'duplicate' => 'Y',
+ }
+ if $want_summary;
+
+ push @cust_bill_pkg, new FS::cust_bill_pkg {
+ 'pkgnum' => $cust_pkg->pkgnum,
+ 'setup' => 0,
+ 'unitsetup ' => 0,
+ 'recur' => sprintf( "%.2f", $charges), # hmmm
+ 'unitrecur ' => 0,
+ 'quantity' => $cust_pkg->quantity,
+ 'sdate' => $$sdate,
+ 'edate' => $cust_pkg->bill, # already fiddled
+ 'itemdesc' => 'Usage charges', # configurable?
+ 'section' => $self->option('usage_section', 'Hush!'),
+ 'details' => \@details,
+ 'post_total' => ( $want_summary ? 'Y' : '' ),
};
- return [ $cust_bill_pkg ];
+
+ return [ @cust_bill_pkg ];
}
1;