Skip to content

Add Money Support #3

@clphillips

Description

@clphillips

Represent all pricing values as Money from Blesta\Money.

Example usage:

$fiveDollars = new Money(500, new Currency('USD'));
$fiveDollars = Money::fromString('5.00', 'USD'); // or this
$fiveDollars = Money::fromString('5.00', new Currency('USD')); // or this

$price = new UnitPrice($fiveDollars, 2);
$price-->setDescription('2 x 5.00');
$unit_price = $price->price(); // Money
$qty = $price->qty(); // 2
$tenDollars = $price->total(); // Money

$tenDollars->getConvertedAmount(); // 10.00
echo $tenDollars; // 10.00

Any value that supports float should support Money, and convert to Money internally if provided with float. Should use the XXX currency code (which denotes no currency), where the precision is out to 4 decimal places. For example:

$price = new UnitPrice(5.00, 2);
$price->price(); // Money 5.0000 XXX
$price->total(); // Money 10.0000 XXX

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions