},
'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ',
+ 'validate' => \&FS::part_pkg::validate_number_blank,
+ 'js_validate' => 'digits: true',
},
'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ',
+ 'validate' => \&FS::part_pkg::validate_number_blank,
+ 'js_validate' => 'digits: true',
},
'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this cdrtypenum: ',
'type' => 'checkbox',
},
+ 'bill_only_pkg_dates' => { 'name' => 'Only bill CDRs with a date during the package billing period',
+ 'type' => 'checkbox',
+ },
+
#XXX also have option for an external db
# 'cdr_location' => { 'name' => 'CDR database location'
# 'type' => 'select',
use_duration
output_format usage_mandate summarize_usage usage_section
bill_every_call
+ bill_only_pkg_dates
)
],
'weight' => 42,
sub price_info {
my $self = shift;
- my $str = $self->SUPER::price_info;
+ my $str = $self->SUPER::price_info(@_);
$str .= " plus usage" if $str;
$str;
}
if $self->recur_temporality eq 'preceding'
&& ( $last_bill eq '' || $last_bill == 0 );
- my $spool_cdr = $cust_pkg->cust_main->spool_cdr;
-
-
my $charges = 0;
# my $downstream_cdr = '';
my $included_min = $self->option('min_included', 1) || 0;
+ $included_min *= ($cust_pkg->quantity || 1);
my $use_duration = $self->option('use_duration');
my $output_format = $self->option('output_format', 1) || 'default';
my $formatter =
- FS::detail_format->new($output_format, buffer => $details, inbound => 1);
+ FS::detail_format->new($output_format,
+ buffer => $details,
+ inbound => 1,
+ locale => $cust_pkg->cust_main->locale
+ );
my $granularity = length($self->option('sec_granularity'))
? $self->option('sec_granularity')
) {
my $svc_phone = $cust_svc->svc_x;
- my $cdr_search = $svc_phone->psearch_cdrs(
+ my %options = (
'inbound' => 1,
'default_prefix' => $self->option('default_prefix'),
'status' => '', # unprocessed only
'for_update' => 1,
);
+ if ( $self->option('bill_only_pkg_dates') ) {
+ $options{'begin'} = $last_bill;
+ $options{'end'} = $$sdate;
+ }
+
+ my $cdr_search = $svc_phone->psearch_cdrs(%options);
$cdr_search->limit(1000);
$cdr_search->increment(0);
while ( my $cdr = $cdr_search->fetch ) {
my @call_details = (
$cdr->downstream_csv( 'format' => $output_format,
'charge' => $charge,
- 'seconds' => ($use_duration
- ? $cdr->duration
- : $cdr->billsec
- ),
+ 'seconds' => $seconds,
'granularity' => $granularity,
)
);
'done',
$charge,
$cust_svc->svcnum,
- 'rated_seconds' => $use_duration ? $cdr->duration : $cdr->billsec,
+ 'rated_seconds' => $seconds,
'rated_granularity' => $granularity,
'rated_classnum' => $cdr->calltypenum,
- 'inbound' => 1,
+ 'inbound' => 1, # to update cdr_termination, not cdr
);
die $error if $error;
$formatter->append($cdr);
0;
}
-# This equates svc_phone records; perhaps svc_phone should have a field
-# to indicate it represents a line
-sub calc_units {
- my($self, $cust_pkg ) = @_;
- my $count =
- scalar(grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc);
- $count;
-}
-
1;