[freeside-commits] branch FREESIDE_3_BRANCH updated. 3b713bdad84257fcff1e51457215be67ef3382f6

Mark Wells mark at 420.am
Mon Mar 9 20:40:27 PDT 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  3b713bdad84257fcff1e51457215be67ef3382f6 (commit)
      from  5156232ada5f9bd31aabb7def5cab671cd8e674f (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 3b713bdad84257fcff1e51457215be67ef3382f6
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Mar 9 20:39:45 2015 -0700

    set invoice default location to customer location as of the invoice date, #25343

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index fe50e4a..1a57754 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -3013,7 +3013,22 @@ sub _items_cust_bill_pkg {
   my $maxlength = $conf->config('cust_bill-latex_lineitem_maxlength') || 50;
 
   my $cust_main = $self->cust_main;#for per-agent cust_bill-line_item-ate_style
-                                   # and location labels
+
+  # for location labels: use default location on the invoice date
+  my $default_locationnum;
+  if ( $self->custnum ) {
+    my $h_cust_main;
+    my @h_search = FS::h_cust_main->sql_h_search($self->_date);
+    $h_cust_main = qsearchs({
+        'table'     => 'h_cust_main',
+        'hashref'   => { custnum => $self->custnum },
+        'extra_sql' => $h_search[1],
+        'addl_from' => $h_search[3],
+    }) || $cust_main;
+    $default_locationnum = $h_cust_main->ship_locationnum;
+  } elsif ( $self->prospectnum ) {
+    $default_locationnum = $self->prospect_main->cust_location->locationnum;
+  }
 
   my @b = (); # accumulator for the line item hashes that we'll return
   my ($s, $r, $u, $d) = ( undef, undef, undef, undef );
@@ -3198,11 +3213,10 @@ sub _items_cust_bill_pkg {
 
             push @d, @svc_labels
               unless $cust_bill_pkg->pkgpart_override; #don't redisplay services
-            my $lnum = $cust_main ? $cust_main->ship_locationnum
-                                  : $self->prospect_main->locationnum;
             # show the location label if it's not the customer's default
             # location, and we're not grouping items by location already
-            if ( $cust_pkg->locationnum != $lnum and !defined($locationnum) ) {
+            if ( $cust_pkg->locationnum != $default_locationnum
+                  and !defined($locationnum) ) {
               my $loc = $cust_pkg->location_label;
               $loc = substr($loc, 0, $maxlength). '...'
                 if $format eq 'latex' && length($loc) > $maxlength;
@@ -3300,11 +3314,10 @@ sub _items_cust_bill_pkg {
             warn "$me _items_cust_bill_pkg done adding service details\n"
               if $DEBUG > 1;
 
-            my $lnum = $cust_main ? $cust_main->ship_locationnum
-                                  : $self->prospect_main->locationnum;
             # show the location label if it's not the customer's default
             # location, and we're not grouping items by location already
-            if ( $cust_pkg->locationnum != $lnum and !defined($locationnum) ) {
+            if ( $cust_pkg->locationnum != $default_locationnum
+                  and !defined($locationnum) ) {
               my $loc = $cust_pkg->location_label;
               $loc = substr($loc, 0, $maxlength). '...'
                 if $format eq 'latex' && length($loc) > $maxlength;

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

Summary of changes:
 FS/FS/Template_Mixin.pm |   27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)




More information about the freeside-commits mailing list