X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pkg.pm;h=d396f8239c6e626b72b1849c43d1c8059f1b4b5d;hp=c825c15672bdeb37919d0f6fb34f5b4711ebcfd8;hb=f8f4c51eaa6f5aa3d49672fe7a17f19fa22494c0;hpb=0d3dee3cf6dc3518fb21d1014f5ebb5ea7f95434 diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index c825c1567..d396f8239 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -480,6 +480,35 @@ sub details { #qsearch ( 'cust_bill_pkg_detail', { 'lineitemnum' => $self->lineitemnum }); } +=item details_header [ OPTION => VALUE ... ] + +Returns a list representing an invoice line item detail header, if any. +This relies on the behavior of voip_cdr in that it expects the header +to be the first CSV formatted detail (as is expected by invoice generation +routines). Returns the empty list otherwise. + +=cut + +sub details_header { + my $self = shift; + return '' unless defined dbdef->table('cust_bill_pkg_detail'); + + eval "use Text::CSV_XS;"; + die $@ if $@; + my $csv = new Text::CSV_XS; + + my @detail = + qsearch ({ 'table' => 'cust_bill_pkg_detail', + 'hashref' => { 'billpkgnum' => $self->billpkgnum, + 'format' => 'C', + }, + 'order_by' => 'ORDER BY detailnum LIMIT 1', + }); + return() unless scalar(@detail); + $csv->parse($detail[0]->detail) or return (); + $csv->fields; +} + =item desc Returns a description for this line item. For typical line items, this is the