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

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Tue Apr 12 15:08:01 EDT 2005


User:      jon
Date:      2005-04-12 19:08:01 GMT
Modified:  lib/Vend Interpolate.pm
Log:
Patch from Ethan Rowe <ethan at endpoint.com>:

Test 60 was failing due to an oversite on my part in
Vend::Interpolate::subtotal(). The pre-discount-space logic had a check:
my $discounts = defined $Vend::Session->{discount};

Later on, while looping through the products, it checks if $discounts is
true, and if so, adds the item's discounted subtotal to the running subtotal;
otherwise, it adds the item's full-price subtotal.

The discount spaces expect the $::Discounts hash to always exist. Therefore,
I changed the check to be based on:
my $discounts = (defined $::Discounts and %$::Discounts);

The discount_price sub forces the discount hash into exist when it encounters
an item with an mv_price attribute. However, the logic is now expecting the
discount hash to actually contain members, because it will always exist.
Therefore, the following patch to Interpolate.pm struck me as the right fix.
Let me know if you think there's a better way to do it. In any case, it
fixes the problem specific to test #60.

Revision  Changes    Path
2.239     +3 -3      interchange/lib/Vend/Interpolate.pm


rev 2.239, prev_rev 2.238
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.238
retrieving revision 2.239
diff -u -u -r2.238 -r2.239
--- Interpolate.pm	12 Apr 2005 15:14:39 -0000	2.238
+++ Interpolate.pm	12 Apr 2005 19:08:01 -0000	2.239
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.238 2005/04/12 15:14:39 mheins Exp $
+# $Id: Interpolate.pm,v 2.239 2005/04/12 19:08:01 jon 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.238 $, 10);
+$VERSION = substr(q$Revision: 2.239 $, 10);
 
 @EXPORT = qw (
 
@@ -5572,7 +5572,7 @@
     foreach $i (0 .. $#$Vend::Items) {
         $item = $Vend::Items->[$i];
         $tmp = Vend::Data::item_subtotal($item);
-        if($discount) {
+        if($discount || $item->{mv_discount}) {
             $subtotal +=
                 apply_discount($item, $tmp);
         }








More information about the interchange-cvs mailing list