make customer tax status a required field when the vendor requires it, #39639
authorMark Wells <mark@freeside.biz>
Wed, 29 Jun 2016 07:41:18 +0000 (00:41 -0700)
committerMark Wells <mark@freeside.biz>
Wed, 29 Jun 2016 07:41:18 +0000 (00:41 -0700)
httemplate/edit/process/cust_main.cgi
httemplate/edit/process/prospect_main.html
httemplate/edit/prospect_main.html

index 99c7f90..04516e9 100755 (executable)
@@ -188,6 +188,15 @@ if ( $cgi->param('residential_commercial') eq 'Residential' ) {
 
 }
 
+# kind of a hack, but some tax data vendors require a status and others
+# don't.
+my $vendor = $conf->config('tax_data_vendor');
+if ( $vendor eq 'avalara' or $vendor eq 'suretax' ) {
+  if ( ! $cgi->param('taxstatusnum') ) {
+    $error ||= 'Tax status required';
+  }
+}
+
 #perhaps this stuff should go to cust_main.pm
 if ( $new->custnum eq '' or $duplicate_of ) {
 
index 7c8cc27..b2ae88e 100644 (file)
@@ -1,5 +1,6 @@
 <% include('elements/process.html',
      'table'          => 'prospect_main',
+     'precheck_callback' => $precheck,
      'args_callback'  => $args_callback,
      'agent_virt'     => 1,
      'process_o2m' => {
 %>
 <%init>
 
+my $precheck = sub {
+  my $cgi = shift;
+  my $vendor = FS::Conf->new->config('tax_data_vendor');
+  if ( $vendor eq 'avalara' or $vendor eq 'suretax' ) {
+    if ( ! $cgi->param('taxstatusnum') ) {
+      return 'Tax status required';
+    }
+  }
+};
+
 my $args_callback = sub {
   my( $cgi, $object ) = @_;
 
index fb67515..7c02538 100644 (file)
@@ -50,6 +50,7 @@
        },
        { 'field'    => 'taxstatusnum',
          'type'     => 'select-tax_status',
+         'required' => 1,
          'empty_label'   => ' ',
        },
      ],