From: Mark Wells <mark@freeside.biz>
Date: Tue, 12 Jul 2016 22:46:47 +0000 (-0700)
Subject: option to show all package locations on invoice, #71474
X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;ds=inline;h=7773547423c9cd0e8ac7915de58daacbec7ccf09;p=freeside.git

option to show all package locations on invoice, #71474
---

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index cf505de36..e916678e5 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3867,6 +3867,13 @@ and customer address. Include units.',
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'invoice-all_pkg_addresses',
+    'section'     => 'invoicing',
+    'description' => 'Show all package addresses on invoices, even the default.',
+    'type'        => 'checkbox',
+  },
+
   {
     'key'         => 'invoice-unitprice',
     'section'     => 'invoicing',
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index ed4bb6273..b197c6ce2 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -3177,7 +3177,9 @@ sub _items_cust_bill_pkg {
 
   # for location labels: use default location on the invoice date
   my $default_locationnum;
-  if ( $self->custnum ) {
+  if ( $conf->exists('invoice-all_pkg_addresses') ) {
+    $default_locationnum = 0; # treat them all as non-default
+  } elsif ( $self->custnum ) {
     my $h_cust_main;
     my @h_search = FS::h_cust_main->sql_h_search($self->_date);
     $h_cust_main = qsearchs({
@@ -3394,7 +3396,7 @@ sub _items_cust_bill_pkg {
             # location, and we're not grouping items by location already
             if ( $cust_pkg->locationnum != $default_locationnum
                   and !defined($locationnum) ) {
-              my $loc = $cust_pkg->location_label;
+              my $loc = $cust_pkg->location_label(no_prefix => 1);
               $loc = substr($loc, 0, $maxlength). '...'
                 if $format eq 'latex' && length($loc) > $maxlength;
               push @d, &{$escape_function}($loc);
@@ -3504,7 +3506,7 @@ sub _items_cust_bill_pkg {
             # location, and we're not grouping items by location already
             if ( $cust_pkg->locationnum != $default_locationnum
                   and !defined($locationnum) ) {
-              my $loc = $cust_pkg->location_label;
+              my $loc = $cust_pkg->location_label(no_prefix => 1);
               $loc = substr($loc, 0, $maxlength). '...'
                 if $format eq 'latex' && length($loc) > $maxlength;
               push @d, &{$escape_function}($loc);