X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=f102d97eea2cb459448b8b76c17b09c27698a148;hp=7594fa85245a10aa7f1703fd227cb938a2f56ed6;hb=ad3bcb39580173f0ac1b6357cb49515d48af7ddf;hpb=e151a538a611ed5aa3c08164cebc7230e5fa0da1 diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 7594fa852..f102d97ee 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 ); @@ -93,6 +92,8 @@ our $skip_fuzzyfiles = 0; our $ucfirst_nowarn = 0; +#this info is in cust_payby as of 4.x +#this and the fields themselves can be removed in 5.x our @encrypted_fields = ('payinfo', 'paycvv'); sub nohistory_fields { ('payinfo', 'paycvv'); } @@ -278,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 @@ -1588,6 +1593,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)) { @@ -1632,6 +1638,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 = @@ -1845,7 +1856,7 @@ sub check { return "You are not permitted to create complimentary accounts." if ! $self->custnum && $self->complimentary eq 'Y' - && ! $FS::CurrentUser->CurrentUser->access_right('Complimentary customer'); + && ! $FS::CurrentUser::CurrentUser->access_right('Complimentary customer'); if ( $self->paydate eq '' || $self->paydate eq '-' ) { return "Expiration date required" @@ -1912,6 +1923,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. @@ -1989,6 +2015,17 @@ sub cust_payby { }); } +sub has_cust_payby_auto { + my $self = shift; + scalar( qsearch({ + 'table' => 'cust_payby', + 'hashref' => { 'custnum' => $self->custnum, }, + 'extra_sql' => " AND payby IN ( 'CARD', 'CHEK' ) ", + 'order_by' => 'LIMIT 1', + }) ); + +} + =item unsuspend Unsuspends all unflagged suspended packages (see L @@ -2127,16 +2164,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'} ) { + + foreach my $cust_payby ( $self->cust_payby ) { - #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); + #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 $self->_new_banned_pay_hashref; - my $error = $ban->insert; - return ( $error ) if $error; + my $ban = new FS::banned_pay $cust_payby->_new_banned_pay_hashref; + my $error = $ban->insert; + return ( $error ) if $error; + + } } @@ -2173,13 +2215,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.