X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FSignup.pm;h=abfcac88280522bcb189ae9032a40d088fb31612;hb=697ca3ce9ca4a6a357d6d2b1cfc31525edf252dc;hp=5407a8fa665bcf942a08fbe2e04416d22b175826;hpb=e18442a0b77e7ef55d51f369eabba19848d19a08;p=freeside.git diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 5407a8fa6..abfcac882 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -2,6 +2,7 @@ package FS::ClientAPI::Signup; use strict; use vars qw( $DEBUG $me ); +use subs qw( _myaccount_cache ); use Data::Dumper; use Tie::RefHash; use Digest::SHA qw(sha512_hex); @@ -24,6 +25,7 @@ use FS::queue; use FS::reg_code; use FS::payby; use FS::banned_pay; +use FS::part_tag; $DEBUG = 1; $me = '[FS::ClientAPI::Signup]'; @@ -178,6 +180,7 @@ sub signup_info { 'require_cvv' => $conf->exists('signup-require_cvv'), 'stateid_enabled' => $conf->exists('show_stateid'), 'paystate_enabled' => $conf->exists('show_bankstate'), + 'exempt_groups' => [ grep /\S/, $conf->config('tax-cust_exempt-groups') ], 'ship_enabled' => 1, 'msgcat' => $msgcat, 'label' => $label, @@ -520,6 +523,28 @@ sub new_customer { #shares some stuff with htdocs/edit/process/cust_main.cgi... take any # common that are still here and library them. + + my %cust_main = ( + 'agentnum' => $agentnum, + 'refnum' => $packet->{refnum} + || $conf->config('signup_server-default_refnum'), + 'tagnum' => [ FS::part_tag->default_tags ], + + ( map { $_ => $packet->{$_} } qw( + salesnum + ss stateid stateid_state + + payby + payinfo paycvv paydate payname paystate paytype + paystart_month paystart_year payissue + payip + + referral_custnum comments + ) + ), + + ); + my $template_custnum = $conf->config('signup_server-prepaid-template-custnum'); my $cust_main; if ( $template_custnum && $packet->{prepaid_shortform} ) { @@ -527,27 +552,10 @@ sub new_customer { my $template_cust = qsearchs('cust_main', { 'custnum' => $template_custnum } ); return { 'error' => 'Configuration error' } unless $template_cust; $cust_main = new FS::cust_main ( { - 'agentnum' => $agentnum, - 'refnum' => $packet->{refnum} - || $conf->config('signup_server-default_refnum'), - - ( map { $_ => $template_cust->$_ } qw( - last first company daytime night fax mobile - ) - ), - - ( map { $_ => $packet->{$_} } qw( - ss stateid stateid_state - - payby - payinfo paycvv paydate payname paystate paytype - paystart_month paystart_year payissue - payip - - referral_custnum comments - ) + %cust_main, + map { $_ => $template_cust->$_ } qw( + last first company daytime night fax mobile ), - } ); $bill_hash = { $template_cust->bill_location->location_hash }; @@ -556,23 +564,11 @@ sub new_customer { } else { $cust_main = new FS::cust_main ( { - #'custnum' => '', - 'agentnum' => $agentnum, - 'refnum' => $packet->{refnum} - || $conf->config('signup_server-default_refnum'), - + %cust_main, map { $_ => $packet->{$_} } qw( - last first ss company - daytime night fax mobile - stateid stateid_state - payby - payinfo paycvv paydate payname paystate paytype - paystart_month paystart_year payissue - payip + last first company daytime night fax mobile override_ban_warn - referral_custnum comments ), - } ); } @@ -630,7 +626,7 @@ sub new_customer { ); } - $cust_main->payby('BILL') # MCRD better? + $cust_main->payby('BILL') # MCRD better? no, that's for something else if $gw && $gw->gateway_namespace eq 'Business::OnlineThirdPartyPayment'; } @@ -646,6 +642,14 @@ sub new_customer { ? split( /\s*\,\s*/, $packet->{'invoicing_list'} ) : (); + my %insert_options = (); + + my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups'); + my @tax_exempt = grep { $packet->{"tax_$_"} eq 'Y' } @exempt_groups; + $insert_options{'tax_exemption'} = { + map { $_ => $packet->{"tax_$_".'_num'} } @tax_exempt + }; + $packet->{'pkgpart'} =~ /^(\d+)$/ or '' =~ /^()$/; my $pkgpart = $1; return { 'error' => 'Please select a package' } unless $pkgpart; #msgcat @@ -761,6 +765,7 @@ sub new_customer { \%hash, \@invoicing_list, 'depend_jobnum' => $placeholder->jobnum, + %insert_options, ); if ( $error ) { my $perror = $placeholder->delete; @@ -923,19 +928,29 @@ sub new_customer_minimal { # common that are still here and library them. my $cust_main = new FS::cust_main ( { - #'custnum' => '', - 'agentnum' => $agentnum, - 'refnum' => $packet->{refnum} - || $conf->config('signup_server-default_refnum'), - 'payby' => 'BILL', + 'agentnum' => $agentnum, + 'refnum' => $packet->{refnum} + || $conf->config('signup_server-default_refnum'), + 'tagnum' => [ FS::part_tag->default_tags ], map { $_ => $packet->{$_} } qw( - last first ss company - daytime night fax mobile + salesnum + last first company daytime night fax mobile + ss ), } ); + if ( grep length($packet->{$_}), FS::cust_main->location_fields ) { + my $bill_hash; + foreach my $f (FS::cust_main->location_fields) { + $bill_hash->{$f} = $packet->{$f}; + } + my $bill_location = FS::cust_location->new($bill_hash); + $cust_main->set('bill_location' => $bill_location); + $cust_main->set('ship_location' => $bill_location); + } + my @invoicing_list = $packet->{'invoicing_list'} ? split( /\s*\,\s*/, $packet->{'invoicing_list'} ) : (); @@ -1028,10 +1043,10 @@ sub new_customer_minimal { my $session_id; do { - $session_id = sha1_hex(time(). {}. rand(). $$) + $session_id = sha512_hex(time(). {}. rand(). $$) } until ( ! defined _myaccount_cache->get($session_id) ); #just in case - _cache->set( $session_id, $session, '1 hour' ); # 1 hour? + _myaccount_cache->set( $session_id, $session, '1 hour' ); # 1 hour? my %return = ( 'error' => '', 'signup_service' => $svc_x,