X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_svc.pm;h=118ab79d20d419be6979de3cef99be98571372e9;hb=4f9e876b1e2549e09bafc85289951bbb973194aa;hp=b97539681d7643a9cc0506e4d10a5a2e2fa96064;hpb=8ce96f4accb45f2577d38de81b9f96c0031a2f8a;p=freeside.git diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index b97539681..118ab79d2 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -12,6 +12,7 @@ use FS::svc_acct; use FS::svc_domain; use FS::svc_forward; use FS::svc_broadband; +use FS::svc_external; use FS::domain_record; use FS::part_export; @@ -171,15 +172,9 @@ sub replace { local $FS::UID::AutoCommit = 0; my $dbh = dbh; - my $error = $new->SUPER::replace($old); - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return $error if $error; - } - if ( $new->svcpart != $old->svcpart ) { my $svc_x = $new->svc_x; - my $new_svc_x = ref($svc_x)->new({$svc_x->hash}); + my $new_svc_x = ref($svc_x)->new({$svc_x->hash, svcpart=>$new->svcpart }); my $error = $new_svc_x->replace($svc_x); if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -187,6 +182,12 @@ sub replace { } } + my $error = $new->SUPER::replace($old); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error if $error; + } + $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; #no error @@ -323,6 +324,7 @@ sub svc_x { if ( $svcdb eq 'svc_acct' && $self->{'_svc_acct'} ) { $self->{'_svc_acct'}; } else { + #require "FS/$svcdb.pm"; qsearchs( $svcdb, { 'svcnum' => $self->svcnum } ); } } @@ -590,6 +592,23 @@ sub get_session_history { } +=item pkg_svc + +Returns the pkg_svc record for for this service, if applicable. + +=cut + +sub pkg_svc { + my $self = shift; + my $cust_pkg = $self->cust_pkg; + return undef unless $cust_pkg; + + qsearchs( 'pkg_svc', { 'svcpart' => $self->svcpart, + 'pkgpart' => $cust_pkg->pkgpart, + } + ); +} + =back =head1 BUGS