[freeside-commits] freeside/httemplate/edit part_pkg_taxoverride.html, NONE, 1.1 part_pkg_taxproduct.html, NONE, 1.1 tax_class.html, NONE, 1.1 tax_rate.html, NONE, 1.1 part_pkg.cgi, 1.82, 1.83

Jeff Finucane,420,, jeff at wavetail.420.am
Mon Mar 31 17:54:45 PDT 2008


Update of /home/cvs/cvsroot/freeside/httemplate/edit
In directory wavetail.420.am:/tmp/cvs-serv19578/httemplate/edit

Modified Files:
	part_pkg.cgi 
Added Files:
	part_pkg_taxoverride.html part_pkg_taxproduct.html 
	tax_class.html tax_rate.html 
Log Message:
checkpoint of new tax rating system

--- NEW FILE: part_pkg_taxproduct.html ---
<% include('/elements/header-popup.html', 'Select tax product') %>
<SCRIPT>
  function saveit() {
    var num = parent.document.getElementById('taxproductnum');
    var disp = parent.document.getElementById('taxproduct_description');
    var sel = document.getElementById('taxproduct_popup_select');
    num.value = sel.options[sel.selectedIndex].value;
    disp.value = sel.options[sel.selectedIndex].text;
    parent.cClick();
  }
</SCRIPT>
<FORM="dummy" METHOD="POST" onsubmit="saveit();return false;" >

<% ntable("#cccccc", 2) %>
<TR>
  <TD align="left">Tax product</TD>
  <TD>
    <% include( '/elements/select-table.html',
                'empty_label' => '(select product)',
                'table'       => 'part_pkg_taxproduct',
                'name_col'    => 'description',
                'curr_value'  => $curr_value,
                'element_etc' => "id='taxproduct_popup_select'",
              )
    %>
  </TD>
</TR>
</TABLE>
<BR><BR>
<CENTER><INPUT type="submit" value="Select"></CENTER>
</FORM>
<% include('/elements/footer.html') %>

<%init>

my $conf = new FS::Conf;

my ( $query ) = $cgi->keywords;
$query =~ /^(\d+)$/;
my $curr_value = $1;

</%init>

--- NEW FILE: tax_class.html ---
<% include('/elements/header.html', "$action taxclass") %>

<% include('/elements/error.html') %>

<FORM ACTION="<% $p1 %>process/tax_class.html" METHOD=POST>

<INPUT TYPE="hidden" NAME="taxclassnum" VALUE="">
<INPUT TYPE="hidden" NAME="data_vendor" VALUE="">

Tax class <INPUT TYPE="text" NAME="taxclass" VALUE="<% $taxclass |h %>"><BR>
Description <INPUT TYPE="text" NAME="description" VALUE="<% $description |h %>">

<BR><BR>
<INPUT TYPE="submit" VALUE="<% $action %> taxclass">

</FORM>

<% include('/elements/footer.html') %>

<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $taxclass = '';
my $description = '';
if ( $cgi->param('error') ) {
  $taxclass = $cgi->param('taxclass');
  $description = $cgi->param('description');
}

my $action = 'Add';

my $p1 = popurl(1);

</%init>

--- NEW FILE: tax_rate.html ---
<% include('elements/edit.html',
     'popup'  => 1,
     'name'   => 'Tax rate', #Edit tax rate
     'table'  => 'tax_rate',
     'labels' => $labels,
     'fields' => \@fields,
   )
%>
<%once>

my $conf = new FS::Conf;

</%once>

<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $taxnum;
if ( $cgi->param('error') ) {
  $cgi->param('taxnum') =~ /^(\d+)$/ or die 'error, but no taxnum';
  $taxnum = $1;
} else {
  my($query) = $cgi->keywords;
  $query =~ /^(\d+)$/ or die 'no taxnum';
  $taxnum = $1;
}

my $tax_rate = qsearchs('tax_rate', { 'taxnum' => $taxnum })
  or die "unknown taxnum $1";

