option for residential-only requirement for individual tax exemption numbers, RT...
authorIvan Kohler <ivan@freeside.biz>
Wed, 19 Nov 2014 08:12:38 +0000 (00:12 -0800)
committerIvan Kohler <ivan@freeside.biz>
Wed, 19 Nov 2014 08:12:38 +0000 (00:12 -0800)
FS/FS/Conf.pm
FS/FS/Upgrade.pm
FS/FS/cust_main_exemption.pm
httemplate/edit/cust_main/billing.html

index cb4274f..8fb6220 100644 (file)
@@ -5161,19 +5161,30 @@ and customer address. Include units.',
 
   {
     'key'         => 'tax-cust_exempt-groups',
-    'section'     => '',
+    'section'     => 'billing',
     'description' => 'List of grouping possibilities for tax names, for per-customer exemption purposes, one tax name per line.  For example, "GST" would indicate the ability to exempt customers individually from taxes named "GST" (but not other taxes).',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'tax-cust_exempt-groups-require_individual_nums',
-    'section'     => '',
-    'description' => 'When using tax-cust_exempt-groups, require an individual tax exemption number for each exemption from different taxes.',
+    'section'     => 'deprecated',
+    'description' => 'Deprecated: see tax-cust_exempt-groups-number_requirement',
     'type'        => 'checkbox',
   },
 
   {
+    'key'         => 'tax-cust_exempt-groups-num_req',
+    'section'     => 'billing',
+    'description' => 'When using tax-cust_exempt-groups, control whether individual tax exemption numbers are required for exemption from different taxes.',
+    'type'        => 'select',
+    'select_hash' => [ ''            => 'Not required',
+                       'residential' => 'Required for residential customers only',
+                       'all'         => 'Required for all customers',
+                     ],
+  },
+
+  {
     'key'         => 'cust_main-default_view',
     'section'     => 'UI',
     'description' => 'Default customer view, for users who have not selected a default view in their preferences.',
index 7aa7ce3..381fd5f 100644 (file)
@@ -133,6 +133,12 @@ If you need to continue using the old Form 477 report, turn on the
 
   }
 
+  # boolean tax-cust_exempt-groups-require_individual_nums is now -num_req all
+  if ( $conf->exists('tax-cust_exempt-groups-require_individual_nums') ) {
+    $conf->set('tax-cust_exempt-groups-num_req', 'all');
+    $conf->delete('tax-cust_exempt-groups-require_individual_nums');
+  }
+
 }
 
 sub upgrade_overlimit_groups {
index 6492e22..4fe6b71 100644 (file)
@@ -115,9 +115,14 @@ sub check {
   return $error if $error;
 
   my $conf = new FS::Conf;
-  if ( ! $self->exempt_number && $conf->exists('tax-cust_exempt-groups-require_individual_nums') ) {
-    return 'Tax exemption number required for '. $self->taxname. ' exemption';
-  }
+  return 'Tax exemption number required for '. $self->taxname. ' exemption'
+    if ! $self->exempt_number
+    && (    $conf->exists('tax-cust_exempt-groups-require_individual_nums')
+         || $conf->config('tax-cust_exempt-groups-num_req') eq 'all'
+         || ( $conf->config('tax-cust_exempt-groups-num_req') eq 'residential'
+              && ! $self->cust_main->company
+            )
+       );
 
   $self->SUPER::check;
 }
index 16ddb2e..1f44905 100644 (file)
 %   my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
 %   if (    $conf->exists('cust_class-tax_exempt')
 %        || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
+%        || $conf->config('tax-cust_exempt-groups-num_req') =~ /\w/
 %        || ! $curuser->access_right('Edit customer tax exemptions')
 %      )
 %   {