optimize invoice rendering, RT#80177
authorIvan Kohler <ivan@freeside.biz>
Wed, 11 Apr 2018 01:11:06 +0000 (18:11 -0700)
committerIvan Kohler <ivan@freeside.biz>
Wed, 11 Apr 2018 01:11:06 +0000 (18:11 -0700)
FS/FS/TemplateItem_Mixin.pm
FS/FS/Template_Mixin.pm

index 28fbd59..28ef845 100644 (file)
@@ -107,14 +107,13 @@ Returns a formatted time period for this line item.
 =cut
 
 sub time_period_pretty {
-  my( $self, $part_pkg, $agentnum ) = @_;
+  my( $self, $part_pkg, $agentnum, %opt ) = @_;
 
   #more efficient to look some of this conf stuff up outside the
   # invoice/template display loop we're called from
   # (Template_Mixin::_invoice_cust_bill_pkg) and pass them in as options
 
-  return '' if $conf->exists('disable_line_item_date_ranges')
-            || $part_pkg->option('disable_line_item_date_ranges',1)
+  return '' if $opt{'disable_line_item_date_ranges'}
             || ! $self->sdate
             || ! $self->edate;
 
index 30b0444..d011ff0 100644 (file)
@@ -1200,6 +1200,8 @@ sub print_generic {
     $options{'skip_usage'} =
       scalar(@$extra_sections) && !grep{$section == $_} @$extra_sections;
     $options{'preref_callback'} = $params{'preref_callback'};
+    $options{'disable_line_item_date_ranges'} =
+      $conf->exists('disable_line_item_date_ranges');
 
     warn "$me   searching for line items\n"
       if $DEBUG > 1;
@@ -3474,8 +3476,15 @@ sub _items_cust_bill_pkg {
             || ($discount_show_always and $cust_bill_pkg->unitrecur > 0)
             || $cust_bill_pkg->recur_show_zero;
 
-          $description .= $cust_bill_pkg->time_period_pretty( $part_pkg,
-                                                              $agentnum )
+          my $disable_date_ranges =
+               $opt{disable_line_item_date_ranges}
+            || $part_pkg->option('disable_line_item_date_ranges', 1);
+
+          $description .= $cust_bill_pkg->time_period_pretty(
+                            $part_pkg,
+                            $agentnum,
+                            disable_date_ranges => $disable_date_ranges,
+                          )
             if $part_pkg->is_prepaid #for prepaid, "display the validity period
                                      # triggered by the recurring charge freq
                                      # (RT#26274)
@@ -3566,8 +3575,15 @@ sub _items_cust_bill_pkg {
             $description = $self->mt('Usage charges');
           }
 
-          $description .= $cust_bill_pkg->time_period_pretty( $part_pkg,
-                                                              $agentnum );
+          my $disable_date_ranges =
+               $opt{disable_line_item_date_ranges}
+            || $part_pkg->option('disable_line_item_date_ranges', 1);
+
+          $description .= $cust_bill_pkg->time_period_pretty(
+                                    $part_pkg,
+                                    $agentnum,
+                                    disable_date_ranges => $disable_date_ranges,
+                          );
 
           my @d = ();
           my @seconds = (); # for display of usage info