summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authormark <mark>2010-10-04 18:46:39 +0000
committermark <mark>2010-10-04 18:46:39 +0000
commitd65218690bc95244ea98df2923f552325f8253a5 (patch)
tree0eca67e24e2d538d2cbd47395c80e7c61a96c08a /FS
parent97803d56c88dc4760140d912a76cb2730fcbf713 (diff)
CDR matching by svcnum, RT#10044
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/part_pkg/voip_cdr.pm10
-rw-r--r--FS/FS/svc_pbx.pm30
-rw-r--r--FS/FS/svc_phone.pm2
3 files changed, 29 insertions, 13 deletions
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 5b83cc7..073d779 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -22,6 +22,7 @@ $DEBUG = 0;
tie my %cdr_svc_method, 'Tie::IxHash',
'svc_phone.phonenum' => 'Phone numbers (svc_phone.phonenum)',
'svc_pbx.title' => 'PBX name (svc_pbx.title)',
+ 'svc_pbx.svcnum' => 'Pre-matched to PBX (svc_pbx.svcnum)',
;
tie my %rating_method, 'Tie::IxHash',
@@ -369,13 +370,16 @@ sub calc_usage {
) {
my $svc_x = $cust_svc->svc_x;
- foreach my $cdr (
- $svc_x->get_cdrs(
+ my %options = (
'disable_src' => $self->option('disable_src'),
'default_prefix' => $self->option('default_prefix'),
'status' => '',
'for_update' => 1,
- ) # $last_bill, $$sdate )
+ ); # $last_bill, $$sdate )
+ $options{'by_svcnum'} = 1 if $svc_field eq 'svcnum';
+
+ foreach my $cdr (
+ $svc_x->get_cdrs( %options )
) {
if ( $DEBUG > 1 ) {
warn "rating CDR $cdr\n".
diff --git a/FS/FS/svc_pbx.pm b/FS/FS/svc_pbx.pm
index d2760a5..adc45a7 100644
--- a/FS/FS/svc_pbx.pm
+++ b/FS/FS/svc_pbx.pm
@@ -292,6 +292,9 @@ with the chosen prefix.
=item disable_src => 1: No-op for svc_pbx CDR processing.
+=item by_svcnum => 1: Select CDRs where the svcnum field matches, instead of
+title/charged_party. Normally this field is set after processing.
+
=back
=cut
@@ -307,18 +310,24 @@ sub get_cdrs {
my $for_update = $options{'for_update'} ? 'FOR UPDATE' : '';
- my $title = $self->title;
+ if ( $options{'by_svcnum'} ) {
+ $hash{'svcnum'} = $self->svcnum;
+ }
+ else {
+ #matching by title
+ my $title = $self->title;
- my $prefix = $options{'default_prefix'};
+ my $prefix = $options{'default_prefix'};
- my @orwhere = map " $_ = '$title' ", @fields;
- push @orwhere, map " $_ = '$prefix$title' ", @fields
- if length($prefix);
- if ( $prefix =~ /^\+(\d+)$/ ) {
- push @orwhere, map " $_ = '$1$title' ", @fields
- }
+ my @orwhere = map " $_ = '$title' ", @fields;
+ push @orwhere, map " $_ = '$prefix$title' ", @fields
+ if length($prefix);
+ if ( $prefix =~ /^\+(\d+)$/ ) {
+ push @orwhere, map " $_ = '$1$title' ", @fields
+ }
- push @where, ' ( '. join(' OR ', @orwhere ). ' ) ';
+ push @where, ' ( '. join(' OR ', @orwhere ). ' ) ';
+ }
if ( $options{'begin'} ) {
push @where, 'startdate >= '. $options{'begin'};
@@ -327,7 +336,8 @@ sub get_cdrs {
push @where, 'startdate < '. $options{'end'};
}
- my $extra_sql = ( keys(%hash) ? ' AND ' : ' WHERE ' ). join(' AND ', @where );
+ my $extra_sql = ( keys(%hash) ? ' AND ' : ' WHERE ' ). join(' AND ', @where )
+ if @where;
my @cdrs =
qsearch( {
diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm
index a0a2c3e..a599ea2 100644
--- a/FS/FS/svc_phone.pm
+++ b/FS/FS/svc_phone.pm
@@ -547,6 +547,8 @@ with the chosen prefix.
=item disable_src => 1: Only match on "charged_party", not "src".
+=item by_svcnum: not supported for svc_phone
+
=back
=cut