X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcdr.pm;h=478dcff6bfeb55e9350afa35a2de27ce921f41e4;hb=c6815d4041610785099c820df097326a70c8ce41;hp=f7402eeada012aa0682b916d17612c423e90cc2c;hpb=1f92d7423c25020073258be7453b046b30f88bc1;p=freeside.git diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index f7402eead..478dcff6b 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -678,6 +678,50 @@ sub invoice_header { $export_names{$format}->{'invoice_header'}; } +=item clear_status + +Clears cdr and any associated cdr_termination statuses - used for +CDR reprocessing. + +=cut + +sub clear_status { + my $self = shift; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + $self->freesidestatus(''); + my $error = $self->replace; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + my @cdr_termination = qsearch('cdr_termination', + { 'acctid' => $self->acctid } ); + foreach my $cdr_termination ( @cdr_termination ) { + $cdr_termination->status(''); + $error = $cdr_termination->replace; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + + ''; +} + =item import_formats Returns an ordered list of key value pairs containing import format names