[freeside-commits] branch master updated. c34212f6b04a6796467ad1fb5d32154eae1ea40d

Mitch Jackson mitch at freeside.biz
Sat May 19 17:54:25 PDT 2018


The branch, master has been updated
       via  c34212f6b04a6796467ad1fb5d32154eae1ea40d (commit)
       via  709a481dd9a9f29009505356603db66613bf2cb6 (commit)
       via  9996cfd8b87a47576dbac33a04007ec42d024d23 (commit)
       via  fc5bf4070e3d34c6f6298fb3c61263644fa71ade (commit)
      from  b003202d1bd1ddc6717a4429c1f8863ebc27844c (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 c34212f6b04a6796467ad1fb5d32154eae1ea40d
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Sat May 19 19:51:03 2018 -0500

    RT# 78190 Fix bill summary missing taxes or fees

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 51f89f717..c90e65245 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -1417,13 +1417,12 @@ sub print_generic {
         $tax_section->{'description'} = $self->mt($tax_description);
         $tax_section->{'summarized'} = '';
 
-        if ( !grep $tax_section, @sections ) {
+        # append tax section unless it's already there
+        push @sections, $tax_section
+          unless grep {$_ eq $tax_section} @sections;
 
-          # append it if it's not already there
-          push @sections, $tax_section;
-          push @summary_subtotals, $tax_section;
-
-        }
+        push @summary_subtotals, $tax_section
+          unless grep {$_ eq $tax_section} @summary_subtotals;
 
       }
     } else {

commit 709a481dd9a9f29009505356603db66613bf2cb6
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Sat May 19 20:31:02 2018 +0000

    RT# 79363 Hide empty tax section, invoice_sections_with_taxes

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index f36fb9628..51f89f717 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -1396,6 +1396,14 @@ sub print_generic {
       $other_money_char. sprintf('%.2f', $self->charged - $taxtotal );
 
     if ( $multisection ) {
+
+      if ( $conf->config_bool('invoice_sections_with_taxes', $cust_main->agentnum) ) {
+        # If all tax items are displayed in location/category sections,
+        # remove the empty tax section
+        @sections = grep{ $_ ne $tax_section } @sections
+          unless grep{ $_->{section} eq $tax_section } @detail_items;
+      }
+
       if ( $taxtotal > 0 ) {
         # there are taxes, so prepare the section to be displayed.
         # $taxtotal already includes any line items that were already in the
@@ -1409,14 +1417,7 @@ sub print_generic {
         $tax_section->{'description'} = $self->mt($tax_description);
         $tax_section->{'summarized'} = '';
 
-        if ( $conf->config_bool('invoice_sections_with_taxes', $cust_main->agentnum) ) {
-
-          # If all tax items are displayed in location/category sections,
-          # remove the empty tax section
-          @sections = grep{ $_ ne $tax_section } @sections
-            unless grep{ $_->{section} eq $tax_section } @detail_items;
-
-        } elsif ( !grep $tax_section, @sections ) {
+        if ( !grep $tax_section, @sections ) {
 
           # append it if it's not already there
           push @sections, $tax_section;

commit 9996cfd8b87a47576dbac33a04007ec42d024d23
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Sat May 19 20:05:15 2018 +0000

    RT# 78190 Fix taxes on fees for sectioned invoices
    
    Fix taxes charged on a billing-event fee, such as a late fee,
    displayed incorrectly on some sectioned invoices

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index edbb4d440..f36fb9628 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -3196,6 +3196,7 @@ sub _items_fee {
 
     push @items,
       { feepart     => $cust_bill_pkg->feepart,
+        billpkgnum  => $cust_bill_pkg->billpkgnum,
         amount      => sprintf('%.2f', $cust_bill_pkg->setup + $cust_bill_pkg->recur),
         description => $desc,
         pkg_tax     => \@pkg_tax,
diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
index f6b40f6b2..1262c3874 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -1881,7 +1881,29 @@ sub _pkg_tax_list {
   #   Duplicates can be identified by billpkgtaxlocationnum column.
 
   my $self = shift;
-  return unless $self->pkgnum;
+
+  my $search_selector;
+  if ( $self->pkgnum ) {
+
+    # For taxes applied to normal billing items
+    $search_selector =
+      ' cust_bill_pkg_tax_location.pkgnum = '
+      . dbh->quote( $self->pkgnum );
+
+  } elsif ( $self->feepart ) {
+
+    # For taxes applied to fees, when the fee is not attached to a package
+    # i.e. late fees, billing events fees
+    $search_selector =
+      ' cust_bill_pkg_tax_location.taxable_billpkgnum = '
+      . dbh->quote( $self->billpkgnum );
+
+  } else {
+    warn "_pkg_tax_list() unhandled case breaking taxes into sections";
+    warn "_pkg_tax_list() $_: ".$self->$_
+      for qw(pkgnum billpkgnum feepart);
+    return;
+  }
 
   map +{
       billpkgtaxlocationnum => $_->billpkgtaxlocationnum,
@@ -1907,7 +1929,7 @@ sub _pkg_tax_list {
       ' WHERE '.
       ' cust_bill_pkg.invnum = ' . dbh->quote( $self->invnum ) .
       ' AND '.
-      ' cust_bill_pkg_tax_location.pkgnum = ' . dbh->quote( $self->pkgnum ),
+      $search_selector
   });
 
 }

commit fc5bf4070e3d34c6f6298fb3c61263644fa71ade
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Fri May 18 22:40:08 2018 +0000

    RT# 78190 Fix billing event/late fee on sectioned invoices

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 646312502..edbb4d440 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -1346,27 +1346,36 @@ sub print_generic {
   #$tax_section->{'summarized'} = ''; #why? $summarypage && !$tax_weight ? 'Y' : '';
   #$tax_section->{'sort_weight'} = $tax_weight;
 
+  my $invoice_sections_with_taxes = $conf->config_bool(
+    'invoice_sections_with_taxes', $cust_main->agentnum
+  );
+
   foreach my $tax ( @items_tax ) {
 
-    $taxtotal += $tax->{'amount'};
 
     my $description = &$escape_function( $tax->{'description'} );
     my $amount      = sprintf( '%.2f', $tax->{'amount'} );
 
     if ( $multisection ) {
+      if ( !$invoice_sections_with_taxes ) {
 
-      push @detail_items, {
-        ext_description => [],
-        ref          => '',
-        quantity     => '',
-        description  => $description,
-        amount       => $money_char. $amount,
-        product_code => '',
-        section      => $tax_section,
-      };
+        $taxtotal += $tax->{'amount'};
+
+        push @detail_items, {
+          ext_description => [],
+          ref          => '',
+          quantity     => '',
+          description  => $description,
+          amount       => $money_char. $amount,
+          product_code => '',
+          section      => $tax_section,
+        };
 
+      }
     } else {
 
+      $taxtotal += $tax->{'amount'};
+
       push @total_items, {
         'total_item'   => $description,
         'total_amount' => $other_money_char. $amount,
@@ -1402,8 +1411,10 @@ sub print_generic {
 
         if ( $conf->config_bool('invoice_sections_with_taxes', $cust_main->agentnum) ) {
 
-          # remove tax section if taxes are itemized within other sections
-          @sections = grep{ $_ ne $tax_section } @sections;
+          # If all tax items are displayed in location/category sections,
+          # remove the empty tax section
+          @sections = grep{ $_ ne $tax_section } @sections
+            unless grep{ $_->{section} eq $tax_section } @detail_items;
 
         } elsif ( !grep $tax_section, @sections ) {
 
@@ -3134,16 +3145,30 @@ sub _items_fee {
       warn "fee definition not found for line item #".$cust_bill_pkg->billpkgnum."\n";
       next;
     }
-    if ( exists($options{section}) and exists($options{section}{category}) )
-    {
-      my $categoryname = $options{section}{category};
-      # then filter for items that have that section
-      if ( $part_fee->categoryname ne $categoryname ) {
-        warn "skipping fee '".$part_fee->itemdesc."'--not in section $categoryname\n" if $DEBUG;
-        next;
-      }
-    } # otherwise include them all in the main section
-    # XXX what to do when sectioning by location?
+
+    # If _items_fee is called while building a sectioned invoice,
+    #   - invoice_sections_method: category
+    #     Skip fee records that do not match the section category.
+    #   - invoice_sections_method: location
+    #     Skip fee records always for location sections.
+    #     The fee records will be presented in the tax/fee section instead.
+    if (
+      exists( $options{section} )
+      and
+      (
+        (
+          exists( $options{section}{category} )
+          and
+          $part_fee->categoryname ne $options{section}{category}
+        )
+        or
+        exists( $options{section}{location})
+      )
+    ) {
+      warn "skipping fee '".$part_fee->itemdesc.
+           "'--not in section $options{section}{category}\n" if $DEBUG;
+      next;
+    }
 
     my @ext_desc;
     my %base_invnums; # invnum => invoice date

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

Summary of changes:
 FS/FS/Template_Mixin.pm | 88 ++++++++++++++++++++++++++++++++-----------------
 FS/FS/cust_bill_pkg.pm  | 26 +++++++++++++--
 2 files changed, 81 insertions(+), 33 deletions(-)




More information about the freeside-commits mailing list