X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pkg_detail.pm;h=19b15f7dddee20cb5b97b579c5c2677411095e04;hb=e95a28ea14289ffcfa652bff9b179d3820b56242;hp=dd118c1b2fac7e0899cfbff51bafb057af3262bf;hpb=7516e3da0f17eeecba27219ef96a8b5f46af2083;p=freeside.git diff --git a/FS/FS/cust_bill_pkg_detail.pm b/FS/FS/cust_bill_pkg_detail.pm index dd118c1b2..19b15f7dd 100644 --- a/FS/FS/cust_bill_pkg_detail.pm +++ b/FS/FS/cust_bill_pkg_detail.pm @@ -106,21 +106,37 @@ sub insert { ''; } -=item delete +=item delete [ ARG => VALUE ... ] Delete this record from the database. +If the "reprocess_cdrs" argument is set to true, resets the status of any +related CDRs (and deletes their associated cdr_termination records, if any). + =cut sub delete { - my $self = shift; + my( $self, %args ) = @_; + my $error = $self->SUPER::delete; return $error if $error; + foreach my $cdr (qsearch('cdr', { detailnum => $self->detailnum })) { + $cdr->set('detailnum', ''); + $cdr->set('freesidestatus', '') if $args{'reprocess_cdrs'}; $error = $cdr->replace; return "error unlinking CDR #" . $cdr->acctid . ": $error" if $error; + + #well, technically this could have been on other invoices / termination + # partners... separate flag? + $self->scalar_sql( 'DELETE FROM cdr_termination WHERE acctid = ?', + $cdr->acctid ) + if $args{'reprocess_cdrs'}; + } + + ''; } =item replace OLD_RECORD