X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_svc.pm;h=0a58d559a1570d79611cd45ff8895f36668315c3;hp=b8b64df6b878e1114f528cde0e31de6c6ae10581;hb=90393980e5f2859ee1e186fa461f48f5129e803e;hpb=27096fe50f0427789579dbf28fe574ebcc39d69d diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index b8b64df6b..0a58d559a 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -3,6 +3,7 @@ package FS::cust_svc; use strict; use vars qw( @ISA $DEBUG $me $ignore_quantity ); use Carp; +#use Scalar::Util qw( blessed ); use FS::Conf; use FS::Record qw( qsearch qsearchs dbh str2time_sql ); use FS::cust_pkg; @@ -16,7 +17,7 @@ use FS::cdr; #most FS::svc_ classes are autoloaded in svc_x emthod use FS::svc_acct; #this one is used in the cache stuff -@ISA = qw( FS::cust_main_Mixin FS::Record ); +@ISA = qw( FS::cust_main_Mixin FS::option_Common ); #FS::Record ); $DEBUG = 0; $me = '[cust_svc]'; @@ -108,7 +109,7 @@ If there is an error, returns the error, otherwise returns false. =cut sub cancel { - my $self = shift; + my($self,%opt) = @_; local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; @@ -132,19 +133,26 @@ sub cancel { 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; #this deletes this cust_svc record as well - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return "Error deleting service: $error"; + if ( %opt && $opt{'date'} ) { + my $error = $svc->expire($opt{'date'}); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "Error expiring service: $error"; + } + } else { + my $error = $svc->cancel; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "Error canceling service: $error"; + } + $error = $svc->delete; #this deletes this cust_svc record as well + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "Error deleting service: $error"; + } } - } else { + } elsif ( !%opt ) { #huh? warn "WARNING: no svc_ record found for svcnum ". $self->svcnum. @@ -220,7 +228,13 @@ returns the error, otherwise returns false. =cut sub replace { +# my $new = shift; +# +# my $old = ( blessed($_[0]) && $_[0]->isa('FS::Record') ) +# ? shift +# : $new->replace_old; my ( $new, $old ) = ( shift, shift ); + $old = $new->replace_old unless defined($old); local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; @@ -233,8 +247,6 @@ sub replace { local $FS::UID::AutoCommit = 0; my $dbh = dbh; - $old = $new->replace_old unless defined($old); - if ( $new->svcpart != $old->svcpart ) { my $svc_x = $new->svc_x; my $new_svc_x = ref($svc_x)->new({$svc_x->hash, svcpart=>$new->svcpart }); @@ -246,6 +258,19 @@ sub replace { } } +# #trigger a re-export on pkgnum changes? +# # (of prepaid packages), for Expiration RADIUS attribute +# if ( $new->pkgnum != $old->pkgnum && $new->cust_pkg->part_pkg->is_prepaid ) { +# my $svc_x = $new->svc_x; +# local($FS::Record::nowarn_identical) = 1; +# my $error = $svc_x->export('replace'); +# if ( $error ) { +# $dbh->rollback if $oldAutoCommit; +# return $error if $error; +# } +# } + + #my $error = $new->SUPER::replace($old, @_); my $error = $new->SUPER::replace($old); if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -369,23 +394,34 @@ Usage example: my($label, $value, $svcdb) = $cust_svc->label; +=item label_long + +Like the B