summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/AccessRight.pm1
-rw-r--r--FS/FS/access_right.pm2
-rw-r--r--httemplate/edit/cust_main/billing.html21
-rwxr-xr-xhttemplate/edit/process/cust_main.cgi21
4 files changed, 28 insertions, 17 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index c0bd8d163..bd8a889e2 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -182,6 +182,7 @@ tie my %rights, 'Tie::IxHash',
'Unvoid invoices',
'Delete invoices',
'View customer tax exemptions', #yow
+ 'Edit customer tax exemptions', #NEWNEW
'Add customer tax adjustment', #new, but no need to phase in
'View customer batched payments', #NEW
'View customer pending payments', #NEW
diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm
index 3dd59b9da..18d2695f4 100644
--- a/FS/FS/access_right.pm
+++ b/FS/FS/access_right.pm
@@ -199,6 +199,8 @@ sub _upgrade_data { # class method
'Delete invoices' => 'Void invoices',
'List invoices' => 'List quotations',
'Post credit' => 'Credit line items',
+ #'View customer tax exemptions' => 'Edit customer tax exemptions',
+ 'Edit customer' => 'Edit customer tax exemptions',
'List services' => [ 'Services: Accounts',
'Services: Domains',
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index 2925ca87c..6ba73ad68 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -444,10 +444,11 @@
<TR><TD>&nbsp;</TD></TR>
+% my $curuser = $FS::CurrentUser::CurrentUser;
% my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
-
% if ( $conf->exists('cust_class-tax_exempt')
% || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
+% || ! $curuser->access_right('Edit customer tax exemptions')
% )
% {
@@ -461,14 +462,16 @@
% }
-% foreach my $exempt_group ( @exempt_groups ) {
-% 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>&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>
+% if ( $curuser->access_right('Edit customer tax exemptions') ) {
+% foreach my $exempt_group ( @exempt_groups ) {
+% 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>&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>
+% }
% }
% unless ( $conf->exists('emailinvoiceonly') ) {
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index 31ec4ab12..584462c8c 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -16,8 +16,8 @@ my $DEBUG = 0;
</%once>
<%init>
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Edit customer');
+my $curuser = $FS::CurrentUser::CurrentUser;
+die "access denied" unless $curuser->access_right('Edit customer');
my $conf = new FS::Conf;
@@ -156,9 +156,14 @@ foreach my $dfield (qw(
$new->setfield('paid', $cgi->param('paid') )
if $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;
+my %options = ();
+if ( $curuser->access_right('Edit customer tax exemptions') ) {
+ my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
+ my @tax_exempt = grep { $cgi->param("tax_$_") eq 'Y' } @exempt_groups;
+ $options{'tax_exemption'} = {
+ map { $_ => scalar($cgi->param("tax_$_".'_num')) } @tax_exempt
+ };
+}
#perhaps this stuff should go to cust_main.pm
if ( $new->custnum eq '' or $duplicate_of ) {
@@ -266,8 +271,8 @@ if ( $new->custnum eq '' or $duplicate_of ) {
else {
# create the customer
$error ||= $new->insert( \%hash, \@invoicing_list,
- 'tax_exemption'=> \%tax_exempt,
- 'prospectnum' => scalar($cgi->param('prospectnum')),
+ %options,
+ prospectnum => scalar($cgi->param('prospectnum')),
);
my $conf = new FS::Conf;
@@ -328,7 +333,7 @@ if ( $new->custnum eq '' or $duplicate_of ) {
warn Dumper({ new => $new, old => $old }) if $DEBUG;
$error ||= $new->replace( $old, \@invoicing_list,
- 'tax_exemption' => \%tax_exempt,
+ %options,
);
warn "$me returned from replace" if $DEBUG;