This commit is contained in:
Thomas Peterson 2025-07-17 12:40:09 +02:00
parent 6f0c56b734
commit 8ca48ca174
12 changed files with 5383 additions and 1625 deletions

File diff suppressed because it is too large Load Diff

View File

@ -172,6 +172,11 @@ class Calc
name: $option->getId() . '_' . $collection->getName(),
unParsed: $edge->getCalcValue(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $calcValueId,
unParsed: $edge->getCalcValue(),
));
} catch (\Throwable $e) {
$cv = 0;
}

View File

@ -151,6 +151,11 @@ class CalcValues
name: $id . '_' . $collection->getName(),
unParsed: $edge->getCalcValue(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id,
unParsed: $edge->getCalcValue(),
));
}
if ($edge->getCalcValue1() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue1());
@ -179,6 +184,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_1',
unParsed: $edge->getCalcValue1(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_1',
unParsed: $edge->getCalcValue1(),
));
}
if ($edge->getCalcValue2() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue2());
@ -207,6 +217,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_2',
unParsed: $edge->getCalcValue2(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_2',
unParsed: $edge->getCalcValue2(),
));
}
if ($edge->getCalcValue3() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue3());
@ -235,6 +250,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_3',
unParsed: $edge->getCalcValue3(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_3',
unParsed: $edge->getCalcValue3(),
));
}
if ($edge->getCalcValue4() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue4());
@ -263,6 +283,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_4',
unParsed: $edge->getCalcValue4(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_4',
unParsed: $edge->getCalcValue4(),
));
}
if ($edge->getCalcValue5() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue5());
@ -291,6 +316,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_5',
unParsed: $edge->getCalcValue5(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_5',
unParsed: $edge->getCalcValue5(),
));
}
if ($edge->getCalcValue6() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue6());
@ -319,6 +349,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_6',
unParsed: $edge->getCalcValue6(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_6',
unParsed: $edge->getCalcValue6(),
));
}
if ($edge->getCalcValue7() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue7());
@ -347,6 +382,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_7',
unParsed: $edge->getCalcValue7(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_7',
unParsed: $edge->getCalcValue7(),
));
}
if ($edge->getCalcValue8() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue8());
@ -375,6 +415,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_8',
unParsed: $edge->getCalcValue8(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_8',
unParsed: $edge->getCalcValue8(),
));
}
if ($edge->getCalcValue9() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue9());
@ -403,6 +448,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_9',
unParsed: $edge->getCalcValue9(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_9',
unParsed: $edge->getCalcValue9(),
));
}
if ($edge->getCalcValue10() != '') {
$cv = $this->formelCalc->parse($edge->getCalcValue10());
@ -431,6 +481,11 @@ class CalcValues
name: $id . '_' . $collection->getName() . '_10',
unParsed: $edge->getCalcValue10(),
));
$this->engine->getCalcGraph()->addPart(new Part(
type: PartType::CalcValue,
name: $id . '_10',
unParsed: $edge->getCalcValue10(),
));
}
if ($edge->getEdgesCollectionContainer()->count() > 0) {
$this->parseEdgeCollection(

View File

@ -325,18 +325,20 @@ class Engine
}
foreach ($this->calcVariables as $key => $variable) {
if (is_array($variable)) {
$this->calcGraph->addPart(new Part(
type: PartType::CalcValue,
name: $key,
unParsed: implode(',', $variable),
));
} elseif ($variable != null) {
$this->calcGraph->addPart(new Part(
type: PartType::CalcValue,
name: $key,
unParsed: $variable,
));
if (!$this->calcGraph->hasPart('$CV' . $key . '$CV')) {
if (is_array($variable)) {
$this->calcGraph->addPart(new Part(
type: PartType::CalcValue,
name: $key,
unParsed: implode(',', $variable),
));
} elseif ($variable != null) {
$this->calcGraph->addPart(new Part(
type: PartType::CalcValue,
name: $key,
unParsed: $variable,
));
}
}
}

View File

@ -34,6 +34,11 @@ class Graph
$this->parser->addPart($part);
}
public function hasPart(string $key): bool
{
return $this->parser->hasPart($key);
}
private function build(): bool
{
$this->parser->parseInternals();

View File

@ -79,7 +79,7 @@ class Parser
$this->internalParts->addPart(new Part(
type: PartType::Parameter,
name: $node->var->name,
unParsed: $node->expr->value ?? '',
unParsed: $this->prettyPrinter->prettyPrintExpr($node->expr),
));
}
}
@ -218,4 +218,9 @@ class Parser
{
$this->internalParts->addPart($part);
}
public function hasPart(string $key): bool
{
return $this->internalParts->hasPart($key);
}
}

View File

