- if ( $cust_pkg{'pkgpart'} ) {
- my $cust_pkg = new FS::cust_pkg ( \%cust_pkg );
-
- my @svc_x = ();
- my $svcdb = '';
- if ( $svc_x{'username'} ) {
- $svcdb = 'svc_acct';
- } elsif ( $svc_x{'id'} || $svc_x{'title'} ) {
- $svcdb = 'svc_external';
- }
-
- my $svc_phone = '';
- if ( $svc_x{'countrycode'} || $svc_x{'phonenum'} ) {
- $svc_phone = FS::svc_phone->new( {
- map { $_ => delete($svc_x{$_}) }
- qw( countrycode phonenum sip_password pin)
- } );
- }
-
- if ( $svcdb || $svc_phone ) {
- my $part_pkg = $cust_pkg->part_pkg;
- unless ( $part_pkg ) {
- $dbh->rollback if $oldAutoCommit;
- return "unknown pkgpart: ". $cust_pkg{'pkgpart'};
- }
- if ( $svcdb ) {
- $svc_x{svcpart} = $part_pkg->svcpart_unique_svcdb( $svcdb );
- my $class = "FS::$svcdb";
- push @svc_x, $class->new( \%svc_x );
- }
- if ( $svc_phone ) {
- $svc_phone->svcpart( $part_pkg->svcpart_unique_svcdb('svc_phone') );
- push @svc_x, $svc_phone;
- }
- }