=cut
+my %export_names = (
+ 'convergent' => {},
+ 'voxlinesystems' => { 'name' => 'VoxLineSystems',
+ 'invoice_header' =>
+ "Date,Time,Name,Destination,Duration,Price",
+ },
+ 'voxlinesystems2' => { 'name' => 'VoxLineSystems with source',
+ 'invoice_header' =>
+ "Date,Time,Name,Destination,Called From,Duration,Price",
+ },
+);
+
my %export_formats = (
'convergent' => [
'carriername', #CARRIER
sub { shift->rated_price ? 'Y' : 'N' }, #RATED
'', #OTHER_INFO
],
+ 'voxlinesystems' => [
+ sub { time2str('%D', shift->calldate_unix ) }, #DATE
+ sub { time2str('%r', shift->calldate_unix ) }, #TIME
+ 'userfield', #USER
+ 'dst', #NUMBER_DIALED
+ sub { sprintf('%.2fm', shift->billsec / 60 ) }, #DURATION
+ sub { sprintf('%.3f', shift->upstream_price ) }, #PRICE
+ ],
+ 'voxlinesystems2' => [
+ sub { time2str('%D', shift->calldate_unix ) }, #DATE
+ sub { time2str('%T', shift->calldate_unix ) }, #TIME
+ 'userfield', #USER
+ 'dst', #NUMBER_DIALED
+ 'src', #called from
+ sub { sprintf('%.2fm', shift->billsec / 60 ) }, #DURATION
+ sub { sprintf('%.3f', shift->upstream_price ) }, #PRICE
+ ],
);
sub downstream_csv {
=over 4
+=item invoice_formats
+
+Returns an ordered list of key value pairs containing invoice format names
+as keys (for use with part_pkg::voip_cdr) and "pretty" format names as values.
+
+=cut
+
+sub invoice_formats {
+ map { ($_ => $export_names{$_}->{'name'}) }
+ grep { $export_names{$_}->{'invoice_header'} }
+ keys %export_names;
+}
+
+=item invoice_header FORMAT
+
+Returns a scalar containing the CSV column header for invoice format FORMAT.
+
+=cut
+
+sub invoice_header {
+ my $format = shift;
+ $export_names{$format}->{'invoice_header'};
+}
+
=item import_formats
Returns an ordered list of key value pairs containing import format names
'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??
+ 'accountcode', #Calling customer... map to agent_custid??
sub { my($cdr, $field) = @_; }, #Calling type
- sub { shift->src('30000'); }, #XXX FAKE XXX 'src', #Calling number
+ 'src',
'userfield', #Calling name #?
sub { my($cdr, $field) = @_; }, #Called type
'dst', #Called number