[interchange-cvs] interchange - heins modified lib/Vend/Interpolate.pm

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Mon Nov 7 20:39:38 EST 2005


User:      heins
Date:      2005-11-08 01:39:38 GMT
Modified:  lib/Vend Interpolate.pm
Log:
* Add mv_shipping_when_taxable member to "multi" taxing, so that you
  can tax shipping only when taxable items are in the total.

Revision  Changes    Path
2.261     +25 -8     interchange/lib/Vend/Interpolate.pm


rev 2.261, prev_rev 2.260
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.260
retrieving revision 2.261
diff -u -r2.260 -r2.261
--- Interpolate.pm	7 Nov 2005 22:08:50 -0000	2.260
+++ Interpolate.pm	8 Nov 2005 01:39:37 -0000	2.261
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.260 2005/11/07 22:08:50 jon Exp $
+# $Id: Interpolate.pm,v 2.261 2005/11/08 01:39:37 mheins Exp $
 #
 # Copyright (C) 2002-2005 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.260 $, 10);
+$VERSION = substr(q$Revision: 2.261 $, 10);
 
 @EXPORT = qw (
 
@@ -5352,6 +5352,12 @@
 	return $amount * $rate;
 }
 
+sub percent_rate {
+	my $rate = shift;
+	$rate =~ s/\s*%\s*$// and $rate /= 100;
+	return $rate;
+}
+
 sub tax_vat {
 	my($type, $opt) = @_;
 #::logDebug("entering VAT, opts=" . uneval($opt));
@@ -5458,20 +5464,31 @@
 			my $cat = join ":", @{$rhash}{@pfield};
 			my $rate = defined $tax->{$cat} ? $tax->{$cat} : $tax->{default};
 #::logDebug("item $item->{code} cat=$cat rate=$rate");
-			$rate =~ s/\s*%\s*$// and $rate /= 100;
+			$rate = percent_rate($rate);
 			next if $rate <= 0;
-                        $rate = $rate / (1 + $rate) if $Vend::Cfg->{TaxInclusive};
+			$rate = $rate / (1 + $rate) if $Vend::Cfg->{TaxInclusive};
 			my $sub = discount_subtotal($item);
 #::logDebug("item $item->{code} subtotal=$sub");
 			$total += $sub * $rate;
 #::logDebug("tax total=$total");
 		}
-			
+
+		my $tax_shipping_rate = 0;
+
+		## Add some tax on shipping ONLY IF TAXABLE ITEMS
+		## if rate for mv_shipping_when_taxable category is set
+		if ($tax->{mv_shipping_when_taxable} and $total > 0) {
+			$tax_shipping_rate += percent_rate($tax->{mv_shipping_when_taxable});
+		}
+
 		## Add some tax on shipping if rate for mv_shipping category is set
 		if ($tax->{mv_shipping} > 0) {
-			my $rate = $tax->{mv_shipping};
+			$tax_shipping_rate += percent_rate($tax->{mv_shipping});
+		}
+
+		if($tax_shipping_rate > 0) {
+			my $rate = $tax_shipping_rate;
 			$rate =~ s/\s*%\s*$// and $rate /= 100;
-                        $rate = $rate / (1 + $rate) if $Vend::Cfg->{TaxInclusive};
 			my $sub = tag_shipping() * $rate;
 #::logDebug("applying shipping tax rate of $rate, tax of $sub");
 			$total += $sub;
@@ -5481,7 +5498,7 @@
 		if ($tax->{mv_handling} > 0) {
 			my $rate = $tax->{mv_handling};
 			$rate =~ s/\s*%\s*$// and $rate /= 100;
-                        $rate = $rate / (1 + $rate) if $Vend::Cfg->{TaxInclusive};
+			$rate = $rate / (1 + $rate) if $Vend::Cfg->{TaxInclusive};
 			my $sub = tag_handling() * $rate;
 #::logDebug("applying handling tax rate of $rate, tax of $sub");
 			$total += $sub;








More information about the interchange-cvs mailing list