diff options
Diffstat (limited to 'httemplate/misc')
| -rw-r--r-- | httemplate/misc/choose_tax_location.html | 28 | ||||
| -rw-r--r-- | httemplate/misc/tax-import.cgi | 68 |
2 files changed, 50 insertions, 46 deletions
diff --git a/httemplate/misc/choose_tax_location.html b/httemplate/misc/choose_tax_location.html index 23099c421..9c5881fd4 100644 --- a/httemplate/misc/choose_tax_location.html +++ b/httemplate/misc/choose_tax_location.html @@ -4,9 +4,8 @@ <SELECT NAME='geocodes' ID='geocodes' STYLE="<% $style %>"> % foreach my $location (@cust_tax_location) { -% my %value = ( zip => $zip5, -% map { $_ => $location->$_ } -% qw ( city state geocode ) +% my %value = ( map { $_ => $location->$_ } +% qw ( zip city state geocode ) % ); % map { $value{$_} = $location{$_} } qw ( city state ) % if $location{country} eq 'CA'; @@ -36,10 +35,10 @@ <%init> my $conf = new FS::Conf; +my $tax_engine = FS::TaxEngine->new; -my %location = (); - -($location{data_vendor}) = $cgi->param('data_vendor') =~ /^([-\w]+)$/; +my %location; +($location{data_vendor}) = $conf->config('enable_taxproducts'); ($location{city}) = $cgi->param('city') =~ /^([\w ]+)$/; ($location{state}) = $cgi->param('state') =~ /^(\w+)$/; ($location{zip}) = $cgi->param('zip') =~ /^([-\w ]+)$/; @@ -50,22 +49,7 @@ my($geocode) = $cgi->param('geocode') =~ /^([\w]+)$/; my($formname) = $cgi->param('formname') =~ /^([\w]*)$/; $formname ||= 'CustomerForm'; -my($zip5, $zip4) = split('-', $location{zip}); - -#only support US & CA -my $hashref = { 'data_vendor' => $location{data_vendor} }; -$hashref->{zip} = $location{country} eq 'CA' ? substr($zip5,0,1) : $zip5, - -my @keys = keys(%$hashref); -my @cust_tax_location = (); -until ( @cust_tax_location ) { - @cust_tax_location = qsearch({ table => 'cust_tax_location', - hashref => $hashref, - order_by => 'LIMIT 50', - }); - last unless scalar(@keys); - delete $hashref->{ shift @keys }; -} +my @cust_tax_location = $tax_engine->cust_tax_locations(\%location); my %max = ( city => 4, county => 6, state => 5); foreach my $location (@cust_tax_location) { diff --git a/httemplate/misc/tax-import.cgi b/httemplate/misc/tax-import.cgi index 25414b20d..7e72c74e3 100644 --- a/httemplate/misc/tax-import.cgi +++ b/httemplate/misc/tax-import.cgi @@ -1,4 +1,4 @@ -<% include("/elements/header.html",'Batch Tax Rate Import') %> +<& /elements/header.html,'Batch Tax Rate Import' &> Import a CSV file set containing tax rate records. <BR><BR> @@ -6,22 +6,22 @@ Import a CSV file set containing tax rate records. <& /elements/form-file_upload.html, 'name' => 'TaxRateUpload', 'action' => 'process/tax-import.cgi', - 'num_files' => 6, 'fields' => [ 'format', 'reload' ], + 'num_files' => $vendor_info{$data_vendor}->{num_files}, 'message' => 'Tax rates imported', 'onsubmit' => "document.TaxRateUpload.submitButton.disabled=true;", &> -<% &ntable("#cccccc", 2) %> +<& /elements/table-grid.html &> <TR> <TH ALIGN="right">Format</TH> <TD> <SELECT NAME="format"> - <!-- <OPTION VALUE="cch-update" SELECTED>CCH update (CSV) --> - <OPTION VALUE="cch">CCH import (CSV) - <!-- <OPTION VALUE="cch-fixed-update">CCH update (fixed length) --> - <OPTION VALUE="cch-fixed">CCH import (fixed length) +% my @formats = @{ $vendor_info{$data_vendor}->{formats} }; +% while (@formats) { + <OPTION VALUE="<% shift @formats %>"><% shift @formats %></OPTION> +% } </SELECT> </TD> </TR> @@ -33,24 +33,11 @@ Import a CSV file set containing tax rate records. </TD> </TR> - <% include( '/elements/file-upload.html', - 'field' => [ 'geocodefile', - 'codefile', - 'plus4file', - 'zipfile', - 'txmatrixfile', - 'detailfile', - ], - 'label' => [ 'geocode filename', - 'code filename', - 'plus4 filename', - 'zip filename', - 'txmatrix filename', - 'detail filename', - ], + <& /elements/file-upload.html, + 'field' => $vendor_info{$data_vendor}->{field}, + 'label' => $vendor_info{$data_vendor}->{label}, 'debug' => 0, - ) - %> + &> <TR> <TD COLSPAN=2 ALIGN="center" STYLE="padding-top:6px"> @@ -72,4 +59,37 @@ Import a CSV file set containing tax rate records. die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Import'); +my $conf = FS::Conf->new; +my $data_vendor = $conf->config('enable_taxproducts'); + +my %vendor_info = ( + CCH => { + 'num_files' => 6, + 'formats' => [ 'cch' => 'CCH import (CSV)', + 'cch-fixed' => 'CCH import (fixed length)' ], + 'field' => [ 'geocodefile', + 'codefile', + 'plus4file', + 'zipfile', + 'txmatrixfile', + 'detailfile', + ], + 'label' => [ 'geocode filename', + 'code filename', + 'plus4 filename', + 'zip filename', + 'txmatrix filename', + 'detail filename', + ], + }, + Billsoft => { + 'num_files' => 1, + 'formats' => [ 'billsoft-pcode' => 'Billsoft PCodes', + 'billsoft-taxclass' => 'Tax classes', + 'billsoft-taxproduct' => 'Tax products' ], + 'field' => [ 'file' ], + 'label' => [ 'Filename' ], + }, +); + </%init> |
