[freeside-commits] branch master updated. 9d6c810bf70d12221ff3b7916b717a6f0c924a1c

Ivan ivan at 420.am
Thu Jun 29 13:39:51 PDT 2017


The branch, master has been updated
       via  9d6c810bf70d12221ff3b7916b717a6f0c924a1c (commit)
       via  7565d61a5a62c57f34f4e3efd59d2e3211229181 (commit)
      from  e773f2d834f6757e7a0430184d9db6939e0b632d (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 9d6c810bf70d12221ff3b7916b717a6f0c924a1c
Merge: 7565d61 e773f2d
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Jun 29 13:39:47 2017 -0700

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit 7565d61a5a62c57f34f4e3efd59d2e3211229181
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Jun 29 13:39:41 2017 -0700

    show a total range for prorate quotations

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 758b8ce..2dcf7d0 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -1161,14 +1161,27 @@ sub print_generic {
       if ( $invoice_data{finance_section} &&
            $section->{'description'} eq $invoice_data{finance_section} );
 
-    $section->{'subtotal'} = $other_money_char.
-                             sprintf('%.2f', $section->{'subtotal'})
-      if $multisection;
+    if ( $multisection ) {
+
+      if ( ref($section->{'subtotal'}) ) {
+
+        $section->{'subtotal'} =
+          sprintf("$other_money_char%.2f to $other_money_char%.2f",
+                    $section->{'subtotal'}[0],
+                    $section->{'subtotal'}[1]
+                 );
+
+      } else {
+
+        $section->{'subtotal'} = $other_money_char.
+                                 sprintf('%.2f', $section->{'subtotal'})
 
-    # continue some normalization
-    $section->{'amount'}   = $section->{'subtotal'}
-      if $multisection;
+      }
+
+      # continue some normalization
+      $section->{'amount'}   = $section->{'subtotal'}
 
+    }
 
     if ( $section->{'description'} ) {
       push @buf, ( [ &$escape_function($section->{'description'}), '' ],
@@ -1367,7 +1380,16 @@ sub print_generic {
     foreach ( @new_total_items ) {
       my ($item, $amount) = ($_->{'total_item'}, $_->{'total_amount'});
       $_->{'total_item'}   = &$embolden_function( $item );
-      $_->{'total_amount'} = &$embolden_function( $other_money_char.$amount );
+
+      if ( ref($amount) ) {
+        $_->{'total_amount'} = &$embolden_function(
+                                 $other_money_char.$amount->[0]. ' to '.
+                                 $other_money_char.$amount->[1]
+                               );
+      } else {
+        $_->{'total_amount'} = &$embolden_function( $other_money_char.$amount );
+      }
+
       # but if it's multisection, don't append to @total_items. the adjust
       # section has all this stuff
       push @total_items, $_ if !$multisection;
diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm
index f4c68d5..6b0c914 100644
--- a/FS/FS/quotation.pm
+++ b/FS/FS/quotation.pm
@@ -138,8 +138,9 @@ sub check {
 
   $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum;
 
-  return 'confidence must be an integer between 1 and 100'
-    if length($self->confidence) && (($self->confidence < 1) || ($self->confidence > 100));
+  return 'confidence percentage must be an integer between 1 and 100'
+    if length($self->confidence)
+    && ( ($self->confidence < 1) || ($self->confidence > 100) );
 
   return 'prospectnum or custnum must be specified'
     if ! $self->prospectnum
@@ -277,9 +278,10 @@ sub _items_sections {
   my %opt = @_;
   my $escape = $opt{escape}; # the only one we care about
 
+
   my %show; # package frequency => 1 if there's anything to display
   my %subtotals = (); # package frequency => subtotal
-  my $disable_total = 0;
+  my $prorate_total = 0;
   foreach my $pkg ($self->quotation_pkg) {
 
     my $part_pkg = $pkg->part_pkg;
@@ -293,7 +295,7 @@ sub _items_sections {
     #this is a shitty hack based on what's in part_pkg/ at the moment
     # but its good enough for the 99% common case of preventing totals from
     # displaying for prorate packages
-    $disable_total = 1
+    $prorate_total = 1
       if $part_pkg->plan =~ /^(prorate|torrus|agent$)/
       || $part_pkg->option('recur_method') eq 'prorate'
       || ( $part_pkg->option('sync_bill_date')
@@ -301,6 +303,9 @@ sub _items_sections {
              && $self->cust_main->billing_pkgs #num_billing_pkgs when we have it
          );
 
+    #possible improvement: keep track of flat vs. prorate totals to make the
+    # bottom range more accurate when mixing flat and prorate packages
+
   }
   my @pkg_freq_order = keys %{ FS::Misc->pkg_freqs };
 
@@ -335,15 +340,31 @@ sub _items_sections {
     };
   }
 
-  unless ( $disable_total || $no_recurring ) {
+  unless ( $no_recurring ) {
     my $total = 0;
     $total += $_ for values %subtotals;
-    push @sections, {
-      'description' => 'First payment',
+    my %total = (
       'sort_weight' => 0,
-      'category'   => 'Total category', #required but what's it used for?
-      'subtotal'    => sprintf('%.2f',$total)
-    };
+      'category'    => 'Total category', #required but what's it used for?
+    );
+
+    if ( $prorate_total ) {
+
+      push @sections, {
+        %total,
+        'description' => 'First payment (depending on day of month)',
+        'subtotal'    => [ $subtotals{0}, $total ],
+      };
+
+    } else {
+
+      push @sections, {
+        %total,
+        'description' => 'First payment',
+        'subtotal'    => $total,
+      };
+    }
+
   }
 
   return \@sections, [];

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

Summary of changes:
 FS/FS/Template_Mixin.pm |   36 +++++++++++++++++++++++++++++-------
 FS/FS/quotation.pm      |   41 +++++++++++++++++++++++++++++++----------
 2 files changed, 60 insertions(+), 17 deletions(-)




More information about the freeside-commits mailing list