[freeside-commits] freeside/httemplate/edit/process tax_class.html, NONE, 1.1 tax_rate.html, NONE, 1.1 part_pkg.cgi, 1.28, 1.29

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


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

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

--- NEW FILE: tax_class.html ---
% if ( $error ) {
%  $cgi->param('error', $error);
<% $cgi->redirect(popurl(2). "tax_class.html?". $cgi->query_string ) %>
%} else {
<% $cgi->redirect(popurl(3). "browse/tax_rate.cgi?taxclassnum=". uri_escape($tax_class->taxclassnum) ) %>
%}
<%init>

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

my $tax_class = new FS::tax_class {
  'taxclass' => $cgi->param('taxclass'),
  'description' => $cgi->param('description'),
};

#maybe this whole thing should be in a transaction.  at some point, no biggie
#none of the follow-up stuff will fail unless there's a more serious problem
#than a hanging record in tax_class...

my $error = $tax_class->insert;

# all of this is highly dubious at the moment

#unless ( $error ) {
#  #auto-add the new taxclass to any regions that have taxclasses already
#
#  my $sth = dbh->prepare("
#    SELECT geocode FROM tax_rate
#      WHERE taxclass IS NOT NULL AND taxclass != ''
#      GROUP BY geocode
#  ") or die dbh->errstr;
#  $sth->execute or die $sth->errstr;
#
#  while ( my $row = $sth->fetchrow_hashref ) {
#    warn "inserting for $row";
#    my $cust_main_county = new FS::tax_rate {
#      'geocode'     => $row->{geocode},
#      'tax'         => 0,
#      'taxclassnum' => $tax_class->taxclassnum,
#    };
#    $error = $cust_main_county->insert;
#    #last if $error;
#    die $error if $error;
#  }
#
#}

</%init>

--- NEW FILE: tax_rate.html ---
<% include( 'elements/process.html',
              'table' => 'tax_rate',
              'popup_reload' => 'Tax changed', #a popup "parent reload" for now
              #someday change the individual element and go away instead
          )
%>
<%init>

my $conf = new FS::Conf;
die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

</%init>

Index: part_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/part_pkg.cgi,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- part_pkg.cgi	5 Feb 2008 03:37:01 -0000	1.28
+++ part_pkg.cgi	1 Apr 2008 00:54:43 -0000	1.29
@@ -53,6 +53,9 @@
           !$pkgpart && $conf->exists('agent-defaultpkg')
         );
 
+$cgi->param('tax_override') =~ /^([\d,]+)$/;
+my (@tax_overrides) = (grep "$_", split (",", $1));
+
 my $new = new FS::part_pkg ( {
   map {
     $_ => scalar($cgi->param($_));
@@ -103,11 +106,19 @@
 }
 
 unless ( $error || $conf->exists('agent_defaultpkg') ) {
-  my $error = $new->process_m2m(
+  $error = $new->process_m2m(
     'link_table'   => 'type_pkgs',
     'target_table' => 'agent_type',
     'params'       => \@agents,
   );
 }
 
+unless ( $error  ) {
+  $error = $new->process_m2m(
+    'link_table'   => 'part_pkg_taxoverride',
+    'target_table' => 'tax_rate',
+    'params'       => \@tax_overrides,
+  );
+}
+
 </%init>



More information about the freeside-commits mailing list