Home
The Toolkit for Online Communities
17516 Community Members, 0 members online, 2125 visitors today
Log In Register
OpenACS Home : Forums : OpenACS Development : lc_monetary and currency_codes table

Forum OpenACS Development: lc_monetary and currency_codes table

Icon of envelope Request notifications

Collapse
Posted by Malte Sussdorff on
The lc_monetary function which is in core needs to access the currency_codes table which is not in core anymore.

In my opinion the lc_monetary function should therefore be deprecated and / or point to ref-currencies which is the package that should deal with the currencies, in the tradition of the other "ref-" packages. Opinions ?

Collapse
Posted by Brian Fenton on
Hi Malte,

I had this problem about a year ago and found the currency_codes file for Postgres somewhere on the web. I've pasted an Oracle version I created below for you. Once that table is created and populated, lc_monetary works very well.

Brian

Collapse
Posted by Brian Fenton on
set scan off

create table currency_codes (
  iso     char(3) constraint currency_iso_pk primary key,
  currency_name   varchar(200),
  html_entity       varchar(200),
  fractional_digits   integer,
  supported_p             char(1) default 'f'
                          constraint currency_supp_tf check (supported_p in ('t','f'))
);

insert into currency_codes (iso, currency_name) values ('ZAR', 'South African Rand');
insert into currency_codes (iso, currency_name) values ('VEB', 'Venezualan Bolivar');
insert into currency_codes (iso, currency_name) values ('ISK', 'Iceland Krona');
insert into currency_codes (iso, currency_name) values ('CSK', 'Czech Koruna');
insert into currency_codes (iso, currency_name) values ('CLP', 'Chilean Peso');
insert into currency_codes (iso, currency_name) values ('ARP', 'Argentinian Peso');
insert into currency_codes (iso, currency_name) values ('USD', 'United States Dollar');
insert into currency_codes (iso, currency_name) values ('PHP', 'Philippine Peso');
insert into currency_codes (iso, currency_name) values ('NZD', 'New Zealand Dollar');
insert into currency_codes (iso, currency_name) values ('MXP', 'Mexican Peso');
insert into currency_codes (iso, currency_name) values ('LUF', 'Luxembourg Franc');
insert into currency_codes (iso, currency_name) values ('INR', 'Indian Rupee');
insert into currency_codes (iso, currency_name) values ('IEP', 'Irish Punt');
insert into currency_codes (iso, currency_name) values ('GBP', 'British Pound');
insert into currency_codes (iso, currency_name) values ('FRF', 'French Franc');
insert into currency_codes (iso, currency_name) values ('EUR', 'Euro');
insert into currency_codes (iso, currency_name) values ('ESP', 'Spanish Peseta');
insert into currency_codes (iso, currency_name) values ('DKK', 'Danish Krone');
insert into currency_codes (iso, currency_name) values ('DEM', 'Deutsche Mark');
insert into currency_codes (iso, currency_name) values ('CHF', 'Swiss Franc');
insert into currency_codes (iso, currency_name) values ('CAD', 'Canadian Dollar');
insert into currency_codes (iso, currency_name) values ('BRR', 'Brazilian Real');
insert into currency_codes (iso, currency_name) values ('BEF', 'Belgian Franc');
insert into currency_codes (iso, currency_name) values ('AUD', 'Australian Dollar');
insert into currency_codes (iso, currency_name) values ('ATS', 'Austrian Schilling');

--
-- Set up the list of "valid currencies" as a smaller more sane list.
--
update currency_codes set supported_p = 'f';

update currency_codes set supported_p = 't' where iso in ('ATS','AUD',
       'BEF','BRR','CAD','CHF','DEM','DKK','ESP','EUR','FRF','GBP',
       'IEP','INR','LUF','MXP','NZD','PHP','USD','ARP','CLP','CSK',
       'ISK','VEB','ZAR');


--
-- Currency entities. 
--
-- set define off;

-- taken from http://www.askphil.org/auct03.htm
update currency_codes set html_entity = 'ÖSch',
 fractional_digits = '2'
 where iso = 'ATS';
update currency_codes set html_entity = '$A',
 fractional_digits = '2'
 where iso = 'AUD';
update currency_codes set html_entity = 'BFr',
 fractional_digits = '2'
 where iso = 'BEF';
update currency_codes set html_entity = 'R',
 fractional_digits = '2'
 where iso = 'BRR';
update currency_codes set html_entity = '$C',
 fractional_digits = '2'
 where iso = 'CAD';
update currency_codes set html_entity = 'SFr',
 fractional_digits = '2'
 where iso = 'CHF';
