texas tax diff
Rick Eicher II
rick at pbol.net
Mon Mar 18 12:32:34 PST 2002
I am sure that this is probably is not the way you would prefer this to be
done. But I figure that since this does work you will forgive the method of
posting this.
Any way here it is.
##########################################################
[root at zeppelin src]# diff -rub freeside freeside_new/
Only in freeside_new/FS/FS: CGIwrapper.pm
Only in freeside/FS/FS: CVS
Only in freeside/FS/FS/UI: CVS
diff -rub freeside/FS/FS/cust_main.pm freeside_new/FS/FS/cust_main.pm
--- freeside/FS/FS/cust_main.pm Fri Mar 1 05:14:08 2002
+++ freeside_new/FS/FS/cust_main.pm Mon Mar 18 08:10:33 2002
@@ -861,6 +861,9 @@
my( $total_setup, $total_recur ) = ( 0, 0 );
my( $taxable_setup, $taxable_recur ) = ( 0, 0 );
my @cust_bill_pkg = ();
+ my $taxable_charged = 0;
+ my $tax = 0;
+ my $charged = 0;
foreach my $cust_pkg (
qsearch('cust_pkg', { 'custnum' => $self->custnum } )
@@ -989,17 +992,7 @@
&& $part_pkg->recurtax =~ /^Y$/i;
}
}
-
- }
-
- my $charged = sprintf( "%.2f", $total_setup + $total_recur );
- my $taxable_charged = sprintf( "%.2f", $taxable_setup + $taxable_recur );
-
- unless ( @cust_bill_pkg ) {
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
- return '';
- }
-
+ $taxable_charged = sprintf( "%.2f", $taxable_setup + $taxable_recur );
unless ( $self->tax =~ /Y/i
|| $self->payby eq 'COMP'
|| $taxable_charged == 0 ) {
@@ -1009,10 +1002,31 @@
'country' => $self->country,
} ) or die "fatal: can't find tax rate for state/county/country ".
$self->state. "/". $self->county. "/". $self->country. "\n";
- my $tax = sprintf( "%.2f",
- $taxable_charged * ( $cust_main_county->getfield('tax') / 100 )
- );
+ if ( $part_pkg->dbdef_table->column('taxclass') &&
$part_pkg->taxclass ne 'none' ){
+ if ( $part_pkg->taxclass eq 'access' && $taxable_charged > 25){
+ $taxable_charged = $taxable_charged - 25;
+ $tax += sprintf( "%.2f",$taxable_charged * (
$cust_main_county->getfield('tax') / 100 ));
+ }elsif ($part_pkg->taxclass eq 'hosting')
+ {
+ $taxable_charged = $taxable_charged * .80;
+ $tax += sprintf( "%.2f",$taxable_charged * (
$cust_main_county->getfield('tax') / 100 ));
+ }else
+ {
+ $tax += sprintf("%.2f",0);
+ }
+ }else{
+ $tax += sprintf( "%.2f",$taxable_charged * (
$cust_main_county->getfield('tax') / 100 ));
+ }
+ }
+ }
+
+ $charged = sprintf( "%.2f", $total_setup + $total_recur );
+ $tax = sprintf( "%.2f",$tax);
+ unless ( @cust_bill_pkg ) {
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ return '';
+ }
if ( $tax > 0 ) {
$charged = sprintf( "%.2f", $charged+$tax );
@@ -1025,7 +1039,7 @@
});
push @cust_bill_pkg, $cust_bill_pkg;
}
- }
+
my $cust_bill = new FS::cust_bill ( {
'custnum' => $self->custnum,
diff -rub freeside/FS/FS/part_pkg.pm freeside_new/FS/FS/part_pkg.pm
--- freeside/FS/FS/part_pkg.pm Mon Feb 18 02:39:21 2002
+++ freeside_new/FS/FS/part_pkg.pm Mon Mar 18 08:10:33 2002
@@ -59,6 +59,8 @@
=item recurtax - Recurring fee tax exempt flag, empty or `Y'
+=item taxclass - Texas tax class flag, empty or `Y'
+
=item plan - Price plan
=item plandata - Price plan data
@@ -224,6 +226,7 @@
|| $self->ut_alphan('plan')
|| $self->ut_anything('plandata')
|| $self->ut_enum('setuptax', [ '', 'Y' ] )
+ || $self->ut_enum('taxclass',['none','access','hosting' ] )
|| $self->ut_enum('recurtax', [ '', 'Y' ] )
|| $self->ut_enum('disabled', [ '', 'Y' ] )
;
Only in freeside_new/bin: .fs-setup.swp
diff -rub freeside/bin/fs-setup freeside_new/bin/fs-setup
--- freeside/bin/fs-setup Mon Mar 18 08:18:27 2002
+++ freeside_new/bin/fs-setup Mon Mar 18 08:08:07 2002
@@ -656,6 +656,7 @@
'plan', 'varchar', 'NULL', $char_d,
'plandata', 'text', 'NULL', '',
'disabled', 'char', 'NULL', 1,
+ 'taxclass', 'varchar', '', $char_d,
],
'primary_key' => 'pkgpart',
'unique' => [ [] ],
@@ -956,3 +957,4 @@
%tables;
}
+
diff -rub freeside/httemplate/docs/schema.html
freeside_new/httemplate/docs/schema.html
--- freeside/httemplate/docs/schema.html Thu Mar 14 06:06:14 2002
+++ freeside_new/httemplate/docs/schema.html Mon Mar 18 08:09:12 2002
@@ -226,7 +226,6 @@
<li>plan - price plan
<li>plandata - additional price plan data
<li>disabled - Disabled flag, empty or `Y'
- <li>taxclass - tax class used for calculating texas tax,
none,access,hosting
</ul>
<li><a name="part_referral"
href="man/FS/part_referral.html">part_referral</a> - Referral listing
<ul>
diff -rub freeside/httemplate/edit/part_pkg.cgi
freeside_new/httemplate/edit/part_pkg.cgi
--- freeside/httemplate/edit/part_pkg.cgi Mon Feb 18 20:57:39 2002
+++ freeside_new/httemplate/edit/part_pkg.cgi Mon Mar 18 08:09:12 2002
@@ -100,6 +100,26 @@
print '</TD></TR>';
+print <<END;
+<TR><TD ALIGN="right">Use Texas Tax Class</TD><TD>
+END
+
+#print '<INPUT TYPE="text" NAME="taxclass">';
+
+print '<SELECT SIZE="1" NAME="taxclass">';
+print '<OPTION VALUE="none"';
+print ' SELECTED' if $hashref->{taxclass} eq "none";
+print '>None</OPTION>';
+print '<OPTION VALUE="access"';
+print ' SELECTED' if $hashref->{taxclass} eq "access";
+print '>access</OPTION>';
+print '<OPTION VALUE="hosting"';
+print ' SELECTED' if $hashref->{taxclass} eq "hosting";
+print '>hosting</OPTION></SELECT>';
+
+print '</TD></TR>';
+
+
print '<TR><TD ALIGN="right">Disable new orders</TD><TD>';
print '<INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"';
print ' CHECKED' if $hashref->{disabled} eq "Y";
@@ -354,7 +374,7 @@
}
function fixup(what) {
-<% foreach my $f ( qw( pkg comment freq ), @fixups ) { %>
+<% foreach my $f ( qw( pkg comment freq taxclass), @fixups ) { %>
what.<%= $f %>.value = document.dummy.<%= $f %>.value;
<% } %>
<% foreach my $f ( qw( setuptax recurtax disabled ) ) { %>
@@ -395,6 +415,7 @@
<INPUT TYPE="hidden" NAME="freq" VALUE="<%= $hashref->{freq} %>">
<INPUT TYPE="hidden" NAME="setuptax" VALUE="<%= $hashref->{setuptax} %>">
<INPUT TYPE="hidden" NAME="recurtax" VALUE="<%= $hashref->{recurtax} %>">
+<INPUT TYPE="hidden" NAME="taxclass" VALUE="<%= $hashref->{taxclass} %>">
<INPUT TYPE="hidden" NAME="disabled" VALUE="<%= $hashref->{disabled} %>">
<% foreach my $f ( @fixups ) { %>
<INPUT TYPE="hidden" NAME="<%= $f %>" VALUE="">
Only in freeside_new/httemplate/edit: part_pkg.cgi_new
diff -rub freeside/httemplate/edit/process/part_pkg.cgi
freeside_new/httemplate/edit/process/part_pkg.cgi
--- freeside/httemplate/edit/process/part_pkg.cgi Sun Feb 10 07:21:31
2002
+++ freeside_new/httemplate/edit/process/part_pkg.cgi Mon Mar 18 08:09:12
2002
@@ -1,5 +1,5 @@
<%
-
+$FS::Record::DEBUG = 1;
my $dbh = dbh;
my $pkgpart = $cgi->param('pkgpart');
@@ -13,7 +13,7 @@
join('', map { "$_=". join(', ', $cgi->param($_)). "\n" } @plandata )
);
-foreach (qw( setuptax recurtax disabled )) {
+foreach (qw( setuptax recurtax diabled )) {
$cgi->param($_, '') unless defined $cgi->param($_);
}
@@ -23,8 +23,8 @@
} fields('part_pkg')
} );
-#warn "setuptax: ". $new->setuptax;
-#warn "recurtax: ". $new->recurtax;
+warn "setuptax: ". $new->setuptax;
+warn "recurtax: ". $new->recurtax;
#most of the stuff below should move to part_pkg.pm
Only in freeside_new/httemplate/edit/process: part_pkg.cgi_test
####################################################################
If you prefer this done in a different way let me know. I have never done
diff and patch. As far as the coding goes I know that this works but I am
sure there are other ways of doing this.
Rick
More information about the freeside-devel
mailing list