Chapter 9. Currency Module

9.1. Requirements

Revision for this chapter is $Revision: 1.1 $ $Date: 2003/01/05 00:00:28 $.

9.1.7. Business Object Definition

					
# currency.gcd
#                  
# Copyright (C) 2001 Free Software Foundation, Inc.
#
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 
# GNU Enterprise is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Enterprise; see the file COPYING.  If not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.
#
# This file originally written by Neil Tiffin (neilt@gnue.org).
#
# $Revision: 1.1 $ $Date: 2003/01/05 00:00:28 $ $Author: psu_gnue $
#

# ===========================================================================
# currency - 
# ===========================================================================
module currency
{
  # -------------------------------------------------------------------------
  # currency - definition of available currencies.
  # -------------------------------------------------------------------------
  class currency
  {
    char      code<8>;
    char      description<32>;
    int       default_decimals = 2;
      
    INDEX   (code);
  };


  # -------------------------------------------------------------------------
  # money - TYPE definition of money.
  # -------------------------------------------------------------------------
  type money
  {
    int64      amount = 0;        # this integer has an implied decimal point
                                  # for example if amount = 456192
    int16      num_decimals = 2;  # and num_decimals = 3
                                  # then amount really has a value of 456.192
    currency::currency *currency;
#   char       currency<8>;
#   REFERENCE  currency_reference : currency::currency( code ) = this.currency;
  
                              # select the system configured default currency
    #INITIALISE code = currency_reference(code =
    #                                       $system.default_currency_code );
                              # read the number of decimals from the selected
                              #     currency object
    #INITIALISE num_decimals = code.default_decimals;
  };


  # -------------------------------------------------------------------------
  # conversion_rule - rules for converting different currencies.
  # -------------------------------------------------------------------------
  class conversion_rule
  {
    currency::currency  *to;
    float                numerator = 1.0;   # the conversion
    float                denominator = 1.0; # factor = numerator/denominator
    date                 date_begin;
    date                 date_end;
    
  };
  
  
  # -------------------------------------------------------------------------
  # conversion - convert between different currencies.
  # -------------------------------------------------------------------------
  class conversion
  {
    currency::currency           *from;
    
    currency::conversion_rule [] rule;
    
    text convert_to( char to_currency, char from_value);
  };
  
};
 
				

9.1.8. Default Currency Definitions

					
--    
--    ISO 4217 Currency Codes
--    
--      This is a list of global
--      currencies and their three-character ISO 4217 currency code. The ISO 4217
--      currency code is usually composed of the country's two-character ISO 3166
--      country code, plus a one-character currency designator. For example, the
--      code for Australian Dollars is simply Australia's two-character ISO 3166
--      code (AU) plus a one-character currency designator (D).
--    
--    'EUR' is the official abbreviation for the Euro, as decided by the
--      Maintenance Agency for ISO 4217. The code is for use in any application of
--      trade, commerce and banking.
--
--    last source used (but not original source) to was
--    http://www.logisticsworld.com/currency.asp
--
-- This is a special file format that is converted by the
-- GEAS sql loader into valid sql
--
--    $Id: currency.html,v 1.1 2003/01/05 00:00:28 psu_gnue Exp $
--

