/** * Convert a numeric price to the shop currency * @param mixed $price the price to convert * @return Money the price wrapped in a Money DBField to be used for templates or similar */ public static function price_for_display($price) { $currency = ShopConfig::get_site_currency(); $field = Money::create("Price"); $field->setAmount($price); $field->setCurrency($currency); return $field; }
public function isPositive() { return $this->greaterThan(Money::create(0)); }
/** * returns the symbol for a currency, e.g. $ * @param String $currency * * @return String */ public static function get_default_symbol($currency) { $money = Money::create(); return $money->getSymbol($currency); }
/** * @inheritdoc */ public function toCurrency(MoneyInterface $money, CurrencyInterface $currencyTo, \DateTime $date = null) { $currencyFrom = $money->getCurrency(); if ($currencyFrom->equals($currencyTo)) { return $money; } $rate = $this->currencyService->getRate($currencyFrom, $currencyTo, $date); return Money::create($this->div($money, $rate)->getAmount(), $currencyTo); }