[interchange-cvs] interchange - jon modified 2 files
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Thu Feb 6 15:28:01 2003
User: jon
Date: 2003-02-06 20:27:16 GMT
Modified: lib/Vend Data.pm Interpolate.pm
Log:
A few minor things:
* Have NonTaxableField check all ProductFiles tables for the field if
needed, instead of just the one in mv_ib or the first ProductFiles
table. This allows NonTaxableField to work with options when the base
product has a nontaxable field, but the options table has no nontaxable
field (as in Foundation). This should have no effect on people using
NonTaxableField the standard way.
* Add option to product_common and item_common that allows an empty
field to be returned. In effect this option means "give me the value
of this field from the first ProductFiles table that has the field
at all" instead of "give me the first true value from a ProductFiles
table that has the field".
* Optimize item_common a bit by looking at each table only once.
Revision Changes Path
2.23 +7 -5 interchange/lib/Vend/Data.pm
rev 2.23, prev_rev 2.22
Index: Data.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Data.pm,v
retrieving revision 2.22
retrieving revision 2.23
diff -u -u -r2.22 -r2.23
--- Data.pm 23 Jan 2003 05:00:16 -0000 2.22
+++ Data.pm 6 Feb 2003 20:27:16 -0000 2.23
@@ -1,6 +1,6 @@
# Vend::Data - Interchange databases
#
-# $Id: Data.pm,v 2.22 2003/01/23 05:00:16 jon Exp $
+# $Id: Data.pm,v 2.23 2003/02/06 20:27:16 jon Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -372,7 +372,7 @@
sub product_common {
- my ($field_name, $code) = @_;
+ my ($field_name, $code, $emptyok) = @_;
#::logDebug("product_field: name=$field_name code=$code base=$base");
my $result;
for(@{$Vend::Cfg->{ProductFiles}}) {
@@ -380,7 +380,7 @@
or next;
next unless defined $db->test_column($field_name);
$result = database_field($db, $code, $field_name);
- length($result) and last;
+ last if $emptyok or length($result);
}
return $result;
}
@@ -1860,18 +1860,20 @@
}
sub item_common {
- my ($item, $field) = @_;
+ my ($item, $field, $emptyok) = @_;
my $base = $item->{mv_ib};
+ my %seen;
my $res;
foreach my $code ($item->{code}, $item->{mv_sku}) {
next if ! length($code);
for my $dbname ($base, @{$Vend::Cfg->{ProductFiles}} ) {
next if ! $dbname;
+ next if $seen{$dbname}++;
my $db = database_exists_ref($dbname)
or next;
last unless defined $db->test_column($field);
$res = database_field($db, $code, $field);
- return $res if length $res;
+ return $res if $emptyok or length($res);
}
}
}
2.146 +3 -3 interchange/lib/Vend/Interpolate.pm
rev 2.146, prev_rev 2.145
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.145
retrieving revision 2.146
diff -u -u -r2.145 -r2.146
--- Interpolate.pm 2 Feb 2003 15:00:15 -0000 2.145
+++ Interpolate.pm 6 Feb 2003 20:27:16 -0000 2.146
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.145 2003/02/02 15:00:15 mheins Exp $
+# $Id: Interpolate.pm,v 2.146 2003/02/06 20:27:16 jon Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -27,7 +27,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.145 $, 10);
+$VERSION = substr(q$Revision: 2.146 $, 10);
@EXPORT = qw (
@@ -6354,7 +6354,7 @@
foreach $i (0 .. $#$Vend::Items) {
$item = $Vend::Items->[$i];
next if is_yes( $item->{mv_nontaxable} );
- next if is_yes( item_field($item, $Vend::Cfg->{NonTaxableField}) );
+ next if is_yes( item_common($item, $Vend::Cfg->{NonTaxableField}, 1) );
$tmp = item_subtotal($item);
unless (defined $Vend::Session->{discount}) {
$taxable += $tmp;