NAME

Podius::Property::CurrencyAmount - component property representing units in certain currency


SYNOPSIS

  $property = new Podius::Property::CurrencyAmount;

Supposed to be used in the Podius::Component manpage and the Podius::Property manpage module trees only.


DESCRIPTION

This module implements component property allowing easy representation of price or cost in certain currency. The currency is usually taken from another property of the same or relative component (but it may be more flexible than this). The exact way to access the currency should be defined for this property.

This property derives from Number and has all its features. Additionally, there is an option to convert the current value to another currency (if possible) and make other currency manipulations.

Only the methods different from the Podius::Property::Scalar manpage are described here.


REQUIREMENTS

the Podius::Property::Number manpage, the Podius::Property::Currency manpage.


CONSTRUCTORS

new

description
Class constructor.

parameters
  * class name
  * initial value (may be undef or 0)
  * currency property name of the same owner component, or subroutine
    (taking owner component as param and returning Currency property)
returns
New formed property reference.


METHODS

get_currency_property

description
Returns the currency property assigned to this property in its constructor. Note that if the currency property assigned using code ref, then it is called every time this method is called.

returns
Property of type Currency.

access_currency

description
Gets or sets assigned currency code (see get_currency_property method).

Also see the Podius::Property::Currency manpage, access method.

parameters
  * optional new currency code (only sane for static properties)
returns
Currency code (consisting of 3 english letters).

access_currency_sign

description
Only accessor form is available.

Returns the assigned currenct sign, like ``$'' or euro-sign. Usually this is one unicode chars or abbreviature.

Also see the Podius::Property::Currency manpage, access_sign method.

returns
String (in utf-8).

access_currency_label

description
Only accessor form is available.

Returns the assigned currenct label, like ``US Dollar'' or ``Euro''. This label may contain unicode chars for certain currencies.

Also see the Podius::Property::Currency manpage, access_label method.

returns
String (in utf-8).

access_in_currency

description
Only accessor form is available.

Returns the amount converted to another currency. By default the precision is currency-dependent (usually 2 for most of the world currencies, but may be 0 or 3).

It is possible to make adjustment to the managed amount (relative or absolute, or even replace it) by passing the corresponding parameter, pass any false value to disable adjustment.

Also see the Podius::Property::Currency manpage, convert_amount_to_currency method.

parameters
  * other currency (property or code)
  * adjustment (+X, -X, +X%, -X%, X, or undef/"" to disable)
  * precision (0..8, or 9 - as-is, or undef/"" for actual sub-units)
returns
Converted amount (number).


ALIASES

access_currency_code
An alias to access_currency method.