diff options
author | jeff <jeff> | 2008-04-01 00:54:44 +0000 |
---|---|---|
committer | jeff <jeff> | 2008-04-01 00:54:44 +0000 |
commit | 4104f4e3d1b387296b16b4a035b4b7f42e0c5977 (patch) | |
tree | fcb03d2c518cc91df33059675764d548fedc9e7a /httemplate/edit | |
parent | 12eb930abf31078c68dbf7eb94865faa1c59fc9e (diff) |
checkpoint of new tax rating system
Diffstat (limited to 'httemplate/edit')
-rwxr-xr-x | httemplate/edit/part_pkg.cgi | 42 | ||||
-rw-r--r-- | httemplate/edit/part_pkg_taxoverride.html | 61 | ||||
-rw-r--r-- | httemplate/edit/part_pkg_taxproduct.html | 42 | ||||
-rwxr-xr-x | httemplate/edit/process/part_pkg.cgi | 13 | ||||
-rw-r--r-- | httemplate/edit/process/tax_class.html | 49 | ||||
-rw-r--r-- | httemplate/edit/process/tax_rate.html | 13 | ||||
-rw-r--r-- | httemplate/edit/tax_class.html | 36 | ||||
-rw-r--r-- | httemplate/edit/tax_rate.html | 105 |
8 files changed, 359 insertions, 2 deletions
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index b1851a7..84f7498 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -3,6 +3,11 @@ )) %> % #), ' onLoad="visualize()"'); +<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws.js"></SCRIPT> +<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_iframe.js"></SCRIPT> +<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_draggable.js"></SCRIPT> +<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/iframecontentmws.js"></SCRIPT> + <% include('/elements/error.html') %> <FORM NAME="dummy"> @@ -81,6 +86,34 @@ Tax information % } +% if ( $conf->exists('enable_taxproducts') ) { + + <TR><TD colspan="2"> + <% ntable("#cccccc", 2) %> + <TR> + <TD align="right">Tax product</TD> + <TD> + <INPUT name="part_pkg_taxproduct_taxproductnum" id="taxproductnum" type="hidden" value="<% $hashref->{'taxproductnum'}%>"> + <INPUT name="part_pkg_taxproduct_description" id="taxproduct_description" type="text" value="<% $taxproduct_description %>" size="12" onclick="overlib( OLiframeContent('part_pkg_taxproduct.html?'+document.getElementById('taxproductnum').value, 800, 400, 'tax_product_popup'), CAPTION, 'Select product', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;"> + </TD> + </TR> + <TR> + <TD colspan="2" align="right"> + <INPUT name="tax_override" id="tax_override" type="hidden" value="<% $tax_override %>"> + <A href="javascript:void(0)" onclick="overlib( OLiframeContent('part_pkg_taxoverride.html?'+document.getElementById('tax_override').value, 800, 400, 'tax_product_popup'), CAPTION, 'Edit product tax overrides', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;"> + <% $tax_override ? 'Edit tax overrides' : 'Override taxes' %> + </A> + </TD> + </TR> + </TABLE> + </TD></TR> + +% } else { + + <INPUT TYPE="hidden" NAME="taxproductnum" VALUE="<% $hashref->{taxproductnum} %>"> + +% } + </TABLE> <BR> @@ -234,7 +267,7 @@ Line-item revenue recognition %#} else { %# push @fixups, 'taxclass'; #hidden %#} -%my @form_elements = ( 'classnum', 'taxclass', 'agent_type' ); +%my @form_elements = ( 'classnum', 'taxclass', 'agent_type', 'tax_override' ); % %my @form_radio = ( 'pkg_svc_primary' ); % @@ -252,6 +285,7 @@ Line-item revenue recognition % 'form_elements' => \@form_elements, % 'form_text' => [ qw(pkg comment promo_code clone pkgnum pkgpart), % qw(pay_weight credit_weight), #keys(%weight), +% qw(taxproductnum), % @fixups, % ], % 'form_checkbox' => [ qw(setuptax recurtax disabled) ], @@ -409,12 +443,14 @@ my ($query) = $cgi->keywords; my $conf = new FS::Conf; my $part_pkg = ''; my @agent_type = (); +my $tax_override; my @all_agent_types = map {$_->typenum} qsearch('agent_type',{}); if ( $cgi->param('error') ) { $part_pkg = new FS::part_pkg ( { map { $_, scalar($cgi->param($_)) } fields('part_pkg') } ); (@agent_type) = $cgi->param('agent_type'); + $tax_override = $cgi->param('tax_override'); } my $action = ''; @@ -430,6 +466,9 @@ if ( $cgi->param('clone') ) { } elsif ( $query && $query =~ /^(\d+)$/ ) { (@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1}) unless $part_pkg; + $tax_override = + join (",", map {$_->taxnum} qsearch('part_pkg_taxoverride',{'pkgpart'=>$1})) + unless $part_pkg; $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1}); $pkgpart = $part_pkg->pkgpart; } else { @@ -447,5 +486,6 @@ unless ( $part_pkg->plan ) { #backwards-compat } $action ||= $part_pkg->pkgpart ? 'Edit' : 'Add'; my $hashref = $part_pkg->hashref; +my $taxproduct_description = $part_pkg->taxproduct_description; </%init> diff --git a/httemplate/edit/part_pkg_taxoverride.html b/httemplate/edit/part_pkg_taxoverride.html new file mode 100644 index 0000000..61cca1f --- /dev/null +++ b/httemplate/edit/part_pkg_taxoverride.html @@ -0,0 +1,61 @@ +<%doc> + + The crappy version + +</%doc> +<% include('/elements/header-popup.html', 'Select tax product') %> +<SCRIPT> + function saveit2() { + var num = parent.document.getElementById('tax_override'); + var sel = document.getElementById('taxoverride_popup_select'); + var value = ''; + for (i=0; i< sel.length; i++) { + if (sel.options[i].selected) { + value = value + sel.options[i].value + ","; + } + } + if (value.length > 0) { + value = value.substr(0, value.length-1); + } + + num.value = value; + parent.cClick(); + } +</SCRIPT> +<FORM="dummy" METHOD="POST" onsubmit="saveit2();return false;" > + +<% ntable("#cccccc", 2) %> +<TR> + <TD align="left">Tax override</TD> + <TD> + <% include( '/elements/select-table.html', + 'table' => 'tax_rate', + 'name_col' => 'taxname', + 'curr_value' => \@curr_value, + 'element_etc' => "id='taxoverride_popup_select'", + 'multiple' => '1', + ) + %> + </TD> +</TR> +</TABLE> +<BR><BR> +<CENTER><INPUT type="submit" value="Select"></CENTER> +</FORM> +<% include('/elements/footer.html') %> + +<%init> + +my $conf = new FS::Conf; + +my @curr_value; +my ( $query ) = $cgi->keywords; +$query =~ /^([\d,]+)$/; +push @curr_value, split ',', $1 + if $1; + +unless (scalar(@curr_value)) { + #push @curr_value, map {$_=>taxnum} $part_pkg->tax_rate; +} + +</%init> diff --git a/httemplate/edit/part_pkg_taxproduct.html b/httemplate/edit/part_pkg_taxproduct.html new file mode 100644 index 0000000..033c37f --- /dev/null +++ b/httemplate/edit/part_pkg_taxproduct.html @@ -0,0 +1,42 @@ +<% include('/elements/header-popup.html', 'Select tax product') %> +<SCRIPT> + function saveit() { + var num = parent.document.getElementById('taxproductnum'); + var disp = parent.document.getElementById('taxproduct_description'); + var sel = document.getElementById('taxproduct_popup_select'); + num.value = sel.options[sel.selectedIndex].value; + disp.value = sel.options[sel.selectedIndex].text; + parent.cClick(); + } +</SCRIPT> +<FORM="dummy" METHOD="POST" onsubmit="saveit();return false;" > + +<% ntable("#cccccc", 2) %> +<TR> + <TD align="left">Tax product</TD> + <TD> + <% include( '/elements/select-table.html', + 'empty_label' => '(select product)', + 'table' => 'part_pkg_taxproduct', + 'name_col' => 'description', + 'curr_value' => $curr_value, + 'element_etc' => "id='taxproduct_popup_select'", + ) + %> + </TD> +</TR> +</TABLE> +<BR><BR> +<CENTER><INPUT type="submit" value="Select"></CENTER> +</FORM> +<% include('/elements/footer.html') %> + +<%init> + +my $conf = new FS::Conf; + +my ( $query ) = $cgi->keywords; +$query =~ /^(\d+)$/; +my $curr_value = $1; + +</%init> diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 36debfc..eac20af 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -53,6 +53,9 @@ $error = "At least one agent type must be specified." !$pkgpart && $conf->exists('agent-defaultpkg') ); +$cgi->param('tax_override') =~ /^([\d,]+)$/; +my (@tax_overrides) = (grep "$_", split (",", $1)); + my $new = new FS::part_pkg ( { map { $_ => scalar($cgi->param($_)); @@ -103,11 +106,19 @@ if ( $error ) { } unless ( $error || $conf->exists('agent_defaultpkg') ) { - my $error = $new->process_m2m( + $error = $new->process_m2m( 'link_table' => 'type_pkgs', 'target_table' => 'agent_type', 'params' => \@agents, ); } +unless ( $error ) { + $error = $new->process_m2m( + 'link_table' => 'part_pkg_taxoverride', + 'target_table' => 'tax_rate', + 'params' => \@tax_overrides, + ); +} + </%init> diff --git a/httemplate/edit/process/tax_class.html b/httemplate/edit/process/tax_class.html new file mode 100644 index 0000000..339c908 --- /dev/null +++ b/httemplate/edit/process/tax_class.html @@ -0,0 +1,49 @@ +% if ( $error ) { +% $cgi->param('error', $error); +<% $cgi->redirect(popurl(2). "tax_class.html?". $cgi->query_string ) %> +%} else { +<% $cgi->redirect(popurl(3). "browse/tax_rate.cgi?taxclassnum=". uri_escape($tax_class->taxclassnum) ) %> +%} +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $tax_class = new FS::tax_class { + 'taxclass' => $cgi->param('taxclass'), + 'description' => $cgi->param('description'), +}; + +#maybe this whole thing should be in a transaction. at some point, no biggie +#none of the follow-up stuff will fail unless there's a more serious problem +#than a hanging record in tax_class... + +my $error = $tax_class->insert; + +# all of this is highly dubious at the moment + +#unless ( $error ) { +# #auto-add the new taxclass to any regions that have taxclasses already +# +# my $sth = dbh->prepare(" +# SELECT geocode FROM tax_rate +# WHERE taxclass IS NOT NULL AND taxclass != '' +# GROUP BY geocode +# ") or die dbh->errstr; +# $sth->execute or die $sth->errstr; +# +# while ( my $row = $sth->fetchrow_hashref ) { +# warn "inserting for $row"; +# my $cust_main_county = new FS::tax_rate { +# 'geocode' => $row->{geocode}, +# 'tax' => 0, +# 'taxclassnum' => $tax_class->taxclassnum, +# }; +# $error = $cust_main_county->insert; +# #last if $error; +# die $error if $error; +# } +# +#} + +</%init> diff --git a/httemplate/edit/process/tax_rate.html b/httemplate/edit/process/tax_rate.html new file mode 100644 index 0000000..933bf07 --- /dev/null +++ b/httemplate/edit/process/tax_rate.html @@ -0,0 +1,13 @@ +<% include( 'elements/process.html', + 'table' => 'tax_rate', + 'popup_reload' => 'Tax changed', #a popup "parent reload" for now + #someday change the individual element and go away instead + ) +%> +<%init> + +my $conf = new FS::Conf; +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/tax_class.html b/httemplate/edit/tax_class.html new file mode 100644 index 0000000..d3e2e82 --- /dev/null +++ b/httemplate/edit/tax_class.html @@ -0,0 +1,36 @@ +<% include('/elements/header.html', "$action taxclass") %> + +<% include('/elements/error.html') %> + +<FORM ACTION="<% $p1 %>process/tax_class.html" METHOD=POST> + +<INPUT TYPE="hidden" NAME="taxclassnum" VALUE=""> +<INPUT TYPE="hidden" NAME="data_vendor" VALUE=""> + +Tax class <INPUT TYPE="text" NAME="taxclass" VALUE="<% $taxclass |h %>"><BR> +Description <INPUT TYPE="text" NAME="description" VALUE="<% $description |h %>"> + +<BR><BR> +<INPUT TYPE="submit" VALUE="<% $action %> taxclass"> + +</FORM> + +<% include('/elements/footer.html') %> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $taxclass = ''; +my $description = ''; +if ( $cgi->param('error') ) { + $taxclass = $cgi->param('taxclass'); + $description = $cgi->param('description'); +} + +my $action = 'Add'; + +my $p1 = popurl(1); + +</%init> diff --git a/httemplate/edit/tax_rate.html b/httemplate/edit/tax_rate.html new file mode 100644 index 0000000..e1d8d4f --- /dev/null +++ b/httemplate/edit/tax_rate.html @@ -0,0 +1,105 @@ +<% include('elements/edit.html', + 'popup' => 1, + 'name' => 'Tax rate', #Edit tax rate + 'table' => 'tax_rate', + 'labels' => $labels, + 'fields' => \@fields, + ) +%> +<%once> + +my $conf = new FS::Conf; + +</%once> + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $taxnum; +if ( $cgi->param('error') ) { + $cgi->param('taxnum') =~ /^(\d+)$/ or die 'error, but no taxnum'; + $taxnum = $1; +} else { + my($query) = $cgi->keywords; + $query =~ /^(\d+)$/ or die 'no taxnum'; + $taxnum = $1; +} + +my $tax_rate = qsearchs('tax_rate', { 'taxnum' => $taxnum }) + or die "unknown taxnum $1"; + +my $labels = { 'taxnum' => 'Tax', + 'data_vendor' => 'Data vendor', + 'geocode' => 'Vendor location code', + 'location' => 'Tax auth loc code', + 'taxclass_description' => 'Tax class', + 'taxname' => 'Tax name', + 'effective_date' => 'Effective date', + 'tax' => 'Tax rate (1st bracket)', + 'excessrate' => 'Tax rate (2nd bracket)', + 'taxbase' => 'First bracket', + 'taxmax' => 'Max tax', + 'usetax' => 'Use tax rate (1st bracket)', + 'useexcessrate' => 'Use tax rate (2nd bracket)', + 'unittype_name' => 'Units', + 'fee' => 'Fee per unit (1st bracket)', + 'excessfee' => 'Fee per unit (2st bracket)', + 'feebase' => 'Units in first bracket', + 'feemax' => 'Max Units', + 'maxtype_name' => 'Threshold accumulation', + 'taxauth_name', => 'Tax authority', + 'basetype_name' => 'Basis', + 'passtype_name' => 'Passthru', + 'passflag' => 'Passable', + 'setuptax' => 'This tax not applicable to setup fees', + 'recurtax' => 'This tax not applicable to recurring fees', + }; + +my @fields = ( + { type=>'tablebreak-tr-title', value=>'Location' }, + { field=>'data_vendor', type=>'hidden',}, + { field=>'geocode', type=>'fixed' }, + { field=>'taxclassnum', type=>'hidden' } , + { field=>'taxclass_description', type=>'fixed' } , + { field=>'taxname', type=>'text' } , + { field=>'effective_date', type=>'fixed' } , + { field=>'location', type=>'text' }, + { type=>'tablebreak-tr-title', value=>'Money based rates' }, + { field=>'tax', type=>'percentage' } , + { field=>'excessrate', type=>'percentage' } , + { field=>'taxbase', type=>'money' } , + { field=>'taxmax', type=>'money' } , + { field=>'usetax', type=>'percentage' } , + { field=>'useexcessrate', type=>'percentage' } , + { type=>'tablebreak-tr-title', value=>'Service based rates' }, + { field=>'unittype', type=>'hidden' } , + { field=>'unittype_name', type=>'fixed' } , + { field=>'fee', type=>'money' } , + { field=>'excessfee', type=>'money' } , + { field=>'feebase', type=>'text' } , + { field=>'feemax', type=>'text' } , + { type=>'tablebreak-tr-title', value=>'Taxation rules' }, + { field=>'maxtype', type=>'hidden' } , + { field=>'maxtype_name', type=>'fixed' } , + { field=>'taxauth', type=>'hidden' } , + { field=>'taxauth_name', type=>'fixed' } , + { field=>'basetype', type=>'hidden' } , + { field=>'basetype_name', type=>'fixed' } , + { field=>'passtype', type=>'hidden' } , + { field=>'passtype_name', type=>'fixed' } , + { field=>'passflag', type=>'fixed' } , + { field=>'setuptax', type=>'checkbox' } , + { field=>'recurtax', type=>'checkbox' } , + { field=>'manual', type=>'hidden', value=>'Y' } , +); + +#push @fields, +# { type=>'tablebreak-tr-title', value=>'Exemptions' }, +# { field=>'setuptax', type=>'checkbox', value=>'Y', }, +# { field=>'recurtax', type=>'checkbox', value=>'Y', }, +# { field=>'exempt_amount', type=>'money', }, +#; + +</%init> |