preserve order_date across package changes, #25130
authorMark Wells <mark@freeside.biz>
Fri, 31 Jan 2014 21:37:45 +0000 (13:37 -0800)
committerMark Wells <mark@freeside.biz>
Fri, 31 Jan 2014 21:37:45 +0000 (13:37 -0800)
FS/FS/cust_pkg.pm

index 8aea17d..8ee11a4 100644 (file)
@@ -334,7 +334,9 @@ sub insert {
   }
 
   # set order date unless it was specified as part of an import
-  $self->order_date(time) unless $import && $self->order_date;
+  # or this was previously a different package
+  $self->order_date(time) unless ($import && $self->order_date)
+                              or $self->change_pkgnum;
 
   my $oldAutoCommit = $FS::UID::AutoCommit;
   local $FS::UID::AutoCommit = 0;
@@ -1792,6 +1794,9 @@ sub change {
       $hash{$date} = $self->getfield($date);
     }
   }
+  # always keep this date, regardless of anything
+  # (the date of the package change is in a different field)
+  $hash{'order_date'} = $self->getfield('order_date');
 
   # allow $opt->{'locationnum'} = '' to specifically set it to null
   # (i.e. customer default location)