[freeside-commits] freeside/FS/FS cdr.pm,1.24,1.25
Ivan,,,
ivan at wavetail.420.am
Mon Dec 8 00:52:50 PST 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv4701
Modified Files:
cdr.pm
Log Message:
respect output_format and add an header for rating_method=prefix too, RT#4387
Index: cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cdr.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- cdr.pm 1 Dec 2008 07:53:12 -0000 1.24
+++ cdr.pm 8 Dec 2008 08:52:48 -0000 1.25
@@ -8,6 +8,7 @@
use Date::Format;
use Time::Local;
use FS::UID qw( dbh );
+use FS::Conf;
use FS::Record qw( qsearch qsearchs );
use FS::cdr_type;
use FS::cdr_calltype;
@@ -415,15 +416,23 @@
my %export_names = (
'convergent' => {},
- 'simple' => { 'name' => 'Simple',
- 'invoice_header' =>
- "Date,Time,Name,Destination,Duration,Price",
- },
- 'simple2' => { 'name' => 'Simple with source',
- 'invoice_header' =>
- #"Date,Time,Name,Called From,Destination,Duration,Price",
- "Date,Time,Called From,Destination,Duration,Price",
- },
+ 'simple' => {
+ 'name' => 'Simple',
+ 'invoice_header' => "Date,Time,Name,Destination,Duration,Price",
+ },
+ 'simple2' => {
+ 'name' => 'Simple with source',
+ 'invoice_header' => "Date,Time,Called From,Destination,Duration,Price",
+ #"Date,Time,Name,Called From,Destination,Duration,Price",
+ },
+ 'default' => {
+ 'name' => 'Default',
+ 'invoice_header' => 'Date,Time,Duration,Price,Number,Destination',
+ },
+ 'source_default' => {
+ 'name' => 'Default with source',
+ 'invoice_header' => 'Caller,Date,Time,Duration,Price,Number,Destination',
+ },
);
my %export_formats = (
@@ -459,7 +468,33 @@
sub { sprintf('%.2fm', shift->billsec / 60 ) }, #DURATION
sub { sprintf('%.3f', shift->upstream_price ) }, #PRICE
],
+ 'default' => [
+
+ #DATE
+ sub { time2str('%D', shift->calldate_unix ) },
+ # #time2str("%Y %b %d - %r", $cdr->calldate_unix ),
+
+ #TIME
+ sub { time2str('%r', shift->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
+
+ #DURATION
+ sub { my($cdr, %opt) = @_;
+ $opt{minutes}. ( $opt{granularity} ? 'm' : ' call' );
+ },
+
+ #PRICE
+ sub { my($cdr, %opt) = @_; $opt{money_char}. $opt{charge}; },
+
+ #DEST ("Number")
+ sub { my($cdr, %opt) = @_; $opt{pretty_dst} || $cdr->dst; },
+
+ #REGIONNAME ("Destination")
+ sub { my($cdr, %opt) = @_; $opt{dst_regionname}; },
+
+ ],
);
+$export_formats{'source_default'} = [ 'src', @{ $export_formats{'default'} } ];
sub downstream_csv {
my( $self, %opt ) = @_;
@@ -467,13 +502,17 @@
my $format = $opt{'format'}; # 'convergent';
return "Unknown format $format" unless exists $export_formats{$format};
+ #my $conf = new FS::Conf;
+ #$opt{'money_char'} ||= $conf->config('money_char') || '$';
+ $opt{'money_char'} ||= FS::Conf->new->config('money_char') || '$';
+
eval "use Text::CSV_XS;";
die $@ if $@;
my $csv = new Text::CSV_XS;
my @columns =
map {
- ref($_) ? &{$_}($self) : $self->$_();
+ ref($_) ? &{$_}($self, %opt) : $self->$_();
}
@{ $export_formats{$format} };
More information about the freeside-commits
mailing list