@ -22,4 +22,9 @@ class PartCollection
{
return $this->data;
}
public function hasPart(string $key): bool
{
return isset($this->data[$key]);
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
<?php
namespace PSC\Library\Calc\Tests\Customer\Z;
use PHPUnit\Framework\TestCase;
@ -9,7 +10,6 @@ use PSC\Library\Calc\Tests\Mock\PaperRepostory;
class CalcTest extends TestCase
{
/** @var Engine */
protected $engine = null;
@ -28,7 +28,6 @@ class CalcTest extends TestCase
$this->engine->setTemplates(file_get_contents(__DIR__ . '/calcTemplates.xml'));
$this->engine->loadString(file_get_contents(__DIR__ . '/calc.xml'));
}
public function tearDown(): void
@ -48,5 +47,4 @@ class CalcTest extends TestCase
$this->engine->calc();
self::assertSame(199.6, $this->engine->getPrice());
}
}

File diff suppressed because it is too large Load Diff

View File

@ -179,8 +179,8 @@ $BerNutzen_meP_v1='((floor((($CVoformat_pg1_3$CV)-$CVkalkparameterprodukt_nopres
//$BerNutzenU_meP_v2='((floor((($CVoformatU_pg1_3$CV)-$CVkalkparameterprodukt_nopresentationpdf_pg1$CV)/($CVoformatU_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV) ) *floor((($CVoformatU_pg1_4$CV)-$CVkalkparameterprodukt_nopresentationpdf_pg1$CV)/($CVoformatU_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))) , (floor((($CVoformatU_pg1_4$CV)-$CVkalkparameterprodukt_nopresentationpdf_pg1$CV)/($CVoformatU_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV)) *floor((($CVoformatU_pg1_3$CV)-$CVkalkparameterprodukt_nopresentationpdf_pg1$CV)/($CVoformatU_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))))';
//$BerNutzen_meP_v2='((floor((($CVoformat_pg1_3$CV)-$CVkalkparameterprodukt_nopresentationpdf_pg1$CV)/($CVoformat_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV) ) *floor((($CVoformat_pg1_4$CV)-$CVkalkparameterprodukt_nopresentationpdf_pg1$CV)/($CVoformat_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))) , (floor((($CVoformat_pg1_4$CV)-$CVkalkparameterprodukt_nopresentationpdf_pg1$CV)/($CVoformat_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV)) *floor((($CVoformat_pg1_3$CV)-$CVkalkparameterprodukt_nopresentationpdf_pg1$CV)/($CVoformat_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))))';
$BerNutzen_meP_v2='((floor((($CVoformat_pg1_3$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_2$CV) ) / ($CVoformat_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))*floor((($CVoformat_pg1_4$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_3$CV)) / ($CVoformat_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))),(floor((($CVoformat_pg1_4$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_3$CV)) / ($CVoformat_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))*floor((($CVoformat_pg1_3$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_2$CV)) / ($CVoformat_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))))';
$BerNutzenU_meP_v2='((floor((($CVoformatU_pg1_3$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_2$CV) ) / ($CVoformatU_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_4$CV)) * floor((($CVoformatU_pg1_4$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_3$CV)) / ($CVoformatU_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_4$CV))),(floor((($CVoformatU_pg1_4$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_3$CV)) / ($CVoformatU_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_4$CV))*floor((($CVoformatU_pg1_3$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_2$CV)) / ($CVoformatU_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_4$CV))))';
$BerNutzen_meP_v2='max((floor((($CVoformat_pg1_3$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_2$CV) ) / ($CVoformat_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))*floor((($CVoformat_pg1_4$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_3$CV)) / ($CVoformat_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))),(floor((($CVoformat_pg1_4$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_3$CV)) / ($CVoformat_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))*floor((($CVoformat_pg1_3$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_2$CV)) / ($CVoformat_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_4$CV))))';
$BerNutzenU_meP_v2='max((floor((($CVoformatU_pg1_3$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_2$CV) ) / ($CVoformatU_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_4$CV)) * floor((($CVoformatU_pg1_4$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_3$CV)) / ($CVoformatU_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_4$CV))),(floor((($CVoformatU_pg1_4$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_3$CV)) / ($CVoformatU_pg1$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_4$CV))*floor((($CVoformatU_pg1_3$CV)-($CVkalkparameterprodukt_nopresentationpdf_pg2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_2$CV)) / ($CVoformatU_pg1_2$CV+$CVkalkparameterprodukt_nopresentationpdf_pg2_4$CV))))';
// #### Auflage mit Druckbogenzugabe (ohne Versionen) ####
$AuflageU_mDbZ_v2='($Vauflage$V*$CVseitenU_pg1$CV*$CVkalkparameterprodukt_nopresentationpdf_pg1_9$CV+$CVkalkparameterprodukt_nopresentationpdf_pg1_10$CV)';

File diff suppressed because one or more lines are too long