summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main.pm
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-03-06 20:08:32 -0600
committerJonathan Prykop <jonathan@freeside.biz>2015-03-06 20:08:32 -0600
commit67b05564568d10ee3833a87f09b752d0319934ba (patch)
tree329bbedbc9dfbe70194d258b2f36983f4e39dc28 /FS/FS/cust_main.pm
parent95b6042f37f00de9dca4b5654522fc4098a82d04 (diff)
RT#29406: Per customer option to display service address of package on invoice
Diffstat (limited to 'FS/FS/cust_main.pm')
-rw-r--r--FS/FS/cust_main.pm25
1 files changed, 25 insertions, 0 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index c93a950..427112a 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -279,6 +279,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
@@ -460,6 +464,8 @@ sub insert {
}
}
+ $self->_loc_change();
+
warn " inserting $self\n"
if $DEBUG > 1;
@@ -1332,6 +1338,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);
@@ -1589,6 +1597,7 @@ sub check {
|| $self->ut_currencyn('currency')
|| $self->ut_alphan('po_number')
|| $self->ut_enum('complimentary', [ '', 'Y' ])
+ || $self->ut_flag('invoice_ship_address')
;
foreach (qw(company ship_company)) {
@@ -4773,6 +4782,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