Staffelpreise
This commit is contained in:
parent
755cd972e1
commit
e6cfad0446
11438
cobertura.xml
11438
cobertura.xml
File diff suppressed because it is too large
Load Diff
@ -69,8 +69,8 @@ class Calc
|
|||||||
if ($option->getStaffelCalc() !== null) {
|
if ($option->getStaffelCalc() !== null) {
|
||||||
$formel = $this->formelCalc->parse($option->getStaffelCalc());
|
$formel = $this->formelCalc->parse($option->getStaffelCalc());
|
||||||
eval('$staffelCalcResult = ' . $formel . ';');
|
eval('$staffelCalcResult = ' . $formel . ';');
|
||||||
var_dump($staffelCalcResult);
|
|
||||||
$option->setStaffelCalcResult($staffelCalcResult);
|
$option->setStaffelCalcResult($staffelCalcResult);
|
||||||
|
$this->engine->setVariables($option->parseAdditionalValues($this->engine->getVariables()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($option->getSelectedOptions() as $opt) {
|
foreach ($option->getSelectedOptions() as $opt) {
|
||||||
|
|||||||
@ -220,23 +220,21 @@ class PaperDbSelect extends Select
|
|||||||
|
|
||||||
private function getStaffelValue($paper): ?float
|
private function getStaffelValue($paper): ?float
|
||||||
{
|
{
|
||||||
var_dump(1);
|
if ($this->getStaffelCalcResult() >= $paper->getStaffelMenge5()) {
|
||||||
if ($this->getStaffelCalcResult() < $paper->getStaffelMenge1()) {
|
|
||||||
return (float) $paper->getStaffelPreis1();
|
|
||||||
}
|
|
||||||
if ($this->getStaffelCalcResult() < $paper->getStaffelMenge2()) {
|
|
||||||
return (float) $paper->getStaffelPreis2();
|
|
||||||
}
|
|
||||||
if ($this->getStaffelCalcResult() < $paper->getStaffelMenge3()) {
|
|
||||||
return (float) $paper->getStaffelPreis3();
|
|
||||||
}
|
|
||||||
if ($this->getStaffelCalcResult() < $paper->getStaffelMenge4()) {
|
|
||||||
return (float) $paper->getStaffelPreis4();
|
|
||||||
}
|
|
||||||
if ($this->getStaffelCalcResult() < $paper->getStaffelMenge5()) {
|
|
||||||
return (float) $paper->getStaffelPreis5();
|
return (float) $paper->getStaffelPreis5();
|
||||||
}
|
}
|
||||||
|
if ($this->getStaffelCalcResult() >= $paper->getStaffelMenge4()) {
|
||||||
|
return (float) $paper->getStaffelPreis4();
|
||||||
|
}
|
||||||
|
if ($this->getStaffelCalcResult() >= $paper->getStaffelMenge3()) {
|
||||||
|
return (float) $paper->getStaffelPreis3();
|
||||||
|
}
|
||||||
|
if ($this->getStaffelCalcResult() >= $paper->getStaffelMenge2()) {
|
||||||
|
return (float) $paper->getStaffelPreis2();
|
||||||
|
}
|
||||||
|
if ($this->getStaffelCalcResult() >= $paper->getStaffelMenge1()) {
|
||||||
|
return (float) $paper->getStaffelPreis1();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,24 @@ class CalcTest extends TestCase
|
|||||||
public function testNormalPrice(): void
|
public function testNormalPrice(): void
|
||||||
{
|
{
|
||||||
$this->engine->calc();
|
$this->engine->calc();
|
||||||
$this->assertSame(5.00, $this->engine->getPrice());
|
$this->assertSame(25.00, $this->engine->getPrice());
|
||||||
|
$this->engine->getCalcGraph()->generateJsonGraph();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testStaffel2Price(): void
|
||||||
|
{
|
||||||
|
$this->engine->setVariable('papier', 'staffel2');
|
||||||
|
$this->engine->calc();
|
||||||
|
$this->assertSame(207.00, $this->engine->getPrice());
|
||||||
|
$this->engine->getCalcGraph()->generateJsonGraph();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testStaffel2_1Price(): void
|
||||||
|
{
|
||||||
|
$this->engine->setVariable('papier', 'staffel2');
|
||||||
|
$this->engine->setVariable('auflage', '45');
|
||||||
|
$this->engine->calc();
|
||||||
|
$this->assertSame(407.00, $this->engine->getPrice());
|
||||||
$this->engine->getCalcGraph()->generateJsonGraph();
|
$this->engine->getCalcGraph()->generateJsonGraph();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user