X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=0c50b8462f7653302761ee3f4a30ac4fac21af96;hb=3dff65c08ed16024f5fd5f55d23551f485ced164;hp=ef6628ffd1b66c09b87b49b9e56f605fd7158250;hpb=5f2093d63b321716766535a0ff3e7420882a8888;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index ef6628ffd..0c50b8462 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -35,6 +35,7 @@ use Business::CreditCard 0.28; use Locale::Country; use FS::UID qw( dbh driver_name ); use FS::Record qw( qsearchs qsearch dbdef regexp_sql ); +use FS::Cursor; use FS::Misc qw( generate_email send_email generate_ps do_print ); use FS::Msgcat qw(gettext); use FS::CurrentUser; @@ -77,6 +78,7 @@ use FS::contact; use FS::Locales; use FS::upgrade_journal; use FS::sales; +use FS::cust_payby; # 1 is mostly method/subroutine entry and options # 2 traces progress of some operations @@ -1794,12 +1796,15 @@ sub check { } ### start of stuff moved to cust_payby + # then mostly kept here to support upgrades (can remove in 5.x) + # but modified to allow everything to be empty - #$self->payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP|PREPAY|CASH|WEST|MCRD)$/ - # or return "Illegal payby: ". $self->payby; - #$self->payby($1); - FS::payby->can_payby($self->table, $self->payby) - or return "Illegal payby: ". $self->payby; + if ( $self->payby ) { + FS::payby->can_payby($self->table, $self->payby) + or return "Illegal payby: ". $self->payby; + } else { + $self->payby(''); + } $error = $self->ut_numbern('paystart_month') || $self->ut_numbern('paystart_year') @@ -1971,7 +1976,8 @@ sub check { if ( $self->paydate eq '' || $self->paydate eq '-' ) { return "Expiration date required" # shouldn't payinfo_check do this? - unless $self->payby =~ /^(BILL|PREPAY|CHEK|DCHK|LECB|CASH|WEST|MCRD|PPAL)$/; + unless ! $self->payby + || $self->payby =~ /^(BILL|PREPAY|CHEK|DCHK|LECB|CASH|WEST|MCRD|PPAL)$/; $self->paydate(''); } else { my( $m, $y ); @@ -1999,7 +2005,7 @@ sub check { ) { $self->payname( $self->first. " ". $self->getfield('last') ); } else { - $self->payname =~ /^([\w \,\.\-\'\&]+)$/ + $self->payname =~ /^([\w \,\.\-\'\&]*)$/ or return gettext('illegal_name'). " payname: ". $self->payname; $self->payname($1); } @@ -3300,6 +3306,8 @@ reason, and a 'reason_type' option must be passed to indicate the FS::reason_type for the new reason. An I option may be passed to set the credit's I field. +Likewise for I, I, I and +I. Any other options are passed to FS::cust_credit::insert. @@ -3325,10 +3333,10 @@ sub credit { $cust_credit->set('reason', $reason) } - for (qw( addlinfo eventnum )) { - $cust_credit->$_( delete $options{$_} ) - if exists($options{$_}); - } + $cust_credit->$_( delete $options{$_} ) + foreach grep exists($options{$_}), + qw( addlinfo eventnum ), + map "commission_$_", qw( agentnum salesnum pkgnum ); $cust_credit->insert(%options); @@ -5010,6 +5018,7 @@ sub process_bill_and_collect { # JRNL seq scan of cust_main on paydate... index on substrings? maybe set an # JRNL seq scan of cust_main on payinfo.. certainly not going toi ndex that... # JRNL leading/trailing spaces in first, last, company +# JRNL migrate to cust_payby # - otaker upgrade? journal and call it good? (double check to make sure # we're not still setting otaker here) # @@ -5086,6 +5095,45 @@ sub _upgrade_data { #class method } + unless ( FS::upgrade_journal->is_done('cust_main__cust_payby') ) { + + #we don't want to decrypt them, just stuff them as-is into cust_payby + local(@encrypted_fields) = (); + + local($FS::cust_payby::ignore_expired_card) = 1; + local($FS::cust_payby::ignore_banned_card) = 1; + + my @payfields = qw( payby payinfo paycvv paymask + paydate paystart_month paystart_year payissue + payname paystate paytype payip + ); + + my $search = new FS::Cursor { + 'table' => 'cust_main', + 'extra_sql' => " WHERE ( payby IS NOT NULL AND payby != '' ) ", + }; + + while (my $cust_main = $search->fetch) { + + my $cust_payby = new FS::cust_payby { + 'custnum' => $cust_main->custnum, + 'weight' => 1, + map { $_ => $cust_main->$_(); } @payfields + }; + + my $error = $cust_payby->insert; + die $error if $error; + + $cust_main->setfield($_, '') foreach @payfields; + $DEBUG = 2; + $error = $cust_main->replace; + die $error if $error; + + }; + + FS::upgrade_journal->set_done('cust_main__trimspaces'); + } + $class->_upgrade_otaker(%opts); }