X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fvoip_cdr.pm;h=155d8e78caa7962d88ab95d9663991f5e47eaf48;hb=8e21a8c2ce7617a64ec962b3933c77a868682b94;hp=ea160315b17f127147208117d2c16bcdccf45988;hpb=9464e3517fcae6a735c14b3fb15b91f3886a884a;p=freeside.git diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index ea160315b..155d8e78c 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -17,6 +17,7 @@ $DEBUG = 1; tie my %rating_method, 'Tie::IxHash', 'prefix' => 'Rate calls by using destination prefix to look up a region and rate according to the internal prefix and rate tables', 'upstream' => 'Rate calls based on upstream data: If the call type is "1", map the upstream rate ID directly to an internal rate (rate_detail), otherwise, pass the upstream price through directly.', + 'upstream_simple' => 'Simply pass through and charge the "upstream_price" amount.', ; #tie my %cdr_location, 'Tie::IxHash', @@ -27,13 +28,14 @@ tie my %rating_method, 'Tie::IxHash', %info = ( 'name' => 'VoIP rating by plan of CDR records in an internal (or external) SQL table', + 'shortname' => 'VoIP/telco CDR rating (standard)', 'fields' => { 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, }, - 'recur_flat' => { 'name' => 'Base recurring fee for this package', - 'default' => 0, - }, + 'recur_fee' => { 'name' => 'Base recurring fee for this package', + 'default' => 0, + }, 'unused_credit' => { 'name' => 'Credit the customer for the unused portion'. ' of service at cancellation', 'type' => 'checkbox', @@ -93,7 +95,7 @@ tie my %rating_method, 'Tie::IxHash', # }, }, - 'fieldorder' => [qw( setup_fee recur_flat unused_credit ratenum rating_method default_prefix disable_src domestic_prefix international_prefix )], + 'fieldorder' => [qw( setup_fee recur_fee unused_credit ratenum rating_method default_prefix disable_src domestic_prefix international_prefix )], 'weight' => 40, ); @@ -207,7 +209,7 @@ sub calc_recur { }); # - die "Can't find rate for call $to_or_from +$countrycode $\numbern" + die "Can't find rate for call $to_or_from +$countrycode $number\n" unless $rate_prefix; $regionnum = $rate_prefix->regionnum; @@ -252,6 +254,22 @@ sub calc_recur { } + } elsif ( $self->option('rating_method') eq 'upstream_simple' ) { + + #XXX $charge = sprintf('%.2f', $cdr->upstream_price); + $charge = sprintf('%.3f', $cdr->upstream_price); + $charges += $charge; + + @call_details = ( + #time2str("%Y %b %d - %r", $cdr->calldate_unix ), + time2str("%c", $cdr->calldate_unix), #XXX this should probably be a config option dropdown so they can select US vs- rest of world dates or whatnot + sprintf('%.2f', $cdr->billsec / 60 ).'m', + '$'.$charge, #XXX $money_char + #$pretty_destnum, + $cdr->userfield, #$rate_region->regionname, + $cdr->dst, + ); + } else { die "don't know how to rate CDRs using method: ". $self->option('rating_method'). "\n"; @@ -278,9 +296,10 @@ sub calc_recur { unless exists $included_min{$regionnum}; my $granularity = $rate_detail->sec_granularity; - my $seconds = $cdr->billsec; # |ength($cdr->billsec) ? $cdr->billsec : $cdr->duration; + my $seconds = $cdr->billsec; # length($cdr->billsec) ? $cdr->billsec : $cdr->duration; $seconds += $granularity - ( $seconds % $granularity ) - if $granularity; # 0 is per call + 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; @@ -312,9 +331,10 @@ sub calc_recur { warn " adding details on charge to invoice: ". join(' - ', @call_details ) - if $DEBUG; + if $DEBUG && $charge > 0; - push @$details, join(' - ', @call_details); #\@call_details, + push @$details, join(' - ', @call_details) #\@call_details, + if $charge > 0; # if the customer flag is on, call "downstream_csv" or something # like it to export the call downstream! @@ -358,7 +378,7 @@ sub calc_recur { } #if ( $spool_cdr && length($downstream_cdr) ) - $self->option('recur_flat') + $charges; + $self->option('recur_fee') + $charges; } @@ -368,7 +388,7 @@ sub is_free { sub base_recur { my($self, $cust_pkg) = @_; - $self->option('recur_flat'); + $self->option('recur_fee'); } 1;