[freeside-commits] branch FREESIDE_3_BRANCH updated. e50c06b014a5727385087fac381f978603e227ad

Jonathan Prykop jonathan at 420.am
Tue Apr 26 18:39:51 PDT 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  e50c06b014a5727385087fac381f978603e227ad (commit)
       via  08d94428f0807c3ae2921b5c1f4fe40b5631365f (commit)
      from  0bdda5e655c5c9464c912b4f72b1b173c3878d72 (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 e50c06b014a5727385087fac381f978603e227ad
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Apr 26 20:39:13 2016 -0500

    RT#39819: Packages with Show zero setup/recurring do not print on quotations [v3 only]

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 031c1f2..5e79ae1 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -3285,7 +3285,7 @@ sub _items_cust_bill_pkg {
         my @details = $cust_bill_pkg->details;
 
         # and I guess they're never bundled either?
-        if ( $cust_bill_pkg->setup != 0 ) {
+        if (( $cust_bill_pkg->setup != 0 ) || ( $cust_bill_pkg->setup_show_zero )) {
           my $description = $desc;
           $description .= ' Setup'
             if $cust_bill_pkg->recur != 0
@@ -3306,7 +3306,7 @@ sub _items_cust_bill_pkg {
                              ),
           };
         }
-        if ( $cust_bill_pkg->recur != 0 ) {
+        if (( $cust_bill_pkg->recur != 0 ) || ( $cust_bill_pkg->recur_show_zero )) {
           #push @b, {
           $r = {
             'pkgnum'      => $cust_bill_pkg->pkgpart, #so it displays in Ref
diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm
index f828a39..38b9cd2 100644
--- a/FS/FS/quotation.pm
+++ b/FS/FS/quotation.pm
@@ -313,6 +313,17 @@ sub _items_total {
   });
 
   my $total_setup = $self->total_setup;
+  my $total_recur = $self->total_recur;
+  my $setup_show = $total_setup > 0 ? 1 : 0;
+  my $recur_show = $total_recur > 0 ? 1 : 0;
+  unless ($setup_show && $recur_show) {
+    foreach my $quotation_pkg ($self->quotation_pkg) {
+      $setup_show = 1 if !$setup_show and $quotation_pkg->setup_show_zero;
+      $recur_show = 1 if !$recur_show and $quotation_pkg->recur_show_zero;
+      last if $setup_show && $recur_show;
+    }
+  }
+
   foreach my $pkg_tax (@setup_tax) {
     if ($pkg_tax->setup_amount > 0) {
       $total_setup += $pkg_tax->setup_amount;
@@ -323,9 +334,9 @@ sub _items_total {
     }
   }
 
-  if ( $total_setup > 0 ) {
+  if ( $setup_show ) {
     push @items, {
-      'total_item'   => $self->mt( $self->total_recur > 0 ? 'Total Setup' : 'Total' ),
+      'total_item'   => $self->mt( $recur_show ? 'Total Setup' : 'Total' ),
       'total_amount' => sprintf('%.2f',$total_setup),
       'break_after'  => ( scalar(@recur_tax) ? 1 : 0 )
     };
@@ -333,7 +344,6 @@ sub _items_total {
 
   #could/should add up the different recurring frequencies on lines of their own
   # but this will cover the 95% cases for now
-  my $total_recur = $self->total_recur;
   # label these with the frequency
   foreach my $pkg_tax (@recur_tax) {
     if ($pkg_tax->recur_amount > 0) {
@@ -348,7 +358,7 @@ sub _items_total {
     }
   }
 
-  if ( $total_recur > 0 ) {
+  if ( $recur_show ) {
     push @items, {
       'total_item'   => $self->mt('Total Recurring'),
       'total_amount' => sprintf('%.2f',$total_recur),

commit 08d94428f0807c3ae2921b5c1f4fe40b5631365f
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Apr 26 15:28:55 2016 -0500

    RT#39819: Packages with Show zero setup/recurring do not print on quotations [quotation_pkg methods, v3 reconcile]

diff --git a/FS/FS/quotation_pkg.pm b/FS/FS/quotation_pkg.pm
index f3356b5..959c462 100644
--- a/FS/FS/quotation_pkg.pm
+++ b/FS/FS/quotation_pkg.pm
@@ -384,12 +384,22 @@ sub setup {
     * ($self->quantity || 1);
 }
 
+sub setup_show_zero {
+  my $self = shift;
+  return $self->part_pkg->setup_show_zero;
+}
+
 sub recur {
   my $self = shift;
   ($self->unitrecur - sum(0, map { $_->recur_amount } $self->pkg_discount))
     * ($self->quantity || 1);
 }
 
+sub recur_show_zero {
+  my $self = shift;
+  return $self->part_pkg->recur_show_zero;
+}
+
 =item delete_details
 
 Deletes all quotation_pkgs_details associated with this pkg (see L<FS::quotation_pkg_detail>).

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

Summary of changes:
 FS/FS/Template_Mixin.pm |    4 ++--
 FS/FS/quotation.pm      |   18 ++++++++++++++----
 FS/FS/quotation_pkg.pm  |   10 ++++++++++
 3 files changed, 26 insertions(+), 6 deletions(-)




More information about the freeside-commits mailing list