-=item get_cdrs_for_update
-
-Returns (and SELECTs "FOR UPDATE") all unprocessed (freesidestatus NULL) CDR
-objects (see L<FS::cdr>) associated with this service.
-
-CDRs are associated with svc_phone services via svc_phone.phonenum
-
-=cut
-
-sub get_cdrs_for_update {
- my($self, %options) = @_;
-
- 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 $prefix = $options{'default_prefix'};
-
- my @where = map " $_ = '$number' ", @fields;
- push @where, map " $_ = '$prefix$number' ", @fields
- if length($prefix);
- if ( $prefix =~ /^\+(\d+)$/ ) {
- push @where, map " $_ = '$1$number' ", @fields
- }
-
- my $extra_sql = ' AND ( '. join(' OR ', @where ). ' ) ';
-
- my @cdrs =
- qsearch( {
- 'table' => 'cdr',
- 'hashref' => { 'freesidestatus' => '', },
- 'extra_sql' => "$extra_sql FOR UPDATE",
- } );
-
- @cdrs;
-}
-