somehow rc install wound up without any data
[freeside.git] / bin / freeside-migrate-events
index 2ec2918..76643b8 100644 (file)
@@ -40,7 +40,6 @@ my %plan2action = (
   'collect'                => 'collect',
 );
 
-#XXX may need to fudge some plandata2option names!!!
 
 foreach my $part_bill_event (
   qsearch({
@@ -62,6 +61,11 @@ foreach my $part_bill_event (
     next;
   }
 
+  my %plandata = map { /^(\w+) (.*)$/; ($1, $2); }
+                     split(/\n/, $part_bill_event->plandata);
+
+  #XXX may need to fudge some plandata2option names!!!
+
   my $part_event = new FS::part_event {
     'event'      => $part_bill_event->event,
     'eventtable' => 'cust_bill',
@@ -71,7 +75,7 @@ foreach my $part_bill_event (
     'disabled'   => $part_bill_event->disabled,
   };
 
-  my $error = $part_event->insert;
+  my $error = $part_event->insert(\%plandata);
   die "error inserting part_event: $error\n" if $error;
 
   print ' '. $part_event->eventpart;
@@ -90,6 +94,13 @@ foreach my $part_bill_event (
   $error = $balance->insert( 'balance' => 0 );
   die $error if $error;
 
+  my $cust_bill_owed = new FS::part_event_condition {
+    'eventpart'     => $part_event->eventpart,
+    'conditionname' => 'cust_bill_owed'
+  };
+  $error = $cust_bill_owed->insert( 'owed' => 0 );
+  die $error if $error;
+
   my $payby = new FS::part_event_condition {
     'eventpart'     => $part_event->eventpart,
     'conditionname' => 'payby'