diff options
| author | ivan <ivan> | 2002-05-22 12:17:06 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2002-05-22 12:17:06 +0000 | 
| commit | a55f1c9e63b5428c55aa75d55ab4a280889be288 (patch) | |
| tree | 8f5aa98af11ac8e8aa962e86c6b929197bca495e /FS | |
| parent | e93c23ed5b4fc2fd81501b2371927e6cdfad7a65 (diff) | |
move some code from FS::cust_pkg to FS::cust_svc, becomes the cancel method
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/cust_pkg.pm | 28 | ||||
| -rw-r--r-- | FS/FS/cust_svc.pm | 64 | 
2 files changed, 64 insertions, 28 deletions
| diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index a4256ea1f..8b65ac4bd 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -268,33 +268,11 @@ sub cancel {    foreach my $cust_svc (      qsearch( 'cust_svc', { 'pkgnum' => $self->pkgnum } )    ) { -    my $part_svc = qsearchs( 'part_svc', { 'svcpart' => $cust_svc->svcpart } ); - -    $part_svc->svcdb =~ /^([\w\-]+)$/ or do { -      $dbh->rollback if $oldAutoCommit; -      return "Illegal svcdb value in part_svc!"; -    }; -    my $svcdb = $1; -    require "FS/$svcdb.pm"; - -    my $svc = qsearchs( $svcdb, { 'svcnum' => $cust_svc->svcnum } ); -    if ($svc) { -      $error = $svc->cancel; -      if ( $error ) { -        $dbh->rollback if $oldAutoCommit; -        return "Error cancelling service: $error"  -      } -      $error = $svc->delete; -      if ( $error ) { -        $dbh->rollback if $oldAutoCommit; -        return "Error deleting service: $error"; -      } -    } +    my $error = $cust_svc->cancel; -    $error = $cust_svc->delete;      if ( $error ) {        $dbh->rollback if $oldAutoCommit; -      return "Error deleting cust_svc: $error"; +      return "Error cancelling cust_svc: $error";      }    } @@ -701,7 +679,7 @@ sub order {  =head1 VERSION -$Id: cust_pkg.pm,v 1.21 2002-05-04 00:47:24 ivan Exp $ +$Id: cust_pkg.pm,v 1.22 2002-05-22 12:17:06 ivan Exp $  =head1 BUGS diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index e6194b5b7..c7cc4b322 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -85,9 +85,67 @@ otherwise returns false.  =item delete  Deletes this service from the database.  If there is an error, returns the -error, otherwise returns false. +error, otherwise returns false.  Note that this only removes the cust_svc +record - you should probably use the B<cancel> method instead. -Called by the cancel method of the package (see L<FS::cust_pkg>). +=item cancel + +Cancels the relevant service by calling the B<cancel> method of the associated +FS::svc_XXX object (i.e. an FS::svc_acct object or FS::svc_domain object), +deleting the FS::svc_XXX record and then deleting this record. + +If there is an error, returns the error, otherwise returns false. + +=cut + +sub cancel { +  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; + +  my $part_svc = $self->part_svc; + +  $part_svc->svcdb =~ /^([\w\-]+)$/ or do { +    $dbh->rollback if $oldAutoCommit; +    return "Illegal svcdb value in part_svc!"; +  }; +  my $svcdb = $1; +  require "FS/$svcdb.pm"; + +  my $svc = $self->svc_x; +  if ($svc) { +    my $error = $svc->cancel; +    if ( $error ) { +      $dbh->rollback if $oldAutoCommit; +      return "Error canceling service: $error"; +    } +    $error = $svc->delete; +    if ( $error ) { +      $dbh->rollback if $oldAutoCommit; +      return "Error deleting service: $error"; +    } +  } + +  my $error = $self->delete; +  if ( $error ) { +    $dbh->rollback if $oldAutoCommit; +    return "Error deleting cust_svc: $error"; +  } + +  $dbh->commit or die $dbh->errstr if $oldAutoCommit; + +  ''; #no errors + +}  =item replace OLD_RECORD @@ -286,7 +344,7 @@ sub seconds_since {  =head1 VERSION -$Id: cust_svc.pm,v 1.14 2002-04-20 02:06:38 ivan Exp $ +$Id: cust_svc.pm,v 1.15 2002-05-22 12:17:06 ivan Exp $  =head1 BUGS | 
