[freeside-commits] branch master updated. 4055cf6d3af3a16318a54e374cc04ae065f0dc14

Mark Wells mark at 420.am
Fri Mar 22 17:28:10 PDT 2013


The branch, master has been updated
       via  4055cf6d3af3a16318a54e374cc04ae065f0dc14 (commit)
      from  6a3667417caf5efcd06c3ded9da2df7021a38fe9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4055cf6d3af3a16318a54e374cc04ae065f0dc14
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Mar 22 17:27:55 2013 -0700

    option to skip rating calls where source and destination are the same customer, #21677

diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 9a31144..3ebe6c4 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -644,7 +644,34 @@ sub rate_prefix {
                                             );
   }
 
+  if ( $part_pkg->option_cacheable('skip_same_customer')
+      and ! $self->is_tollfree ) {
+    my ($dst_countrycode, $dst_number) = $self->parse_number(
+      column => 'dst',
+      international_prefix => $part_pkg->option_cacheable('international_prefix'),
+      domestic_prefix => $part_pkg->option_cacheable('domestic_prefix'),
+    );
+    my $dst_same_cust = FS::Record->scalar_sql(
+        'SELECT COUNT(svc_phone.svcnum) AS count '.
+        'FROM cust_pkg ' .
+        'JOIN cust_svc   USING (pkgnum) ' .
+        'JOIN svc_phone  USING (svcnum) ' .
+        'WHERE svc_phone.countrycode = ' . dbh->quote($dst_countrycode) .
+        ' AND svc_phone.phonenum = ' . dbh->quote($dst_number) .
+        ' AND cust_pkg.custnum = ' . $cust_pkg->custnum,
+    );
+    if ( $dst_same_cust > 0 ) {
+      warn "not charging for CDR (same source and destination customer)\n" if $DEBUG;
+      return $self->set_status_and_rated_price( 'skipped',
+                                                0,
+                                                $opt{'svcnum'},
+                                              );
+    }
+  }
+
     
+
+
   ###
   # look up rate details based on called station id
   # (or calling station id for toll free calls)
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 67ddfb5..1c891b1 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -208,6 +208,11 @@ tie my %detail_formats, 'Tie::IxHash',
     'skip_max_callers' => { 'name' => 'Do not charge for CDRs where max_callers is less than or equal to this value: ',
                           },
 
+    'skip_same_customer' => {
+      'name' => 'Do not charge for calls between numbers belonging to the same customer',
+      'type' => 'checkbox',
+    },
+
     'use_duration'   => { 'name' => 'Calculate usage based on the duration field instead of the billsec field',
                           'type' => 'checkbox',
                         },
@@ -313,6 +318,7 @@ tie my %detail_formats, 'Tie::IxHash',
                        noskip_dst_length_accountcode_tollfree
                        skip_lastapp
                        skip_max_callers
+                       skip_same_customer
                        use_duration
                        411_rewrite
                        output_format 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cdr.pm               |   27 +++++++++++++++++++++++++++
 FS/FS/part_pkg/voip_cdr.pm |    6 ++++++
 2 files changed, 33 insertions(+), 0 deletions(-)




More information about the freeside-commits mailing list