update currency_codes set html_entity = 'DM',
 fractional_digits = '2'
 where iso = 'DEM';
update currency_codes set html_entity = 'DKr',
 fractional_digits = '2'
 where iso = 'DKK';
update currency_codes set html_entity = 'Pta',
 fractional_digits = '0'
 where iso = 'ESP';
update currency_codes set html_entity = '€',
 fractional_digits = '2'
 where iso = 'EUR';
update currency_codes set html_entity = 'FFr',
 fractional_digits = '2'
 where iso = 'FRF';
update currency_codes set html_entity = '£',
 fractional_digits = '2'
 where iso = 'GBP';
update currency_codes set html_entity = 'P',
 fractional_digits = '2'
 where iso = 'IEP';
update currency_codes set html_entity = 'R',
 fractional_digits = '2'
 where iso = 'INR';
update currency_codes set html_entity = 'LFr',
 fractional_digits = '2'
 where iso = 'LUF';
update currency_codes set html_entity = 'P',
 fractional_digits = '0'
 where iso = 'MXP';
update currency_codes set html_entity = '$NZ',
 fractional_digits = '2'
 where iso = 'NZD';
update currency_codes set html_entity = 'P',
 fractional_digits = '2'
 where iso = 'PHP';
update currency_codes set html_entity = '$',
 fractional_digits = '2'
 where iso = 'USD';
update currency_codes set html_entity = '€',
 fractional_digits = '2'
 where iso = 'EUR';
update currency_codes set html_entity = 'P',
 fractional_digits = '2'
 where iso = 'ARP';
update currency_codes set html_entity = 'P',
 fractional_digits = '2'
 where iso = 'CLP';
update currency_codes set html_entity = 'K',
 fractional_digits = '2'
 where iso = 'CSK';
update currency_codes set html_entity = 'IKr',
 fractional_digits = '2'
 where iso = 'ISK';
update currency_codes set html_entity = 'Bs',
 fractional_digits = '2'
 where iso = 'VEB';
update currency_codes set html_entity = 'R',
 fractional_digits = '2'
 where iso = 'ZAR';
Collapse
Posted by Malte Sussdorff on
Hi Brian, I've seen this done as well, my main question though is: Shouldn't we abandon the lc_monetary function and direct everyone using it to use ref-currencies package? I guess you are the only ones using it anyway :-).
Collapse
Posted by Torben Brosten on
Hi, Brian, could the data have come from here: http://cvs.openacs.org/cvs/openacs-4/packages/ref-currency ? ;)

Truly, lc_monetary needs be kept with the data it relies on, to prevent having to hunt down the source.

Maltes, I have wondered about moving lc_monetary also.

The locales are in acs-lang, so to be consistent, it seems lc_monetary should be moved to ref-currency

1. Moving lc_monetary keeps the data and api are together.

2. I do not see lc_monetary referenced anywhere that does not already require ref-currency, so there is no need to add any dependencies to package .info files.

3. lc_monetary is not referenced in core (after the proc and its test references in packages/acs-lang/www/admin/test/ have been moved), so ref-currency would not be required for core either.

cheers,

Torben

Collapse
Posted by Torben Brosten on
Oops, looks like I missed something. Brian, Maltes, are you referring to lc_monetary_currency using currency symbols instead of ISO 4217 codes?

If so, perhaps that should be left to acs-lang catalog entries, since most currencies do not have a unique sign: http://en.wikipedia.org/wiki/Currency_sign Or perhaps, the table should be expanded to have a currency sign associated with a locale, realizing that the "$" would have different meaning/values in different locales.

Collapse
Posted by Brian Fenton on
Hi guys,

I don't know enough about ref-currency to comment as to which is preferable, but to answer your questions:
I got the create statement here:
http://cvs.openacs.org/cvs/openacs-4/packages/acs-lang/sql/postgresql/Attic/currency.sql?rev=1.2

And when I refer to lc_monetary, I'm talking about the proc:
http://openacs.org/api-doc/proc-view?proc=lc%5fmonetary

hope this helps,
Brian

Collapse
Posted by Torben Brosten on
Looks like I started halucinating (from lack of sleep) about the time of my second post.. LOL. Anway,

lc_monetary should be moved to ref-currencies

Collapse
Posted by Torben Brosten on
ok, I see where I tweaked out.

lc_monetary_currency should be moved as well.. especially since lc_monetary is private and lc_monetary_currency is public

Collapse
Posted by Don Baccus on
Sounds like this should be done, yes.

But please do it on HEAD, not the oacs-5-3 branch ...