[ic] How to get the right price with my own usertag, if a dealer order some items?

Joachim Leidinger interchange-users@interchange.redhat.com
Fri Dec 14 04:04:03 2001


Hi List,

I'm able to get the salestax right, if I've a multiple tax/vat of each
items. But I've one problem. I've in my catalog.cfg

Variable    COMPUTE_VAT_PRICEFIELD     price

and

Autoload <<EOR
[perl arg="scratch config"]
    if($Scratch->{dealer}) {
            $Config->{PriceField} = 'price';
    } else {
            $Config->{PriceField} = 'price2';
	}
[/perl]
EOR

in my catalog.cfg and my usertag use

my $pricefield = $::Variable->{COMPUTE_VAT_PRICEFIELD};

foreach my $item (@$Vend::Items) {
  for(@{$Vend::Cfg->{ProductFiles}}) {
	unless ($Vend::Database{$_}) {
        die "$_ not a database, cannot use as products file\n";
	}
	$vatrate = tag_data($_, $vatfield, $item->{code});
	$outprice = tag_data($_, $pricefield, $item->{code});
                                  ^^^^^^^^^^
        last if($outprice);
	}
        if (!$vatrate){$vatrate = ($vat_default || 16);}
        if ($pricemode =~ /N/ || $pricemode =~ /n/){
          $vatdivide = $vatrate / 100;
	} else { 
          $vatdivide = 1 / (100 + $vatrate) * $vatrate;
        }
          $vat += ($outprice * $item->{quantity}) * $vatdivide;
          $subtotal += $outprice * $item->{quantity};
        }


I want to rewrite the line

	$outprice = tag_data($_, $pricefield, $item->{code});

to get the right price field. Should I use

my $pricefield = $::Variable->{PriceField};

instead of

my $pricefield = $::Variable->{COMPUTE_VAT_PRICEFIELD};

? Or did someone have a better solution?

Any helps, tips and suggestions are very welcome!

Thanks!

Joachim

-- 
Hans-Joachim Leidinger | Dipl.-Phys.Ing. Entwicklung eCommerce
[Hans-Joachim.leidinger@bpanet.de]
Black Point Arts Internet Solutions GmbH
http://www.bpanet.de