my $labels =  { 'taxnum'               => 'Tax',
                'data_vendor'          => 'Data vendor',
                'geocode'              => 'Vendor location code',
                'location'             => 'Tax auth loc code',
                'taxclass_description' => 'Tax class',
                'taxname'              => 'Tax name',
                'effective_date'       => 'Effective date',
                'tax'                  => 'Tax rate (1st bracket)',
                'excessrate'           => 'Tax rate (2nd bracket)',
                'taxbase'              => 'First bracket',
                'taxmax'               => 'Max tax',
                'usetax'               => 'Use tax rate (1st bracket)',
                'useexcessrate'        => 'Use tax rate (2nd bracket)',
                'unittype_name'        => 'Units',
                'fee'                  => 'Fee per unit (1st bracket)',
                'excessfee'            => 'Fee per unit (2st bracket)',
                'feebase'              => 'Units in first bracket',
                'feemax'               => 'Max Units',
                'maxtype_name'         => 'Threshold accumulation',
                'taxauth_name',        => 'Tax authority',
                'basetype_name'        => 'Basis',
                'passtype_name'        => 'Passthru',
                'passflag'             => 'Passable',
                'setuptax'             => 'This tax not applicable to setup fees',
                'recurtax'             => 'This tax not applicable to recurring fees',
              };

my @fields = (
    { type=>'tablebreak-tr-title',   value=>'Location' },
    { field=>'data_vendor',          type=>'hidden',},
    { field=>'geocode',              type=>'fixed' },
    { field=>'taxclassnum',          type=>'hidden' } ,
    { field=>'taxclass_description', type=>'fixed' } ,
    { field=>'taxname',              type=>'text' } ,
    { field=>'effective_date',       type=>'fixed' } ,
    { field=>'location',             type=>'text' },
    { type=>'tablebreak-tr-title',   value=>'Money based rates' },
    { field=>'tax',                  type=>'percentage' } ,
    { field=>'excessrate',           type=>'percentage' } ,
    { field=>'taxbase',              type=>'money' } ,
    { field=>'taxmax',               type=>'money' } ,
    { field=>'usetax',               type=>'percentage' } ,
    { field=>'useexcessrate',        type=>'percentage' } ,
    { type=>'tablebreak-tr-title',   value=>'Service based rates' },
    { field=>'unittype',             type=>'hidden' } ,
    { field=>'unittype_name',        type=>'fixed' } ,
    { field=>'fee',                  type=>'money' } ,
    { field=>'excessfee',            type=>'money' } ,
    { field=>'feebase',              type=>'text' } ,
    { field=>'feemax',               type=>'text' } ,
    { type=>'tablebreak-tr-title',   value=>'Taxation rules' },
    { field=>'maxtype',              type=>'hidden' } ,
    { field=>'maxtype_name',         type=>'fixed' } ,
    { field=>'taxauth',              type=>'hidden' } ,
    { field=>'taxauth_name',         type=>'fixed' } ,
    { field=>'basetype',             type=>'hidden' } ,
    { field=>'basetype_name',        type=>'fixed' } ,
    { field=>'passtype',             type=>'hidden' } ,
    { field=>'passtype_name',        type=>'fixed' } ,
    { field=>'passflag',             type=>'fixed' } ,
    { field=>'setuptax',             type=>'checkbox' } ,
    { field=>'recurtax',             type=>'checkbox' } ,
    { field=>'manual',               type=>'hidden', value=>'Y' } ,
);

#push @fields,
#  { type=>'tablebreak-tr-title', value=>'Exemptions' },
#  { field=>'setuptax', type=>'checkbox', value=>'Y', },
#  { field=>'recurtax', type=>'checkbox', value=>'Y', },
#  { field=>'exempt_amount', type=>'money', },
#;

</%init>

Index: part_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/part_pkg.cgi,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- part_pkg.cgi	15 Mar 2008 22:18:58 -0000	1.82
+++ part_pkg.cgi	1 Apr 2008 00:54:43 -0000	1.83
@@ -3,6 +3,11 @@
 )) %>
 % #), ' onLoad="visualize()"'); 
 
+<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_iframe.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_draggable.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/iframecontentmws.js"></SCRIPT>
+
 <% include('/elements/error.html') %>
 
 <FORM NAME="dummy">
@@ -81,6 +86,34 @@
 
 % } 
 
+% if ( $conf->exists('enable_taxproducts') ) { 
+
+  <TR><TD colspan="2">
+    <% ntable("#cccccc", 2) %>
+      <TR>
+        <TD align="right">Tax product</TD>
+        <TD>
+          <INPUT name="part_pkg_taxproduct_taxproductnum" id="taxproductnum" type="hidden" value="<% $hashref->{'taxproductnum'}%>">
+          <INPUT name="part_pkg_taxproduct_description" id="taxproduct_description" type="text" value="<% $taxproduct_description %>" size="12" onclick="overlib( OLiframeContent('part_pkg_taxproduct.html?'+document.getElementById('taxproductnum').value, 800, 400, 'tax_product_popup'), CAPTION, 'Select product', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">
+        </TD>
+      </TR>
+      <TR>
+        <TD colspan="2" align="right">
+          <INPUT name="tax_override" id="tax_override" type="hidden" value="<% $tax_override %>">
+          <A href="javascript:void(0)" onclick="overlib( OLiframeContent('part_pkg_taxoverride.html?'+document.getElementById('tax_override').value, 800, 400, 'tax_product_popup'), CAPTION, 'Edit product tax overrides', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK); return false;">
+            <% $tax_override ? 'Edit tax overrides' : 'Override taxes' %>
+          </A>
+        </TD>
+      </TR>
+    </TABLE>
+  </TD></TR>
+
+% } else { 
+
+  <INPUT TYPE="hidden" NAME="taxproductnum" VALUE="<% $hashref->{taxproductnum} %>">
+
+% } 
+
 </TABLE>
 <BR>
 
