summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-05-30 15:12:07 -0700
committerMark Wells <mark@freeside.biz>2015-05-30 15:12:07 -0700
commit817c1ce0e1cbcfd1f684222c66f46dd13b2d6dd7 (patch)
tree25fd80fae19bbe1b4ec2c892a35a631cf232d590 /httemplate
parent3846acae1c2a7ecb275e400cf3802ada6bc89ed2 (diff)
SureTax, #31639, #33015, #34598
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/part_pkg_taxproduct/avalara.html2
-rwxr-xr-xhttemplate/browse/part_pkg_taxproduct/suretax.html172
-rw-r--r--httemplate/config/config-view.cgi5
-rw-r--r--httemplate/edit/part_fee.html2
-rwxr-xr-xhttemplate/edit/part_pkg.cgi44
-rwxr-xr-xhttemplate/edit/process/part_pkg.cgi2
-rw-r--r--httemplate/edit/process/quick-charge.cgi4
-rw-r--r--httemplate/elements/menu.html8
-rw-r--r--httemplate/elements/select-taxproduct.html2
-rw-r--r--httemplate/elements/tr-part_pkg-taxproducts.html34
-rw-r--r--httemplate/elements/tr-select-tax_status.html2
-rw-r--r--httemplate/elements/tr-select-taxproduct.html2
-rw-r--r--httemplate/misc/choose_tax_location.html2
-rw-r--r--httemplate/misc/tax-import.cgi6
-rwxr-xr-xhttemplate/search/report_cust_pkg.html2
-rw-r--r--httemplate/view/cust_main/billing.html2
16 files changed, 251 insertions, 40 deletions
diff --git a/httemplate/browse/part_pkg_taxproduct/avalara.html b/httemplate/browse/part_pkg_taxproduct/avalara.html
index e8da58962..d7d8a6076 100755
--- a/httemplate/browse/part_pkg_taxproduct/avalara.html
+++ b/httemplate/browse/part_pkg_taxproduct/avalara.html
@@ -61,8 +61,6 @@ my $conf = new FS::Conf;
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Edit package definitions');
-warn Dumper({ $cgi->Vars });
-
# id: where to put the taxproductnum (in the parent document) after the user
# selects it
$cgi->param('id') =~ /^([ \w]+)$/
diff --git a/httemplate/browse/part_pkg_taxproduct/suretax.html b/httemplate/browse/part_pkg_taxproduct/suretax.html
new file mode 100755
index 000000000..667c07ee9
--- /dev/null
+++ b/httemplate/browse/part_pkg_taxproduct/suretax.html
@@ -0,0 +1,172 @@
+<& /elements/header-popup.html, $title &>
+<& /browse/elements/browse.html,
+ 'name_singular' => 'tax product',
+ 'html_form' => include('.form', $category_code),
+ 'query' => {
+ 'table' => 'part_pkg_taxproduct',
+ 'hashref' => $hashref,
+ 'order_by' => 'ORDER BY taxproduct',
+ },
+ 'count_query' => $count_query,
+ 'header' => \@header,
+ 'fields' => \@fields,
+ 'align' => $align,
+ 'links' => [],
+ 'link_onclicks' => \@link_onclicks,
+ 'nohtmlheader' => 1,
+ 'disable_total' => 1,
+&>
+<style>
+input { float: right}
+</style>
+<script src="<% $fsurl %>elements/jquery.js"></script>
+<script>
+var category_labels = <% encode_json(\%category_labels) %>;
+$().ready(function() {
+ var new_taxproduct = $('#new_taxproduct');
+ var new_category_desc = $('#new_category_desc');
+ var new_taxproduct_desc = $('#new_taxproduct_desc');
+ var new_taxproduct_submit = $('#new_taxproduct_submit');
+
+ new_taxproduct.on('keyup', function() {
+ var curr_value = this.value || '';
+ var a = curr_value.match(/^\d{2}/);
+ var f = this.form;
+ if (a) { // there is a category code in the box
+ var category = a[0];
+ if (category_labels[category]) { // it matches an existing category
+ new_category_desc.val(category_labels[category]);
+ new_category_desc.prop('disabled', true);
+ } else {
+ new_category_desc.val('');
+ new_category_desc.prop('disabled', false);
+ }
+ } else {
+ new_category_desc.prop('disabled', true);
+ }
+ if (curr_value.match(/^\d{6}$/)) {
+ new_taxproduct_submit.prop('disabled', false);
+ } else {
+ new_taxproduct_submit.prop('disabled', true);
+ }
+ });
+
+ new_taxproduct_submit.on('click', function() {
+ select_taxproduct( -1,
+ new_taxproduct.val()
+ + ' '
+ + new_category_desc.val()
+ + ':'
+ + new_taxproduct_desc.val()
+ );
+ });
+});
+// post the values back to the parent form
+function select_taxproduct(taxproductnum, description) {
+ parent.document.getElementById('<% $id %>').value = taxproductnum;
+ parent.document.getElementById('<% $id %>_description').value = description;
+ parent.cClick();
+}
+
+</script>
+<DIV STYLE="width: 50%">
+<FORM NAME="myform">
+ <label for="new_taxproduct">New tax product code</label>
+ <input type="text" size="6" name="new_taxproduct" id="new_taxproduct">
+ <br>
+ <label for="new_category_desc">Category</label>
+ <input type="text" name="new_category_desc" id="new_category_desc" disabled=1>
+ <br>
+ <label for="new_taxproduct_desc">Product</label>
+ <input type="text" name="new_taxproduct_desc" id="new_taxproduct_desc">
+ <br>
+ <input type="button" id="new_taxproduct_submit" disabled=1 value="Add">
+</FORM>
+</DIV>
+<%shared>
+# populate dropdown
+
+# taxproduct is 6 digits: 2-digit category code + 4-digit detail code.
+# Description is also two parts, corresponding to those codes, separated with
+# a :.
+
+my (@category_codes, @taxproduct_codes, %category_labels, %taxproduct_labels);
+foreach my $row ( qsearch({
+ table => 'part_pkg_taxproduct',
+ select => 'DISTINCT substr(taxproduct, 1, 2) AS code, '.
+ "substring(description from '(.*):') AS label",
+ hashref => { data_vendor => 'suretax' },
+ }))
+{
+ $category_labels{$row->get('code')} = $row->get('label');
+}
+
+@category_codes = sort {$a <=> $b} keys %category_labels;
+
+</%shared>
+<%def .form>
+% my ($category_code) = @_;
+<FORM ACTION="<% $cgi->url %>" METHOD="GET">
+<& /elements/select.html,
+ field => 'category_code',
+ options => \@category_codes,
+ labels => \%category_labels,
+ curr_value => $category_code,
+ onchange => 'this.form.submit()',
+&>
+<& /elements/hidden.html,
+ field => 'id',
+ curr_value => $cgi->param('id'),
+&>
+</%def>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+$cgi->param('id') =~ /^\w+$/ or die "missing id parameter";
+my $id = $cgi->param('id');
+
+my $select_onclick = sub {
+ my $row = shift;
+ my $taxnum = $row->taxproductnum;
+ my $code = $row->taxproduct;
+ my $desc = $row->description;
+ "select_taxproduct('$taxnum', '$desc')";
+};
+
+my @menubar;
+my $title = 'Tax Products';
+
+my $hashref = { data_vendor => 'suretax' };
+
+my ($category_code, $taxproduct);
+if ( $cgi->param('category_code') =~ /^(\d+)$/ ) {
+ $category_code = $1;
+ $taxproduct = $category_code . '%';
+} else {
+ $taxproduct = '%';
+}
+
+$hashref->{taxproduct} = { op => 'LIKE', value => $taxproduct };
+
+my $count_query = "SELECT COUNT(*) FROM part_pkg_taxproduct ".
+ "WHERE data_vendor = 'suretax' AND ".
+ "taxproduct LIKE '$taxproduct'";
+
+my @fields = (
+ 'taxproduct',
+ 'description',
+ 'note'
+);
+
+my @header = (
+ 'Code',
+ 'Description',
+ '',
+);
+
+my $align = 'lll';
+my @link_onclicks = ( $select_onclick, $select_onclick );
+
+</%init>
diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi
index 0d16c5d2f..a2e908847 100644
--- a/httemplate/config/config-view.cgi
+++ b/httemplate/config/config-view.cgi
@@ -416,8 +416,9 @@ my @deleteable = qw( invoice_latexreturnaddress invoice_htmlreturnaddress );
my %deleteable = map { $_ => 1 } @deleteable;
my @sections = (qw(
- required billing invoicing notification UI API self-service ticketing
- network_monitoring username password session shell BIND telephony
+ required billing taxation invoicing notification UI API self-service
+ ticketing network_monitoring username password session shell BIND
+ telephony
), '', 'deprecated'
);
diff --git a/httemplate/edit/part_fee.html b/httemplate/edit/part_fee.html
index 339941015..5f6dc3818 100644
--- a/httemplate/edit/part_fee.html
+++ b/httemplate/edit/part_fee.html
@@ -35,7 +35,7 @@ die "access denied"
my $conf = FS::Conf->new;
my @tax_fields;
-if ( $conf->exists('enable_taxproducts') ) {
+if ( $conf->config('tax_data_vendor') ) {
@tax_fields = (
{ field => 'taxproductnum', type => 'select-taxproduct' }
);
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index fbc19c3f5..bfa5d50ea 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -179,22 +179,28 @@
type => 'hidden',
value => join(',', @taxproductnums),
},
- { field => 'taxproduct_select',
- type => 'selectlayers',
- options => [ '(default)', @taxproductnums ],
- curr_value => '(default)',
- labels => { ( '(default)' => '(default)' ),
- map {($_=>$usage_class{$_})}
- @taxproductnums
- },
- layer_fields => \%taxproduct_fields,
- layer_values_callback => $taxproduct_values,
- layers_only => !$taxproducts,
- cell_style => ( !$taxproducts
- ? 'display:none'
- : ''
- ),
+ #{ field => 'taxproduct_select',
+ # type => 'selectlayers',
+ # options => [ '(default)', @taxproductnums ],
+ # curr_value => '(default)',
+ # labels => { ( '(default)' => '(default)' ),
+ # map {($_=>$usage_class{$_})}
+ # @taxproductnums
+ # },
+ # layer_fields => \%taxproduct_fields,
+ # layer_values_callback => $taxproduct_values,
+ # layers_only => !$taxproducts,
+ # cell_style => ( !$taxproducts
+ # ? 'display:none'
+ # : ''
+ # ),
+ #},
+ { field => 'taxproductnum',
+ type => 'part_pkg-taxproducts',
+ include_opt_callback =>
+ sub { pkgpart => $_[0]->pkgpart },
},
+
{ type => 'tablebreak-tr-title',
value => 'Promotions', #better name?
@@ -414,7 +420,7 @@ my $agent_clone_extra_sql =
' ) ';
my $conf = new FS::Conf;
-my $taxproducts = $conf->exists('enable_taxproducts');
+my $taxproducts = $conf->config('tax_data_vendor') ne '';
my $fcc_opts = $conf->exists('part_pkg-show_fcc_options');
@@ -1120,9 +1126,9 @@ my $html_bottom = sub {
'<SCRIPT TYPE="text/javascript">'.
include('/elements/selectlayers.html', %selectlayers, 'js_only'=>1 );
- $return .=
- "taxproduct_selectchanged(document.getElementById('taxproduct_select'));\n"
- if $taxproducts;
+# $return .=
+# "taxproduct_selectchanged(document.getElementById('taxproduct_select'));\n"
+# if $taxproducts;
$return .= '</SCRIPT>';
diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi
index eda3f33d4..f3ee06157 100755
--- a/httemplate/edit/process/part_pkg.cgi
+++ b/httemplate/edit/process/part_pkg.cgi
@@ -117,7 +117,7 @@ my $args_callback = sub {
$error ||= "Illegal $param: $value"
unless ( $value =~ /^\d*$/ );
if (length($class)) {
- $options{"usage_taxproductnum_$_"} = $value;
+ $options{"usage_taxproductnum_$class"} = $value;
} else {
$new->set('taxproductnum', $value);
}
diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi
index c1e7fc159..23eead451 100644
--- a/httemplate/edit/process/quick-charge.cgi
+++ b/httemplate/edit/process/quick-charge.cgi
@@ -74,7 +74,7 @@ if ( $param->{'pkgnum'} =~ /^(\d+)$/ ) { #modifying an existing one-time charge
if ( $param->{'taxclass'} eq '(select)' ) {
$error .= "Must select a tax class. "
- unless ($conf->exists('enable_taxproducts') &&
+ unless ($conf->config('tax_data_vendor') &&
( $override || $param->{taxproductnum} )
);
$cgi->param('taxclass', '');
@@ -122,7 +122,7 @@ if ( $param->{'pkgnum'} =~ /^(\d+)$/ ) { #modifying an existing one-time charge
if ( $param->{'taxclass'} eq '(select)' ) {
$error .= "Must select a tax class. "
- unless ($conf->exists('enable_taxproducts') &&
+ unless ($conf->config('tax_data_vendor'))
( $override || $param->{taxproductnum} )
);
$cgi->param('taxclass', '');
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 9c9b2de64..7d34d427e 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -375,7 +375,7 @@ if( $curuser->access_right('Financial reports') ) {
$report_financial{'A/R Aging'} = [ $fsurl.'search/report_receivables.html', 'Accounts Receivable Aging report' ];
$report_financial{'Prepaid Income'} = [ $fsurl.'search/report_prepaid_income.html', 'Prepaid income (unearned revenue) report' ];
- my $taxproducts = $conf->exists('enable_taxproducts');
+ my $taxproducts = $conf->config('tax_data_vendor');
$report_financial{'Tax Liability'. ($taxproducts ? ' (internal tax data)' : '')} = [ $fsurl.'search/report_tax.html', 'Tax liability report (internal tax data)' ];
$report_financial{'Tax Liability (vendor tax data)'} = [ $fsurl.'search/report_newtax.html', 'Tax liability report (vendor tax data)' ]
if $taxproducts;
@@ -458,7 +458,7 @@ tie my %tools_importing, 'Tie::IxHash',
'Phone numbers (DIDs)' => [ $fsurl.'misc/phone_avail-import.html', '' ],
'Call Detail Records (CDRs)' => [ $fsurl.'misc/cdr-import.html', '' ],
;
-if ( $conf->exists('enable_taxproducts') ) {
+if ( $conf->config('tax_data_vendor') eq 'cch' ) {
if ( $conf->exists('taxdatadirectdownload') ) {
$tools_importing{'Tax rates from vendor site'} =
[ $fsurl.'misc/tax-fetch_and_import.cgi', '' ];
@@ -680,13 +680,13 @@ if ( $curuser->access_right('Configuration') ) {
$config_billing{'separator2'} = ''; #its a separator!
my $config_taxes_name = 'Locales and tax rates'.
- ( $conf->exists('enable_taxproducts')
+ ( $conf->config('tax_data_vendor')
? ' (internal tax class system)'
: ''
);
$config_billing{$config_taxes_name} = [ $fsurl.'browse/cust_main_county.cgi', 'Change tax rates, or break down a country into states, or a state into counties and assign different tax rates to each' ];
$config_billing{'Tax rates (vendor data tax products system)'} = [ $fsurl.'browse/tax_rate.cgi', 'Edit tax rates for the vendor data tax products system' ]
- if $conf->exists('enable_taxproducts');
+ if $conf->config('tax_data_vendor');
$config_billing{'Tax classes'} = [ $fsurl. 'browse/part_pkg_taxclass.html', 'Tax classes' ];
if ( $conf->config('currencies') ) {
diff --git a/httemplate/elements/select-taxproduct.html b/httemplate/elements/select-taxproduct.html
index 07e554927..5feb71d80 100644
--- a/httemplate/elements/select-taxproduct.html
+++ b/httemplate/elements/select-taxproduct.html
@@ -24,7 +24,7 @@ unless ( $description || ! $value ) {
}
my $conf = FS::Conf->new;
-my $vendor = lc($conf->config('enable_taxproducts'));
+my $vendor = lc($conf->config('tax_data_vendor'));
my $onclick = $opt{onclick} ||
"overlib( OLiframeContent('${p}/browse/part_pkg_taxproduct/$vendor.html?_type=select&id=${name}&taxproductnum='+document.getElementById('${name}').value, 1000, 400, 'tax_product_popup'), CAPTION, 'Select product', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;";
diff --git a/httemplate/elements/tr-part_pkg-taxproducts.html b/httemplate/elements/tr-part_pkg-taxproducts.html
new file mode 100644
index 000000000..274dc3b48
--- /dev/null
+++ b/httemplate/elements/tr-part_pkg-taxproducts.html
@@ -0,0 +1,34 @@
+<TR>
+ <TH COLSPAN=2>Tax products</TH>
+</TR>
+% foreach my $usage_class (@classes) {
+% my $classnum = $usage_class->classnum;
+% my $curr_value =
+% $cgi->param("usage_taxproductnum_$classnum")
+% || $pkg_options{"usage_taxproductnum_$classnum"}
+% || '';
+<TR>
+ <TD><% $usage_class->classname %></TD>
+ <TD><& select-taxproduct.html,
+ %opt,
+ 'field' => $field.'_'.$classnum,
+ 'curr_value' => $curr_value
+ &>
+ </TD>
+</TR>
+% }
+<%init>
+my %opt = @_;
+my $field = delete($opt{field}) || 'taxproductnum';
+my $pkgpart = delete($opt{pkgpart});
+my $part_pkg = FS::part_pkg->by_key($pkgpart);
+my %pkg_options = $part_pkg->options;
+$pkg_options{'usage_taxproductnum_'} = $part_pkg->taxproductnum;
+
+my @classes = qsearch('usage_class', { 'disabled' => '' });
+unshift @classes,
+ FS::usage_class->new({ 'classnum' => '', 'classname' => '(default)', }),
+ FS::usage_class->new({ 'classnum' => 'setup', 'classname' => 'Setup', }),
+ FS::usage_class->new({ 'classnum' => 'recur', 'classname' => 'Recur', }),
+;
+</%init>
diff --git a/httemplate/elements/tr-select-tax_status.html b/httemplate/elements/tr-select-tax_status.html
index 9c2de154f..1e0ea8a98 100644
--- a/httemplate/elements/tr-select-tax_status.html
+++ b/httemplate/elements/tr-select-tax_status.html
@@ -17,7 +17,7 @@
<%shared>
my $conf = FS::Conf->new;
-my $vendor = $conf->config('enable_taxproducts');
+my $vendor = $conf->config('tax_data_vendor');
</%shared>
<%init>
my %opt = @_;
diff --git a/httemplate/elements/tr-select-taxproduct.html b/httemplate/elements/tr-select-taxproduct.html
index 759d0c01c..547f06626 100644
--- a/httemplate/elements/tr-select-taxproduct.html
+++ b/httemplate/elements/tr-select-taxproduct.html
@@ -1,4 +1,4 @@
-% if ( $conf->exists('enable_taxproducts') ) {
+% if ( $conf->config('tax_data_vendor') ) { # still not quite right
<%include('tr-td-label.html', @_) %>
<TD <% $cell_style %>><% include('select-taxproduct.html', @_) %></TD>
</TR>
diff --git a/httemplate/misc/choose_tax_location.html b/httemplate/misc/choose_tax_location.html
index 9c5881fd4..2eb5ab98e 100644
--- a/httemplate/misc/choose_tax_location.html
+++ b/httemplate/misc/choose_tax_location.html
@@ -38,7 +38,7 @@ my $conf = new FS::Conf;
my $tax_engine = FS::TaxEngine->new;
my %location;
-($location{data_vendor}) = $conf->config('enable_taxproducts');
+($location{data_vendor}) = $conf->config('tax_data_vendor');
($location{city}) = $cgi->param('city') =~ /^([\w ]+)$/;
($location{state}) = $cgi->param('state') =~ /^(\w+)$/;
($location{zip}) = $cgi->param('zip') =~ /^([-\w ]+)$/;
diff --git a/httemplate/misc/tax-import.cgi b/httemplate/misc/tax-import.cgi
index 7e72c74e3..9581a7975 100644
--- a/httemplate/misc/tax-import.cgi
+++ b/httemplate/misc/tax-import.cgi
@@ -60,10 +60,10 @@ die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Import');
my $conf = FS::Conf->new;
-my $data_vendor = $conf->config('enable_taxproducts');
+my $data_vendor = $conf->config('tax_data_vendor');
my %vendor_info = (
- CCH => {
+ cch => {
'num_files' => 6,
'formats' => [ 'cch' => 'CCH import (CSV)',
'cch-fixed' => 'CCH import (fixed length)' ],
@@ -82,7 +82,7 @@ my %vendor_info = (
'detail filename',
],
},
- Billsoft => {
+ billsoft => {
'num_files' => 1,
'formats' => [ 'billsoft-pcode' => 'Billsoft PCodes',
'billsoft-taxclass' => 'Tax classes',
diff --git a/httemplate/search/report_cust_pkg.html b/httemplate/search/report_cust_pkg.html
index f124f0f87..dd1f97d0d 100755
--- a/httemplate/search/report_cust_pkg.html
+++ b/httemplate/search/report_cust_pkg.html
@@ -190,7 +190,7 @@
<& /elements/tr-title.html, value => mt('Location search options') &>
% my @location_options = qw(cust nocust census nocensus);
-% if ( $conf->exists('enable_taxproducts') ) {
+% if ( $conf->config('tax_data_vendor') eq 'cch' ) {
% push @location_options, 'geocode', 'nogeocode';
% }
<& /elements/tr-checkbox-multiple.html,
diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html
index a16e8a564..0f794e334 100644
--- a/httemplate/view/cust_main/billing.html
+++ b/httemplate/view/cust_main/billing.html
@@ -71,7 +71,7 @@
</TR>
% }
-% if ( $conf->exists('enable_taxproducts') ) {
+% if ( $conf->config('tax_data_vendor') eq 'cch' ) {
<TR>
<TH ALIGN="right"><% mt('Tax location') |h %></TH>
% my $tax_location = $conf->exists('tax-ship_address')