summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-05-08 15:34:25 -0700
committerIvan Kohler <ivan@freeside.biz>2012-05-08 15:34:25 -0700
commita68564e6856a7ea63763eeaf7962a5cb2df649af (patch)
tree45022b1dc0208ac6c3fdc5f413e25598c815dab7 /httemplate
parent52cf6949df47667d9864f5807549aa68789ef2fa (diff)
separate tax exemption numbers for individual exemptions w/tax-cust_exempt-groups, RT#17658
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/edit/cust_main.cgi2
-rw-r--r--httemplate/edit/cust_main/billing.html21
-rwxr-xr-xhttemplate/edit/process/cust_main.cgi5
-rw-r--r--httemplate/view/cust_main/billing.html10
4 files changed, 30 insertions, 8 deletions
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index 119572a11..b97fb16bf 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -367,7 +367,7 @@ if ( $cgi->param('error') ) {
}
my %keep = map { $_=>1 } qw( error tagnum lock_agentnum lock_pkgpart );
-$cgi->delete( grep !$keep{$_}, $cgi->param );
+$cgi->delete( grep { !$keep{$_} && $_ !~ /^tax_/ } $cgi->param );
my $title = $custnum ? 'Edit Customer' : 'Add Customer';
$title = mt($title);
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index 0194d31a6..3f873174f 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -117,6 +117,15 @@
//why? select.selectedIndex = 0;
}
}
+
+ function tax_changed(what) {
+ var num = document.getElementById(what.id + '_num');
+ if ( what.checked ) {
+ num.disabled = false;
+ } else {
+ num.disabled = true;
+ }
+ }
</SCRIPT>
@@ -437,7 +446,10 @@
% my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
-% if ( $conf->exists('cust_class-tax_exempt') ) {
+% if ( $conf->exists('cust_class-tax_exempt')
+% || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
+% )
+% {
<INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax eq 'Y' ? 'Y' : '' %>">
@@ -450,9 +462,12 @@
% }
% foreach my $exempt_group ( @exempt_groups ) {
-% #escape $exempt_group for NAME
+% my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
+% #escape $exempt_group for NAME etc.
+% my $checked = ($cust_main_exemption || $cgi->param("tax_$exempt_group"));
<TR>
- <TD WIDTH="608" COLSPAN="2">&nbsp;&nbsp;<INPUT TYPE="checkbox" NAME="tax_<% $exempt_group %>" VALUE="Y" <% $cust_main->tax_exemption($exempt_group) ? 'CHECKED' : '' %>> Tax Exempt (<% $exempt_group %> taxes)<TD>
+ <TD>&nbsp;&nbsp;<INPUT TYPE="checkbox" NAME="tax_<% $exempt_group %>" ID="tax_<% $exempt_group %>" VALUE="Y" <% $checked ? 'CHECKED' : '' %> onChange="tax_changed(this)"> Tax Exempt (<% $exempt_group %> taxes)</TD>
+ <TD> - Exemption number <INPUT TYPE="text" NAME="tax_<% $exempt_group %>_num" ID="tax_<% $exempt_group %>_num" VALUE="<% $cgi->param("tax_$exempt_group".'_num') || ( $cust_main_exemption ? $cust_main_exemption->exempt_number : '' ) |h %>" <% $checked ? '' : 'DISABLED' %>></TD>
</TR>
% }
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index 793426cc3..1cf7a3eb4 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -132,6 +132,7 @@ $new->setfield('paid', $cgi->param('paid') )
my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
my @tax_exempt = grep { $cgi->param("tax_$_") eq 'Y' } @exempt_groups;
+my %tax_exempt = map { $_ => scalar($cgi->param("tax_$_".'_num')) } @tax_exempt;
#perhaps this stuff should go to cust_main.pm
if ( $new->custnum eq '' or $duplicate_of ) {
@@ -239,7 +240,7 @@ if ( $new->custnum eq '' or $duplicate_of ) {
else {
# create the customer
$error ||= $new->insert( \%hash, \@invoicing_list,
- 'tax_exemption'=> \@tax_exempt,
+ 'tax_exemption'=> \%tax_exempt,
'prospectnum' => scalar($cgi->param('prospectnum')),
);
@@ -297,7 +298,7 @@ if ( $new->custnum eq '' or $duplicate_of ) {
local($FS::Record::DEBUG) = $DEBUG if $DEBUG;
$error ||= $new->replace( $old, \@invoicing_list,
- 'tax_exemption' => \@tax_exempt,
+ 'tax_exemption' => \%tax_exempt,
);
warn "$me returned from replace" if $DEBUG;
diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html
index 4d55f7002..ba60e13d1 100644
--- a/httemplate/view/cust_main/billing.html
+++ b/httemplate/view/cust_main/billing.html
@@ -190,7 +190,10 @@
% my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
-% unless ( $conf->exists('cust_class-tax_exempt') ) {
+% unless ( $conf->exists('cust_class-tax_exempt')
+% || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
+% )
+% {
<TR>
<TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
<TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
@@ -198,9 +201,12 @@
% }
% foreach my $exempt_group ( @exempt_groups ) {
+% my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
<TR>
<TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
- <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? $yes : $no %></TD>
+ <TD BGCOLOR="#ffffff"><% $cust_main_exemption ? $yes : $no %>
+ <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
+ </TD>
</TR>
% }