[freeside-commits] branch FREESIDE_4_BRANCH updated. da77773f5fb48f16ead80647e176a5c1914e1a97

Ivan ivan at 420.am
Mon Jun 29 21:21:58 PDT 2015


The branch, FREESIDE_4_BRANCH has been updated
       via  da77773f5fb48f16ead80647e176a5c1914e1a97 (commit)
      from  7aebaecacccf7966d464733fd9718fe182e2489b (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 da77773f5fb48f16ead80647e176a5c1914e1a97
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Jun 29 21:21:57 2015 -0700

    setup+recur total on quotations, RT#36997

diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm
index 8843a87..7bf5ecb 100644
--- a/FS/FS/quotation.pm
+++ b/FS/FS/quotation.pm
@@ -260,15 +260,30 @@ sub _items_sections {
   my %opt = @_;
   my $escape = $opt{escape}; # the only one we care about
 
-  my %subtotals; # package frequency => subtotal
+  my %subtotals = (); # package frequency => subtotal
+  my $disable_total = 0;
   foreach my $pkg ($self->quotation_pkg) {
-    my $recur_freq = $pkg->part_pkg->freq;
+
+    my $part_pkg = $pkg->part_pkg;
+
+    my $recur_freq = $part_pkg->freq;
     ($subtotals{0} ||= 0) += $pkg->setup + $pkg->setup_tax;
     ($subtotals{$recur_freq} ||= 0) += $pkg->recur + $pkg->recur_tax;
+
+    #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
+      if $part_pkg->plan =~ /^prorate/
+      || $part_pkg->plan eq 'agent'
+      || $part_pkg->plan =~ /^torrus/
+      || $part_pkg->option('sync_bill_date');
+
   }
   my @pkg_freq_order = keys %{ FS::Misc->pkg_freqs };
 
   my @sections;
+  my $no_recurring = 0;
   foreach my $freq (keys %subtotals) {
 
     next if $subtotals{$freq} == 0;
@@ -279,6 +294,7 @@ sub _items_sections {
     if ( $freq eq '0' ) {
       if ( scalar(keys(%subtotals)) == 1 ) {
         # there are no recurring packages
+        $no_recurring = 1;
         $desc = $self->mt('Charges');
       } else {
         $desc = $self->mt('Setup Charges');
@@ -295,6 +311,18 @@ sub _items_sections {
       'subtotal'    => sprintf('%.2f',$subtotals{$freq}),
     };
   }
+
+  unless ( $disable_total || $no_recurring ) {
+    my $total = 0;
+    $total += $_ for values %subtotals;
+    push @sections, {
+      'description' => 'First payment',
+      'sort_weight' => 0,
+      'category'   => 'Total category', #required but what's it used for?
+      'subtotal'    => sprintf('%.2f',$total)
+    };
+  }
+
   return \@sections, [];
 }
 

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

Summary of changes:
 FS/FS/quotation.pm |   32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)




More information about the freeside-commits mailing list