INSERT INTO "currency__currency" (GEAS-SYS, code, description, default_decimals) VALUES
  (GEAS-SYS, 'ADP', 'Andorran Peseta',2);
  (GEAS-SYS, 'AED', 'United Arab Emirates Dirham',2);
  (GEAS-SYS, 'AFA', 'Afghanistan Afghani',2);
  (GEAS-SYS, 'ALL', 'Albanian Lek',2);
  (GEAS-SYS, 'ANG', 'Netherlands Antillian Guilder',2);
  (GEAS-SYS, 'AOK', 'Angolan Kwanza',2);
  (GEAS-SYS, 'ARA', 'Argentinian Austral',2);
  (GEAS-SYS, 'ATS', 'Austrian Schilling',2);
  (GEAS-SYS, 'AUD', 'Australian Dollar',2);
  (GEAS-SYS, 'AWG', 'Aruban Florin',2);
  (GEAS-SYS, 'BBD', 'Barbados Dollar',2);
  (GEAS-SYS, 'BDT', 'Bangladeshi Taka',2);
  (GEAS-SYS, 'BEF', 'Belgian Franc',2);
  (GEAS-SYS, 'BGL', 'Bulgarian Lev',2);
  (GEAS-SYS, 'BHD', 'Bahraini Dinar',2);
  (GEAS-SYS, 'BIF', 'Burundi Franc',2);
  (GEAS-SYS, 'BMD', 'Bermudian Dollar',2);
  (GEAS-SYS, 'BND', 'Brunei Dollar',2);
  (GEAS-SYS, 'BOB', 'Bolivian Boliviano',2);
  (GEAS-SYS, 'BRC', 'Brazilian Cruzeiro',2);
  (GEAS-SYS, 'BSD', 'Bahamian Dollar',2);
  (GEAS-SYS, 'BTN', 'Bhutan Ngultrum',2);
  (GEAS-SYS, 'BUK', 'Burma Kyat',2);
  (GEAS-SYS, 'BWP', 'Botswanian Pula',2);
  (GEAS-SYS, 'BZD', 'Belize Dollar',2);
  (GEAS-SYS, 'CAD', 'Canadian Dollar',2);
  (GEAS-SYS, 'CHF', 'Swiss Franc',2);
  (GEAS-SYS, 'CLF', 'Chilean Unidades de Fomento',2);
  (GEAS-SYS, 'CLP', 'Chilean Peso',2);
  (GEAS-SYS, 'CNY', 'Yuan (Chinese) Renminbi',2);
  (GEAS-SYS, 'COP', 'Colombian Peso',2);
  (GEAS-SYS, 'CRC', 'Costa Rican Colon',2);
  (GEAS-SYS, 'CSK', 'Czech Koruna',2);
  (GEAS-SYS, 'CUP', 'Cuban Peso',2);
  (GEAS-SYS, 'CVE', 'Cape Verde Escudo',2);
  (GEAS-SYS, 'CYP', 'Cyprus Pound',2);
  (GEAS-SYS, 'DDM', 'East German Mark',2);
  (GEAS-SYS, 'DEM', 'Deutsche Mark',2);
  (GEAS-SYS, 'DJF', 'Djibouti Franc',2);
  (GEAS-SYS, 'DKK', 'Danish Krone',2);
  (GEAS-SYS, 'DOP', 'Dominican Peso',2);
  (GEAS-SYS, 'DZD', 'Algerian Dinar',2);
  (GEAS-SYS, 'ECS', 'Ecuador Sucre',2);
  (GEAS-SYS, 'EGP', 'Egyptian Pound',2);
  (GEAS-SYS, 'ESP', 'Spanish Peseta',2);
  (GEAS-SYS, 'ETB', 'Ethiopian Birr',2);
  (GEAS-SYS, 'EUR', 'Euro',2);
  (GEAS-SYS, 'FIM', 'Finnish Markka',2);
  (GEAS-SYS, 'FJD', 'Fiji Dollar',2);
  (GEAS-SYS, 'FKP', 'Falkland Islands Pound',2);
  (GEAS-SYS, 'FRF', 'French Franc',2);
  (GEAS-SYS, 'GBP', 'British Pound',2);
  (GEAS-SYS, 'GHC', 'Ghanaian Cedi',2);
  (GEAS-SYS, 'GIP', 'Gibraltar Pound',2);
  (GEAS-SYS, 'GMD', 'Gambian Dalasi',2);
  (GEAS-SYS, 'GNF', 'Guinea Franc',2);
  (GEAS-SYS, 'GRD', 'Greek Drachma',2);
  (GEAS-SYS, 'GTQ', 'Guatemalan Quetzal',2);
  (GEAS-SYS, 'GWP', 'Guinea-Bissau Peso',2);
  (GEAS-SYS, 'GYD', 'Guyanan Dollar',2);
  (GEAS-SYS, 'HKD', 'Hong Kong Dollar',2);
  (GEAS-SYS, 'HNL', 'Honduran Lempira',2);
  (GEAS-SYS, 'HTG', 'Haitian Gourde',2);
  (GEAS-SYS, 'HUF', 'Hungarian Forint',2);
  (GEAS-SYS, 'IDR', 'Indonesian Rupiah',2);
  (GEAS-SYS, 'IEP', 'Irish Punt',2);
  (GEAS-SYS, 'ILS', 'Israeli Shekel',2);
  (GEAS-SYS, 'INR', 'Indian Rupee',2);
  (GEAS-SYS, 'IQD', 'Iraqi Dinar',2);
  (GEAS-SYS, 'IRR', 'Iranian Rial',2);
  (GEAS-SYS, 'ISK', 'Iceland Krona',2);
  (GEAS-SYS, 'ITL', 'Italian Lira',2);
  (GEAS-SYS, 'JMD', 'Jamaican Dollar',2);
  (GEAS-SYS, 'JOD', 'Jordanian Dinar',2);
  (GEAS-SYS, 'JPY', 'Japanese Yen',2);
  (GEAS-SYS, 'KES', 'Kenyan Schilling',2);
  (GEAS-SYS, 'KHR', 'Kampuchean (Cambodian) Riel',2);
  (GEAS-SYS, 'KMF', 'Comoros Franc',2);
  (GEAS-SYS, 'KPW', 'North Korean Won',2);
  (GEAS-SYS, 'KRW', '(South) Korean Won',2);
  (GEAS-SYS, 'KWD', 'Kuwaiti Dinar',2);
  (GEAS-SYS, 'KYD', 'Cayman Islands Dollar',2);
  (GEAS-SYS, 'LAK', 'Lao Kip',2);
  (GEAS-SYS, 'LBP', 'Lebanese Pound',2);
  (GEAS-SYS, 'LKR', 'Sri Lanka Rupee',2);
  (GEAS-SYS, 'LRD', 'Liberian Dollar',2);
  (GEAS-SYS, 'LSL', 'Lesotho Loti',2);
  (GEAS-SYS, 'LUF', 'Luxembourg Franc',2);
  (GEAS-SYS, 'LYD', 'Libyan Dinar',2);
  (GEAS-SYS, 'MAD', 'Moroccan Dirham',2);
  (GEAS-SYS, 'MGF', 'Malagasy Franc',2);
  (GEAS-SYS, 'MNT', 'Mongolian Tugrik',2);
  (GEAS-SYS, 'MOP', 'Macau Pataca',2);
  (GEAS-SYS, 'MRO', 'Mauritanian Ouguiya',2);
  (GEAS-SYS, 'MTL', 'Maltese Lira',2);
  (GEAS-SYS, 'MUR', 'Mauritius Rupee',2);
  (GEAS-SYS, 'MVR', 'Maldive Rufiyaa',2);
  (GEAS-SYS, 'MWK', 'Malawi Kwacha',2);
  (GEAS-SYS, 'MXP', 'Mexican Peso',2);
  (GEAS-SYS, 'MYR', 'Malaysian Ringgit',2);
  (GEAS-SYS, 'MZM', 'Mozambique Metical',2);
  (GEAS-SYS, 'NGN', 'Nigerian Naira',2);
  (GEAS-SYS, 'NIC', 'Nicaraguan Cordoba',2);
  (GEAS-SYS, 'NLG', 'Dutch Guilder',2);
  (GEAS-SYS, 'NOK', 'Norwegian Kroner',2);
  (GEAS-SYS, 'NPR', 'Nepalese Rupee',2);
  (GEAS-SYS, 'NZD', 'New Zealand Dollar',2);
  (GEAS-SYS, 'OMR', 'Omani Rial',2);
  (GEAS-SYS, 'PAB', 'Panamanian Balboa',2);
  (GEAS-SYS, 'PEI', 'Peruvian Inti',2);
  (GEAS-SYS, 'PGK', 'Papua New Guinea Kina',2);
  (GEAS-SYS, 'PHP', 'Philippine Peso',2);
  (GEAS-SYS, 'PKR', 'Pakistan Rupee',2);
  (GEAS-SYS, 'PLZ', 'Polish Zloty',2);
  (GEAS-SYS, 'PTE', 'Portuguese Escudo',2);
  (GEAS-SYS, 'PYG', 'Paraguay Guarani',2);
  (GEAS-SYS, 'QAR', 'Qatari Rial',2);
  (GEAS-SYS, 'ROL', 'Romanian Leu',2);
  (GEAS-SYS, 'RWF', 'Rwanda Franc',2);
  (GEAS-SYS, 'SAR', 'Saudi Arabian Riyal',2);
  (GEAS-SYS, 'SBD', 'Solomon Islands Dollar',2);
  (GEAS-SYS, 'SCR', 'Seychelles Rupee',2);
  (GEAS-SYS, 'SDP', 'Sudanese Pound',2);
  (GEAS-SYS, 'SEK', 'Swedish Krona',2);
  (GEAS-SYS, 'SGD', 'Singapore Dollar',2);
  (GEAS-SYS, 'SHP', 'St. Helena Pound',2);
  (GEAS-SYS, 'SLL', 'Sierra Leone Leone',2);
  (GEAS-SYS, 'SOS', 'Somali Schilling',2);
  (GEAS-SYS, 'SRG', 'Suriname Guilder',2);
  (GEAS-SYS, 'STD', 'Sao Tome and Principe Dobra',2);
  (GEAS-SYS, 'RUR', 'Russian Ruble',2);
  (GEAS-SYS, 'RUB', 'Russian Ruble',2);
  (GEAS-SYS, 'SVC', 'El Salvador Colon',2);
  (GEAS-SYS, 'SYP', 'Syrian Potmd',2);
  (GEAS-SYS, 'SZL', 'Swaziland Lilangeni',2);
  (GEAS-SYS, 'THB', 'Thai Bhat',2);
  (GEAS-SYS, 'TND', 'Tunisian Dinar',2);
  (GEAS-SYS, 'TOP', 'Tongan Paanga',2);
  (GEAS-SYS, 'TPE', 'East Timor Escudo',2);
  (GEAS-SYS, 'TRL', 'Turkish Lira',2);
  (GEAS-SYS, 'TTD', 'Trinidad and Tobago Dollar',2);
  (GEAS-SYS, 'TWD', 'Taiwan Dollar',2);
  (GEAS-SYS, 'TZS', 'Tanzanian Schilling',2);
  (GEAS-SYS, 'UAH', 'Ukranian Hrivnya',2);
  (GEAS-SYS, 'UGS', 'Uganda Shilling',2);
  (GEAS-SYS, 'USD', 'US Dollar',2);
  (GEAS-SYS, 'UYP', 'Uruguayan Peso',2);
  (GEAS-SYS, 'VEB', 'Venezualan Bolivar',2);
  (GEAS-SYS, 'VND', 'Vietnamese Dong',2);
  (GEAS-SYS, 'VUV', 'Vanuatu Vatu',2);
  (GEAS-SYS, 'WST', 'Samoan Tala',2);
  (GEAS-SYS, 'YDD', 'Democratic Yemeni Dinar',2);
  (GEAS-SYS, 'YER', 'Yemeni Rial',2);
  (GEAS-SYS, 'YUD', 'New Yugoslavia Dinar',2);
  (GEAS-SYS, 'ZAR', 'South African Rand',2);
  (GEAS-SYS, 'ZMK', 'Zambian Kwacha',2);
  (GEAS-SYS, 'ZRZ', 'Zaire Zaire',2);
  (GEAS-SYS, 'ZWD', 'Zimbabwe Dollar',2);