tax-exempt numbers during signup, RT#32299
[freeside.git] / FS / FS / ClientAPI / Signup.pm
index 29ec239..ebf5693 100644 (file)
@@ -178,6 +178,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,
@@ -475,6 +476,7 @@ sub domain_select_hash {
 
 sub new_customer {
   my $packet = shift;
+warn Dumper($packet);
 
   my $conf = new FS::Conf;
   my $svc_x = $conf->config('signup_server-service') || 'svc_acct';
@@ -532,7 +534,7 @@ sub new_customer {
                          || $conf->config('signup_server-default_refnum'),
 
       ( map { $_ => $template_cust->$_ } qw( 
-              last first company daytime night fax 
+              last first company daytime night fax mobile
             )
       ),
 
@@ -563,7 +565,8 @@ sub new_customer {
 
       map { $_ => $packet->{$_} } qw(
         last first ss company 
-        daytime night fax stateid stateid_state
+        daytime night fax mobile
+        stateid stateid_state
         payby
         payinfo paycvv paydate payname paystate paytype
         paystart_month paystart_year payissue
@@ -645,6 +648,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
@@ -760,6 +771,7 @@ sub new_customer {
     \%hash,
     \@invoicing_list,
     'depend_jobnum' => $placeholder->jobnum,
+     %insert_options,
   );
   if ( $error ) {
     my $perror = $placeholder->delete;
@@ -930,7 +942,7 @@ sub new_customer_minimal {
 
       map { $_ => $packet->{$_} } qw(
         last first ss company 
-        daytime night fax
+        daytime night fax mobile
       ),
 
   } );