X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=f4b9c5993395940411764d21873f6f8442d32c5e;hb=03eaa0e229c5f5fc68a178d20fb69733db709787;hp=ac5e4561421cd3db43dc8b07c0d2fc2057244442;hpb=2e45f85a3b2544f89fb149a77b3a20df3381d48f;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index ac5e45614..f4b9c5993 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -31,6 +31,7 @@ use FS::UID qw( getotaker dbh driver_name ); use FS::Record qw( qsearchs qsearch dbdef regexp_sql ); use FS::Misc qw( generate_email send_email generate_ps do_print ); use FS::Msgcat qw(gettext); +use FS::CurrentUser; use FS::payby; use FS::cust_pkg; use FS::cust_svc; @@ -1790,7 +1791,8 @@ sub check { # bad idea to disable, causes billing to fail because of no tax rates later -# unless ( $import ) { +# except we don't fail any more + unless ( $import ) { unless ( qsearch('cust_main_county', { 'country' => $self->country, 'state' => '', @@ -1803,7 +1805,7 @@ sub check { 'country' => $self->country, } ); } -# } + } $error = $self->ut_phonen('daytime', $self->country) @@ -2072,7 +2074,7 @@ sub check { $self->$flag($1); } - $self->otaker(getotaker) unless $self->otaker; + $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum; warn "$me check AFTER: \n". $self->_dump if $DEBUG > 2; @@ -3473,6 +3475,7 @@ sub _make_lines { my %param = ( 'precommit_hooks' => $precommit_hooks, 'increment_next_bill' => $increment_next_bill, 'discounts' => \@discounts, + 'real_pkgpart' => $real_pkgpart, ); my $method = $options{cancel} ? 'calc_cancel' : 'calc_recur'; @@ -4924,8 +4927,7 @@ sub realtime_bop { #false laziness w/misc/process/payment.cgi - check both to make sure working # correctly - if ( defined $self->dbdef_table->column('paycvv') - && length($self->paycvv) + if ( length($self->paycvv) && ! grep { $_ eq cardtype($options{payinfo}) } $conf->config('cvv-save') ) { my $error = $self->remove_cvv; @@ -8863,7 +8865,17 @@ sub batch_charge { my $param = shift; #warn join('-',keys %$param); my $fh = $param->{filehandle}; - my @fields = @{$param->{fields}}; + my $agentnum = $param->{agentnum}; + my $format = $param->{format}; + + my $extra_sql = ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql; + + my @fields; + if ( $format eq 'simple' ) { + @fields = qw( custnum agent_custid amount pkg ); + } else { + die "unknown format $format"; + } eval "use Text::CSV_XS;"; die $@ if $@; @@ -8903,10 +8915,32 @@ sub batch_charge { $row{$field} = shift @columns; } - my $cust_main = qsearchs('cust_main', { 'custnum' => $row{'custnum'} } ); + if ( $row{custnum} && $row{agent_custid} ) { + dbh->rollback if $oldAutoCommit; + return "can't specify custnum with agent_custid $row{agent_custid}"; + } + + my %hash = (); + if ( $row{agent_custid} && $agentnum ) { + %hash = ( 'agent_custid' => $row{agent_custid}, + 'agentnum' => $agentnum, + ); + } + + if ( $row{custnum} ) { + %hash = ( 'custnum' => $row{custnum} ); + } + + unless ( scalar(keys %hash) ) { + $dbh->rollback if $oldAutoCommit; + return "can't find customer without custnum or agent_custid and agentnum"; + } + + my $cust_main = qsearchs('cust_main', { %hash } ); unless ( $cust_main ) { $dbh->rollback if $oldAutoCommit; - return "unknown custnum $row{'custnum'}"; + my $custnum = $row{custnum} || $row{agent_custid}; + return "unknown custnum $custnum"; } if ( $row{'amount'} > 0 ) {