- Publicity: Public Only All
currency-procs.tcl
Currency widgets for the OpenACS Templating System
- Location:
- packages/acs-templating/tcl/currency-procs.tcl
- Author:
- Don Baccus <dhogaza@pacifier.com>
Procedures in this file
- template::data::transform::currency (private)
- template::data::validate::currency (public)
- template::util::currency (public)
- template::util::currency::acquire (public)
- template::util::currency::create (public)
- template::util::currency::get_property (public)
- template::util::currency::set_property (public)
- template::widget::currency (public)
Detailed information
template::data::transform::currency (private)
template::data::transform::currency element_ref
Transform the previously-validated submitted form data into a six-element currency list
- Parameters:
- element_ref (required)
- Reference variable to the form element
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
template::data::validate::currency (public)
template::data::validate::currency value_ref message_ref
form validation for currency type. Should validate according to locale for example, the following forms: "$2.03" "Rs 50.42" "12.52L" "Y5,13c"
- Parameters:
- value_ref (required)
- Reference variable to the submitted value
- message_ref (required)
- Reference variable for returning error messages
- Returns:
- true (1) if valid, false (0) if not
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- validate_currency
template::util::currency (public)
template::util::currency command [ args... ]
Dispatch procedure for the currency object
- Parameters:
- command (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
template::util::currency::acquire (public)
template::util::currency::acquire type [ value ]
Create a new currency value with some predefined value Basically, create and set the currency value
- Parameters:
- type (required)
- The set_property type to set (only sql_number supported currently)
- value (optional)
- Returns:
- The new currency value set to the predefined value
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
template::util::currency::create (public)
template::util::currency::create [ leading_symbol ] [ whole_part ] \ [ separator ] [ fractional_part ] [ trailing_money ] [ format ]
Create a currency form element.
- Parameters:
- leading_symbol (optional)
- The leading symbol for the currency format (default: "$")
- whole_part (optional)
- The number of digits in the whole part of the value (default: 5)
- separator (optional)
- The character the separates the whole part from the fractional part (default ".")
- fractional_part (optional)
- The number of digits allowed in the fractional part of the value (default: 2, i.e. US Pennies)
- trailing_money (optional)
- For those currencies that use a trailing rather than leading character in their normal representation
- format (optional, defaults to
"$ 5 . 2"
)- The actual format to use in list form
- Returns:
- The parameters joined in a six-element list
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
template::util::currency::get_property (public)
template::util::currency::get_property what currency_list
Return a property of a currency list which was created by a currency widget. The most useful properties that can be returned are sql_number (compatible with SQL's NUMERIC type, historically called NUMBER by Oracle) and display_currency, which takes the value and formats properly.
- Parameters:
- what (required)
- The name of the property (see code for allowed values)
- currency_list (required)
- a currency widget list, usually created with ad_form
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
template::util::currency::set_property (public)
template::util::currency::set_property what currency_list value
Set a currency value to a set value, with that value being of "what" form. Currently the only "what" supported is sql_number, it being assumed (somewhat reasonably) that SQL's NUMERIC datatype will be used to store currency data in the database, regardless of locale.
- Parameters:
- what (required)
- What kind of value is being passed in (sql_number is the only format supported)
- currency_list (required)
- A currency data type value
- value (required)
- The value to set currency_list to
- Returns:
- currency_list set to value
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
template::widget::currency (public)
template::widget::currency element_reference tag_attributes [ mode ]
Render a currency widget. By default, the currency widget takes the form $ddddd.dd, i.e. US dollars and cents. You can optionally pass along a format for different currency.
- Parameters:
- element_reference (required)
- Reference variable to the form element
- tag_attributes (required)
- HTML attributes to add to the tag
- mode (optional, defaults to
"edit"
)- If edit, the rendered widget allows input, otherwise the values are passed along as hidden input HTML tags
- Returns:
- Form HTML for widget
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.