X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=427112a8e6b42a995d661bc4ce021eb42d063fa3;hb=67b05564568d10ee3833a87f09b752d0319934ba;hp=671ad214becff4e7673adebf821be42abc7b86b3;hpb=8142815f404a02df9ba3f92ad8e703a7355c5bcd;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 671ad214b..427112a8e 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -24,7 +24,6 @@ use Scalar::Util qw( blessed ); use Time::Local qw(timelocal); use Data::Dumper; use Tie::IxHash; -use Digest::MD5 qw(md5_base64); use Date::Format; #use Date::Manip; use File::Temp; #qw( tempfile ); @@ -280,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 @@ -461,6 +464,8 @@ sub insert { } } + $self->_loc_change(); + warn " inserting $self\n" if $DEBUG > 1; @@ -1333,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); @@ -1590,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)) { @@ -2129,16 +2137,21 @@ sub cancel { return ( 'access denied' ) unless $FS::CurrentUser::CurrentUser->access_right('Cancel customer'); - if ( $opt{'ban'} && $self->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ ) { + if ( $opt{'ban'} ) { - #should try decryption (we might have the private key) - # and if not maybe queue a job for the server that does? - return ( "Can't (yet) ban encrypted credit cards" ) - if $self->is_encrypted($self->payinfo); + foreach my $cust_payby ( $self->cust_payby ) { - my $ban = new FS::banned_pay $self->_new_banned_pay_hashref; - my $error = $ban->insert; - return ( $error ) if $error; + #well, if they didn't get decrypted on search, then we don't have to + # try again... queue a job for the server that does have decryption + # capability if we're in a paranoid multi-server implementation? + return ( "Can't (yet) ban encrypted credit cards" ) + if $cust_payby->is_encrypted($cust_payby->payinfo); + + my $ban = new FS::banned_pay $cust_payby->_new_banned_pay_hashref; + my $error = $ban->insert; + return ( $error ) if $error; + + } } @@ -2175,13 +2188,6 @@ sub _banned_pay_hashref { }; } -sub _new_banned_pay_hashref { - my $self = shift; - my $hr = $self->_banned_pay_hashref; - $hr->{payinfo} = md5_base64($hr->{payinfo}); - $hr; -} - =item notes Returns all notes (see L) for this customer. @@ -4776,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