+=item get_session_history TIMESTAMP_START TIMESTAMP_END
+
+See L<FS::svc_acct/get_session_history>. Equivalent to
+$cust_svc->svc_x->get_session_history, but more efficient. Meaningless for
+records where B<svcdb> is not "svc_acct".
+
+=cut
+
+sub get_session_history {
+ my($self, $start, $end, $attrib) = @_;
+
+ #$attrib ???
+
+ my @part_export = $self->part_svc->part_export_usage;
+ die "no accounting-capable exports are enabled for ". $self->part_svc->svc.
+ " service definition"
+ unless @part_export;
+ #or return undef;
+
+ my @sessions = ();
+
+ foreach my $part_export ( @part_export ) {
+ push @sessions,
+ @{ $part_export->usage_sessions( $start, $end, $self->svc_x ) };
+ }
+
+ @sessions;
+
+}
+
+=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;
+}
+