Add Debug Vars

This commit is contained in:
Thomas Peterson 2022-05-19 20:27:01 +02:00
parent 5bb9f562f3
commit 987a2cd5a9
3 changed files with 40 additions and 2 deletions

View File

@ -106,16 +106,20 @@ class Calc
if($edge->getPauschale() != 0) {
eval('$gesamt += ' . $edge->getPauschale() . ';');
$this->engine->addDebugFlatPrice($collection->getName(), $edge->getPauschale());
}
if($edge->getPreis() != 0) {
eval('$gesamt += ' . ($edge->getPreis()*$var) . ';');
$this->engine->addDebugPrice($collection->getName(), $edge->getPreis(), $var, $edge->getPreis()*$var);
}
if($edge->getCalcValue() != "") {
$cv = $this->formelCalc->parse($edge->getCalcValue());
$orgCv = $cv;
try {
eval('@$cv = ' . $cv . ';');
$this->engine->addDebugCalcVariables($option->getId() . '_' . $collection->getName(), $edge->getCalcValue(), $orgCv . ' = ' . $cv);
}catch (\Throwable $e) {
$cv = 0;
}

View File

@ -115,11 +115,12 @@ class CalcValues
if ($edge->getCalcValue() != "") {
$cv = $this->formelCalc->parse($edge->getCalcValue());
$orgCv = $cv;
try {
eval('@$cv = ' . $cv . ';');
$this->engine->addDebugCalcVariables($id, $edge->getCalcValue(), $cv . ' = ' . $cv);
$this->engine->addDebugCalcVariables($id, $edge->getCalcValue(), $orgCv . ' = ' . $cv);
}catch (\Throwable $e) {
$this->engine->addDebugCalcVariables($id, $edge->getCalcValue(), $cv . ' = ERROR');
$this->engine->addDebugCalcVariables($id, $edge->getCalcValue(), $orgCv . ' = ERROR');
$cv = 0;
}

View File

@ -50,6 +50,9 @@ class Engine
/** @var array */
protected $debugCalcVariables = array();
protected $debugFlatPrice = array();
protected $debugPrice = array();
/** @var float */
protected $price = 0;
@ -351,6 +354,36 @@ class Engine
{
return $this->debugCalcFormel;
}
public function addDebugFlatPrice($key, $flatPrice)
{
if(!isset($this->debugFlatPrice[$key])) {
$this->debugFlatPrice[$key] = array();
}
$this->debugFlatPrice[$key][] = $flatPrice;
}
public function getDebugFlatPrice()
{
return $this->debugFlatPrice;
}
public function addDebugPrice($key, $price, $multiplicator, $result)
{
if(!isset($this->debugPrice[$key])) {
$this->debugPrice[$key] = array();
}
$this->debugPrice[$key][] = [
'price' => $price,
'multiplicator' => $multiplicator,
'result' => $result
];
}
public function getDebugPrice()
{
return $this->debugPrice;
}
/**
* @return array
*/