This commit is contained in:
Thomas Peterson 2018-04-17 10:29:29 +02:00
parent dceccfbd59
commit 0b25641c35
2 changed files with 32 additions and 0 deletions

View File

@ -37,6 +37,9 @@ class Engine
/** @var float */
protected $price = 0;
/** @var float */
protected $tax = 0;
/** @var bool */
protected $dirty = true;
@ -224,6 +227,17 @@ class Engine
return round($this->price,2);
}
/**
* @return mixed
*/
public function getTaxPrice()
{
if($this->dirty) {
$this->calc();
}
return round($this->price+($this->price/100*$this->tax),2);
}
/**
* @param mixed $price
*/
@ -253,4 +267,20 @@ class Engine
$this->variables[$var] = $value;
}
/**
* @return float
*/
public function getTax()
{
return $this->tax;
}
/**
* @param float $tax
*/
public function setTax($tax)
{
$this->tax = $tax;
}
}

View File

@ -33,6 +33,8 @@ class PriceMinTest extends \PHPUnit_Framework_TestCase
$this->engine->calc();
$this->assertEquals(2500, $this->engine->getPrice());
$this->engine->setTax(19);
$this->assertEquals(2975, $this->engine->getTaxPrice());
}
public function testIfCalcReturnsGrenzeWithFormular()