[freeside-commits] branch master updated. 820fe0ac288d4f2bb975b7f58ee02baefd96ed24

Ivan ivan at 420.am
Sun Apr 15 15:39:22 PDT 2012


The branch, master has been updated
       via  820fe0ac288d4f2bb975b7f58ee02baefd96ed24 (commit)
       via  2ce6ee8e5cd817a4018ad26eb1e364198c1dd931 (commit)
      from  401ba3ab0637de1bc460370949b75dca092375d8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 820fe0ac288d4f2bb975b7f58ee02baefd96ed24
Merge: 2ce6ee8 401ba3a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Apr 15 15:38:47 2012 -0700

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit 2ce6ee8e5cd817a4018ad26eb1e364198c1dd931
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Apr 15 15:38:27 2012 -0700

    add cust_class-tax_exempt conf setting to control the tax exemption flag per customer class rather than per indivual customer, RT#16818

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index edfe3c2..8144363 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4909,6 +4909,12 @@ and customer address. Include units.',
     'type'        => 'select-agent',
   },
 
+  {
+    'key'         => 'cust_class-tax_exempt',
+    'section'     => 'billing',
+    'description' => 'Control the tax exemption flag per customer class rather than per indivual customer.',
+    'type'        => 'checkbox',
+  },
 
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 5b8525c..3894f65 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1130,10 +1130,11 @@ sub tables_hashref {
 
     'cust_class' => {
       'columns' => [
-        'classnum',    'serial',   '',      '', '', '', 
-        'classname',   'varchar',  '', $char_d, '', '', 
-        'categorynum', 'int',  'NULL',      '', '', '', 
-        'disabled',    'char', 'NULL',       1, '', '', 
+        'classnum',     'serial',     '',      '', '', '', 
+        'classname',   'varchar',     '', $char_d, '', '', 
+        'categorynum',     'int', 'NULL',      '', '', '', 
+        'tax',            'char', 'NULL',       1, '', '', 
+        'disabled',       'char', 'NULL',       1, '', '', 
       ],
       'primary_key' => 'classnum',
       'unique' => [],
diff --git a/FS/FS/cust_class.pm b/FS/FS/cust_class.pm
index a811be7..7cbc9b8 100644
--- a/FS/FS/cust_class.pm
+++ b/FS/FS/cust_class.pm
@@ -44,6 +44,11 @@ Text name of this customer class
 
 Number of associated cust_category (see L<FS::cust_category>)
 
+=item tax
+
+Tax exempt flag, empty or 'Y'.  Used when the cust_class-tax_exempt
+configuration setting is turned on.
+
 =item disabled
 
 Disabled flag, empty or 'Y'
@@ -86,6 +91,16 @@ Checks all fields to make sure this is a valid customer class.  If there is
 an error, returns the error, otherwise returns false.  Called by the insert
 and replace methods.
 
+=cut
+
+sub check {
+  my $self = shift;
+
+     $self->ut_enum('tax', [ '', 'Y' ])
+  || $self->SUPER::check;
+
+}
+
 =item cust_category
 
 =item category
diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm
index 0a557fc..ca8d996 100644
--- a/FS/FS/cust_main/Billing.pm
+++ b/FS/FS/cust_main/Billing.pm
@@ -877,7 +877,7 @@ sub _make_lines {
 
   my $part_pkg = $params{part_pkg} or die "no part_pkg specified";
   my $cust_pkg = $params{cust_pkg} or die "no cust_pkg specified";
-  my $precommit_hooks = $params{precommit_hooks} or die "no package specified";
+  my $precommit_hooks = $params{precommit_hooks} or die "no precommit_hooks specified";
   my $cust_bill_pkgs = $params{line_items} or die "no line buffer specified";
   my $total_setup = $params{setup} or die "no setup accumulator specified";
   my $total_recur = $params{recur} or die "no recur accumulator specified";
@@ -1178,7 +1178,11 @@ sub _handle_taxes {
   push @classes, 'setup' if ($cust_bill_pkg->setup && !$options->{cancel});
   push @classes, 'recur' if ($cust_bill_pkg->recur && !$options->{cancel});
 
-  if ( $self->tax !~ /Y/i && $self->payby ne 'COMP' ) {
+  my $exempt = $conf->exists('cust_class-tax_exempt')
+                 ? ( $self->cust_class ? $self->cust_class->tax : '' )
+                 : $self->tax;
+
+  if ( $exempt !~ /Y/i && $self->payby ne 'COMP' ) {
 
     if ( $conf->exists('enable_taxproducts')
          && ( scalar($part_pkg->part_pkg_taxoverride)
diff --git a/httemplate/edit/cust_class.html b/httemplate/edit/cust_class.html
index fdb58e6..8fce905 100644
--- a/httemplate/edit/cust_class.html
+++ b/httemplate/edit/cust_class.html
@@ -1,5 +1,24 @@
 <% include( 'elements/class_Common.html',
-              'name'   => 'Customer Class',
-              'table'  => 'cust_class',
+              'name'        => 'Customer Class',
+              'table'       => 'cust_class',
+              'addl_fields' => \@addl_fields,
+              'addl_labels' => { 'tax' => 'Tax Exempt' },
           )
 %>
+<%init>
+
+my $conf = new FS::Conf;
+
+my @addl_fields = ();
+if ( $conf->exists('cust_class-tax_exempt') ) {
+  push @addl_fields, { 'field' => 'tax',
+                       'type'  => 'checkbox',
+                       'value' => 'Y',
+                     };
+} else {
+  push @addl_fields, { 'field' => 'tax',
+                       'type'  => 'hidden',
+                     };
+}
+
+</%init>
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index 18c7ae9..9f4cb74 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -437,9 +437,17 @@
 
 %   my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
 
-    <TR>
-      <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <% $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
-    </TR>
+%   if ( $conf->exists('cust_class-tax_exempt') ) {
+
+      <INPUT TYPE="hidden" NAME="tax" VALUE="<% $cust_main->tax eq 'Y' ? 'Y' : '' %>">
+
+%   } else {
+
+      <TR>
+        <TD WIDTH="608" COLSPAN="2"><INPUT TYPE="checkbox" NAME="tax" VALUE="Y" <% $cust_main->tax eq "Y" ? 'CHECKED' : '' %>> Tax Exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
+      </TR>
+
+%   }
 
 %   foreach my $exempt_group ( @exempt_groups ) {
 %     #escape $exempt_group for NAME
diff --git a/httemplate/edit/elements/class_Common.html b/httemplate/edit/elements/class_Common.html
index 69da4db..a0025b3 100644
--- a/httemplate/edit/elements/class_Common.html
+++ b/httemplate/edit/elements/class_Common.html
@@ -34,9 +34,9 @@ my $fields = [   'classname',
         ),
         { field=>'disabled', type=>'checkbox', value=>'Y', },
         ];
-push @$fields, $opt{'addl_fields'} if $opt{'addl_fields'};
+push @$fields, @{ $opt{'addl_fields'} } if $opt{'addl_fields'};
 
 my %addl_labels = ();
-%addl_labels = %{$opt{'addl_labels'}} if $opt{'addl_labels'};
+%addl_labels = %{ $opt{'addl_labels'} } if $opt{'addl_labels'};
 
 </%init>
diff --git a/httemplate/edit/pkg_class.html b/httemplate/edit/pkg_class.html
index 1bc100e..c4e3d8a 100644
--- a/httemplate/edit/pkg_class.html
+++ b/httemplate/edit/pkg_class.html
@@ -10,7 +10,7 @@ my $conf = new FS::Conf;
 
 my %opt = ();
 if($conf->exists('cust_main-require_censustract')) {
- $opt{'addl_fields'} = qw( fcc_ds0s );
+ $opt{'addl_fields'} = [ 'fcc_ds0s' ];
  $opt{'addl_labels'} = { 'fcc_ds0s' => 'FCC form 477 voice-grade equivalents' };
 }
 </%init>
diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html
index 522c6db..4d55f70 100644
--- a/httemplate/view/cust_main/billing.html
+++ b/httemplate/view/cust_main/billing.html
@@ -189,15 +189,19 @@
 % my $no = emt('no');
 
 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
-<TR>
-  <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
-  <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
-</TR>
+
+% unless ( $conf->exists('cust_class-tax_exempt') ) {
+    <TR>
+      <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
+      <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
+    </TR>
+% }
+
 % foreach my $exempt_group ( @exempt_groups ) {
-<TR>
-  <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
-  <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? $yes : $no %></TD>
-</TR>
+    <TR>
+      <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
+      <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? $yes : $no %></TD>
+    </TR>
 % }
 
 % if ( $conf->exists('enable_taxproducts') ) {

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                              |    6 ++++++
 FS/FS/Schema.pm                            |    9 +++++----
 FS/FS/cust_class.pm                        |   15 +++++++++++++++
 FS/FS/cust_main/Billing.pm                 |    8 ++++++--
 httemplate/edit/cust_class.html            |   23 +++++++++++++++++++++--
 httemplate/edit/cust_main/billing.html     |   14 +++++++++++---
 httemplate/edit/elements/class_Common.html |    4 ++--
 httemplate/edit/pkg_class.html             |    2 +-
 httemplate/view/cust_main/billing.html     |   20 ++++++++++++--------
 9 files changed, 79 insertions(+), 22 deletions(-)




More information about the freeside-commits mailing list