X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fcdr-vitelity.import;h=55eb8ccf18ba282cd7cf0f4b96111b5794adb702;hp=a047c4aa31355cb43f8ee93dd9ad54760a583eaa;hb=5f4099e52bd894d644c676ea75e1b0cb588393c8;hpb=bec390c8334dc0d3dd8d13e95f0a04ed673f1319 diff --git a/bin/cdr-vitelity.import b/bin/cdr-vitelity.import index a047c4aa3..55eb8ccf1 100755 --- a/bin/cdr-vitelity.import +++ b/bin/cdr-vitelity.import @@ -64,14 +64,6 @@ foreach my $export (@part_exports) { $export->isa('FS::part_export::vitelity') or die "exportnum $exportnum is not a Vitelity export\n"; - if ( $opt{'r'} ) { - my $result = $export->vitelity_command('resetcdrlist'); - if ( $result ne 'ok' ) { - $dbh->rollback; - die "Failed to reset CDR list: $result\n"; - } - } - my $dir = $FS::UID::cache_dir . "/cache.". $FS::UID::datasrc; my $temp = new File::Temp ( TEMPLATE => 'download.XXXXXXXX', SUFFIX => '.csv', @@ -81,11 +73,20 @@ foreach my $export (@part_exports) { print "Downloading to ".$temp->filename."\n" if $opt{'v'}; print "Sending API request..." if $opt{'v'}; - my @records = eval { $export->vitelity_command('getcdr') }; + + my $s = time2str('%m-%d-%Y', $start); + my $e = time2str('%m-%d-%Y', $end); + + my @records = eval { $export->vitelity_command('getcdr', + 'startdate' => $s, + 'enddate' => $e, + ); + }; if ( $@ ) { print "download error: $@\n"; exit(-1); } + print "received ".scalar(@records)." records\n" if $opt{'v'}; if ( !@records ) { print "No records to process.\n" if $opt{'v'}; @@ -94,19 +95,10 @@ foreach my $export (@part_exports) { print $temp "Date,Source,Destination,Seconds,CallerID,Disposition,Cost\n"; - my $regex = qr/^(\d{4})-(\d{2})-(\d{2})/; - my $s = time2str('%m-%d-%Y', $start); - my $e = time2str('%m-%d-%Y', $end); - my $count = 0; while (my $rec = shift @records) { - my $date = substr($rec, 0, 10); - next if ($start and $s gt $date); - next if ($end and $e le $date); print $temp $rec, "\n"; - $count++; } close $temp; - print "Selected $count records in date range." if $opt{'v'} and ($s or $e); my $format = 'vitelity'; my $batchname = "vitelity-$exportnum-".time2str('%Y/%m/%d-%T',time);