summaryrefslogtreecommitdiff
path: root/FS/FS/cdr.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-03-22 17:27:55 -0700
committerMark Wells <mark@freeside.biz>2013-03-22 17:27:55 -0700
commit4055cf6d3af3a16318a54e374cc04ae065f0dc14 (patch)
tree64e2b44b15b2bf42b8b891049c98e69913fe5933 /FS/FS/cdr.pm
parent6a3667417caf5efcd06c3ded9da2df7021a38fe9 (diff)
option to skip rating calls where source and destination are the same customer, #21677
Diffstat (limited to 'FS/FS/cdr.pm')
-rw-r--r--FS/FS/cdr.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 9a3114442..3ebe6c420 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)