summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-11-19 00:12:41 -0800
committerIvan Kohler <ivan@freeside.biz>2014-11-19 00:12:41 -0800
commitb05ecb709b4ff5cd10a4df93af3e1ca9b79732e2 (patch)
tree9f527b5add4994a905e4cd0c6736896006047003
parenteaa349aa44febf4271b0b16dcffb894f360df834 (diff)
option for residential-only requirement for individual tax exemption numbers, RT#32027
-rw-r--r--FS/FS/Conf.pm17
-rw-r--r--FS/FS/Upgrade.pm6
-rw-r--r--FS/FS/cust_main_exemption.pm24
-rw-r--r--httemplate/edit/cust_main/billing.html1
4 files changed, 40 insertions, 8 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 46cac1917..c7a3dcb64 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -5168,19 +5168,30 @@ and customer address. Include units.',
{
'key' => 'tax-cust_exempt-groups',
- 'section' => '',
+ 'section' => 'billing',
'description' => 'List of grouping possibilities for tax names, for per-customer exemption purposes, one tax name per line. For example, "GST" would indicate the ability to exempt customers individually from taxes named "GST" (but not other taxes).',
'type' => 'textarea',
},
{
'key' => 'tax-cust_exempt-groups-require_individual_nums',
- 'section' => '',
- 'description' => 'When using tax-cust_exempt-groups, require an individual tax exemption number for each exemption from different taxes.',
+ 'section' => 'deprecated',
+ 'description' => 'Deprecated: see tax-cust_exempt-groups-number_requirement',
'type' => 'checkbox',
},
{
+ 'key' => 'tax-cust_exempt-groups-num_req',
+ 'section' => 'billing',
+ 'description' => 'When using tax-cust_exempt-groups, control whether individual tax exemption numbers are required for exemption from different taxes.',
+ 'type' => 'select',
+ 'select_hash' => [ '' => 'Not required',
+ 'residential' => 'Required for residential customers only',
+ 'all' => 'Required for all customers',
+ ],
+ },
+
+ {
'key' => 'cust_main-default_view',
'section' => 'UI',
'description' => 'Default customer view, for users who have not selected a default view in their preferences.',
diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index a7be5c838..dbac17e6a 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -125,6 +125,12 @@ If you need to continue using the old Form 477 report, turn on the
$conf->set($newname, 'location');
}
+ # boolean tax-cust_exempt-groups-require_individual_nums is now -num_req all
+ if ( $conf->exists('tax-cust_exempt-groups-require_individual_nums') ) {
+ $conf->set('tax-cust_exempt-groups-num_req', 'all');
+ $conf->delete('tax-cust_exempt-groups-require_individual_nums');
+ }
+
}
sub upgrade_overlimit_groups {
diff --git a/FS/FS/cust_main_exemption.pm b/FS/FS/cust_main_exemption.pm
index c6f3d5e6e..dcbfb8ff8 100644
--- a/FS/FS/cust_main_exemption.pm
+++ b/FS/FS/cust_main_exemption.pm
@@ -1,8 +1,8 @@
package FS::cust_main_exemption;
+use base qw( FS::Record );
use strict;
-use base qw( FS::Record );
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearchs );
use FS::Conf;
use FS::cust_main;
@@ -117,13 +117,27 @@ sub check {
return $error if $error;
my $conf = new FS::Conf;
- if ( ! $self->exempt_number && $conf->exists('tax-cust_exempt-groups-require_individual_nums') ) {
- return 'Tax exemption number required for '. $self->taxname. ' exemption';
- }
+ return 'Tax exemption number required for '. $self->taxname. ' exemption'
+ if ! $self->exempt_number
+ && ( $conf->exists('tax-cust_exempt-groups-require_individual_nums')
+ || $conf->config('tax-cust_exempt-groups-num_req') eq 'all'
+ || ( $conf->config('tax-cust_exempt-groups-num_req') eq 'residential'
+ && ! $self->cust_main->company
+ )
+ );
$self->SUPER::check;
}
+=item cust_main
+
+=cut
+
+sub cust_main {
+ my $self = shift;
+ qsearchs('cust_main', { custnum=>$self->custnum } );
+}
+
=back
=head1 BUGS
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index d52fb3c40..f1daebe90 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -448,6 +448,7 @@
% 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')
+% || $conf->config('tax-cust_exempt-groups-num_req') =~ /\w/
% || ! $curuser->access_right('Edit customer tax exemptions')
% )
% {