taxclass fix (?)
authorivan <ivan>
Fri, 13 Dec 2002 00:31:32 +0000 (00:31 +0000)
committerivan <ivan>
Fri, 13 Dec 2002 00:31:32 +0000 (00:31 +0000)
FS/FS/cust_main.pm
httemplate/misc/process/meta-import.cgi

index 237abcd..890371d 100644 (file)
@@ -1058,26 +1058,25 @@ sub bill {
                  || $self->payby eq 'COMP'
                  || $taxable_charged == 0 ) {
 
                  || $self->payby eq 'COMP'
                  || $taxable_charged == 0 ) {
 
-          my $cust_main_county =
-            qsearchs('cust_main_county',{
+          my $cust_main_county = qsearchs('cust_main_county',{
               'state'    => $self->state,
               'county'   => $self->county,
               'country'  => $self->country,
               'taxclass' => $part_pkg->taxclass,
               'state'    => $self->state,
               'county'   => $self->county,
               'country'  => $self->country,
               'taxclass' => $part_pkg->taxclass,
-            } )
-            or qsearchs('cust_main_county',{
+          } );
+          $cust_main_county ||= qsearchs('cust_main_county',{
               'state'    => $self->state,
               'county'   => $self->county,
               'country'  => $self->country,
               'taxclass' => '',
               'state'    => $self->state,
               'county'   => $self->county,
               'country'  => $self->country,
               'taxclass' => '',
-            } )
-            or do {
-              $dbh->rollback if $oldAutoCommit;
-              return
-                "fatal: can't find tax rate for state/county/country/taxclass ".
-                join('/', ( map $self->$_(), qw(state county country) ),
-                          $part_pkg->taxclass ).  "\n";
-            };
+          } );
+          unless ( $cust_main_county ) {
+            $dbh->rollback if $oldAutoCommit;
+            return
+              "fatal: can't find tax rate for state/county/country/taxclass ".
+              join('/', ( map $self->$_(), qw(state county country) ),
+                        $part_pkg->taxclass ).  "\n";
+          }
 
           if ( $cust_main_county->exempt_amount ) {
             my ($mon,$year) = (localtime($sdate) )[4,5];
 
           if ( $cust_main_county->exempt_amount ) {
             my ($mon,$year) = (localtime($sdate) )[4,5];
index d42d6d4..4c3c7d6 100644 (file)
@@ -19,6 +19,7 @@ function SafeOnsubmit() {
     gSafeOnsubmit[i]();
 }
 </SCRIPT>
     gSafeOnsubmit[i]();
 }
 </SCRIPT>
+<FORM NAME="OneTrueForm" METHOD="POST" ACTION="meta-import.cgi">
 <%
   #one
   unless ( $cgi->param('magic') ) {
 <%
   #one
   unless ( $cgi->param('magic') ) {
@@ -41,23 +42,19 @@ credcode  dundet    invline  payment  prodclas  repforms  webserv
     );
 
     %>
     );
 
     %>
-    <FORM NAME="OneTrueForm" METHOD="POST" ACTION="meta-import.cgi">
     <INPUT TYPE="hidden" NAME="magic" VALUE="process">
     <%= hashmaker('schema', \@files, [ grep { ! /^h_/ } dbdef->tables ] ) %>
     <br><INPUT TYPE="submit" VALUE="done">
     <INPUT TYPE="hidden" NAME="magic" VALUE="process">
     <%= hashmaker('schema', \@files, [ grep { ! /^h_/ } dbdef->tables ] ) %>
     <br><INPUT TYPE="submit" VALUE="done">
-    </FORM>
-    </BODY>
-    </HTML>
     <%
 
   } elsif ( $cgi->param('magic') eq 'process' ) {
 
     %>
     <%
 
   } elsif ( $cgi->param('magic') eq 'process' ) {
 
     %>
-    <FORM NAME="OneTrueForm" METHOD="POST" ACTION="meta-import.cgi">
     <INPUT TYPE="hidden" NAME="magic" VALUE="process2">
     <%
 
     my $schema_string = $cgi->param('schema');
     <INPUT TYPE="hidden" NAME="magic" VALUE="process2">
     <%
 
     my $schema_string = $cgi->param('schema');
+    %><INPUT TYPE="hidden" NAME="schema" VALUE="<%=$schema_string%>"><%
     my %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/
                          or die "guru meditation #420: $_";
                        ( $1 => $2 );
     my %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/
                          or die "guru meditation #420: $_";
                        ( $1 => $2 );
@@ -88,18 +85,47 @@ credcode  dundet    invline  payment  prodclas  repforms  webserv
 
     %>
     <br><INPUT TYPE="submit" VALUE="done">
 
     %>
     <br><INPUT TYPE="submit" VALUE="done">
-    </FORM>
-    </BODY>
-    </HTML>
     <%
 
     <%
 
-  } elsif ( $cgi->param('magic') eq 'process' ) {
+  } elsif ( $cgi->param('magic') eq 'process2' ) {
 
 
-    %>
-    print results!!
-    <%
+    print "<pre>\n";
+    #false laziness with above
+    my $schema_string = $cgi->param('schema');
+    my %schema = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/
+                         or die "guru meditation #420: $_";
+                       ( $1 => $2 );
+                     }
+                 split( /\n/, $schema_string );
+    foreach my $table ( keys %schema ) {
+      ( my $spaces = $table ) =~ s/./ /g;
+      print "'$table' => { 'table' => '$schema{$table}',\n".
+            #(length($table) x ' '). "         'map'   => {\n";
+            "$spaces        'map'   => {\n";
+      my %map = map { /^\s*(\w+)\s*=>\s*(\w+)\s*$/
+                         or die "guru meditation #420: $_";
+                       ( $1 => $2 );
+                     }
+                 split( /\n/, $cgi->param($table) );
+      foreach ( keys %map ) {
+        print "$spaces                     '$_' => '$map{$_}',\n";
+      }
+      print "$spaces                   },\n";
+      print "$spaces      },\n";
+
+    }
+    print "\n</pre>";
+
+  } else {
+    warn "unrecognized magic: ". $cgi->param('magic');
   }
 
   }
 
+  %>
+</FORM>
+</BODY>
+</HTML>
+
+  <%
   #hashmaker widget
   sub hashmaker {
     my($name, $from, $to, $labelfrom, $labelto) = @_;
   #hashmaker widget
   sub hashmaker {
     my($name, $from, $to, $labelfrom, $labelto) = @_;