[freeside-commits] freeside/FS/FS Schema.pm, 1.84, 1.85 cdr.pm, 1.10, 1.11 cust_bill.pm, 1.198, 1.199 cust_bill_pkg.pm, 1.14, 1.15 cust_bill_pkg_detail.pm, 1.3, 1.4
Jeff Finucane,420,,
jeff at wavetail.420.am
Fri May 16 12:26:40 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv32587/FS/FS
Modified Files:
Schema.pm cdr.pm cust_bill.pm cust_bill_pkg.pm
cust_bill_pkg_detail.pm
Log Message:
typeset CDRs into 5 columns on invoices
Index: cust_bill_pkg_detail.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg_detail.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cust_bill_pkg_detail.pm 3 Mar 2005 08:52:22 -0000 1.3
+++ cust_bill_pkg_detail.pm 16 May 2008 19:26:37 -0000 1.4
@@ -104,6 +104,7 @@
$self->ut_numbern('detailnum')
|| $self->ut_foreign_key('pkgnum', 'cust_pkg', 'pkgnum')
|| $self->ut_foreign_key('invnum', 'cust_bill', 'invnum')
+ || $self->ut_enum('format', [ '', 'C' ] )
|| $self->ut_text('detail')
|| $self->SUPER::check
;
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- Schema.pm 17 Apr 2008 01:39:53 -0000 1.84
+++ Schema.pm 16 May 2008 19:26:36 -0000 1.85
@@ -499,6 +499,7 @@
'detailnum', 'serial', '', '', '', '',
'pkgnum', 'int', '', '', '', '',
'invnum', 'int', '', '', '', '',
+ 'format', 'char', 'NULL', 1, '', '',
'detail', 'varchar', '', $char_d, '', '',
],
'primary_key' => 'detailnum',
Index: cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cdr.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cdr.pm 22 Apr 2008 10:56:01 -0000 1.10
+++ cdr.pm 16 May 2008 19:26:37 -0000 1.11
@@ -408,6 +408,14 @@
sub { shift->rated_price ? 'Y' : 'N' }, #RATED
'', #OTHER_INFO
],
+ 'voxlinesystems' => [
+ sub { time2str('%D', shift->calldate_unix ) }, #DATE
+ sub { time2str('%T', shift->calldate_unix ) }, #TIME
+ 'userfield', #USER
+ 'dst', #NUMBER_DIALED
+ sub { sprintf('%.2fm', shift->billsec / 60 ) }, #DURATION
+ sub { sprintf('%.3f', shift->upstream_price ) }, #PRICE
+ ],
);
sub downstream_csv {
Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cust_bill_pkg.pm 14 May 2008 18:07:22 -0000 1.14
+++ cust_bill_pkg.pm 16 May 2008 19:26:37 -0000 1.15
@@ -112,7 +112,8 @@
my $cust_bill_pkg_detail = new FS::cust_bill_pkg_detail {
'pkgnum' => $self->pkgnum,
'invnum' => $self->invnum,
- 'detail' => $detail,
+ 'format' => (ref($detail) ? $detail->[0] : '' ),
+ 'detail' => (ref($detail) ? $detail->[1] : $detail ),
};
$error = $cust_bill_pkg_detail->insert;
if ( $error ) {
@@ -220,18 +221,62 @@
qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
}
-=item details
+=item details [ OPTION => VALUE ... ]
Returns an array of detail information for the invoice line item.
+Currently available options are: I<format> I<escape_function>
+
+If I<format> is set to html or latex then the array members are improved
+for tabular appearance in those environments if possible.
+
+If I<escape_function> is set then the array members are processed by this
+function before being returned.
+
=cut
sub details {
- my $self = shift;
+ my ( $self, %opt ) = @_;
+ my $format = $opt{format} || '';
+ my $escape_function = $opt{escape_function} || sub { shift };
return () unless defined dbdef->table('cust_bill_pkg_detail');
- map { $_->detail }
- qsearch ( 'cust_bill_pkg_detail', { 'pkgnum' => $self->pkgnum,
- 'invnum' => $self->invnum, } );
+
+ eval "use Text::CSV_XS;";
+ die $@ if $@;
+ my $csv = new Text::CSV_XS;
+
+ my $format_sub = sub { my $detail = shift;
+ $csv->parse($detail) or return "can't parse $detail";
+ join(' - ', map { &$escape_function($_) }
+ $csv->fields
+ );
+ };
+
+ $format_sub = sub { my $detail = shift;
+ $csv->parse($detail) or return "can't parse $detail";
+ join('</TD><TD>', map { &$escape_function($_) }
+ $csv->fields
+ );
+ }
+ if $format eq 'html';
+
+ $format_sub = sub { my $detail = shift;
+ $csv->parse($detail) or return "can't parse $detail";
+ join(' & ', map { &$escape_function($_) } $csv->fields );
+ }
+ if $format eq 'latex';
+
+ map { ( $_->format eq 'C'
+ ? &{$format_sub}( $_->detail )
+ : &{$escape_function}( $_->detail )
+ )
+ }
+ qsearch ({ 'table' => 'cust_bill_pkg_detail',
+ 'hashref' => { 'pkgnum' => $self->pkgnum,
+ 'invnum' => $self->invnum,
+ },
+ 'order_by' => 'ORDER BY detailnum',
+ });
#qsearch ( 'cust_bill_pkg_detail', { 'lineitemnum' => $self->lineitemnum });
}
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -d -r1.198 -r1.199
--- cust_bill.pm 14 May 2008 21:23:00 -0000 1.198
+++ cust_bill.pm 16 May 2008 19:26:37 -0000 1.199
@@ -2000,6 +2000,7 @@
my %options = ();
$options{'section'} = $section if $multisection;
+ $options{'format'} = $format;
foreach my $line_item ( $self->_items_pkg(%options) ) {
my $detail = {
@@ -2010,9 +2011,7 @@
$detail->{'section'} = $section;
$detail->{'description'} = &$escape_function($line_item->{'description'});
if ( exists $line_item->{'ext_description'} ) {
- @{$detail->{'ext_description'}} = map {
- &$escape_function($_);
- } @{$line_item->{'ext_description'}};
+ @{$detail->{'ext_description'}} = @{$line_item->{'ext_description'}};
}
{
my $money = $old_latex ? '' : $money_char;
@@ -2528,6 +2527,9 @@
sub _items_cust_bill_pkg {
my $self = shift;
my $cust_bill_pkg = shift;
+ my %opt = @_;
+ my $format = $opt{format} || '';
+ my $escape_function = $opt{escape_function} || sub { shift };
my @b = ();
foreach my $cust_bill_pkg ( @$cust_bill_pkg ) {
@@ -2542,7 +2544,10 @@
my $description = $desc;
$description .= ' Setup' if $cust_bill_pkg->recur != 0;
my @d = $cust_pkg->h_labels_short($self->_date);
- push @d, $cust_bill_pkg->details if $cust_bill_pkg->recur == 0;
+ push @d, $cust_bill_pkg->details( 'format' => $format,
+ 'escape_function' => $escape_function,
+ )
+ if $cust_bill_pkg->recur == 0;
push @b, {
description => $description,
#pkgpart => $part_pkg->pkgpart,
@@ -2569,7 +2574,8 @@
[ $cust_pkg->h_labels_short( $self->_date ),
#$cust_bill_pkg->edate,
#$cust_bill_pkg->sdate),
- $cust_bill_pkg->details,
+ $cust_bill_pkg->details( 'format' => $format,
+ 'escape_function' => $escape_function),
],
};
}
More information about the freeside-commits
mailing list