tax-exempt numbers during signup, RT#32299
[freeside.git] / FS / FS / ClientAPI / Signup.pm
index 5407a8f..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';
@@ -646,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
@@ -761,6 +771,7 @@ sub new_customer {
     \%hash,
     \@invoicing_list,
     'depend_jobnum' => $placeholder->jobnum,
+     %insert_options,
   );
   if ( $error ) {
     my $perror = $placeholder->delete;