@@ -234,7 +267,7 @@
 %#} else {
 %#  push @fixups, 'taxclass'; #hidden
 %#}
-%my @form_elements = ( 'classnum', 'taxclass', 'agent_type' );
+%my @form_elements = ( 'classnum', 'taxclass', 'agent_type', 'tax_override' );
 %
 %my @form_radio = ( 'pkg_svc_primary' );
 %
@@ -252,6 +285,7 @@
 %  'form_elements'  => \@form_elements,
 %  'form_text'      => [ qw(pkg comment promo_code clone pkgnum pkgpart),
 %                        qw(pay_weight credit_weight), #keys(%weight),
+%                        qw(taxproductnum),
 %                        @fixups,
 %                      ],
 %  'form_checkbox'  => [ qw(setuptax recurtax disabled) ],
@@ -409,12 +443,14 @@
 my $conf = new FS::Conf; 
 my $part_pkg = '';
 my @agent_type = ();
+my $tax_override;
 my @all_agent_types = map {$_->typenum} qsearch('agent_type',{});
 if ( $cgi->param('error') ) {
   $part_pkg = new FS::part_pkg ( {
     map { $_, scalar($cgi->param($_)) } fields('part_pkg')
   } );
   (@agent_type) = $cgi->param('agent_type');
+  $tax_override = $cgi->param('tax_override');
 }
 
 my $action = '';
@@ -430,6 +466,9 @@
 } elsif ( $query && $query =~ /^(\d+)$/ ) {
   (@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1})
     unless $part_pkg;
+  $tax_override =
+    join (",", map {$_->taxnum} qsearch('part_pkg_taxoverride',{'pkgpart'=>$1}))
+    unless $part_pkg;
   $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1});
   $pkgpart = $part_pkg->pkgpart;
 } else {
@@ -447,5 +486,6 @@
 }
 $action ||= $part_pkg->pkgpart ? 'Edit' : 'Add';
 my $hashref = $part_pkg->hashref;
+my $taxproduct_description = $part_pkg->taxproduct_description;
 
 </%init>

--- NEW FILE: part_pkg_taxoverride.html ---
<%doc>

  The crappy version
  
</%doc>
<% include('/elements/header-popup.html', 'Select tax product') %>
<SCRIPT>
  function saveit2() {
    var num = parent.document.getElementById('tax_override');
    var sel = document.getElementById('taxoverride_popup_select');
    var value = '';
    for (i=0; i< sel.length; i++) {
      if (sel.options[i].selected) {
        value = value + sel.options[i].value + ",";
      }
    }
    if (value.length > 0) {
      value = value.substr(0, value.length-1);
    }
      
    num.value = value;
    parent.cClick();
  }
</SCRIPT>
<FORM="dummy" METHOD="POST" onsubmit="saveit2();return false;" >

<% ntable("#cccccc", 2) %>
<TR>
  <TD align="left">Tax override</TD>
  <TD>
    <% include( '/elements/select-table.html',
                'table'       => 'tax_rate',
                'name_col'    => 'taxname',
                'curr_value'  => \@curr_value,
                'element_etc' => "id='taxoverride_popup_select'",
                'multiple'    => '1',
              )
    %>
  </TD>
</TR>
</TABLE>
<BR><BR>
<CENTER><INPUT type="submit" value="Select"></CENTER>
</FORM>
<% include('/elements/footer.html') %>

<%init>

my $conf = new FS::Conf;

my @curr_value;
my ( $query ) = $cgi->keywords;
$query =~ /^([\d,]+)$/;
push @curr_value, split ',', $1
  if $1;

unless (scalar(@curr_value)) {
  #push @curr_value, map {$_=>taxnum} $part_pkg->tax_rate;
}

</%init>



More information about the freeside-commits mailing list