diff --git a/src/Calc/Calc.php b/src/Calc/Calc.php index f1ee69d..fe7e907 100644 --- a/src/Calc/Calc.php +++ b/src/Calc/Calc.php @@ -12,7 +12,11 @@ use PSC\Library\Calc\Article; use PSC\Library\Calc\Engine; use PSC\Library\Calc\General\Type\Edge; use PSC\Library\Calc\General\Type\EdgeCollection; +use PSC\Library\Calc\General\Type\EdgeCollectionContainer; use PSC\Library\Calc\Option\Type\Base; +use PSC\Library\Calc\Option\Type\PaperDbSelect; +use PSC\Library\Calc\Option\Type\Select; +use PSC\Library\Calc\Tests\Mock\Paper; class Calc { @@ -47,23 +51,84 @@ class Calc /** @var Base $option */ foreach($this->article->getOptions() as $option) { - /** @var EdgeCollection $collection */ - foreach($option->getEdgesCollectionContainer() as $collection) { + if($option instanceof PaperDbSelect) { + /** @var Select\Opt $opt */ + foreach($option->getOptions() as $opt) { + if ($opt->isValid() && $opt->isSelected()) { + /** @var Paper $paper */ + $paper = $this->engine->getPaperRepository()->findOneBy(['artNr' => $opt->getId()]); + $this->engine->setVariable($option->getId().'_digital_fix', $paper->getDigitalFix()); + $this->engine->setVariable($option->getId().'_digital_var', $paper->getDigitalVar()); + $this->engine->setVariable($option->getId().'_value', $paper->getPreis()); + $this->engine->setVariable($option->getId().'_volume', $paper->getVolume()); - if($collection->getFormel() != "") { - $formel = $this->formelCalc->parseVariables($collection->getFormel()); - eval('$var = ' . $formel . ';'); - }else{ - $var = $this->engine->getVariables()[$collection->getName()]; + } } - /** @var Edge $edge */ - foreach($collection as $edge) { + }elseif($option instanceof Select) { + /** @var Select\Opt $opt */ + foreach($option->getOptions() as $opt) { + if($opt->isValid() && $opt->isSelected()) { + $price = $this->parseEdgeCollection($price, $option, $opt->getEdgesCollectionContainer()); + } + } + } - if($edge->isValid($var)) { - $formel = $this->formelCalc->parseVariables($edge->getFormel()); - if ($formel != "") { - eval('$price += ' . $formel . ';'); + $price = $this->parseEdgeCollection($price, $option, $option->getEdgesCollectionContainer()); + } + + return $price; + } + + /** + * @param $price + * @param Base $option + * @param EdgeCollectionContainer $container + * @return int + */ + private function parseEdgeCollection($price, $option, EdgeCollectionContainer $container) + { + + $calcValue1 = 0; + $calcValue2 = 0; + $calcValueAccount1 = 0; + $calcValueAccount2 = 0; + + /** @var EdgeCollection $collection */ + foreach($container as $collection) { + + if($collection->getFormel() != "") { + $formel = $this->formelCalc->parse($collection->getFormel()); + eval('$var = ' . $formel . ';'); + }else{ + $var = $this->engine->getVariables()[$collection->getName()]; + } + + /** @var Edge $edge */ + foreach($collection as $edge) { + + if($edge->isValid($var)) { + + if($edge->getPauschale() != 0) { + eval('$price += ' . $edge->getPauschale() . ';'); + } + + if($edge->getPreis() != 0) { + eval('$price += ' . ($edge->getPreis()*$var) . ';'); + } + + if($edge->getCalcValue() != "") { + $cv = $this->formelCalc->parse($edge->getCalcValue()); + eval('$cv = ' . $cv . ';'); + $this->engine->addCalcVariable($option->getId() . '_' . $collection->getName(), $cv); + } + + if($edge->getFormel() != "") { + $formel = $this->formelCalc->parse($edge->getFormel()); + if ($formel != "" && $option->getId() != 'weight' && !$option->isAjaxExport()) { + $p = 0; + eval('$p = ' . $formel . ';'); + $price += $p; $this->engine->setVariable('price', $price); } diff --git a/src/Calc/Formel.php b/src/Calc/Formel.php index 58b0f64..87ac77d 100644 --- a/src/Calc/Formel.php +++ b/src/Calc/Formel.php @@ -28,7 +28,24 @@ class Formel $this->article = $article; } - public function parseVariables($formel) + public function parse($formel) { + + $i = 0; + + while((strpos($formel,'$F') !== false || strpos($formel,'$P') !== false || strpos($formel,'$V') !== false || strpos($formel,'$CV') !== false) && $i < 6) { + $formel = $this->parseCalcVariables($formel); + $formel = $this->parseFormulas($formel); + $formel = $this->parseParameters($formel); + $formel = $this->parseVariables($formel); + + $i++; + } + + return $formel; + + } + + private function parseVariables($formel) { preg_match_all('/\$V\w*\$V/', $formel, $founds); @@ -59,4 +76,72 @@ class Formel return $formel; } + + private function parseParameters($formel) + { + preg_match_all('/\$P\w*\$P/', $formel, $founds); + + if (!empty($founds [0])) { + eval(str_replace('\\', '', $this->engine->getParameters())); + + foreach ($founds [0] as $key => $found) { + $foundvalue = str_replace('$P', '', $found); + if (isset($$foundvalue)) { + $formel = str_replace($found, $$foundvalue, $formel); + } else { + $formel = str_replace($found, 0, $formel); + } + } + } + + return $formel; + } + + private function parseFormulas($formel) + { + preg_match_all('/\$F\w*\$F/', $formel, $founds); + + if (!empty($founds [0])) { + eval(str_replace('\\', '', $this->engine->getFormulas())); + + foreach ($founds [0] as $key => $found) { + $foundvalue = str_replace('$F', '', $found); + $formel = str_replace($found, $$foundvalue, $formel); + } + } + + return $formel; + } + + private function parseCalcVariables($formel) + { + preg_match_all('/\$CV\w*\$CV/', $formel, $founds); + + $variables = $this->engine->getCalcVariables(); + + if (!empty($founds [0])) { + foreach ($founds [0] as $key => $found) { + $foundvalue = str_replace('$CV', '', $found); + if (isset($variables [$foundvalue])) { + if ($variables [$foundvalue] == 'null') { + $formel = str_replace($found, 0, $formel); + } else { + if ($foundvalue == 'auflage') { + $formel = str_replace($found, str_replace(',', '.', $variables [$foundvalue]), $formel); + } else { + if ($variables [$foundvalue] == '') { + $formel = str_replace($found, 0, $formel); + } else { + $formel = str_replace($found, $variables [$foundvalue], $formel); + } + } + } + } else { + $formel = str_replace($found, 0, $formel); + } + } + } + + return $formel; + } } \ No newline at end of file diff --git a/src/Calc/Valid.php b/src/Calc/Valid.php index b1cda91..6c6c9cc 100644 --- a/src/Calc/Valid.php +++ b/src/Calc/Valid.php @@ -7,6 +7,7 @@ use PSC\Library\Calc\General\Type\Edge; use PSC\Library\Calc\General\Type\EdgeCollection; use PSC\Library\Calc\General\Type\EdgeCollectionContainer; use PSC\Library\Calc\Option\Type\Base; +use PSC\Library\Calc\Option\Type\Select; class Valid { @@ -24,11 +25,10 @@ class Valid } /** - * @return float + * @return void */ - public function calc() + public function perform() { - $price = 0; /** @var Base $option */ foreach($this->article->getOptions() as $option) { @@ -45,12 +45,35 @@ class Valid } } } + + if($option instanceof Select) { + + /** @var Select\Opt $opt */ + foreach ($option->getOptions() as $opt) { + if(count($opt->getEdgesCollectionContainer()) > 0) { + $opt->setIsValid(false); + } + /** @var EdgeCollection $collection */ + foreach($opt->getEdgesCollectionContainer() as $collection) { + /** @var Edge $edge */ + foreach($collection as $edge) { + if($this->edgeIsValid($collection->getName(), $edge)) { + $opt->setIsValid(true); + } + } + } + + if($this->engine->getVariables()[$option->getId()] == $opt->getId()) { + $opt->setIsSelected(true); + } + } + + + } } - return $price; } - /** * @param $section * @param Edge $edge diff --git a/src/Engine.php b/src/Engine.php index 940dae7..9ed1171 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -22,11 +22,11 @@ class Engine /** @var ObjectRepository */ protected $paperRepository; - /** @var array */ - protected $formulas = array(); + /** @var string */ + protected $formulas = ""; - /** @var array */ - protected $parameters = array(); + /** @var string */ + protected $parameters = ""; /** @var array */ protected $variables = array(); @@ -43,6 +43,9 @@ class Engine /** @var bool */ protected $dirty = true; + /** @var Article */ + protected $article = null; + /** * Load XML From String @@ -88,10 +91,10 @@ class Engine * @return Article * @throws \Exception */ - public function getArticleByName($name = false) + private function getArticleByName($name = false) { if($name === false) { - $this->articles[0]; + return $this->articles[0]; } /** @var Article $article */ @@ -138,7 +141,7 @@ class Engine } /** - * @return mixed + * @return string */ public function getFormulas() { @@ -146,7 +149,7 @@ class Engine } /** - * @param mixed $formulas + * @param string $formulas */ public function setFormulas($formulas) { @@ -155,7 +158,7 @@ class Engine } /** - * @return array + * @return string */ public function getParameters() { @@ -163,7 +166,7 @@ class Engine } /** - * @param array $parameters + * @param string $parameters */ public function setParameters($parameters) { @@ -190,27 +193,28 @@ class Engine public function calc($name = false) { + $this->price = 0; if($name) { - $article = $this->getArticleByName($name); + $this->article = $this->getArticleByName($name); }else{ - $article = $this->articles[0]; + $this->article = $this->articles[0]; } // Prefill with defaults /** @var Base $option */ - foreach($article->getOptions() as $option) { + foreach($this->article->getOptions() as $option) { if(!isset($this->variables[$option->getId()]) && $option->getDefault() !== null && !$option instanceof Text) { $this->variables[$option->getId()] = $option->getDefault(); } } // Check if Option is valid - $calcValid = new Valid($this, $article); - $calcValid->calc(); + $calcValid = new Valid($this, $this->article); + $calcValid->perform(); // CALC Formel - $calcFormel = new Calc($this, $article); - $this->price += $calcFormel->calc(); + $calcFormel = new Calc($this, $this->article); + $this->price = $calcFormel->calc(); $this->dirty = false; return true; @@ -273,6 +277,10 @@ class Engine $this->calcVariables = $calcVariables; } + public function addCalcVariable($id, $value) { + $this->calcVariables[$id] = $value; + } + public function setVariable($var, $value) { $this->variables[$var] = $value; @@ -294,4 +302,15 @@ class Engine $this->tax = $tax; } + /** + * @return Article + */ + public function getArticle($name = false) + { + if($this->dirty || $this->article == null || ($name != false && $this->article->getName() != $name)) { + $this->calc($name); + } + return $this->article; + } + } \ No newline at end of file diff --git a/src/Option/Parser/Base.php b/src/Option/Parser/Base.php index f0db61a..bbf6b12 100644 --- a/src/Option/Parser/Base.php +++ b/src/Option/Parser/Base.php @@ -28,6 +28,9 @@ class Base if(isset($this->node['help'])) { $this->element->setHelp((string)$this->node['help']); } + if(isset($this->node['exportAjax']) && (string)$this->node['exportAjax'] == 1) { + $this->element->setIsAjaxExport(true); + } } diff --git a/src/Option/Parser/Select.php b/src/Option/Parser/Select.php index 60c0b3c..4a98314 100644 --- a/src/Option/Parser/Select.php +++ b/src/Option/Parser/Select.php @@ -22,7 +22,12 @@ class Select extends Base public function __construct(\SimpleXMLElement $node) { - $this->element = new \PSC\Library\Calc\Option\Type\Select(); + if(isset($node['mode']) && (string)$node['mode'] == \PSC\Library\Calc\Option\Type\Select::$modePaperDb) { + $this->element = new \PSC\Library\Calc\Option\Type\PaperDbSelect(); + }else{ + $this->element = new \PSC\Library\Calc\Option\Type\Select(); + } + parent::__construct($node); } @@ -48,12 +53,13 @@ class Select extends Base /** @var PaperContainer\Item $papier */ foreach ($container->getItems() as $papier) { - /** @var Paper $papierDb */ - $papierDb = $this->getPaperRepository()->findOneBy(array('artNr' => $papier->getId())); - if($papierDb) { - $optPapier = new \PSC\Library\Calc\Option\Type\Select\Opt(); - $optPapier->setId($papierDb->getArtNr()); - $optPapier->setLabel($papierDb->getDescription1()); + /** @var Paper $paper */ + $paper = $this->getPaperRepository()->findOneBy(array('artNr' => $papier->getId())); + if($paper) { + $optPapier = new \PSC\Library\Calc\Option\Type\Select\PaperOpt(); + $optPapier->setId($paper->getArtNr()); + $optPapier->setLabel($paper->getDescription1()); + $optPapier->setPaper($paper); $this->element->addOption($optPapier); } } diff --git a/src/Option/Parser/Select/Opt.php b/src/Option/Parser/Select/Opt.php index 88896ba..265bff0 100644 --- a/src/Option/Parser/Select/Opt.php +++ b/src/Option/Parser/Select/Opt.php @@ -1,6 +1,7 @@ element->setId((string)$this->node['id']); $this->element->setLabel((string)$this->node['name']); + if($this->node->children()) { + $edgeCollectionContainerParser = new EdgeCollectionContainer($this->node); + $this->element->setEdgesCollectionContainer($edgeCollectionContainerParser->parse()); + } + return $this->element; } diff --git a/src/Option/Type/Base.php b/src/Option/Type/Base.php index 3ee5f14..20d0b55 100644 --- a/src/Option/Type/Base.php +++ b/src/Option/Type/Base.php @@ -1,7 +1,6 @@ edgesCollectionContainer = new EdgeCollectionContainer(); } /** @@ -208,5 +212,21 @@ class Base $this->edgesCollectionContainer = $edgesCollectionContainer; } + /** + * @return bool + */ + public function isAjaxExport() + { + return $this->isAjaxExport; + } + + /** + * @param bool $isAjaxExport + */ + public function setIsAjaxExport($isAjaxExport) + { + $this->isAjaxExport = $isAjaxExport; + } + } \ No newline at end of file diff --git a/src/Option/Type/PaperDbSelect.php b/src/Option/Type/PaperDbSelect.php new file mode 100644 index 0000000..f9aae23 --- /dev/null +++ b/src/Option/Type/PaperDbSelect.php @@ -0,0 +1,14 @@ +options; } + public function getSelectedOption() + { + /** @var Opt $opt */ + foreach($this->getOptions() as $opt) { + if($opt->isSelected()) return $opt; + } + } + } \ No newline at end of file diff --git a/src/Option/Type/Select/Opt.php b/src/Option/Type/Select/Opt.php index 4b253bb..fd5e40c 100644 --- a/src/Option/Type/Select/Opt.php +++ b/src/Option/Type/Select/Opt.php @@ -1,6 +1,7 @@ edgesCollectionContainer = new EdgeCollectionContainer(); + } + + /** * @return string */ @@ -43,5 +62,51 @@ class Opt $this->label = $label; } + /** + * @return EdgeCollectionContainer + */ + public function getEdgesCollectionContainer() + { + return $this->edgesCollectionContainer; + } + /** + * @param EdgeCollectionContainer $edgesCollectionContainer + */ + public function setEdgesCollectionContainer($edgesCollectionContainer) + { + $this->edgesCollectionContainer = $edgesCollectionContainer; + } + + /** + * @return bool + */ + public function isValid() + { + return $this->isValid; + } + + /** + * @param bool $isValid + */ + public function setIsValid($isValid) + { + $this->isValid = $isValid; + } + + /** + * @return bool + */ + public function isSelected() + { + return $this->isSelected; + } + + /** + * @param bool $isSelected + */ + public function setIsSelected($isSelected) + { + $this->isSelected = $isSelected; + } } \ No newline at end of file diff --git a/src/Option/Type/Select/PaperOpt.php b/src/Option/Type/Select/PaperOpt.php new file mode 100644 index 0000000..1145ecc --- /dev/null +++ b/src/Option/Type/Select/PaperOpt.php @@ -0,0 +1,23 @@ +paper = $paper; + } + + /** + * @return null + */ + public function getPaper() + { + return $this->paper; + } +} \ No newline at end of file diff --git a/tests/Article/CalendarXmlTest.php b/tests/Article/CalendarXmlTest.php index 042dd61..aaea23d 100644 --- a/tests/Article/CalendarXmlTest.php +++ b/tests/Article/CalendarXmlTest.php @@ -38,7 +38,7 @@ class CalendarXmlTest extends \PHPUnit_Framework_TestCase $parser->loadString(file_get_contents(__DIR__ .'/../TestFiles/General/calendar.xml')); /** @var Article $article */ - $article = $parser->getArticleByName('Kalender'); + $article = $parser->getArticle(); $this->assertInstanceOf('PSC\Library\Calc\Article', $article); $this->assertEquals('Kalender', $article->getName()); } @@ -55,7 +55,7 @@ class CalendarXmlTest extends \PHPUnit_Framework_TestCase $parser->setPaperContainer($paperContainer); $parser->loadString(file_get_contents(__DIR__ .'/../TestFiles/General/calendar.xml')); /** @var Article $article */ - $article = $parser->getArticleByName('Kalender'); + $article = $parser->getArticle(); /** @var Select $option */ $option = $article->getOptionById('size'); @@ -77,7 +77,7 @@ class CalendarXmlTest extends \PHPUnit_Framework_TestCase $parser->loadString(file_get_contents(__DIR__ .'/../TestFiles/General/calendar.xml')); /** @var Article $article */ - $article = $parser->getArticleByName('Kalender'); + $article = $parser->getArticle(); $article->setParams(array( "motive" => 0, @@ -123,7 +123,7 @@ class CalendarXmlTest extends \PHPUnit_Framework_TestCase $parser->loadString(file_get_contents(__DIR__ .'/../TestFiles/General/calendar.xml')); /** @var Article $article */ - $article = $parser->getArticleByName('Kalender'); + $article = $parser->getArticle(); $this->assertEquals(11, $article->getOptions()->count()); } diff --git a/tests/Article/Complete1Test.php b/tests/Article/Complete1Test.php index e6f5338..9d2d6ed 100644 --- a/tests/Article/Complete1Test.php +++ b/tests/Article/Complete1Test.php @@ -27,7 +27,7 @@ class Complete1Test extends \PHPUnit_Framework_TestCase public function testIfParserGetArticleCorrect() { - $article = $this->engine->getArticleByName('test1'); + $article = $this->engine->getArticle(); $this->assertEquals('test1', $article->getName()); $this->assertEquals(17, count($article->getOptions())); diff --git a/tests/Article/SimpleXmlTest.php b/tests/Article/SimpleXmlTest.php index f5959f7..cdb08c4 100644 --- a/tests/Article/SimpleXmlTest.php +++ b/tests/Article/SimpleXmlTest.php @@ -27,7 +27,8 @@ class SimpleXmlTest extends \PHPUnit_Framework_TestCase $parser = new Engine(new Container()); $parser->loadString(file_get_contents(__DIR__ .'/../TestFiles/General/simple2articles.xml')); - $article = $parser->getArticleByName('Blocks A5 25blatt geleimt'); + $parser->calc("Blocks A5 25blatt geleimt"); + $article = $parser->getArticle(); $this->assertInstanceOf('PSC\Library\Calc\Article', $article); $this->assertEquals('Blocks A5 25blatt geleimt', $article->getName()); } diff --git a/tests/Calc/OptionsRemoveTest.php b/tests/Calc/OptionsRemoveTest.php index a466dcc..0b9f57c 100644 --- a/tests/Calc/OptionsRemoveTest.php +++ b/tests/Calc/OptionsRemoveTest.php @@ -29,7 +29,7 @@ class OptionsRemoveTest extends \PHPUnit_Framework_TestCase public function testIfParserGetArticleCorrect() { - $article = $this->engine->getArticleByName('test1'); + $article = $this->engine->getArticle(); $this->assertEquals('test1', $article->getName()); $this->assertEquals(2, count($article->getOptions())); @@ -43,7 +43,7 @@ class OptionsRemoveTest extends \PHPUnit_Framework_TestCase $this->engine->calc('test1'); /** @var Article $article */ - $article = $this->engine->getArticleByName('test1'); + $article = $this->engine->getArticle(); /** @var Base $option */ $option = $article->getOptionById('gebwert'); diff --git a/tests/Calc/PreisPauschale.php b/tests/Calc/PreisPauschale.php new file mode 100644 index 0000000..9a9110b --- /dev/null +++ b/tests/Calc/PreisPauschale.php @@ -0,0 +1,43 @@ +engine = new Engine(new Container()); + $this->engine->loadString(file_get_contents(__DIR__ . '/../TestFiles/Calc/pauschale_preis.xml')); + + } + + public function tearDown() + { + $this->engine = null; + } + + public function testIfArticleCountIsCorrect() + { + $this->assertEquals(1, $this->engine->getArticles()->Count()); + } + + public function testPreisPauschaleCalc() + { + $this->engine->calc(); + + $this->assertEquals(110, $this->engine->getPrice()); + $this->engine->setVariables(['auflage' => 50]); + $this->assertEquals(270, $this->engine->getPrice()); + $this->engine->setVariables(['auflage' => 250]); + $this->assertEquals(0, $this->engine->getPrice()); + + } + +} \ No newline at end of file diff --git a/tests/CalcValue/ComplexTest.php b/tests/CalcValue/ComplexTest.php new file mode 100644 index 0000000..aa62318 --- /dev/null +++ b/tests/CalcValue/ComplexTest.php @@ -0,0 +1,47 @@ +parse(simplexml_load_string(file_get_contents(__DIR__ .'/../TestFiles/CalcValue/papierContainer.xml'))); + + $this->engine = new Engine(); + $this->engine->setPaperRepository($repository); + $this->engine->setPaperContainer($paperContainer); + $this->engine->loadString(file_get_contents(__DIR__ . '/../TestFiles/CalcValue/complex.xml')); + $this->engine->setFormulas(file_get_contents(__DIR__.'/../TestFiles/formels.txt')); + $this->engine->setParameters(file_get_contents(__DIR__.'/../TestFiles/parameters.txt')); + } + + public function tearDown() + { + $this->engine = null; + } + + public function testIfParseValue() + { + $this->assertEquals(28.54, $this->engine->getPrice()); + } + + public function testIfPaperGrammaturValue() + { + $this->assertInstanceOf(PaperDbSelect::Class, $this->engine->getArticle()->getOptionById('papier')); + + $this->assertEquals("INM115", $this->engine->getArticle()->getOptionById('papier')->getSelectedOption()->getId()); + $this->assertEquals(0.104, $this->engine->getArticle()->getOptionById('papier')->getSelectedOption()->getPaper()->getVolume()); + } +} \ No newline at end of file diff --git a/tests/CalcValue/SimpleTest.php b/tests/CalcValue/SimpleTest.php new file mode 100644 index 0000000..c3cb6ff --- /dev/null +++ b/tests/CalcValue/SimpleTest.php @@ -0,0 +1,27 @@ +engine = new Engine(new Container()); + $this->engine->loadString(file_get_contents(__DIR__ . '/../TestFiles/CalcValue/simple.xml')); + } + + public function tearDown() + { + $this->engine = null; + } + + public function testIfParseValue() + { + $this->assertEquals(20, $this->engine->getPrice()); + } +} \ No newline at end of file diff --git a/tests/Mock/Paper.php b/tests/Mock/Paper.php index 065084c..ff0038c 100644 --- a/tests/Mock/Paper.php +++ b/tests/Mock/Paper.php @@ -244,6 +244,8 @@ class Paper private $digitalVar; + private $volume; + /** * @return mixed */ @@ -1092,5 +1094,21 @@ class Paper $this->digitalVar = $digitalVar; } + /** + * @return mixed + */ + public function getVolume() + { + return $this->volume; + } + + /** + * @param mixed $volume + */ + public function setVolume($volume) + { + $this->volume = $volume; + } + } diff --git a/tests/Mock/PaperRepostory.php b/tests/Mock/PaperRepostory.php index 7f02d3f..6f940b9 100644 --- a/tests/Mock/PaperRepostory.php +++ b/tests/Mock/PaperRepostory.php @@ -101,6 +101,64 @@ class PaperRepostory implements ObjectRepository $papier['bdg300']->setArtNr('bdg300'); $papier['bdg300']->setDescription1('Bilderdruck glänzend 300 gr'); + + $papier['INM115'] = new Paper(); + $papier['INM115']->setArtNr('INM115'); + $papier['INM115']->setGrammatur('115'); + $papier['INM115']->setDigitalVar('495'); + $papier['INM115']->setDigitalFix('345'); + $papier['INM115']->setPreis(24); + $papier['INM115']->setVolume(0.104); + $papier['INM115']->setDescription1('115 g/m² Bilderdruck matt gestrichen'); + $papier['INM115']->setDescription2('115 g/m² Inapa Infinity silk, seidenmatt'); + + $papier['INM300'] = new Paper(); + $papier['INM300']->setArtNr('INM300'); + $papier['INM300']->setGrammatur('300'); + $papier['INM300']->setDigitalVar('495'); + $papier['INM300']->setDigitalFix('345'); + $papier['INM300']->setPreis(58); + $papier['INM300']->setVolume(0.303); + $papier['INM300']->setDescription1('115 g/m² Bilderdruck matt gestrichen'); + $papier['INM300']->setDescription2('115 g/m² Inapa Infinity silk, seidenmatt'); + + $papier['INA90'] = new Paper(); + $papier['INA90']->setArtNr('INA90'); + $papier['INA90']->setArtNr('90'); + $papier['INA90']->setDigitalVar('495'); + $papier['INA90']->setDigitalFix('345'); + $papier['INA90']->setPreis(28.3); + $papier['INA90']->setVolume(0.119); + $papier['INA90']->setDescription1(' 90 g/m² Offsetpapier hochweiß, natur'); + $papier['INA90']->setDescription2('90 g/m² Multi Business, 1,3-faches Volumen'); + + $papier['INA400'] = new Paper(); + $papier['INA400']->setArtNr('INA400'); + $papier['INA400']->setGrammatur('400'); + $papier['INA400']->setDigitalVar('495'); + $papier['INA400']->setDigitalFix('345'); + $papier['INA400']->setPreis(154); + $papier['INA400']->setVolume(0.548); + $papier['INA400']->setDescription1('400 g/m² Offsetpapier hochweiß, natur'); + $papier['INA400']->setDescription2('400 g/m² Maestro extra, 1,3-faches Volumen'); + + $papier['ZETL260'] = new Paper(); + $papier['ZETL260']->setArtNr('ZETL260'); + $papier['ZETL260']->setGrammatur('260'); + $papier['ZETL260']->setDigitalVar('495'); + $papier['ZETL260']->setDigitalFix('345'); + $papier['ZETL260']->setPreis(220); + $papier['ZETL260']->setVolume(0.280); + $papier['ZETL260']->setDescription1('260 g/m² Zanders ZETA leinen brilliantweiß'); + $papier['ZETL260']->setDescription2('260 g/m² Naturkarton leinengeprägt'); + + $papier['CONG300_1'] = new Paper(); + $papier['CONG300_1']->setArtNr('CONG300_1'); + $papier['CONG300_1']->setGrammatur('300'); + $papier['CONG300_1']->setDescription1('300 g/m² Naturkarton gerippt hochweiß'); + $papier['CONG300_1']->setDescription2('300 g/m² Conqueror gerippt diamantweiß'); + + return $papier[$criteria['artNr']]; } diff --git a/tests/TestFiles/Calc/pauschale_preis.xml b/tests/TestFiles/Calc/pauschale_preis.xml new file mode 100644 index 0000000..8c9786d --- /dev/null +++ b/tests/TestFiles/Calc/pauschale_preis.xml @@ -0,0 +1,17 @@ + + + + preis und pauschale + kein + + + + \ No newline at end of file diff --git a/tests/TestFiles/Calc/price_min.xml b/tests/TestFiles/Calc/price_min.xml index 692a097..84857ee 100644 --- a/tests/TestFiles/Calc/price_min.xml +++ b/tests/TestFiles/Calc/price_min.xml @@ -56,7 +56,7 @@ -