[freeside-commits] branch FREESIDE_3_BRANCH updated. 500bdb00535dd46c34ef1148e891f90fa9bd9f6c

Ivan ivan at 420.am
Thu Dec 26 23:35:40 PST 2013


The branch, FREESIDE_3_BRANCH has been updated
       via  500bdb00535dd46c34ef1148e891f90fa9bd9f6c (commit)
      from  7b42fc3d69f111b2e79f2a43263c129fd3505938 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 500bdb00535dd46c34ef1148e891f90fa9bd9f6c
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Dec 26 23:35:39 2013 -0800

    for prepaid, display the time period triggered by a 0 recurring with freq in the setup line item, RT#26274

diff --git a/FS/FS/TemplateItem_Mixin.pm b/FS/FS/TemplateItem_Mixin.pm
index 8b0e16a..7df75d4 100644
--- a/FS/FS/TemplateItem_Mixin.pm
+++ b/FS/FS/TemplateItem_Mixin.pm
@@ -1,15 +1,21 @@
 package FS::TemplateItem_Mixin;
 
 use strict;
-use vars qw( $DEBUG $me ); # but NOT $conf
+use vars qw( $DEBUG $me $conf $date_format );
 use Carp;
+use Date::Format;
 use FS::UID;
 use FS::Record qw( qsearch qsearchs dbh );
+use FS::Conf;
 use FS::part_pkg;
 use FS::cust_pkg;
 
 $DEBUG = 0;
 $me = '[FS::TemplateItem_Mixin]';
+FS::UID->install_callback( sub { 
+  $conf = new FS::Conf;
+  $date_format      = $conf->config('date_format')      || '%x'; #/YY
+} );
 
 =item cust_pkg
 
@@ -63,6 +69,51 @@ sub desc {
   }
 }
 
+=item time_period_pretty PART_PKG, AGENTNUM
+
+Returns a formatted time period for this line item.
+
+=cut
+
+sub time_period_pretty {
+  my( $self, $part_pkg, $agentnum ) = @_;
+
+  #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)
+            || ! $self->sdate
+            || ! $self->edate;
+
+  my $date_style = '';
+  $date_style = $conf->config( 'cust_bill-line_item-date_style-non_monhtly',
+                               $agentnum
+                             )
+    if $part_pkg && $part_pkg->freq !~ /^1m?$/;
+  $date_style ||= $conf->config( 'cust_bill-line_item-date_style',
+                                  $agentnum
+                               );
+
+  my $time_period;
+  if ( defined($date_style) && $date_style eq 'month_of' ) {
+    $time_period = time2str('The month of %B', $self->sdate);
+  } elsif ( defined($date_style) && $date_style eq 'X_month' ) {
+    my $desc = $conf->config( 'cust_bill-line_item-date_description',
+                               $agentnum
+                            );
+    $desc .= ' ' unless $desc =~ /\s$/;
+    $time_period = $desc. time2str('%B', $self->sdate);
+  } else {
+    $time_period =      time2str($date_format, $self->sdate).
+                 " - ". time2str($date_format, $self->edate);
+  }
+
+  " ($time_period)";
+
+}
+
 =item details [ OPTION => VALUE ... ]
 
 Returns an array of detail information for the invoice line item.
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 2314c02..2d9be61 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -15,6 +15,7 @@ use Locale::Country;
 use Cwd;
 use FS::UID;
 use FS::Record qw( qsearch qsearchs );
+use FS::Conf;
 use FS::Misc qw( generate_ps generate_pdf );
 use FS::pkg_category;
 use FS::pkg_class;
@@ -2485,6 +2486,7 @@ sub _items_cust_bill_pkg {
           if $DEBUG > 1;
  
         my $cust_pkg = $cust_bill_pkg->cust_pkg;
+        my $part_pkg = $cust_pkg->part_pkg;
 
         # which pkgpart to show for display purposes?
         my $pkgpart = $cust_bill_pkg->pkgpart_override || $cust_pkg->pkgpart;
@@ -2493,7 +2495,7 @@ sub _items_cust_bill_pkg {
         # things with them
         my %item_dates = ();
         %item_dates = map { $_ => $cust_bill_pkg->$_ } ('sdate', 'edate')
-          unless $cust_pkg->part_pkg->option('disable_line_item_date_ranges',1);
+          unless $part_pkg->option('disable_line_item_date_ranges',1);
 
         if (    (!$type || $type eq 'S')
              && (    $cust_bill_pkg->setup != 0
@@ -2511,6 +2513,14 @@ sub _items_cust_bill_pkg {
             || $discount_show_always
             || $cust_bill_pkg->recur_show_zero;
 
+          $description .= $cust_bill_pkg->time_period_pretty( $part_pkg,
+                                                              $self->agentnum )
+            if $part_pkg->is_prepaid #for prepaid, "display the validity period
+                                     # triggered by the recurring charge freq
+                                     # (RT#26274)
+            && $cust_bill_pkg->recur == 0
+            && ! $cust_bill_pkg->recur_show_zero;
+
           my @d = ();
           my $svc_label;
           unless ( $cust_pkg->part_pkg->hide_svc_detail
@@ -2581,37 +2591,8 @@ sub _items_cust_bill_pkg {
 
           my $part_pkg = $cust_pkg->part_pkg;
 
-          #pry be a bit more efficient to look some of this conf stuff up
-          # outside the loop
-          unless (
-            $conf->exists('disable_line_item_date_ranges')
-              || $part_pkg->option('disable_line_item_date_ranges',1)
-              || ! $cust_bill_pkg->sdate
-              || ! $cust_bill_pkg->edate
-          ) {
-            my $time_period;
-            my $date_style = '';
-            $date_style = $conf->config( 'cust_bill-line_item-date_style-non_monhtly',
-                                         $self->agentnum
-                                       )
-              if $part_pkg && $part_pkg->freq !~ /^1m?$/;
-            $date_style ||= $conf->config( 'cust_bill-line_item-date_style',
-                                            $self->agentnum
-                                         );
-            if ( defined($date_style) && $date_style eq 'month_of' ) {
-              $time_period = time2str('The month of %B', $cust_bill_pkg->sdate);
-            } elsif ( defined($date_style) && $date_style eq 'X_month' ) {
-              my $desc = $conf->config( 'cust_bill-line_item-date_description',
-                                         $self->agentnum
-                                      );
-              $desc .= ' ' unless $desc =~ /\s$/;
-              $time_period = $desc. time2str('%B', $cust_bill_pkg->sdate);
-            } else {
-              $time_period =      time2str($date_format, $cust_bill_pkg->sdate).
-                           " - ". time2str($date_format, $cust_bill_pkg->edate);
-            }
-            $description .= " ($time_period)";
-          }
+          $description .= $cust_bill_pkg->time_period_pretty( $part_pkg,
+                                                              $self->agentnum );
 
           my @d = ();
           my @seconds = (); # for display of usage info

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/TemplateItem_Mixin.pm |   53 ++++++++++++++++++++++++++++++++++++++++++-
 FS/FS/Template_Mixin.pm     |   45 ++++++++++--------------------------
 2 files changed, 65 insertions(+), 33 deletions(-)




More information about the freeside-commits mailing list