From b05ecb709b4ff5cd10a4df93af3e1ca9b79732e2 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 19 Nov 2014 00:12:41 -0800 Subject: [PATCH] option for residential-only requirement for individual tax exemption numbers, RT#32027 --- FS/FS/Conf.pm | 17 ++++++++++++++--- FS/FS/Upgrade.pm | 6 ++++++ FS/FS/cust_main_exemption.pm | 24 +++++++++++++++++++----- httemplate/edit/cust_main/billing.html | 1 + 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') % ) % { -- 2.11.0