X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcdr.pm;h=3de022466ceb6225e10b8a89e76a9fe32458cc91;hb=e2ee874843b19f6c5221f5ce0af90979dba34e57;hp=d3d62e0b58b5893a32e07f3922888789e3c64bc1;hpb=0586dafb71594726138cd3b7b721b9f1a0b79ae2;p=freeside.git diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index d3d62e0b5..3de022466 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -28,10 +28,11 @@ use FS::rate_detail; # LRN lookup use LWP::UserAgent; use HTTP::Request::Common qw(POST); +use IO::Socket::SSL; use Cpanel::JSON::XS qw(decode_json); @ISA = qw(FS::Record); -@EXPORT_OK = qw( _cdr_date_parser_maker _cdr_min_parser_maker ); +@EXPORT_OK = qw( _cdr_date_parser_maker _cdr_min_parser_maker _cdr_date_parse ); $DEBUG = 0; $me = '[FS::cdr]'; @@ -169,7 +170,7 @@ following fields are currently supported: =item freesiderewritestatus - NULL, done, skipped -=item cdrbatch +=item cdrbatchnum =item detailnum - Link to invoice detail (L) @@ -239,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', }, @@ -507,8 +507,9 @@ sub set_status_and_rated_price { rated_price => $rated_price, status => $status, }); - $term->rated_seconds($opt{rated_seconds}) if exists($opt{rated_seconds}); - $term->rated_minutes($opt{rated_minutes}) if exists($opt{rated_minutes}); + foreach (qw(rated_seconds rated_minutes rated_granularity)) { + $term->set($_, $opt{$_}) if exists($opt{$_}); + } $term->svcnum($svcnum) if $svcnum; return $term->insert; @@ -1497,7 +1498,13 @@ sub get_lrn { my $self = shift; my $field = shift; - my $ua = LWP::UserAgent->new; + my $ua = LWP::UserAgent->new( + 'ssl_opts' => { + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + }, + ); + my $url = 'https://ws.freeside.biz/get_lrn'; my %content = ( 'support-key' => $support_key, @@ -1651,7 +1658,12 @@ foreach my $INC ( @INC ) { tie my %import_formats, 'Tie::IxHash', map { $_ => $cdr_info{$_}->{'name'} } - sort { $cdr_info{$a}->{'weight'} <=> $cdr_info{$b}->{'weight'} } + + #this is not doing anything useful anymore + #sort { $cdr_info{$a}->{'weight'} <=> $cdr_info{$b}->{'weight'} } + #so just sort alpha + sort { lc($cdr_info{$a}->{'name'}) cmp lc($cdr_info{$b}->{'name'}) } + grep { exists($cdr_info{$_}->{'import_fields'}) } keys %cdr_info; @@ -1725,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... } @@ -1852,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 @@ -1924,4 +1909,3 @@ L, schema.html from the base documentation. =cut 1; -