From 4d55f1e5d79e666eb2d2b9fafbe2022c45f00c34 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 25 May 2009 06:03:06 +0000 Subject: [PATCH] BUGFIX Fixed Money->Nice() to provide symbol and currency shortname based on Money->getCurrency() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77754 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/fieldtypes/Money.php | 3 +++ tests/model/MoneyTest.php | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/model/fieldtypes/Money.php b/core/model/fieldtypes/Money.php index ce954b052..1097985c1 100644 --- a/core/model/fieldtypes/Money.php +++ b/core/model/fieldtypes/Money.php @@ -131,6 +131,9 @@ class Money extends DBField implements CompositeDBField { */ function Nice($options = array()) { $amount = $this->getAmount(); + if(!isset($options['display'])) $options['display'] = Zend_Currency::USE_SYMBOL; + if(!isset($options['currency'])) $options['currency'] = $this->getCurrency(); + if(!isset($options['symbol'])) $options['symbol'] = $this->currencyLib->getSymbol($this->getCurrency(), $this->getLocale()); return (is_numeric($amount)) ? $this->currencyLib->toCurrency($amount, $options) : ''; } diff --git a/tests/model/MoneyTest.php b/tests/model/MoneyTest.php index e2d87c9e0..bd64cefa4 100644 --- a/tests/model/MoneyTest.php +++ b/tests/model/MoneyTest.php @@ -117,7 +117,6 @@ class MoneyTest extends SapphireTest { } */ - /* $INR = new Money(); $INR->setLocale('de_AT'); $INR->setCurrency('INR'); @@ -129,7 +128,6 @@ class MoneyTest extends SapphireTest { $this->assertSame('Rs. 0,00', $INR->Nice()); $INR->setAmount(-3); $this->assertSame('-Rs. 3,00', $INR->Nice()); - */ } public function testGetSign() {