X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fvoip_cdr.pm;h=ee009146931729aeb4f74815b9bf24858914d0c0;hb=5f92e7e7cb4a87f4e1b823a4684497cbda498b23;hp=11ff76be424ea8e7f5ad46ac896d239003b7463c;hpb=8de398042315381f8db2a62475e95d391ca0a24f;p=freeside.git diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 11ff76be4..ee0091469 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -35,6 +35,8 @@ tie my %temporalities, 'Tie::IxHash', 'preceding' => "Preceding (past)", ; +tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); + %info = ( 'name' => 'VoIP rating by plan of CDR records in an internal (or external) SQL table', 'shortname' => 'VoIP/telco CDR rating (standard)', @@ -84,6 +86,11 @@ tie my %temporalities, 'Tie::IxHash', 'min_charge' => { 'name' => 'Charge per minute when using "single price per minute" rating method', }, + 'sec_granularity' => { 'name' => 'Granularity when using "single price per minute" rating method', + 'type' => 'select', + 'select_options' => \%granularity, + }, + 'ignore_unrateable' => { 'name' => 'Ignore calls without a rate in the rate tables. By default, the system will throw a fatal error upon encountering unrateable calls.', 'type' => 'checkbox', }, @@ -199,7 +206,8 @@ tie my %temporalities, 'Tie::IxHash', 'fieldorder' => [qw( setup_fee recur_fee recur_temporality unused_credit recur_method cutoff_day - rating_method ratenum min_charge ignore_unrateable + rating_method ratenum min_charge sec_granularity + ignore_unrateable default_prefix disable_src domestic_prefix international_prefix @@ -464,21 +472,25 @@ sub calc_usage { # a little false laziness w/below - my $granularity = 60; + my $granularity = length($self->option('sec_granularity')) + ? $self->option('sec_granularity') + : 60; # length($cdr->billsec) ? $cdr->billsec : $cdr->duration; my $seconds = $use_duration ? $cdr->duration : $cdr->billsec; $seconds += $granularity - ( $seconds % $granularity ) if $seconds # don't granular-ize 0 billsec calls (bills them) - ;#&& $granularity; # 0 is per call - my $minutes = sprintf("%.1f", $seconds / 60); - $minutes =~ s/\.0$// ;# if $granularity == 60; + && $granularity; # 0 is per call + my $minutes = $seconds / 60; # sprintf("%.1f", + #$minutes =~ s/\.0$// if $granularity == 60; - $charge = sprintf('%.2f', ( $self->option('min_charge') * $minutes ) - + 0.00000001 ); #so 1.005 rounds to 1.01 + # XXX config? + #$charge = sprintf('%.2f', ( $self->option('min_charge') * $minutes ) + #+ 0.00000001 ); #so 1.005 rounds to 1.01 + $charge = sprintf('%.4f', ( $self->option('min_charge') * $minutes ) + + 0.0000000001 ); #so 1.00005 rounds to 1.0001 - $charge = $charges += $charge; @call_details = ($cdr->downstream_csv( 'format' => $output_format, @@ -556,13 +568,16 @@ sub calc_usage { if ( $charge > 0 ) { #just use FS::cust_bill_pkg_detail objects? my $call_details; + my $phonenum = $cust_svc->svc_x->phonenum; #if ( $self->option('rating_method') eq 'upstream_simple' ) { if ( scalar(@call_details) == 1 ) { - $call_details = [ 'C', $call_details[0], $charge, $classnum ]; + $call_details = + [ 'C', $call_details[0], $charge, $classnum, $phonenum ]; } else { #only used for $rating_method eq 'upstream' now $csv->combine(@call_details); - $call_details = [ 'C', $csv->string, $charge, $classnum ]; + $call_details = + [ 'C', $csv->string, $charge, $classnum, $phonenum ]; } warn " adding details on charge to invoice: [ ". join(', ', @{$call_details} ). " ]"