X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=f56e1f0ed578a24531d7cbdacfb1ddce66c406b3;hp=aed99e51d22f580749725d014b096fe2099165f3;hb=00938b30a69411a743aa01db5e27100818a3c82b;hpb=08ac47123e098939db3d94cc136ff02f174e8dd0 diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index aed99e51d..f56e1f0ed 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -1319,7 +1319,8 @@ sub credit_remaining { Unsuspends all services (see L and L) in this package, then unsuspends the package itself (clears the susp field and the -adjourn field if it is in the past). +adjourn field if it is in the past). If the suspend reason includes an +unsuspension package, that package will be ordered. Available options are: @@ -1423,6 +1424,8 @@ sub unsuspend { } + my $reason = $self->last_cust_pkg_reason('susp')->reason; + my %hash = $self->hash; my $inactive = time - $hash{'susp'}; @@ -1449,6 +1452,33 @@ sub unsuspend { return $error; } + my $unsusp_pkg; + + if ( $reason->unsuspend_pkgpart ) { + my $part_pkg = FS::part_pkg->by_key($reason->unsuspend_pkgpart) + or $error = "Unsuspend package definition ".$reason->unsuspend_pkgpart. + " not found."; + my $start_date = $self->cust_main->next_bill_date + if $reason->unsuspend_hold; + + if ( $part_pkg ) { + $unsusp_pkg = FS::cust_pkg->new({ + 'custnum' => $self->custnum, + 'pkgpart' => $reason->unsuspend_pkgpart, + 'start_date' => $start_date, + 'locationnum' => $self->locationnum, + # discount? probably not... + }); + + $error ||= $self->cust_main->order_pkg( 'cust_pkg' => $unsusp_pkg ); + } + + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + if ( $conf->config('unsuspend_email_admin') ) { my $error = send_email( @@ -1462,6 +1492,11 @@ sub unsuspend { 'Customer: #'. $self->custnum. ' '. $self->cust_main->name. "\n", 'Package : #'. $self->pkgnum. " (". $self->part_pkg->pkg_comment. ")\n", ( map { "Service : $_\n" } @labels ), + ($unsusp_pkg ? + "An unsuspension fee was charged: Package #".$unsusp_pkg->pkgnum. + " (.".$unsusp_pkg->pkg_comment.")\n" + : '' + ), ], );