[freeside-commits] freeside/FS/FS cust_svc.pm,1.66.2.7,1.66.2.8
Ivan,,,
ivan at wavetail.420.am
Fri Mar 28 15:31:16 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv24087
Modified Files:
Tag: FREESIDE_1_7_BRANCH
cust_svc.pm
Log Message:
fix double charging for CDRs when number is in both src and charged_party fields, and disable_src is not checked
Index: cust_svc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_svc.pm,v
retrieving revision 1.66.2.7
retrieving revision 1.66.2.8
diff -u -d -r1.66.2.7 -r1.66.2.8
--- cust_svc.pm 15 Mar 2008 21:14:30 -0000 1.66.2.7
+++ cust_svc.pm 28 Mar 2008 22:31:12 -0000 1.66.2.8
@@ -642,44 +642,29 @@
sub get_cdrs_for_update {
my($self, %options) = @_;
- my @cdrs = $self->get_cdrs_fromfield('charged_party', %options);
-
- push @cdrs, $self->get_cdrs_fromfield('src', %options)
- unless $options{'disable_src'};
-
- @cdrs;
-}
-
-sub get_cdrs_fromfield {
- my($self, $field, %options) = @_;
-
- my $default_prefix = $options{'default_prefix'};
+ my @fields = ( 'charged_party' );
+ push @fields, 'src' unless $options{'disable_src'};
#CDRs are now associated with svc_phone services via svc_phone.phonenum
#return () unless $self->svc_x->isa('FS::svc_phone');
return () unless $self->part_svc->svcdb eq 'svc_phone';
my $number = $self->svc_x->phonenum;
- my @cdrs =
+ my $prefix = $options{'default_prefix'};
+
+ my @where = map " $_ = '$number' ", @fields;
+ push @where, map " $_ = '$prefix$number' ", @fields
+ if length($prefix);
+
+ my $extra_sql = ' AND ( '. join(' OR ', @where ). ' ) ';
+
+ my @cdrs =
qsearch( {
'table' => 'cdr',
- 'hashref' => { 'freesidestatus' => '',
- $field => $number
- },
- 'extra_sql' => 'FOR UPDATE',
+ 'hashref' => { 'freesidestatus' => '', },
+ 'extra_sql' => "$extra_sql FOR UPDATE",
} );
- if ( length($default_prefix) ) {
- push @cdrs,
- qsearch( {
- 'table' => 'cdr',
- 'hashref' => { 'freesidestatus' => '',
- $field => "$default_prefix$number",
- },
- 'extra_sql' => 'FOR UPDATE',
- } );
- }
-
@cdrs;
}
More information about the freeside-commits
mailing list