X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=site_perl%2Fcust_main.pm;h=7dba86a7a930f0f3daa1d5f5755d3a6a9b977ee3;hb=8f4617e35f89b741b8ab5ba9136667b4c877d992;hp=2002f7a5957272b9f3d8490615f7a02deacc3599;hpb=220ac1e017ab668f9fac1e5ff0ca648f8fdfe913;p=freeside.git diff --git a/site_perl/cust_main.pm b/site_perl/cust_main.pm index 2002f7a59..7dba86a7a 100644 --- a/site_perl/cust_main.pm +++ b/site_perl/cust_main.pm @@ -5,7 +5,8 @@ use vars qw($paymentserversecret $paymentserverport $paymentserverhost); package FS::cust_main; use strict; -use vars qw(@ISA $conf $lpr $processor $xaction $E_NoErr $invoice_from); +use vars qw( @ISA $conf $lpr $processor $xaction $E_NoErr $invoice_from + $smtpmachine ); use Safe; use Carp; use Time::Local; @@ -34,6 +35,7 @@ $FS::UID::callback{'FS::cust_main'} = sub { $conf = new FS::Conf; $lpr = $conf->config('lpr'); $invoice_from = $conf->config('invoice_from'); + $smtpmachine = $conf->config('smtpmachine'); if ( $conf->exists('cybercash3.2') ) { require CCMckLib3_2; @@ -227,10 +229,12 @@ sub check { return "Unknown referral" unless qsearchs( 'part_referral', { 'refnum' => $self->refnum } ); - $self->getfield('last') =~ /^([\w \,\.\-\']+)$/ or return "Illegal last name"; + $self->getfield('last') =~ /^([\w \,\.\-\']+)$/ + or return "Illegal last name: ". $self->getfield('last'); $self->setfield('last',$1); - $self->first =~ /^([\w \,\.\-\']+)$/ or return "Illegal first name"; + $self->first =~ /^([\w \,\.\-\']+)$/ + or return "Illegal first name: ". $self->first; $self->first($1); if ( $self->ss eq '' ) { @@ -239,18 +243,18 @@ sub check { my $ss = $self->ss; $ss =~ s/\D//g; $ss =~ /^(\d{3})(\d{2})(\d{4})$/ - or return "Illegal social security number"; + or return "Illegal social security number: ". $self->ss; $self->ss("$1-$2-$3"); } - $self->country =~ /^(\w\w)$/ or return "Illegal country"; + $self->country =~ /^(\w\w)$/ or return "Illegal country: ". $self->country; $self->country($1); unless ( qsearchs('cust_main_county', { 'country' => $self->country, 'state' => '', } ) ) { - return "Unknown state/county/country" - #" state ". $self->state. " county ". $self->county. " country ". $self->country + return "Unknown state/county/country: ". + $self->state. "/". $self->county. "/". $self->country unless qsearchs('cust_main_county',{ 'state' => $self->state, 'county' => $self->county, @@ -258,10 +262,12 @@ sub check { } ); } - $self->zip =~ /^\s*(\w[\w\-\s]{3,8}\w)\s*$/ or return "Illegal zip"; + $self->zip =~ /^\s*(\w[\w\-\s]{3,8}\w)\s*$/ + or return "Illegal zip: ". $self->zip; $self->zip($1); - $self->payby =~ /^(CARD|BILL|COMP)$/ or return "Illegal payby"; + $self->payby =~ /^(CARD|BILL|COMP)$/ + or return "Illegal payby: ". $self->payby; $self->payby($1); if ( $self->payby eq 'CARD' ) { @@ -269,21 +275,22 @@ sub check { my $payinfo = $self->payinfo; $payinfo =~ s/\D//g; $payinfo =~ /^(\d{13,16})$/ - or return "Illegal credit card number"; + or return "Illegal credit card number: ". $self->payinfo; $payinfo = $1; $self->payinfo($payinfo); - validate($payinfo) or return "Illegal credit card number"; + validate($payinfo) + or return "Illegal credit card number: ". $self->payinfo; return "Unknown card type" if cardtype($self->payinfo) eq "Unknown"; } elsif ( $self->payby eq 'BILL' ) { $error = $self->ut_textn('payinfo'); - return "Illegal P.O. number" if $error; + return "Illegal P.O. number: ". $self->payinfo if $error; } elsif ( $self->payby eq 'COMP' ) { $error = $self->ut_textn('payinfo'); - return "Illegal comp account issuer" if $error; + return "Illegal comp account issuer: ". $self->payinfo if $error; } @@ -292,7 +299,7 @@ sub check { $self->paydate(''); } else { $self->paydate =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/ - or return "Illegal expiration date"; + or return "Illegal expiration date: ". $self->paydate; if ( length($2) == 4 ) { $self->paydate("$2-$1-01"); } elsif ( $2 > 97 ) { #should pry change to check for "this year" @@ -306,11 +313,11 @@ sub check { $self->payname( $self->first. " ". $self->getfield('last') ); } else { $self->payname =~ /^([\w \,\.\-\']+)$/ - or return "Illegal billing name"; + or return "Illegal billing name: ". $self->payname; $self->payname($1); } - $self->tax =~ /^(Y?)$/ or return "Illegal tax"; + $self->tax =~ /^(Y?)$/ or return "Illegal tax: ". $self->tax; $self->tax($1); $self->otaker(getotaker); @@ -591,6 +598,8 @@ sub collect { #my @print_text = $cust_bill->print_text; #( date ) my @invoicing_list = $self->invoicing_list; if ( grep { $_ ne 'POST' } @invoicing_list ) { #email invoice + $ENV{SMTPHOSTS} = $smtpmachine; + $ENV{MAILADDRESS} = $invoice_from; my $header = new Mail::Header ( [ "From: $invoice_from", "To: ". join(', ', grep { $_ ne 'POST' } @invoicing_list ), @@ -809,8 +818,13 @@ This interface may change in the future. sub invoicing_list { my( $self, $arrayref ) = @_; if ( $arrayref ) { - my @cust_main_invoice = - qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } ); + my @cust_main_invoice; + if ( $self->custnum ) { + @cust_main_invoice = + qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } ); + } else { + @cust_main_invoice = (); + } foreach my $cust_main_invoice ( @cust_main_invoice ) { #warn $cust_main_invoice->destnum; unless ( grep { $cust_main_invoice->address eq $_ } @{$arrayref} ) { @@ -819,8 +833,12 @@ sub invoicing_list { warn $error if $error; } } - @cust_main_invoice = - qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } ); + if ( $self->custnum ) { + @cust_main_invoice = + qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } ); + } else { + @cust_main_invoice = (); + } foreach my $address ( @{$arrayref} ) { unless ( grep { $address eq $_->address } @cust_main_invoice ) { my $cust_main_invoice = new FS::cust_main_invoice ( { @@ -832,8 +850,12 @@ sub invoicing_list { } } } - map { $_->address } - qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } ); + if ( $self->custnum ) { + map { $_->address } + qsearch( 'cust_main_invoice', { 'custnum' => $self->custnum } ); + } else { + (); + } } =item check_invoicing_list ARRAYREF @@ -863,7 +885,7 @@ sub check_invoicing_list { =head1 VERSION -$Id: cust_main.pm,v 1.13 1999-02-28 20:09:03 ivan Exp $ +$Id: cust_main.pm,v 1.20 1999-04-10 08:35:14 ivan Exp $ =head1 BUGS @@ -919,7 +941,28 @@ enable cybercash, cybercash v3 support, don't need to import FS::UID::{datasrc,checkruid} ivan@sisd.com 98-sep-19-21 $Log: cust_main.pm,v $ -Revision 1.13 1999-02-28 20:09:03 ivan +Revision 1.20 1999-04-10 08:35:14 ivan +say what the unknown state/county/country are! + +Revision 1.19 1999/04/10 07:38:06 ivan +_all_ check stuff with illegal data return the bad data too, to help debugging + +Revision 1.18 1999/04/10 06:54:11 ivan +ditto + +Revision 1.17 1999/04/10 05:27:38 ivan +display an illegal payby, to assist importing + +Revision 1.16 1999/04/07 14:32:19 ivan +more &invoicing_list logic to skip searches when there is no custnum + +Revision 1.15 1999/04/07 13:41:54 ivan +in &invoicing_list, don't search if there's no custnum yet + +Revision 1.14 1999/03/29 12:06:15 ivan +buglet in email invoices fixed + +Revision 1.13 1999/02/28 20:09:03 ivan allow spaces in zip codes, for (at least) canada. pointed out by Clayton Gray