X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=f5c1de3e2df8f9657e649205f6a4e89d546f8f83;hb=e96a3fd1c8ee8c711a7e119c0937da6866bbd4f0;hp=cd808d4fa15a8a8c819fb6e36fe12dfa1472c389;hpb=c2829eb15ff44d34ce82ae02c88810a321614ce9;p=freeside.git diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index cd808d4fa..f5c1de3e2 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -423,7 +423,7 @@ sub cancel { $dbh->commit or die $dbh->errstr if $oldAutoCommit; my $conf = new FS::Conf; - my @invoicing_list = grep { $_ ne 'POST' } $self->cust_main->invoicing_list; + my @invoicing_list = grep { $_ !~ /^(POST|FAX)$/ } $self->cust_main->invoicing_list; if ( !$options{'quiet'} && $conf->exists('emailcancel') && @invoicing_list ) { my $conf = new FS::Conf; my $error = send_email( @@ -1106,12 +1106,23 @@ sub order { my $cust_main = qsearchs('cust_main', { custnum => $custnum }); return "Customer not found: $custnum" unless $cust_main; - my $change = scalar(@$remove_pkgnum) != 0; + my @old_cust_pkg = map { qsearchs('cust_pkg', { pkgnum => $_ }) } + @$remove_pkgnum; + + my $change = scalar(@old_cust_pkg) != 0; + + my %hash = (); + if ( scalar(@old_cust_pkg) == 1 ) { + #$hash{$_} = $old_cust_pkg[0]->$_() foreach qw( last_bill bill ); + $hash{'setup'} = time; + } # Create the new packages. foreach my $pkgpart (@$pkgparts) { my $cust_pkg = new FS::cust_pkg { custnum => $custnum, - pkgpart => $pkgpart }; + pkgpart => $pkgpart, + %hash, + }; $error = $cust_pkg->insert( 'change' => $change ); if ($error) { $dbh->rollback if $oldAutoCommit; @@ -1123,8 +1134,7 @@ sub order { # created packages. # Transfer services and cancel old packages. - foreach my $old_pkgnum (@$remove_pkgnum) { - my $old_pkg = qsearchs ('cust_pkg', { pkgnum => $old_pkgnum }); + foreach my $old_pkg (@old_cust_pkg) { foreach my $new_pkg (@$return_cust_pkg) { $error = $old_pkg->transfer($new_pkg);