[interchange-cvs] interchange - jon modified 4 files
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Thu Jan 23 00:01:02 2003
User: jon
Date: 2003-01-23 05:00:17 GMT
Modified: dist/test catalog.cfg
Modified: dist/test/products pricing.asc tests.asc
Modified: lib/Vend Data.pm
Log:
* Support sparsely-populated quantity pricing tables.
* Fix bug in field name ranges in CommonAdjust where q99..q101 was handled
as a Perl alphanumeric range q99, r00, r01, r02, etc. instead of
q99, q100, q101.
* Add regression test for these changes.
Revision Changes Path
2.4 +1 -1 interchange/dist/test/catalog.cfg
rev 2.4, prev_rev 2.3
Index: catalog.cfg
===================================================================
RCS file: /var/cvs/interchange/dist/test/catalog.cfg,v
retrieving revision 2.3
retrieving revision 2.4
diff -u -u -r2.3 -r2.4
--- catalog.cfg 20 Jan 2003 19:58:30 -0000 2.3
+++ catalog.cfg 23 Jan 2003 05:00:16 -0000 2.4
@@ -31,7 +31,7 @@
Variable ENCRYPTOR none
PriceField no_price
-CommonAdjust $ ;pricing:price1,price5,price10:, ;:price:, ==size:pricing, ==color:pricing:common
+CommonAdjust $ ;pricing:price1,price5,price10,price15,price20,price21,price97..price102:, ;:price:, ==size:pricing, ==color:pricing:common
##########################################################
ParseVariables Yes
2.1 +12 -11 interchange/dist/test/products/pricing.asc
rev 2.1, prev_rev 2.0
Index: pricing.asc
===================================================================
RCS file: /var/cvs/interchange/dist/test/products/pricing.asc,v
retrieving revision 2.0
retrieving revision 2.1
diff -u -u -r2.0 -r2.1
--- pricing.asc 18 Jul 2001 02:22:35 -0000 2.0
+++ pricing.asc 23 Jan 2003 05:00:16 -0000 2.1
@@ -1,11 +1,12 @@
-sku price XL S common price1 price5 price10
-00-0011 price data ok 500 250
-00-0011a 50 45 35 30
-00-343 400 200 50 20
-19-202 400 200 50 20
-21-221 400 200 50 20
-99-102 2 -0.50 12 9 8
-34-101 400 200 50 20
-00-341 400 200 50 20
-red 1 -0.50 -1.00 9 8
-00-342 400 200 50 20
+sku price XL S common price1 price5 price10 price15 price20 price21 price98 price102
+00-0011 price data ok 500 250
+00-0011a 50 45 35 30
+00-343 400 200 50 20
+19-202 400 200 50 20
+21-221 400 200 50 20
+99-102 2 -0.50 12 9 8
+34-101 400 200 50 20
+00-341 400 200 50 20
+red 1 -0.50 -1.00 9 8
+00-342 400 200 50 20
+93-111 85.00 80.00 72.50 69.95 67.25 65
2.6 +35 -4 interchange/dist/test/products/tests.asc
rev 2.6, prev_rev 2.5
Index: tests.asc
===================================================================
RCS file: /var/cvs/interchange/dist/test/products/tests.asc,v
retrieving revision 2.5
retrieving revision 2.6
diff -u -u -r2.5 -r2.6
--- tests.asc 20 Jan 2003 19:15:40 -0000 2.5
+++ tests.asc 23 Jan 2003 05:00:16 -0000 2.6
@@ -1930,7 +1930,7 @@
%%
%%
-
+attr_list test
%%%
000129
%%
@@ -1959,7 +1959,7 @@
%%
%%
-Skeleton test.
+Test for assign tag's effects on the cart.
%%%
000130
%%
@@ -1981,7 +1981,7 @@
%%
%%
-Skeleton test.
+error tag test
%%%
000131
%%
@@ -2014,7 +2014,38 @@
%%
%%
-Skeleton test.
+accessories tag test
+%%%
+000133
+%%
+[perl]
+$Carts->{main} = [
+ { code => '93-111', quantity => 1000, },
+ { code => '93-111', quantity => 102, },
+ { code => '93-111', quantity => 100, },
+ { code => '93-111', quantity => 98, },
+ { code => '93-111', quantity => 21, },
+ { code => '93-111', quantity => 20, },
+ { code => '93-111', quantity => 15, },
+ { code => '93-111', quantity => 10, },
+ { code => '93-111', quantity => 9, },
+ { code => '93-111', quantity => 5, },
+ { code => '93-111', quantity => 4, },
+ { code => '93-111', quantity => 1, },
+ { code => '00-342', quantity => 2, },
+ { code => '00-0011a', quantity => 1, },
+];
+return;
+[/perl]
+:[item-list main][item-subtotal noformat=1] [/item-list]:
+%%
+:65000 6630 6725 6590\.5 1468\.95 1399 1087\.5 725 652\.5 362\.5 320 80 40000000 1000 :
+%%
+
+%%
+
+%%
+sparse quantity pricing check (introduced in Interchange 4.9.7)
%%%
999999
%%
2.22 +27 -12 interchange/lib/Vend/Data.pm
rev 2.22, prev_rev 2.21
Index: Data.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Data.pm,v
retrieving revision 2.21
retrieving revision 2.22
diff -u -u -r2.21 -r2.22
--- Data.pm 16 Dec 2002 11:05:33 -0000 2.21
+++ Data.pm 23 Jan 2003 05:00:16 -0000 2.22
@@ -1,6 +1,6 @@
# Vend::Data - Interchange databases
#
-# $Id: Data.pm,v 2.21 2002/12/16 11:05:33 racke Exp $
+# $Id: Data.pm,v 2.22 2003/01/23 05:00:16 jon Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -1596,8 +1596,8 @@
$price = $item->{mv_price} || $mod;
redo CHAIN;
}
- elsif($mod =~ /^(\w*):([^:]*)(:(\S*))?$/) {
- my ($table,$field,$key) = ($1, $2, $4);
+ elsif($mod =~ /^(\w*):([^:]*)(?::(\S*))?$/) {
+ my ($table, $field, $key) = ($1, $2, $3);
#::logDebug("field begins as '$field'");
$field = $Vend::Cfg->{PriceDefault} if ! $field;
if($passed_key) {
@@ -1608,12 +1608,17 @@
(! $table and $table = $passed_key);
undef $passed_key;
}
+ $table = $item->{mv_ib} || $Vend::Cfg->{ProductFiles}[0]
+ if ! $table;
+ if($key and defined $item->{$key}) {
+ $key = $item->{$key};
+ }
my @breaks;
if($field =~ /,/ || $field =~ /\.\./) {
my (@tmp) = split /,/, $field;
for(@tmp) {
- if (/(.+)\.\.+(.+)/) {
- push @breaks, $1 .. $2;
+ if (/(.+?)(\d+)\.\.+.+?(\d+)/) {
+ push @breaks, map { "$1$_" } $2 .. $3;
}
else {
push @breaks, $_;
@@ -1621,6 +1626,7 @@
}
}
if(@breaks) {
+#::logDebug("price breaks: " . join(',', @breaks));
my $quantity;
my $attribute;
$attribute = shift @breaks if $breaks[0] !~ /\d/;
@@ -1644,24 +1650,33 @@
my $test = $field;
$test =~ s/\D+//;
redo CHAIN if $quantity < $test;
- for(@breaks) {
+
+ my $row = database_row(
+ ($table || $item->{mv_ib} || $Vend::Cfg->{ProductFiles}[0]),
+ ($key || $item->{code}),
+ );
+#::logDebug("database reference to price breaks found table=$table key=$key|$item->{$key}|$item->{code} row=" . ::uneval($row));
+
+ my $keep;
+ $keep = $row->{$field} if $row->{$field} != 0;
+ for (@breaks) {
+ next unless exists $row->{$_};
$test = $_;
$test =~ s/\D+//;
last if $test > $quantity;
$field = $_;
+ $keep = $row->{$field} if $row->{$field} != 0;
}
- }
- $table = $item->{mv_ib} || $Vend::Cfg->{ProductFiles}[0]
- if ! $table;
- if($key and defined $item->{$key}) {
- $key = $item->{$key};
+#::logDebug("price=$keep") if $keep;
+ $price = $keep if $keep;
+ redo CHAIN;
}
$price = database_field(
($table || $item->{mv_ib} || $Vend::Cfg->{ProductFiles}[0]),
($key || $item->{code}),
$field
);
-#::logDebug("database referenc found table=$table field=$field key=$key|$item->{$key}|$item->{code} price=$price");
+#::logDebug("database reference found table=$table field=$field key=$key|$item->{$key}|$item->{code} price=$price");
redo CHAIN;
}
elsif ($mod =~ s/(\w+)=(.*)//) {