From ecb7665dc7dadd32cdfa5a1b98be57f0850c234d Mon Sep 17 00:00:00 2001 From: mark Date: Sat, 10 Dec 2011 01:03:14 +0000 Subject: [PATCH] option to keep track of unrateable CDRs, #15502 --- FS/FS/part_pkg/voip_cdr.pm | 28 ++++++++++++++++++++++++---- httemplate/elements/menu.html | 1 + httemplate/search/cdr.html | 14 ++++++++++---- httemplate/search/report_cdr.html | 7 ++++--- httemplate/view/svc_phone.cgi | 1 + 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 81de0bda0..35b0cac15 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -43,6 +43,13 @@ tie my %temporalities, 'Tie::IxHash', tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); +# previously "1" was "ignore +tie my %unrateable_opts, 'Tie::IxHash', + '' => 'Exit with a fatal error', + 1 => 'Flag for later review', + 2 => 'Ignore and continue', +; + %info = ( 'name' => 'VoIP rating by plan of CDR records in an internal (or external) SQL table', 'shortname' => 'VoIP/telco CDR rating (standard)', @@ -105,8 +112,9 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities(); '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', + 'ignore_unrateable' => { 'name' => 'Handling of calls without a rate in the rate table', + 'type' => 'select', + 'select_options' => \%unrateable_opts, }, 'default_prefix' => { 'name' => 'Default prefix optionally prepended to customer DID numbers when searching for CDR records', @@ -637,8 +645,20 @@ sub calc_usage { #if ( ! $rate_detail && ! scalar(@call_details) ) {} if ( ! $rate_detail && $charge eq '' ) { - warn "no rate_detail found for CDR.acctid: ". $cdr->acctid. - "; skipping\n" + if ( $ignore_unrateable == 2 ) { + # throw a warning--not recommended + warn "no rate_detail found for CDR.acctid: ". $cdr->acctid. + "; skipping\n" + } + else { + # mark the CDR as unrateable + my $error = $cdr->set_status_and_rated_price( + 'failed', + '', + $cust_svc->svcnum + ); + die $error if $error; + }#if $ignore_unrateable } else { # there *is* a rate_detail (or call_details), proceed... # About this section: diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index df45e058d..8e6937303 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -252,6 +252,7 @@ tie my %report_inventory, 'Tie::IxHash', tie my %report_rating, 'Tie::IxHash', 'RADIUS sessions' => [ $fsurl.'search/sqlradius.html', '' ], 'Call Detail Records (CDRs)' => [ $fsurl.'search/report_cdr.html', '' ], + 'Unrateable CDRs' => [ $fsurl.'search/cdr.html?freesidestatus=failed' ], 'Time worked' => [ $fsurl.'search/report_rt_transaction.html', '' ], 'Time worked summary' => [ $fsurl.'search/report_rt_ticket.html', '' ], ; diff --git a/httemplate/search/cdr.html b/httemplate/search/cdr.html index 1e3c57cae..5e917db2e 100644 --- a/httemplate/search/cdr.html +++ b/httemplate/search/cdr.html @@ -80,15 +80,21 @@ my @qsearch = @search; # freesidestatus ### -if ( $cgi->param('freesidestatus') eq 'NULL' ) { +my $status = $cgi->param('freesidestatus'); +if ( $status eq 'NULL' ) { $title = "Unprocessed $title"; $hashref->{'freesidestatus'} = ''; # Record.pm will take care of it push @search, "( freesidestatus IS NULL OR freesidestatus = '' )"; -} elsif ( $cgi->param('freesidestatus') =~ /^([\w ]+)$/ ) { - - $title = "Processed $title"; +} elsif ( $status =~ /^([\w ]+)$/ ) { + + if ( $status eq 'done' ) { + $title = "Processed $title"; + } + elsif ( $status eq 'failed' ) { + $title = "Skipped $title"; + } $hashref->{'freesidestatus'} = $1; push @search, "freesidestatus = '$1'"; diff --git a/httemplate/search/report_cdr.html b/httemplate/search/report_cdr.html index b9f883777..f305ed913 100644 --- a/httemplate/search/report_cdr.html +++ b/httemplate/search/report_cdr.html @@ -22,9 +22,10 @@ Status: diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi index ffb6fcc4a..40c8d850b 100644 --- a/httemplate/view/svc_phone.cgi +++ b/httemplate/view/svc_phone.cgi @@ -127,6 +127,7 @@ my $html_foot = sub { tie my %what, 'Tie::IxHash', 'pending' => 'NULL', 'billed' => 'done', + 'skipped' => 'failed', ; my $number = $svc_phone->phonenum; -- 2.11.0