sub import_formats {
(
- 'asterisk' => 'Asterisk',
- 'taqua' => 'Taqua',
- 'unitel' => 'Unitel/RSLCOM',
- 'simple' => 'Simple',
+ 'asterisk' => 'Asterisk',
+ 'taqua' => 'Taqua',
+ 'unitel' => 'Unitel/RSLCOM',
+ 'voxlinesystems' => 'VoxLineSystems', #XXX? get the actual vendor name
+ 'simple' => 'Simple',
);
}
'carrierid',
'upstream_rateid',
],
+ 'voxlinesystems' => [ #XXX get the actual vendor name
+ 'disposition', #Status
+ 'startdate', #Start (what do you know, a timestamp!
+ sub { my($cdr, $field) = @_; }, #Start date
+ sub { my($cdr, $field) = @_; }, #Start time
+ 'enddate', #End (also a timestamp!)
+ sub { my($cdr, $field) = @_; }, #End date
+ sub { my($cdr, $field) = @_; }, #End time
+ 'accountcode', #Calling customer XXX map to agent_custid??
+ sub { my($cdr, $field) = @_; }, #Calling type
+ sub { shift->src('30000'); }, #XXX FAKE XXX 'src', #Calling number
+ 'userfield', #Calling name #?
+ sub { my($cdr, $field) = @_; }, #Called type
+ 'dst', #Called number
+ sub { my($cdr, $field) = @_; }, #Destination customer
+ sub { my($cdr, $field) = @_; }, #Destination type
+ sub { my($cdr, $field) = @_; }, #Destination Number
+ sub { my($cdr, $field) = @_; }, #Inbound calling type
+ sub { my($cdr, $field) = @_; }, #Inbound calling number
+ sub { my($cdr, $field) = @_; }, #Inbound called type
+ sub { my($cdr, $field) = @_; }, #Inbound called number
+ sub { my($cdr, $field) = @_; }, #Inbound destination type
+ sub { my($cdr, $field) = @_; }, #Inbound destination number
+ sub { my($cdr, $field) = @_; }, #Outbound calling type
+ sub { my($cdr, $field) = @_; }, #Outbound calling number
+ sub { my($cdr, $field) = @_; }, #Outbound called type
+ sub { my($cdr, $field) = @_; }, #Outbound called number
+ sub { my($cdr, $field) = @_; }, #Outbound destination type
+ sub { my($cdr, $field) = @_; }, #Outbound destination number
+ sub { my($cdr, $field) = @_; }, #Internal calling type
+ sub { my($cdr, $field) = @_; }, #Internal calling number
+ sub { my($cdr, $field) = @_; }, #Internal called type
+ sub { my($cdr, $field) = @_; }, #Internal called number
+ sub { my($cdr, $field) = @_; }, #Internal destination type
+ sub { my($cdr, $field) = @_; }, #Internal destination number
+ 'duration', #Total seconds
+ sub { my($cdr, $field) = @_; }, #Ring seconds
+ 'billsec', #Billable seconds
+ 'upstream_price', #Cost
+ sub { my($cdr, $field) = @_; }, #Billing customer
+ sub { my($cdr, $field) = @_; }, #Billing customer name
+ sub { my($cdr, $field) = @_; }, #Billing type
+ sub { my($cdr, $field) = @_; }, #Billing reference
+ ],
'simple' => [
# Date
);
my %import_header = (
- 'simple' => 1,
- 'taqua' => 1,
+ 'simple' => 1,
+ 'taqua' => 1,
+ 'voxlinesystems' => 2, #XXX vendor name
);
=item batch_import HASHREF
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- my $body = 0;
+ my $header_lines =
+ exists($import_header{$format}) ? $import_header{$format} : 0;
+
my $line;
while ( defined($line=<$fh>) ) {
- #skip header...
- if ( ! $body++ && $import_header{$format} ) { #&& $line =~ /^[\w, "]+$/ ) {
- next;
- }
+ next if $header_lines-- > 0; #&& $line =~ /^[\w, "]+$/
$csv->parse($line) or do {
$dbh->rollback if $oldAutoCommit;
tie my %rating_method, 'Tie::IxHash',
'prefix' => 'Rate calls by using destination prefix to look up a region and rate according to the internal prefix and rate tables',
'upstream' => 'Rate calls based on upstream data: If the call type is "1", map the upstream rate ID directly to an internal rate (rate_detail), otherwise, pass the upstream price through directly.',
+ 'upstream_simple' => 'Simply pass through and charge the "upstream_price" amount.',
;
#tie my %cdr_location, 'Tie::IxHash',
}
+ } elsif ( $self->option('rating_method') eq 'upstream_simple' ) {
+
+ #XXX $charge = sprintf('%.2f', $cdr->upstream_price);
+ $charge = sprintf('%.3f', $cdr->upstream_price);
+ $charges += $charge;
+
+ @call_details = (
+ #time2str("%Y %b %d - %r", $cdr->calldate_unix ),
+ time2str("%c", $cdr->calldate_unix), #XXX this should probably be a config option dropdown so they can select US vs- rest of world dates or whatnot
+ sprintf('%.2f', $cdr->billsec / 60 ).'m',
+ '$'.$charge, #XXX $money_char
+ #$pretty_destnum,
+ $cdr->userfield, #$rate_region->regionname,
+ $cdr->dst,
+ );
+
} else {
die "don't know how to rate CDRs using method: ".
$self->option('rating_method'). "\n";
warn " adding details on charge to invoice: ".
join(' - ', @call_details )
- if $DEBUG;
+ if $DEBUG && $charge > 0;
- push @$details, join(' - ', @call_details); #\@call_details,
+ push @$details, join(' - ', @call_details) #\@call_details,
+ if $charge > 0;
# if the customer flag is on, call "downstream_csv" or something
# like it to export the call downstream!