From: jeff Date: Tue, 7 Apr 2009 01:20:38 +0000 (+0000) Subject: correct taqua toll free handling and hasten cdr import (skip uninteresting records) X-Git-Tag: root_of_svc_elec_features~1299 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=1a588ca640701eac6e6f1c9dcd31fdc48d93fc9e correct taqua toll free handling and hasten cdr import (skip uninteresting records) --- diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 7019cb99c..168984555 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1708,11 +1708,14 @@ sub batch_import { my $record = $class->new( \%hash ); + my $param = {}; while ( scalar(@later) ) { my $sub = shift @later; my $data = shift @later; - &{$sub}($record, $data, $conf); # $record->&{$sub}($data, $conf); + &{$sub}($record, $data, $conf, $param); # $record->&{$sub}($data, $conf); + last if exists( $param->{skiprow} ); } + next if exists( $param->{skiprow} ); my $error = $record->insert; diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index 35bb71cf6..5f467394c 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -269,6 +269,17 @@ sub check { $self->SUPER::check; } +=item is_tollfree + + Returns true when the cdr represents a toll free number and false otherwise. + +=cut + +sub is_tollfree { + my $self = shift; + ( $self->dst =~ /^(\+?1)?8(8|[02-7]{2})/ ) ? 1 : 0; +} + =item set_charged_party If the charged_party field is already set, does nothing. Otherwise: @@ -294,7 +305,7 @@ sub set_charged_party { } else { - if ( $self->dst =~ /^(\+?1)?8[02-8]{2}/ ) { + if ( $self->is_tollfree ) { $self->charged_party($self->dst); } else { $self->charged_party($self->src); diff --git a/FS/FS/cdr/taqua.pm b/FS/FS/cdr/taqua.pm index 5d6c6945a..44e274729 100644 --- a/FS/FS/cdr/taqua.pm +++ b/FS/FS/cdr/taqua.pm @@ -13,7 +13,13 @@ use FS::cdr qw(_cdr_date_parser_maker); 'import_fields' => [ #some of these are kind arbitrary... #0 - 'cdrtypenum', #RecordType + #RecordType + sub { + my($cdr, $field, $conf, $hashref) = @_; + $hashref->{skiprow} = 1 unless ($field == 0 && $cdr->disposition == 100); + $cdr->cdrtypenum($field); + }, + sub { my($cdr, $field) = @_; }, #all10#RecordVersion sub { my($cdr, $field) = @_; }, #OrigShelfNumber sub { my($cdr, $field) = @_; }, #OrigCardNumber @@ -88,7 +94,7 @@ use FS::cdr qw(_cdr_date_parser_maker); return; } } - $cdr->charged_party($field); + ''; }, sub { my($cdr, $field) = @_; }, #SubscriberNumber diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 9f6dd0111..e25bba5b4 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -308,9 +308,7 @@ sub calc_recur { ### my( $to_or_from, $number ); - if ( $cdr->dst =~ /^(\+?1)?8(8|[02-7]{2})/ - && ! $disable_tollfree - ) + if ( $cdr->is_tollfree && ! $disable_tollfree ) { #tollfree call $to_or_from = 'from'; $number = $cdr->src;