X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fvoip_cdr.pm;h=658df544634675b79ff64306b23531592a59c3b5;hb=2a54fd15d357ce97c8becef00d19ed1f711c1c6a;hp=5dbd115addc25393bb2cd336b2964c8529e93f31;hpb=53195d41237e1541515f62cbab5a6b2c1c63a5dd;p=freeside.git diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 5dbd115ad..658df5446 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -278,6 +278,13 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); 'weight' => 40, ); +sub price_info { + my $self = shift; + my $str = $self->SUPER::price_info; + $str .= " plus usage" if $str; + $str; +} + sub calc_setup { my($self, $cust_pkg ) = @_; $self->option('setup_fee'); @@ -385,6 +392,8 @@ sub calc_usage { ); # $last_bill, $$sdate ) $options{'by_svcnum'} = 1 if $svc_field eq 'svcnum'; + my @invoice_details_sort; + foreach my $cdr ( $svc_x->get_cdrs( %options ) ) { @@ -471,7 +480,7 @@ sub calc_usage { } } else { - $countrycode = $domestic_prefix || '1'; + $countrycode = length($domestic_prefix) ? $domestic_prefix : '1'; $number =~ s/^$countrycode//;# if length($number) > 10; } @@ -743,7 +752,7 @@ sub calc_usage { warn " adding details on charge to invoice: [ ". join(', ', @{$call_details} ). " ]" if ( $DEBUG && ref($call_details) ); - push @$details, $call_details; #\@call_details, + push @invoice_details_sort, [ $call_details, $cdr->calldate_unix ]; } # if the customer flag is on, call "downstream_csv" or something @@ -761,6 +770,11 @@ sub calc_usage { } } # $cdr + + my @sorted_invoice_details = sort { @{$a}[1] <=> @{$b}[1] } @invoice_details_sort; + foreach my $sorted_call_detail ( @sorted_invoice_details ) { + push @$details, @{$sorted_call_detail}[0]; + } } # $cust_svc