diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2015-03-06 20:08:32 -0600 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2015-03-09 23:31:41 -0500 |
commit | d7d7b020db58c4aa5be2521c38719df2ec0bacb2 (patch) | |
tree | c695b747e855bfc4fa80645c579ccc4b74d35bfe /FS | |
parent | 3b713bdad84257fcff1e51457215be67ef3382f6 (diff) |
RT#29406: Per customer option to display service address of package on invoice
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
-rw-r--r-- | FS/FS/Template_Mixin.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 25 |
3 files changed, 27 insertions, 1 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 6ed1d9716..e512d2d4e 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 1a577549e..ec1902a8c 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 7d80746ba..b87fda4d6 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 |