package import w/locationnum, RT#38764
[freeside.git] / FS / FS / cust_pkg / Import.pm
index cac31f8..e8c4427 100644 (file)
@@ -100,6 +100,7 @@ sub process_batch_import {
 
 my %formatfields = (
   'default'      => [],
+  'all_dates'    => [],
   'svc_acct'     => [qw( username _password domsvc )],
   'svc_phone'    => [qw( countrycode phonenum sip_password pin )],
   'svc_external' => [qw( id title )],
@@ -125,7 +126,6 @@ my %import_options = (
         $cust_location->set($1, $param->{$p});
       }
 
-warn Dumper $cust_location; # XXX
       my $error = $cust_location->find_or_insert; # this avoids duplicates
       return "error creating location: $error" if $error;
       $record->set('locationnum', $cust_location->locationnum);
@@ -206,11 +206,30 @@ sub batch_import {
     @fields = ( 'custnum' );
   }
 
+  if ( $format =~ /^(.*)-locationnum$/ ) {
+    $format = $1;
+    push @fields, 'locationnum';
+  }
+
   push @fields, ( 'pkgpart', 'discountnum' );
 
-  foreach my $field ( 
-    qw( start_date setup bill last_bill susp adjourn cancel expire )
-  ) {
+  my @date_fields = ();
+  if ( $format =~ /all_dates/ ) {
+    @date_fields = qw(
+      order_date
+      start_date setup bill last_bill susp adjourn
+      resume
+      cancel expire
+      contract_end dundate
+    );
+  } else {
+    @date_fields = qw(
+      start_date setup bill last_bill susp adjourn
+      cancel expire
+    );
+  }
+
+  foreach my $field (@date_fields) { 
     push @fields, sub {
       my( $self, $value ) = @_; # $conf, $param
       #->$field has undesirable effects