projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
52cf694
)
separate tax exemption numbers for individual exemptions w/tax-cust_exempt-groups...
author
Ivan Kohler
<ivan@freeside.biz>
Tue, 8 May 2012 22:34:25 +0000
(15:34 -0700)
committer
Ivan Kohler
<ivan@freeside.biz>
Tue, 8 May 2012 22:34:25 +0000
(15:34 -0700)
FS/FS/Conf.pm
patch
|
blob
|
history
FS/FS/Schema.pm
patch
|
blob
|
history
FS/FS/cust_main.pm
patch
|
blob
|
history
FS/FS/cust_main_exemption.pm
patch
|
blob
|
history
httemplate/edit/cust_main.cgi
patch
|
blob
|
history
httemplate/edit/cust_main/billing.html
patch
|
blob
|
history
httemplate/edit/process/cust_main.cgi
patch
|
blob
|
history
httemplate/view/cust_main/billing.html
patch
|
blob
|
history
diff --git
a/FS/FS/Conf.pm
b/FS/FS/Conf.pm
index
85e6186
..
a1fda68
100644
(file)
--- a/
FS/FS/Conf.pm
+++ b/
FS/FS/Conf.pm
@@
-4620,6
+4620,13
@@
and customer address. Include units.',
},
{
},
{
+ '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.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'cust_main-default_view',
'section' => 'UI',
'description' => 'Default customer view, for users who have not selected a default view in their preferences.',
'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/Schema.pm
b/FS/FS/Schema.pm
index
086f86e
..
84ab528
100644
(file)
--- a/
FS/FS/Schema.pm
+++ b/
FS/FS/Schema.pm
@@
-1180,9
+1180,10
@@
sub tables_hashref {
'cust_main_exemption' => {
'columns' => [
'cust_main_exemption' => {
'columns' => [
- 'exemptionnum', 'serial', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
- 'taxname', 'varchar', '', $char_d, '', '',
+ 'exemptionnum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ 'taxname', 'varchar', '', $char_d, '', '',
+ 'exempt_number', 'varchar', 'NULL', $char_d, '', '',
#start/end dates? for reporting?
],
'primary_key' => 'exemptionnum',
#start/end dates? for reporting?
],
'primary_key' => 'exemptionnum',
diff --git
a/FS/FS/cust_main.pm
b/FS/FS/cust_main.pm
index
49b76ce
..
6f4a4d7
100644
(file)
--- a/
FS/FS/cust_main.pm
+++ b/
FS/FS/cust_main.pm
@@
-399,8
+399,9
@@
The I<noexport> option is deprecated. If I<noexport> is set true, no
provisioning jobs (exports) are scheduled. (You can schedule them later with
the B<reexport> method.)
provisioning jobs (exports) are scheduled. (You can schedule them later with
the B<reexport> method.)
-The I<tax_exemption> option can be set to an arrayref of tax names.
-FS::cust_main_exemption records will be created and inserted.
+The I<tax_exemption> option can be set to an arrayref of tax names or a hashref
+of tax names and exemption numbers. FS::cust_main_exemption records will be
+created and inserted.
If I<prospectnum> is set, moves contacts and locations from that prospect.
If I<prospectnum> is set, moves contacts and locations from that prospect.
@@
-545,10
+546,15
@@
sub insert {
my $tax_exemption = delete $options{'tax_exemption'};
if ( $tax_exemption ) {
my $tax_exemption = delete $options{'tax_exemption'};
if ( $tax_exemption ) {
- foreach my $taxname ( @$tax_exemption ) {
+
+ $tax_exemption = { map { $_ => '' } @$tax_exemption }
+ if ref($tax_exemption) eq 'ARRAY';
+
+ foreach my $taxname ( keys %$tax_exemption ) {
my $cust_main_exemption = new FS::cust_main_exemption {
my $cust_main_exemption = new FS::cust_main_exemption {
- 'custnum' => $self->custnum,
- 'taxname' => $taxname,
+ 'custnum' => $self->custnum,
+ 'taxname' => $taxname,
+ 'exempt_number' => $tax_exemption->{$taxname},
};
my $error = $cust_main_exemption->insert;
if ( $error ) {
};
my $error = $cust_main_exemption->insert;
if ( $error ) {
@@
-1461,8
+1467,9
@@
check_invoicing_list first. Here's an example:
Currently available options are: I<tax_exemption>.
Currently available options are: I<tax_exemption>.
-The I<tax_exemption> option can be set to an arrayref of tax names.
-FS::cust_main_exemption records will be deleted and inserted as appropriate.
+The I<tax_exemption> option can be set to an arrayref of tax names or a hashref
+of tax names and exemption numbers. FS::cust_main_exemption records will be
+deleted and inserted as appropriate.
=cut
=cut
@@
-1598,17
+1605,27
@@
sub replace {
my $tax_exemption = delete $options{'tax_exemption'};
if ( $tax_exemption ) {
my $tax_exemption = delete $options{'tax_exemption'};
if ( $tax_exemption ) {
+ $tax_exemption = { map { $_ => '' } @$tax_exemption }
+ if ref($tax_exemption) eq 'ARRAY';
+
my %cust_main_exemption =
map { $_->taxname => $_ }
qsearch('cust_main_exemption', { 'custnum' => $old->custnum } );
my %cust_main_exemption =
map { $_->taxname => $_ }
qsearch('cust_main_exemption', { 'custnum' => $old->custnum } );
- foreach my $taxname (
@
$tax_exemption ) {
+ foreach my $taxname (
keys %
$tax_exemption ) {
- next if delete $cust_main_exemption{$taxname};
+ if ( $cust_main_exemption{$taxname} &&
+ $cust_main_exemption{$taxname}->exempt_number eq $tax_exemption->{$taxname}
+ )
+ {
+ delete $cust_main_exemption{$taxname};
+ next;
+ }
my $cust_main_exemption = new FS::cust_main_exemption {
my $cust_main_exemption = new FS::cust_main_exemption {
- 'custnum' => $self->custnum,
- 'taxname' => $taxname,
+ 'custnum' => $self->custnum,
+ 'taxname' => $taxname,
+ 'exempt_number' => $tax_exemption->{$taxname},
};
my $error = $cust_main_exemption->insert;
if ( $error ) {
};
my $error = $cust_main_exemption->insert;
if ( $error ) {
diff --git
a/FS/FS/cust_main_exemption.pm
b/FS/FS/cust_main_exemption.pm
index
06d22b7
..
c6f3d5e
100644
(file)
--- a/
FS/FS/cust_main_exemption.pm
+++ b/
FS/FS/cust_main_exemption.pm
@@
-3,6
+3,7
@@
package FS::cust_main_exemption;
use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );
use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );
+use FS::Conf;
use FS::cust_main;
=head1 NAME
use FS::cust_main;
=head1 NAME
@@
-44,6
+45,9
@@
Customer (see L<FS::cust_main>)
taxname
taxname
+=item exempt_number
+
+Exemption number
=back
=back
@@
-108,9
+112,15
@@
sub check {
$self->ut_numbern('exemptionnum')
|| $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
|| $self->ut_text('taxname')
$self->ut_numbern('exemptionnum')
|| $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
|| $self->ut_text('taxname')
+ || $self->ut_textn('exempt_number')
;
return $error if $error;
;
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';
+ }
+
$self->SUPER::check;
}
$self->SUPER::check;
}
diff --git
a/httemplate/edit/cust_main.cgi
b/httemplate/edit/cust_main.cgi
index
119572a
..
b97fb16
100755
(executable)
--- 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 );
}
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);
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
0194d31
..
3f87317
100644
(file)
--- a/
httemplate/edit/cust_main/billing.html
+++ b/
httemplate/edit/cust_main/billing.html
@@
-117,6
+117,15
@@
//why? select.selectedIndex = 0;
}
}
//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>
</SCRIPT>
@@
-437,7
+446,10
@@
% my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
% 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' : '' %>">
<INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax eq 'Y' ? 'Y' : '' %>">
@@
-450,9
+462,12
@@
% }
% foreach my $exempt_group ( @exempt_groups ) {
% }
% 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>
<TR>
- <TD WIDTH="608" COLSPAN="2"> <INPUT TYPE="checkbox" NAME="tax_<% $exempt_group %>" VALUE="Y" <% $cust_main->tax_exemption($exempt_group) ? 'CHECKED' : '' %>> Tax Exempt (<% $exempt_group %> taxes)<TD>
+ <TD> <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>
% }
</TR>
% }
diff --git
a/httemplate/edit/process/cust_main.cgi
b/httemplate/edit/process/cust_main.cgi
index
793426c
..
1cf7a3e
100755
(executable)
--- 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 @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 ) {
#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,
else {
# create the customer
$error ||= $new->insert( \%hash, \@invoicing_list,
- 'tax_exemption'=> \
@
tax_exempt,
+ 'tax_exemption'=> \
%
tax_exempt,
'prospectnum' => scalar($cgi->param('prospectnum')),
);
'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,
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;
);
warn "$me returned from replace" if $DEBUG;
diff --git
a/httemplate/view/cust_main/billing.html
b/httemplate/view/cust_main/billing.html
index
4d55f70
..
ba60e13
100644
(file)
--- 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');
% 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>
<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 ) {
% }
% 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>
<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>
% }
</TR>
% }