[ic] Changing currency conversion

Mike Heins mike at perusion.com
Wed Mar 9 14:09:58 EST 2005


Quoting daniel castro (daniel_castro at hotmail.com):
> 
> Hi list,
> 
> I am looking for a way to do currency conversion on the fly, something like 
> changing PriceDivide without having to restart interchange. Right now we 
> use a cron, change the PriceDivide in locales.txt, then restart 
> interchange. It happens daily at 2 pm.
> 
> Any ideas, how to do this within interchange?
> 

Easily done with CommonAdjust and a UserTag.

UserTag convert_currency Routine <<EOR
sub {
    my $loc = $::Scratch->{mv_locale}
	or return;
    my $rate = tag_data('locale', $loc, 'PriceDivide')
	or return;
    return unless $rate > 0;
    my $price = tag_data('products', 'price', $item->{code});
    $price = $price / $rate;
    return round_to_frac_digits($price);
}
EOR

CommonAdjust  [convert-currency] ;products:price

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

Experience is what allows you to recognize a mistake the second
time you make it. -- unknown


More information about the interchange-users mailing list