Skip to content
Snippets Groups Projects
Commit 7a18a3a2 authored by jaapjansma's avatar jaapjansma
Browse files

added bounded calculation

parent a37f314e
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,11 @@ class BoundedAggregateFunctionFieldOutputHandler extends AggregateFunctionFieldO
*/
protected $maxValue = 0.00;
/**
* @var float
*/
protected $multiplier = 1;
/**
* Initialize the processor
*
......@@ -60,6 +65,9 @@ class BoundedAggregateFunctionFieldOutputHandler extends AggregateFunctionFieldO
$this->maxBound = (float) $configuration['max_bound'];
$this->maxValue = (float) $configuration['max_value'];
}
if (!empty($configuration['multiplier']) && $configuration['multiplier'] != '1') {
$this->multiplier = (float) $configuration['multiplier'];
}
}
/**
......@@ -72,9 +80,13 @@ class BoundedAggregateFunctionFieldOutputHandler extends AggregateFunctionFieldO
*/
public function formatField($rawRecord, $formattedRecord) {
$value = (float) $rawRecord[$this->aggregateField->alias];
if ($this->minBound !== null && $value < $this->minBound) {
$pureValue = $value;
if ($this->multiplier > 0) {
$pureValue = $pureValue / $this->multiplier;
}
if ($this->minBound !== null && $pureValue < $this->minBound) {
$value = $this->minValue;
} elseif ($this->maxBound !== null && $value > $this->maxBound) {
} elseif ($this->maxBound !== null && $pureValue > $this->maxBound) {
$value = $this->maxValue;
} elseif ($this->roundToNearestWholeNumber) {
$value = $this->roundUpToNearest($value, $this->roundToNearestWholeNumber);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment