From 7201f0647631b0b6c903831aabc77f1e05032094 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 18 May 2012 13:28:57 +1200 Subject: [PATCH] API CHANGE: Added new config option Money.default_currency. --- model/fieldtypes/Money.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/model/fieldtypes/Money.php b/model/fieldtypes/Money.php index 963608b6a..ab81f7e0e 100644 --- a/model/fieldtypes/Money.php +++ b/model/fieldtypes/Money.php @@ -106,9 +106,11 @@ class Money extends DBField implements CompositeDBField { $this->setCurrency($value->getCurrency(), $markChanged); $this->setAmount($value->getAmount(), $markChanged); if($markChanged) $this->isChanged = true; - } else if($record && isset($record[$this->name . 'Currency']) && isset($record[$this->name . 'Amount'])) { - if($record[$this->name . 'Currency'] && $record[$this->name . 'Amount']) { - $this->setCurrency($record[$this->name . 'Currency'], $markChanged); + } else if($record && isset($record[$this->name . 'Amount'])) { + if($record[$this->name . 'Amount']) { + if(!empty($record[$this->name . 'Currency'])) $this->setCurrency($record[$this->name . 'Currency'], $markChanged); + else if($currency = (string)$this->config()->get('default_currency')) $this->setCurrency($currency, $markChanged); + $this->setAmount($record[$this->name . 'Amount'], $markChanged); } else { $this->value = $this->nullValue();