[freeside-commits] branch FREESIDE_3_BRANCH updated. b041163aaf2e447e66899b0e4a530662431cc680

Jonathan Prykop jonathan at 420.am
Mon Mar 9 21:40:26 PDT 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  b041163aaf2e447e66899b0e4a530662431cc680 (commit)
       via  d7d7b020db58c4aa5be2521c38719df2ec0bacb2 (commit)
      from  3b713bdad84257fcff1e51457215be67ef3382f6 (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 b041163aaf2e447e66899b0e4a530662431cc680
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Mar 9 23:02:26 2015 -0500

    RT#29406: Per customer option to display service address of package on invoice [slight refactor]

diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index b87fda4..7c26d89 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -448,8 +448,6 @@ sub insert {
     }
   }
 
-  $self->_loc_change();
-
   warn "  inserting $self\n"
     if $DEBUG > 1;
 
@@ -1536,8 +1534,6 @@ sub replace {
     $self->set($l.'num', $new_loc->locationnum);
   } #for $l
 
-  $self->_loc_change($old);
-
   # replace the customer record
   my $error = $self->SUPER::replace($old);
 
@@ -1828,6 +1824,11 @@ sub check {
     $self->ss("$1-$2-$3");
   }
 
+  #turn off invoice_ship_address if ship & bill are the same
+  if ($self->bill_locationnum eq $self->ship_locationnum) {
+    $self->invoice_ship_address('');
+  }
+
   # cust_main_county verification now handled by cust_location check
 
   $error =
@@ -2093,6 +2094,21 @@ sub check {
   $self->SUPER::check;
 }
 
+=item replace_check
+
+Additional checks for replace only.
+
+=cut
+
+sub replace_check {
+  my ($new,$old) = @_;
+  #preserve old value if global config is set
+  if ($old && $conf->exists('invoice-ship_address')) {
+    $new->invoice_ship_address($old->invoice_ship_address);
+  }
+  return '';
+}
+
 =item addr_fields 
 
 Returns a list of fields which have ship_ duplicates.
@@ -5172,22 +5188,6 @@ sub process_bill_and_collect {
   $cust_main->bill_and_collect( %$param );
 }
 
-#hook for insert/replace
-#runs after locations have been set
-#but before custnum has been set (for insert)
-sub _loc_change {
-  my $self = shift;
-  my $old = shift;
-  #turn off invoice_ship_address if ship & bill are the same
-  if ($self->bill_locationnum eq $self->ship_locationnum) {
-    $self->invoice_ship_address('');
-  }
-  #preserve old value if global config is set (replace only)
-  elsif ($old && $conf->exists('invoice-ship_address')) {
-    $self->invoice_ship_address($old->invoice_ship_address);
-  }
-}
-
 #starting to take quite a while for big dbs
 #   (JRNL: journaled so it only happens once per database)
 # - seq scan of h_cust_main (yuck), but not going to index paycvv, so

commit d7d7b020db58c4aa5be2521c38719df2ec0bacb2
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Mar 6 20:08:32 2015 -0600

    RT#29406: Per customer option to display service address of package on invoice

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 6ed1d97..e512d2d 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1197,6 +1197,7 @@ sub tables_hashref {
         'message_noemail', 'char', 'NULL', 1, '', '',
         'bill_locationnum', 'int', 'NULL', '', '', '',
         'ship_locationnum', 'int', 'NULL', '', '', '',
+        'invoice_ship_address', 'char', 'NULL', 1, '', '',
       ],
       'primary_key' => 'custnum',
       'unique' => [ [ 'agentnum', 'agent_custid' ] ],
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 1a57754..ec1902a 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -570,7 +570,7 @@ sub print_generic {
     )),
 
     #global config
-    'ship_enable'     => $conf->exists('invoice-ship_address'),
+    'ship_enable'     => $cust_main->invoice_ship_address || $conf->exists('invoice-ship_address'),
     'unitprices'      => $conf->exists('invoice-unitprice'),
     'smallernotes'    => $conf->exists('invoice-smallernotes'),
     'smallerfooter'   => $conf->exists('invoice-smallerfooter'),
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 7d80746..b87fda4 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -274,6 +274,10 @@ Allow self-service editing of ticket subjects, empty or 'Y'
 
 Do not call, empty or 'Y'
 
