novnov wrote:
> Bumping this in hopes that someone can give me a bit of input?

Wow, nobody replied?...

> novnov wrote:
>> I'm working on an application that will eventually need to support various
>> currencies. I've never touched this area before, have dealt with dollars
>> till now. I'm not sure what the regular practices are re mulitple
>> currencies in the same application.
>>
>> The app includes calculations like price per unit, which of course
>> involves division and thus fractional monetary units. I'm more concerned
>> about that stuff than formatting/presentation.
>>
>> Users of the app will be able to identify the currency that is relevant
>> for their use, and each individual user won't be using more than one
>> currency.
>>
>> Do I handle all currency calcs in functions that adjust for currency?

A few things you'll probably want:
- Store prices in your db with their original currency
- Make sure you have up-to-date conversion rates (how up to date that
needs to be is up to you)
- Calculate actual prices on demand

We are satisfied with daily updates to our conversion rates, which we
store in a table. Conversion isn't too difficult that way.

Say you want to convert the price of a product from dollars (the
original currency) to euros, your query would look something like this:

SELECT price * target.rate / source.rate
  FROM products
   INNER JOIN rates source ON (products.currency = source.currency),
        rates target
 WHERE products.id = 1234
   AND target.currency = 'euro';

I don't think you'll need any functions, unless to retrieve real-time
conversion rates somehow. Otherwise a cron job will do nicely.

-- 
Alban Hertroys
[EMAIL PROTECTED]

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

Reply via email to