diff options
author | ivan <ivan> | 2001-10-22 08:29:42 +0000 |
---|---|---|
committer | ivan <ivan> | 2001-10-22 08:29:42 +0000 |
commit | fcf83b9d956af1049af0d13812cc6756c78308b5 (patch) | |
tree | 67ab059c284e494405951b6d16078ffb0d73a3db /FS | |
parent | 60c837e0aaf454dfa0b0c0283dc36928782d1b6c (diff) |
better delete customer code & warnings, delete package ability (& warning)
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_main.pm | 25 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 15 |
2 files changed, 28 insertions, 12 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 3895514d4..12be7aba9 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -362,11 +362,13 @@ This will completely remove all traces of the customer record. This is not what you want when a customer cancels service; for that, cancel all of the customer's packages (see L<FS::cust_pkg/cancel>). -If the customer has any packages, you need to pass a new (valid) customer -number for those packages to be transferred to. +If the customer has any uncancelled packages, you need to pass a new (valid) +customer number for those packages to be transferred to. Cancelled packages +will be deleted. Did I mention that this is NOT what you want when a customer +cancels service and that you really should be looking see L<FS::cust_pkg/cancel>? You can't delete a customer with invoices (see L<FS::cust_bill>), -or credits (see L<FS::cust_credit>). +or credits (see L<FS::cust_credit>) or payments (see L<FS::cust_pay>). =cut @@ -392,8 +394,12 @@ sub delete { $dbh->rollback if $oldAutoCommit; return "Can't delete a customer with credits"; } + if ( qsearch( 'cust_pay', { 'custnum' => $self->custnum } ) ) { + $dbh->rollback if $oldAutoCommit; + return "Can't delete a customer with payments"; + } - my @cust_pkg = qsearch( 'cust_pkg', { 'custnum' => $self->custnum } ); + my @cust_pkg = $self->ncancelled_pkgs; if ( @cust_pkg ) { my $new_custnum = shift; unless ( qsearchs( 'cust_main', { 'custnum' => $new_custnum } ) ) { @@ -411,6 +417,15 @@ sub delete { } } } + my @cancelled_pkgs = $self->all_pkgs; + foreach my $cust_pkg ( @cancelled_cust_pkg ) { + my $error = $cust_pkg->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + foreach my $cust_main_invoice ( qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } ) ) { @@ -1840,7 +1855,7 @@ sub append_fuzzyfiles { =head1 VERSION -$Id: cust_main.pm,v 1.42 2001-10-20 12:17:59 ivan Exp $ +$Id: cust_main.pm,v 1.43 2001-10-22 08:29:42 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 069ac8cf7..7aee8d027 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -123,15 +123,16 @@ sub insert { =item delete -Currently unimplemented. You don't want to delete billing items, because there -would then be no record the customer ever purchased the item. Instead, see -the cancel method. +This method now works but you probably shouldn't use it. + +You don't want to delete billing items, because there would then be no record +the customer ever purchased the item. Instead, see the cancel method. =cut -sub delete { - return "Can't delete cust_pkg records!"; -} +#sub delete { +# return "Can't delete cust_pkg records!"; +#} =item replace OLD_RECORD @@ -588,7 +589,7 @@ sub order { =head1 VERSION -$Id: cust_pkg.pm,v 1.11 2001-10-15 14:58:03 ivan Exp $ +$Id: cust_pkg.pm,v 1.12 2001-10-22 08:29:42 ivan Exp $ =head1 BUGS |