+=item invoice_ship_address
+
+Display ship_address ("Service address") on invoices for this customer, empty or 'Y'
+
 =back
 
 =head1 METHODS
@@ -444,6 +448,8 @@ sub insert {
     }
   }
 
+  $self->_loc_change();
+
   warn "  inserting $self\n"
     if $DEBUG > 1;
 
@@ -1530,6 +1536,8 @@ sub replace {
     $self->set($l.'num', $new_loc->locationnum);
   } #for $l
 
+  $self->_loc_change($old);
+
   # replace the customer record
   my $error = $self->SUPER::replace($old);
 
@@ -1784,6 +1792,7 @@ sub check {
     || $self->ut_flag('invoice_noemail')
     || $self->ut_flag('message_noemail')
     || $self->ut_enum('locale', [ '', FS::Locales->locales ])
+    || $self->ut_flag('invoice_ship_address')
   ;
 
   foreach (qw(company ship_company)) {
@@ -5163,6 +5172,22 @@ sub process_bill_and_collect {
   $cust_main->bill_and_collect( %$param );
 }
 
+#hook for insert/replace
+#runs after locations have been set
+#but before custnum has been set (for insert)
+sub _loc_change {
+  my $self = shift;
+  my $old = shift;
+  #turn off invoice_ship_address if ship & bill are the same
+  if ($self->bill_locationnum eq $self->ship_locationnum) {
+    $self->invoice_ship_address('');
+  }
+  #preserve old value if global config is set (replace only)
+  elsif ($old && $conf->exists('invoice-ship_address')) {
+    $self->invoice_ship_address($old->invoice_ship_address);
+  }
+}
+
 #starting to take quite a while for big dbs
 #   (JRNL: journaled so it only happens once per database)
 # - seq scan of h_cust_main (yuck), but not going to index paycvv, so
diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html
index cd4914a..bb18612 100644
--- a/httemplate/docs/schema.html
+++ b/httemplate/docs/schema.html
@@ -137,6 +137,7 @@
         <li>otaker - order taker
         <li>referral_custnum
         <li>comments
+        <li>invoice_ship_address - Y or null, does ship address appear on invoice
       </ul>
       (columns in <i>italics</i> are optional)
     <li><a name="cust_main_invoice" href="man/FS/cust_main_invoice.html">cust_main_invoice</a> - Invoice destinations for email invoices.  Note that a customer can have many email destinations for their invoice (either literal or via svcnum), but only one postal destination.
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index d789572..7343a9d 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -82,6 +82,19 @@
           enable_district => 1,
           enable_coords => 1,
       &>
+% unless ($conf->exists('invoice-ship_address')) { #it's always on, so hide per-cust config
+        <TR>
+          <TD> </TD>
+          <TD COLSPAN="7">
+            <% include('/elements/checkbox.html',
+                 'field'      => 'invoice_ship_address',
+                 'value'      => 'Y',
+                 'curr_value' => $cust_main->invoice_ship_address,
+                 'postfix'    => emt('included on invoices'),
+            ) %>
+          </TD>
+        </TR>
+% }
       </TABLE>
     </DIV>
   </TD>
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index 5b61e74..e810d6f 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -13,6 +13,13 @@
  (<% mt('same as billing') %>)
 %   }
 </FONT>
+%   if (
+%     ($this eq 'ship')
+%     && $cust_main->invoice_ship_address 
+%     && !$conf->exists('invoice-ship_address') #it's always on, so hide per-cust config
+%    ) {
+<SPAN STYLE="padding-left: .25em;">(<% emt('included on invoices') %>)</SPAN>
+%   }
 <TABLE CLASS="fsinnerbox">
 
 % if ( $this eq 'bill' ) {

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

Summary of changes:
 FS/FS/Schema.pm                         |    1 +
 FS/FS/Template_Mixin.pm                 |    2 +-
 FS/FS/cust_main.pm                      |   25 +++++++++++++++++++++++++
 httemplate/docs/schema.html             |    1 +
 httemplate/edit/cust_main.cgi           |   13 +++++++++++++
 httemplate/view/cust_main/contacts.html |    7 +++++++
 6 files changed, 48 insertions(+), 1 deletion(-)




More information about the freeside-commits mailing list