1 <?php
2 3 4 5 6
7 class CatalogPrice extends Decimal {
8
9 public static function getCurrency() {
10 return SiteConfig::current_site_config()->CatalogCurrency;
11 }
12
13 function __construct($name, $defaultValue = 0) {
14 parent::__construct($name, 12, 2, $defaultValue);
15 }
16
17 function getValue() {
18 $decimalSize = (SiteConfig::current_site_config()->CatalogDiscountCeil) ? 0 : 2;
19 return round($this->value, $decimalSize);
20 }
21
22 function Nice($decimalSize = false) {
23 if (!$decimalSize)
24 $decimalSize = (SiteConfig::current_site_config()->CatalogDiscountCeil) ? 0 : 2;
25 return parent::Nice($decimalSize);
26 }
27
28 function Whole() {
29 return $this->Int();
30 }
31
32 function requireField() {
33 $parts=Array('datatype'=>'decimal', 'precision'=>"$this->wholeSize,2", 'default'=>sprintf("%.2f", $this->defaultValue), 'arrayValue'=>$this->arrayValue);
34 $values=Array('type'=>'decimal', 'parts'=>$parts);
35 DB::requireField($this->tableName, $this->name, $values);
36 }
37 }
38
39
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-