Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / FS / FS / cdr.pm
index a7d0028..3de0224 100644 (file)
@@ -170,7 +170,7 @@ following fields are currently supported:
 
 =item freesiderewritestatus - NULL, done, skipped
 
-=item cdrbatch
+=item cdrbatchnum
 
 =item detailnum - Link to invoice detail (L<FS::cust_bill_pkg_detail>)
 
@@ -240,7 +240,6 @@ sub table_info {
         'svcnum'                => 'Freeside service',
         'freesidestatus'        => 'Freeside status',
         'freesiderewritestatus' => 'Freeside rewrite status',
-        'cdrbatch'              => 'Legacy batch',
         'cdrbatchnum'           => 'Batch',
         'detailnum'             => 'Freeside invoice detail line',
     },
@@ -1738,6 +1737,14 @@ sub _cdr_date_parse {
     # Telos 2014-10-10T05:30:33Z
     ($year, $mon, $day, $hour, $min, $sec) = ( $1, $2, $3, $4, $5, $6 );
     $options{gmt} = 1;
+  } elsif ( $date =~ /^(\d+):(\d+):(\d+)\.\d+ \w+ (\w+) (\d+) (\d+)$/ ) {
+    ($hour, $min, $sec, $mon, $day, $year) = ( $1, $2, $3, $4, $5, $6 );
+    $mon = { # Acme Packet: 15:54:56.868 PST DEC 18 2017
+      # My best guess of month abbv they may use
+      JAN => '01', FEB => '02', MAR => '03', APR => '04',
+      MAY => '05', JUN => '06', JUL => '07', AUG => '08',
+      SEP => '09', OCT => '10', NOV => '11', DEC => '12'
+    }->{$mon};
   } else {
      die "unparsable date: $date"; #maybe we shouldn't die...
   }
@@ -1865,41 +1872,6 @@ sub process_batch_import {
 #    @columns = map { s/^ +//; $_; } @columns;
 #  }
 
-# _ upgrade_data
-#
-# Used by FS::Upgrade to migrate to a new database.
-
-sub _upgrade_data {
-  my ($class, %opts) = @_;
-
-  warn "$me upgrading $class\n" if $DEBUG;
-
-  my $sth = dbh->prepare(
-    'SELECT DISTINCT(cdrbatch) FROM cdr WHERE cdrbatch IS NOT NULL'
-  ) or die dbh->errstr;
-
-  $sth->execute or die $sth->errstr;
-
-  my %cdrbatchnum = ();
-  while (my $row = $sth->fetchrow_arrayref) {
-
-    my $cdr_batch = qsearchs( 'cdr_batch', { 'cdrbatch' => $row->[0] } );
-    unless ( $cdr_batch ) {
-      $cdr_batch = new FS::cdr_batch { 'cdrbatch' => $row->[0] };
-      my $error = $cdr_batch->insert;
-      die $error if $error;
-    }
-
-    $cdrbatchnum{$row->[0]} = $cdr_batch->cdrbatchnum;
-  }
-
-  $sth = dbh->prepare('UPDATE cdr SET cdrbatch = NULL, cdrbatchnum = ? WHERE cdrbatch IS NOT NULL AND cdrbatch = ?') or die dbh->errstr;
-
-  foreach my $cdrbatch (keys %cdrbatchnum) {
-    $sth->execute($cdrbatchnum{$cdrbatch}, $cdrbatch) or die $sth->errstr;
-  }
-
-}
 
 =item ip_addr_sql FIELD RANGE
 
@@ -1937,4 +1909,3 @@ L<FS::Record>, schema.html from the base documentation.
 =cut
 
 1;
-