bundled package presentation improvements
[freeside.git] / FS / FS / cust_bill.pm
index c404b8b..96c1db7 100644 (file)
@@ -226,7 +226,12 @@ Returns the line items (see L<FS::cust_bill_pkg>) for this invoice.
 
 sub cust_bill_pkg {
   my $self = shift;
-  qsearch( 'cust_bill_pkg', { 'invnum' => $self->invnum } );
+  qsearch(
+    { 'table'    => 'cust_bill_pkg',
+      'hashref'  => { 'invnum' => $self->invnum },
+      'order_by' => 'ORDER BY billpkgnum',
+    }
+  );
 }
 
 =item cust_pkg
@@ -1626,6 +1631,8 @@ L<Time::Local> and L<Date::Parse> for conversion functions.
 
 cid - 
 
+unsquelch_cdr - overrides any per customer cdr squelching when true
+
 =cut
 
 sub print_generic {
@@ -2049,6 +2056,8 @@ sub print_generic {
     $options{'section'} = $section if $multisection;
     $options{'format'} = $format;
     $options{'escape_function'} = $escape_function;
+    $options{'format_function'} = sub { () }
+      unless $params{unsquelch_cdr} || $cust_main->squelch_cdr ne 'Y';
 
     foreach my $line_item ( $self->_items_pkg(%options) ) {
       my $detail = {
@@ -2156,8 +2165,8 @@ sub print_generic {
                )
       );
     if ( $multisection ) {
-      $adjust_section->{'pretotal'} = 'New charges total '.
-                                      $total->{'total_amount'};
+      $adjust_section->{'pretotal'} = 'New charges total '. $other_money_char.
+                                      sprintf('%.2f', $self->charged );
     }else{
       push @total_items, $total;
     }
@@ -2633,6 +2642,7 @@ sub _items_cust_bill_pkg {
 
   my $format = $opt{format} || '';
   my $escape_function = $opt{escape_function} || sub { shift };
+  my $format_function = $opt{format_function} || '';
 
   my @b = ();
   foreach my $cust_bill_pkg ( @$cust_bill_pkg ) {
@@ -2643,6 +2653,7 @@ sub _items_cust_bill_pkg {
 
     my %details_opt = ( 'format'          => $format,
                         'escape_function' => $escape_function,
+                        'format_function' => $format_function,
                       );
 
     if ( $cust_bill_pkg->pkgnum > 0 ) {
@@ -2672,8 +2683,8 @@ sub _items_cust_bill_pkg {
 
         my $description = $desc;
         unless ( $conf->exists('disable_line_item_date_ranges') ) {
-          $desc .= " (" . time2str("%x", $cust_bill_pkg->sdate).
-                   " - ". time2str("%x", $cust_bill_pkg->edate). ")";
+          $description .= " (" . time2str("%x", $cust_bill_pkg->sdate).
+                          " - ". time2str("%x", $cust_bill_pkg->edate). ")";
         }
 
         #at least until cust_bill_pkg has "past" ranges in addition to
@@ -2682,6 +2693,7 @@ sub _items_cust_bill_pkg {
                     $cust_pkg->h_labels_short($self->_date);
                                               #$cust_bill_pkg->edate,
                                               #$cust_bill_pkg->sdate),
+        @d = () if $cust_bill_pkg->itemdesc;
         push @d, $cust_bill_pkg->details(%details_opt);
 
         push @b, {