[ic] Discounting Entire Orders

Kevin Walsh interchange-users@interchange.redhat.com
Thu Oct 25 11:46:00 2001


> > Try something like the following code:
> >
> >    [discount ENTIRE_ORDER]
> >        $s > 100 ? $s * 0.9 : $s;
> >    [/discount]
> >
> How can I pass this into etc/report so that when I process the
> order I know how much discount they have been promised?
>
Let's see if I understand - Are you asking how to show the fact
that a 10% discount has been given?  The original question called
for all orders with a value over 100.00 to be given a 10% discount.

If this is to be made variable, then perhaps you could work out the
10% and save it into a scratch value with something like the following:

    [seti discount_pct] query db and set 10 (for 10% discount) [/seti]
    [seti discount_amount] query db and set 100 (for > $100) [/seti]

    [discount ENTIRE_ORDER]
        my $pct = (100 - ($::Scratch->{'discount_pct'} || 0)) / 100;
        my $amt = $::Scratch->{'discount_amount'} or return $s;
        $s > $amt ? $s * $pct : $s;
    [/discount]

Then you have the discount set to the rules you want, and have scratch
values set to those rules.  Your report page can show those scratch
values to explain the discount applied.

The rules could be set on a per-user basis, depending upon the code you
use to set the scratch values.

All untested - just have a play with it and see what you get.

If I misunderstood your question, then please ask it again.

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin@cursor.uk.com
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/