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 Nice($decimalSize = false) {
18 if (!$decimalSize)
19 $decimalSize = (SiteConfig::current_site_config()->CatalogDiscountCeil) ? 0 : 2;
20 return parent::Nice($decimalSize);
21 }
22
23 function Whole() {
24 return $this->Int();
25 }
26
27 function requireField() {
28 $parts=Array('datatype'=>'decimal', 'precision'=>"$this->wholeSize,2", 'default'=>sprintf("%.2f", $this->defaultValue), 'arrayValue'=>$this->arrayValue);
29 $values=Array('type'=>'decimal', 'parts'=>$parts);
30 DB::requireField($this->tableName, $this->name, $values);
31 }
32 }
33
34
[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.
-