Fixes
This commit is contained in:
parent
5b4abb6a85
commit
6dcfb6ea27
49
.gitignore
vendored
49
.gitignore
vendored
@ -2,55 +2,6 @@
|
||||
composer.phar
|
||||
vendor/
|
||||
|
||||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
|
||||
|
||||
*.iml
|
||||
|
||||
## Directory-based project format:
|
||||
.idea/
|
||||
# if you remove the above rule, at least ignore the following:
|
||||
|
||||
# User-specific stuff:
|
||||
# .idea/workspace.xml
|
||||
# .idea/tasks.xml
|
||||
# .idea/dictionaries
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
# .idea/dataSources.ids
|
||||
# .idea/dataSources.xml
|
||||
# .idea/sqlDataSources.xml
|
||||
# .idea/dynamic.xml
|
||||
# .idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
# .idea/gradle.xml
|
||||
# .idea/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
# .idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
|
||||
@ -17,6 +17,6 @@
|
||||
"doctrine/orm": "^2.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.7"
|
||||
"phpunit/phpunit": "^5"
|
||||
}
|
||||
}
|
||||
895
composer.lock
generated
895
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -14,9 +14,14 @@
|
||||
bootstrap = "vendor/autoload.php" >
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Docker PHP Tests Suite">
|
||||
<testsuite name="Calc Tests Suite">
|
||||
<directory>tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="false">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
</phpunit>
|
||||
115
src/Calc/Formel.php
Normal file
115
src/Calc/Formel.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Calc;
|
||||
|
||||
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;
|
||||
|
||||
class Formel
|
||||
{
|
||||
|
||||
/** @var Engine */
|
||||
protected $engine = null;
|
||||
|
||||
/** @var Article */
|
||||
protected $article = null;
|
||||
|
||||
public function __construct($engine, $article)
|
||||
{
|
||||
$this->engine = $engine;
|
||||
$this->article = $article;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function calc()
|
||||
{
|
||||
$price = 0;
|
||||
|
||||
/** @var Base $option */
|
||||
foreach($this->article->getOptions() as $option) {
|
||||
|
||||
/** @var EdgeCollection $collection */
|
||||
foreach($option->getEdgesCollectionContainer() as $collection) {
|
||||
/** @var Edge $edge */
|
||||
foreach($collection as $edge) {
|
||||
if($this->edgeIsValid($collection->getName(), $edge)) {
|
||||
$formel = $this->parseVar($edge->getFormel());
|
||||
if ($formel != "") {
|
||||
eval('$price += ' . $formel . ';');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $price;
|
||||
}
|
||||
|
||||
private function parseVar($formel)
|
||||
{
|
||||
preg_match_all('/\$V\w*\$V/', $formel, $founds);
|
||||
|
||||
$variables = $this->engine->getVariables();
|
||||
|
||||
if (!empty($founds [0])) {
|
||||
foreach ($founds [0] as $key => $found) {
|
||||
$foundvalue = str_replace('$V', '', $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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $section
|
||||
* @param Edge $edge
|
||||
* @return bool
|
||||
*/
|
||||
private function edgeIsValid($section, $edge)
|
||||
{
|
||||
if(!isset($this->engine->getVariables()[$section])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if($edge->isRegion() &&
|
||||
$edge->getFrom() <= $this->engine->getVariables()[$section] &&
|
||||
$edge->getTo() >= $this->engine->getVariables()[$section]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($edge->isRegion() &&
|
||||
$edge->getFrom() <= $this->engine->getVariables()[$section] &&
|
||||
$edge->getTo() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!$edge->isRegion() && in_array($this->engine->getVariables()[$section], $edge->getValues())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
84
src/Calc/Valid.php
Normal file
84
src/Calc/Valid.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Calc;
|
||||
|
||||
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;
|
||||
|
||||
class Valid
|
||||
{
|
||||
|
||||
/** @var Engine */
|
||||
protected $engine = null;
|
||||
|
||||
/** @var Article */
|
||||
protected $article = null;
|
||||
|
||||
public function __construct($engine, $article)
|
||||
{
|
||||
$this->engine = $engine;
|
||||
$this->article = $article;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function calc()
|
||||
{
|
||||
$price = 0;
|
||||
|
||||
/** @var Base $option */
|
||||
foreach($this->article->getOptions() as $option) {
|
||||
|
||||
if(count($option->getEdgesCollectionContainer()) > 0) {
|
||||
$option->setIsValid(false);
|
||||
}
|
||||
/** @var EdgeCollection $collection */
|
||||
foreach($option->getEdgesCollectionContainer() as $collection) {
|
||||
/** @var Edge $edge */
|
||||
foreach($collection as $edge) {
|
||||
if($this->edgeIsValid($collection->getName(), $edge)) {
|
||||
$option->setIsValid(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $price;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $section
|
||||
* @param Edge $edge
|
||||
* @return bool
|
||||
*/
|
||||
private function edgeIsValid($section, $edge)
|
||||
{
|
||||
if(!isset($this->engine->getVariables()[$section])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if($edge->isRegion() &&
|
||||
$edge->getFrom() <= $this->engine->getVariables()[$section] &&
|
||||
$edge->getTo() >= $this->engine->getVariables()[$section]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($edge->isRegion() &&
|
||||
$edge->getFrom() <= $this->engine->getVariables()[$section] &&
|
||||
$edge->getTo() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!$edge->isRegion() && in_array($this->engine->getVariables()[$section], $edge->getValues())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
124
src/Engine.php
124
src/Engine.php
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc;
|
||||
|
||||
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use PSC\Library\Calc\Calc\Formel;
|
||||
use PSC\Library\Calc\Calc\Valid;
|
||||
use PSC\Library\Calc\Option\Type\Base;
|
||||
use PSC\Library\Calc\Option\Type\Text;
|
||||
|
||||
class Engine
|
||||
{
|
||||
@ -20,6 +22,22 @@ class Engine
|
||||
/** @var ObjectRepository */
|
||||
protected $paperRepository;
|
||||
|
||||
/** @var array */
|
||||
protected $formulas = array();
|
||||
|
||||
/** @var array */
|
||||
protected $parameters = array();
|
||||
|
||||
/** @var array */
|
||||
protected $variables = array();
|
||||
|
||||
/** @var float */
|
||||
protected $price = 0;
|
||||
|
||||
/** @var bool */
|
||||
protected $dirty = true;
|
||||
|
||||
|
||||
/**
|
||||
* Load XML From String
|
||||
*
|
||||
@ -48,6 +66,7 @@ class Engine
|
||||
$this->articles->append($parser->parse($article));
|
||||
|
||||
}
|
||||
$this->dirty = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,6 +114,7 @@ class Engine
|
||||
*/
|
||||
public function setPaperContainer($paperContainer)
|
||||
{
|
||||
$this->dirty = true;
|
||||
$this->paperContainer = $paperContainer;
|
||||
}
|
||||
|
||||
@ -111,7 +131,107 @@ class Engine
|
||||
*/
|
||||
public function setPaperRepository($paperRepository)
|
||||
{
|
||||
$this->dirty = true;
|
||||
$this->paperRepository = $paperRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFormulas()
|
||||
{
|
||||
return $this->formulas;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $formulas
|
||||
*/
|
||||
public function setFormulas($formulas)
|
||||
{
|
||||
$this->dirty = true;
|
||||
$this->formulas = $formulas;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function setParameters($parameters)
|
||||
{
|
||||
$this->dirty = true;
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getVariables()
|
||||
{
|
||||
return $this->variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $variables
|
||||
*/
|
||||
public function setVariables($variables)
|
||||
{
|
||||
$this->dirty = true;
|
||||
$this->variables = $variables;
|
||||
}
|
||||
|
||||
public function calc($name = false) {
|
||||
|
||||
if($name) {
|
||||
$article = $this->getArticleByName($name);
|
||||
}else{
|
||||
$article = $this->articles[0];
|
||||
}
|
||||
|
||||
// Prefill with defaults
|
||||
/** @var Base $option */
|
||||
foreach($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();
|
||||
|
||||
// CALC Formel
|
||||
|
||||
$calcFormel = new Formel($this, $article);
|
||||
$this->price += $calcFormel->calc();
|
||||
|
||||
$this->dirty = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPrice()
|
||||
{
|
||||
if($this->dirty) {
|
||||
$this->calc();
|
||||
}
|
||||
return round($this->price,2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $price
|
||||
*/
|
||||
public function setPrice($price)
|
||||
{
|
||||
$this->price = $price;
|
||||
}
|
||||
|
||||
}
|
||||
59
src/General/Parser/Edge.php
Normal file
59
src/General/Parser/Edge.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: thomas
|
||||
* Date: 09.04.18
|
||||
* Time: 15:58
|
||||
*/
|
||||
|
||||
namespace PSC\Library\Calc\General\Parser;
|
||||
|
||||
|
||||
class Edge
|
||||
{
|
||||
/** @var \SimpleXMLElement $node */
|
||||
protected $node;
|
||||
|
||||
public function __construct($node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PSC\Library\Calc\General\Type\Edge
|
||||
*/
|
||||
public function parse()
|
||||
{
|
||||
$edge = new \PSC\Library\Calc\General\Type\Edge();
|
||||
if(isset($this->node->attributes()->formel)) {
|
||||
$edge->setFormel((string)$this->node->attributes()->formel);
|
||||
}
|
||||
if(isset($this->node->attributes()->calc_value)) {
|
||||
$edge->setCalcValue((string)$this->node->attributes()->calc_value);
|
||||
}
|
||||
if(isset($this->node->attributes()->preis)) {
|
||||
$edge->setPreis(floatval($this->node->attributes()->preis));
|
||||
}
|
||||
if(isset($this->node->attributes()->pauschale)) {
|
||||
$edge->setPauschale(floatval($this->node->attributes()->pauschale));
|
||||
}
|
||||
|
||||
$value = (string)$this->node;
|
||||
if(preg_match("/^([0-9a-zA-Z_]+)$/", trim($value), $regs)) {
|
||||
$edge->setValues([$regs[1]]);
|
||||
}elseif(preg_match("/^([0-9]+)-([0-9]+)$/", trim($value), $regs)) {
|
||||
$edge->setRegion(true);
|
||||
$edge->setFrom(intval($regs[1]));
|
||||
$edge->setTo(intval($regs[2]));
|
||||
}elseif(preg_match("/^([0-9]+)-$/", trim($value), $regs)) {
|
||||
$edge->setRegion(true);
|
||||
$edge->setFrom(intval($regs[1]));
|
||||
}elseif(strpos(trim($value), ",") !== false) {
|
||||
$values = explode(",", trim($value));
|
||||
$edge->setValues($values);
|
||||
}
|
||||
|
||||
return $edge;
|
||||
}
|
||||
}
|
||||
|
||||
39
src/General/Parser/EdgeCollection.php
Normal file
39
src/General/Parser/EdgeCollection.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: thomas
|
||||
* Date: 09.04.18
|
||||
* Time: 15:58
|
||||
*/
|
||||
|
||||
namespace PSC\Library\Calc\General\Parser;
|
||||
|
||||
|
||||
class EdgeCollection
|
||||
{
|
||||
/** @var \SimpleXMLElement $node */
|
||||
protected $node;
|
||||
|
||||
public function __construct($node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \PSC\Library\Calc\General\Type\EdgeCollection
|
||||
*/
|
||||
public function parse()
|
||||
{
|
||||
$collection = new \PSC\Library\Calc\General\Type\EdgeCollection();
|
||||
|
||||
foreach($this->node->grenze as $row) {
|
||||
$edgeParser = new Edge($row);
|
||||
$edge = $edgeParser->parse();
|
||||
|
||||
$collection->append($edge);
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
36
src/General/Parser/EdgeCollectionContainer.php
Normal file
36
src/General/Parser/EdgeCollectionContainer.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: thomas
|
||||
* Date: 09.04.18
|
||||
* Time: 15:58
|
||||
*/
|
||||
|
||||
namespace PSC\Library\Calc\General\Parser;
|
||||
|
||||
class EdgeCollectionContainer
|
||||
{
|
||||
/** @var \SimpleXMLElement $node */
|
||||
protected $node;
|
||||
|
||||
public function __construct($node)
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
public function parse()
|
||||
{
|
||||
$container = new \PSC\Library\Calc\General\Type\EdgeCollectionContainer();
|
||||
|
||||
foreach($this->node->children() as $key => $row) {
|
||||
$collectionParser = new EdgeCollection($row);
|
||||
|
||||
$collection = $collectionParser->parse();
|
||||
$collection->setName($key);
|
||||
|
||||
$container->append($collection);
|
||||
}
|
||||
|
||||
return $container;
|
||||
}
|
||||
}
|
||||
146
src/General/Type/Edge.php
Normal file
146
src/General/Type/Edge.php
Normal file
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\General\Type;
|
||||
|
||||
class Edge
|
||||
{
|
||||
protected $formel = '';
|
||||
protected $pauschale = 0;
|
||||
protected $preis = 0;
|
||||
protected $calcValue = '';
|
||||
|
||||
protected $from = 0;
|
||||
protected $to = 0;
|
||||
protected $values = [];
|
||||
|
||||
protected $region = false;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFormel()
|
||||
{
|
||||
return $this->formel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $formel
|
||||
*/
|
||||
public function setFormel($formel)
|
||||
{
|
||||
$this->formel = $formel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPauschale()
|
||||
{
|
||||
return $this->pauschale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $pauschale
|
||||
*/
|
||||
public function setPauschale($pauschale)
|
||||
{
|
||||
$this->pauschale = $pauschale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPreis()
|
||||
{
|
||||
return $this->preis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $preis
|
||||
*/
|
||||
public function setPreis($preis)
|
||||
{
|
||||
$this->preis = $preis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCalcValue()
|
||||
{
|
||||
return $this->calcValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $calcValue
|
||||
*/
|
||||
public function setCalcValue($calcValue)
|
||||
{
|
||||
$this->calcValue = $calcValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFrom()
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $from
|
||||
*/
|
||||
public function setFrom($from)
|
||||
{
|
||||
$this->from = $from;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTo()
|
||||
{
|
||||
return $this->to;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $to
|
||||
*/
|
||||
public function setTo($to)
|
||||
{
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
*/
|
||||
public function setValues($values)
|
||||
{
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isRegion()
|
||||
{
|
||||
return $this->region;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $region
|
||||
*/
|
||||
public function setRegion($region)
|
||||
{
|
||||
$this->region = $region;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
27
src/General/Type/EdgeCollection.php
Normal file
27
src/General/Type/EdgeCollection.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace PSC\Library\Calc\General\Type;
|
||||
|
||||
class EdgeCollection extends \ArrayIterator
|
||||
{
|
||||
|
||||
public $name = '';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
19
src/General/Type/EdgeCollectionContainer.php
Normal file
19
src/General/Type/EdgeCollectionContainer.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace PSC\Library\Calc\General\Type;
|
||||
|
||||
class EdgeCollectionContainer extends \ArrayIterator
|
||||
{
|
||||
public function getCollectionByName($string)
|
||||
{
|
||||
while($this->valid()) {
|
||||
if($string == $this->current()->getName()) {
|
||||
return $this->current();
|
||||
}
|
||||
|
||||
$this->next();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ namespace PSC\Library\Calc\Option;
|
||||
|
||||
use PSC\Library\Calc\Option\Parser\Input;
|
||||
use PSC\Library\Calc\Option\Parser\Select;
|
||||
use PSC\Library\Calc\Option\Parser\Text;
|
||||
use PSC\Library\Calc\PaperContainer\Container;
|
||||
|
||||
class Parser
|
||||
@ -26,6 +27,9 @@ class Parser
|
||||
case 'select':
|
||||
$obj = new Select($node);
|
||||
break;
|
||||
case 'text':
|
||||
$obj = new Text($node);
|
||||
break;
|
||||
}
|
||||
|
||||
return $obj;
|
||||
|
||||
@ -28,6 +28,7 @@ class Base
|
||||
if(isset($this->node['help'])) {
|
||||
$this->element->setHelp((string)$this->node['help']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function getBoolean($value)
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Parser;
|
||||
|
||||
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
||||
|
||||
class Input extends Base
|
||||
{
|
||||
|
||||
@ -16,6 +18,11 @@ class Input extends Base
|
||||
{
|
||||
parent::parse();
|
||||
|
||||
if($this->node->children()) {
|
||||
$edgeCollectionContainerParser = new EdgeCollectionContainer($this->node);
|
||||
$this->element->setEdgesCollectionContainer($edgeCollectionContainerParser->parse());
|
||||
}
|
||||
|
||||
return $this->element;
|
||||
}
|
||||
|
||||
|
||||
22
src/Option/Parser/Text.php
Normal file
22
src/Option/Parser/Text.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Parser;
|
||||
|
||||
class Text extends Base
|
||||
{
|
||||
|
||||
protected $element;
|
||||
|
||||
public function __construct(\SimpleXMLElement $node)
|
||||
{
|
||||
$this->element = new \PSC\Library\Calc\Option\Type\Text();
|
||||
parent::__construct($node);
|
||||
}
|
||||
|
||||
public function parse()
|
||||
{
|
||||
parent::parse();
|
||||
|
||||
return $this->element;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Type;
|
||||
|
||||
use General\EdgeCollection;
|
||||
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
||||
|
||||
class Base
|
||||
{
|
||||
/** @var string $name */
|
||||
@ -10,7 +13,7 @@ class Base
|
||||
protected $id;
|
||||
|
||||
/** @var string $default */
|
||||
protected $default = '';
|
||||
protected $default = null;
|
||||
|
||||
/** @var string $help */
|
||||
protected $help = '';
|
||||
@ -27,6 +30,12 @@ class Base
|
||||
/** @var string $value */
|
||||
protected $value = '';
|
||||
|
||||
/** @var EdgeCollectionContainer */
|
||||
protected $edgesCollectionContainer = [];
|
||||
|
||||
/** @var bool */
|
||||
protected $isValid = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
@ -167,4 +176,37 @@ class Base
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid()
|
||||
{
|
||||
return $this->isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isValid
|
||||
*/
|
||||
public function setIsValid($isValid)
|
||||
{
|
||||
$this->isValid = $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EdgeCollectionContainer
|
||||
*/
|
||||
public function getEdgesCollectionContainer()
|
||||
{
|
||||
return $this->edgesCollectionContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EdgeCollectionContainer $edgesCollectionContainer
|
||||
*/
|
||||
public function setEdgesCollectionContainer($edgesCollectionContainer)
|
||||
{
|
||||
$this->edgesCollectionContainer = $edgesCollectionContainer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
9
src/Option/Type/Text.php
Normal file
9
src/Option/Type/Text.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Type;
|
||||
|
||||
class Text extends Base
|
||||
{
|
||||
|
||||
static public $type = 'text';
|
||||
|
||||
}
|
||||
@ -125,7 +125,7 @@ class CalendarXmlTest extends \PHPUnit_Framework_TestCase
|
||||
/** @var Article $article */
|
||||
$article = $parser->getArticleByName('Kalender');
|
||||
|
||||
$this->assertEquals(10, $article->getOptions()->count());
|
||||
$this->assertEquals(11, $article->getOptions()->count());
|
||||
}
|
||||
|
||||
}
|
||||
79
tests/Article/Complete1Test.php
Normal file
79
tests/Article/Complete1Test.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Tests\Article;
|
||||
|
||||
use PSC\Library\Calc\Engine;
|
||||
use PSC\Library\Calc\PaperContainer\Container;
|
||||
|
||||
class Complete1Test extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @var Engine */
|
||||
protected $engine = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->engine = new Engine(new Container());
|
||||
$this->engine->loadString(file_get_contents(__DIR__ . '/../TestFiles/General/complete1.xml'));
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$this->engine = null;
|
||||
}
|
||||
|
||||
public function testIfArticleCountIsCorrect()
|
||||
{
|
||||
$this->assertEquals(1, $this->engine->getArticles()->Count());
|
||||
}
|
||||
|
||||
public function testIfParserGetArticleCorrect()
|
||||
{
|
||||
$article = $this->engine->getArticleByName('test1');
|
||||
$this->assertEquals('test1', $article->getName());
|
||||
|
||||
$this->assertEquals(17, count($article->getOptions()));
|
||||
}
|
||||
|
||||
public function testIfCalcArticleCorrect()
|
||||
{
|
||||
$this->engine->setParameters([]);
|
||||
$this->engine->setFormulas([]);
|
||||
$this->engine->setVariables([]);
|
||||
$this->engine->calc('test1');
|
||||
$this->assertEquals(0, $this->engine->getPrice());
|
||||
|
||||
}
|
||||
|
||||
public function testIfCalcReturnsPrice()
|
||||
{
|
||||
$this->engine->setParameters([]);
|
||||
$this->engine->setFormulas([]);
|
||||
$this->engine->setVariables(['gebwert' => 20000]);
|
||||
$this->engine->calc('test1');
|
||||
$this->assertEquals(18.12, $this->engine->getPrice());
|
||||
}
|
||||
|
||||
public function testIfCalcReturnsPriceWithEdge()
|
||||
{
|
||||
$this->engine->setParameters([]);
|
||||
$this->engine->setFormulas([]);
|
||||
$this->engine->setVariables(['gebyn' => 2, 'gebwert' => 20000]);
|
||||
$this->engine->calc('test1');
|
||||
$this->assertEquals(0, $this->engine->getPrice());
|
||||
}
|
||||
|
||||
public function testIfCalcCompletePrice()
|
||||
{
|
||||
$this->engine->setParameters([]);
|
||||
$this->engine->setFormulas([]);
|
||||
$this->engine->setVariables([
|
||||
'gebwert' => 20000,
|
||||
'maschwertjuengerfuenf' => 12000,
|
||||
'maschwertaelterfuenf' => 13000,
|
||||
'allegereate' => 14000,
|
||||
'betriebsunterbrechung' => 15000,
|
||||
'umsatzjahrtransport' => 16000,
|
||||
'umsatzjahrbh' => 17000]);
|
||||
$this->engine->calc('test1');
|
||||
$this->assertEquals(82.09, $this->engine->getPrice());
|
||||
}
|
||||
}
|
||||
61
tests/Calc/OptionsRemoveTest.php
Normal file
61
tests/Calc/OptionsRemoveTest.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Tests\Calc;
|
||||
|
||||
use PSC\Library\Calc\Article;
|
||||
use PSC\Library\Calc\Engine;
|
||||
use PSC\Library\Calc\Option\Type\Base;
|
||||
use PSC\Library\Calc\PaperContainer\Container;
|
||||
|
||||
class OptionsRemoveTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @var Engine */
|
||||
protected $engine = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->engine = new Engine(new Container());
|
||||
$this->engine->loadString(file_get_contents(__DIR__ . '/../TestFiles/Calc/option_remove.xml'));
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$this->engine = null;
|
||||
}
|
||||
|
||||
public function testIfArticleCountIsCorrect()
|
||||
{
|
||||
$this->assertEquals(1, $this->engine->getArticles()->Count());
|
||||
}
|
||||
|
||||
public function testIfParserGetArticleCorrect()
|
||||
{
|
||||
$article = $this->engine->getArticleByName('test1');
|
||||
$this->assertEquals('test1', $article->getName());
|
||||
|
||||
$this->assertEquals(2, count($article->getOptions()));
|
||||
}
|
||||
|
||||
public function testIfOptionsNotValid()
|
||||
{
|
||||
$this->engine->setParameters([]);
|
||||
$this->engine->setFormulas([]);
|
||||
$this->engine->setVariables([]);
|
||||
$this->engine->calc('test1');
|
||||
|
||||
/** @var Article $article */
|
||||
$article = $this->engine->getArticleByName('test1');
|
||||
|
||||
/** @var Base $option */
|
||||
$option = $article->getOptionById('gebwert');
|
||||
|
||||
$this->assertTrue($option->isValid());
|
||||
|
||||
$this->engine->setVariables(['gebyn' => 2]);
|
||||
$this->engine->calc('test1');
|
||||
|
||||
$option = $article->getOptionById('gebwert');
|
||||
|
||||
$this->assertFalse($option->isValid());
|
||||
}
|
||||
|
||||
}
|
||||
22
tests/Parse/Edge/ContainerTest.php
Normal file
22
tests/Parse/Edge/ContainerTest.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Tests\Parse\Edge;
|
||||
|
||||
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
||||
|
||||
class ContainerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIfLoadsCorrect()
|
||||
{
|
||||
$node = simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Edges/collections.xml'));
|
||||
|
||||
$containerParser = new EdgeCollectionContainer($node);
|
||||
/** @var \PSC\Library\Calc\General\Type\EdgeCollectionContainer $container */
|
||||
$container = $containerParser->parse();
|
||||
|
||||
$this->assertCount(2, $container);
|
||||
|
||||
$this->assertCount(4, $container->getCollectionByName('gebyn'));
|
||||
$this->assertCount(2, $container->getCollectionByName('seiten'));
|
||||
|
||||
}
|
||||
}
|
||||
77
tests/Parse/Edge/SimpleTest.php
Normal file
77
tests/Parse/Edge/SimpleTest.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Tests\Parse\Edge;
|
||||
|
||||
use PSC\Library\Calc\General\Parser\Edge;
|
||||
|
||||
class SimpleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIfOneValue()
|
||||
{
|
||||
$node = simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Edges/simple.xml'));
|
||||
|
||||
$edgeParser = new Edge($node->grenze[2]);
|
||||
|
||||
/** @var \PSC\Library\Calc\General\Type\Edge $edge */
|
||||
$edge = $edgeParser->parse();
|
||||
$this->assertEquals(12, $edge->getPreis());
|
||||
$this->assertEquals(10, $edge->getPauschale());
|
||||
$this->assertEquals('$Vmaschwertjuengerfuenf$V/1000*0.900', $edge->getFormel());
|
||||
$this->assertEquals('$Vauflage$V', $edge->getCalcValue());
|
||||
$this->assertFalse($edge->isRegion());
|
||||
$this->assertEquals(34, $edge->getValues()[0]);
|
||||
|
||||
}
|
||||
|
||||
public function testIfRegionFrom()
|
||||
{
|
||||
$node = simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Edges/simple.xml'));
|
||||
|
||||
$edgeParser = new Edge($node->grenze[1]);
|
||||
|
||||
/** @var \PSC\Library\Calc\General\Type\Edge $edge */
|
||||
$edge = $edgeParser->parse();
|
||||
$this->assertEquals(12, $edge->getPreis());
|
||||
$this->assertEquals(10, $edge->getPauschale());
|
||||
$this->assertEquals('$Vmaschwertjuengerfuenf$V/1000*0.900', $edge->getFormel());
|
||||
$this->assertEquals('$Vauflage$V', $edge->getCalcValue());
|
||||
$this->assertTrue($edge->isRegion());
|
||||
$this->assertEquals(101, $edge->getFrom());
|
||||
|
||||
}
|
||||
|
||||
public function testIfRegionFromTo()
|
||||
{
|
||||
$node = simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Edges/simple.xml'));
|
||||
|
||||
$edgeParser = new Edge($node->grenze[0]);
|
||||
|
||||
/** @var \PSC\Library\Calc\General\Type\Edge $edge */
|
||||
$edge = $edgeParser->parse();
|
||||
$this->assertEquals(12, $edge->getPreis());
|
||||
$this->assertEquals(10, $edge->getPauschale());
|
||||
$this->assertEquals('$Vmaschwertjuengerfuenf$V/1000*0.900', $edge->getFormel());
|
||||
$this->assertEquals('$Vauflage$V', $edge->getCalcValue());
|
||||
$this->assertTrue($edge->isRegion());
|
||||
$this->assertEquals(1, $edge->getFrom());
|
||||
$this->assertEquals(100, $edge->getTo());
|
||||
|
||||
}
|
||||
|
||||
public function testIfCommaSeperated()
|
||||
{
|
||||
$node = simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Edges/simple.xml'));
|
||||
|
||||
$edgeParser = new Edge($node->grenze[3]);
|
||||
|
||||
/** @var \PSC\Library\Calc\General\Type\Edge $edge */
|
||||
$edge = $edgeParser->parse();
|
||||
$this->assertEquals(12, $edge->getPreis());
|
||||
$this->assertEquals(10, $edge->getPauschale());
|
||||
$this->assertEquals('$Vmaschwertjuengerfuenf$V/1000*0.900', $edge->getFormel());
|
||||
$this->assertEquals('$Vauflage$V', $edge->getCalcValue());
|
||||
$this->assertFalse($edge->isRegion());
|
||||
$this->assertEquals([12,23], $edge->getValues());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,7 +11,7 @@ class InputTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new Parser();
|
||||
/** @var Parser\Input $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Option/input.xml')));
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/input.xml')));
|
||||
|
||||
/** @var Input $element */
|
||||
$element = $obj->parse();
|
||||
@ -23,7 +23,7 @@ class InputTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new Parser();
|
||||
/** @var Parser\Input $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Option/input.xml')));
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/input.xml')));
|
||||
|
||||
/** @var Input $element */
|
||||
$element = $obj->parse();
|
||||
@ -13,7 +13,7 @@ class SelectTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new Parser();
|
||||
/** @var Parser\Select $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Option/select.xml')));
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml')));
|
||||
$obj->setPaperContainer(new PaperContainer());
|
||||
|
||||
/** @var Select $element */
|
||||
@ -26,7 +26,7 @@ class SelectTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$parser = new Parser();
|
||||
/** @var Select $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Option/select.xml')));
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml')));
|
||||
$obj->setPaperContainer(new PaperContainer());
|
||||
|
||||
/** @var Select $element */
|
||||
@ -42,7 +42,7 @@ class SelectTest extends \PHPUnit_Framework_TestCase
|
||||
public function testIfPaperContainerReturnsCorrectItems()
|
||||
{
|
||||
$paperContainer = new PaperContainer();
|
||||
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Option/Select/papierContainer.xml')));
|
||||
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/papierContainer.xml')));
|
||||
|
||||
$this->assertEquals(2, $paperContainer->getContainer()->count());
|
||||
|
||||
@ -66,11 +66,11 @@ class SelectTest extends \PHPUnit_Framework_TestCase
|
||||
$repository = new PaperRepostory();
|
||||
|
||||
$paperContainer = new PaperContainer();
|
||||
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Option/Select/papierContainer.xml')));
|
||||
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/papierContainer.xml')));
|
||||
|
||||
$parser = new Parser();
|
||||
/** @var Parser\Select $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ .'/../../TestFiles/Option/Select/selectPaperDB.xml')));
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectPaperDB.xml')));
|
||||
$obj->setPaperContainer($paperContainer);
|
||||
$obj->setPaperRepository($repository);
|
||||
|
||||
37
tests/Parse/Option/TextTest.php
Normal file
37
tests/Parse/Option/TextTest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Tests\Option\Type;
|
||||
|
||||
use PSC\Library\Calc\Option\Parser;
|
||||
use PSC\Library\Calc\Option\Type\Input;
|
||||
use PSC\Library\Calc\PaperContainer\Container;
|
||||
|
||||
class TextTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testIfCorrectType()
|
||||
{
|
||||
$parser = new Parser();
|
||||
/** @var Parser\Input $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/text.xml')));
|
||||
|
||||
/** @var Input $element */
|
||||
$element = $obj->parse();
|
||||
|
||||
$this->assertInstanceOf('PSC\Library\Calc\Option\Type\Text', $element);
|
||||
}
|
||||
|
||||
public function testIfCorrectAttributes()
|
||||
{
|
||||
$parser = new Parser();
|
||||
/** @var Parser\Input $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/text.xml')));
|
||||
|
||||
/** @var Input $element */
|
||||
$element = $obj->parse();
|
||||
|
||||
$this->assertInstanceOf('PSC\Library\Calc\Option\Type\Text', $element);
|
||||
$this->assertEquals('testtext', $element->getDefault());
|
||||
$this->assertEquals('t60', $element->getId());
|
||||
$this->assertEquals('', $element->getName());
|
||||
}
|
||||
|
||||
}
|
||||
23
tests/TestFiles/Calc/option_remove.xml
Normal file
23
tests/TestFiles/Calc/option_remove.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<kalkulation>
|
||||
|
||||
<artikel>
|
||||
<name>test1</name>
|
||||
<kommentar>test2</kommentar>
|
||||
|
||||
<option id="gebyn" name="" type="Select" default="1">
|
||||
<opt id="1" name="Ja">
|
||||
</opt>
|
||||
<opt id="2" name="Nein">
|
||||
</opt>
|
||||
</option>
|
||||
|
||||
<option id="gebwert" name="" type="Input" default="0" require="true" hidden="false">
|
||||
<gebyn>
|
||||
<grenze formel="">1</grenze>
|
||||
</gebyn>
|
||||
</option>
|
||||
|
||||
|
||||
</artikel>
|
||||
</kalkulation>
|
||||
14
tests/TestFiles/Edges/collections.xml
Normal file
14
tests/TestFiles/Edges/collections.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<grenzen>
|
||||
<gebyn>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">1-100</grenze>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">101-</grenze>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">34</grenze>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">12,23</grenze>
|
||||
</gebyn>
|
||||
<seiten>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">1-100</grenze>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">101-</grenze>
|
||||
</seiten>
|
||||
|
||||
</grenzen>
|
||||
7
tests/TestFiles/Edges/simple.xml
Normal file
7
tests/TestFiles/Edges/simple.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<gebyn>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">1-100</grenze>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">101-</grenze>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">34</grenze>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900" preis="12" pauschale="10" calc_value="$Vauflage$V">12,23</grenze>
|
||||
</gebyn>
|
||||
71
tests/TestFiles/General/complete1.xml
Normal file
71
tests/TestFiles/General/complete1.xml
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<kalkulation>
|
||||
|
||||
<artikel>
|
||||
<name>test1</name>
|
||||
<kommentar>test2</kommentar>
|
||||
|
||||
<option id="t10" name="Bitte füllen Sie alle Felder aus und lesen Sie die dazugehörigen, links eingeblendeten Erklärungen!" type="Text" default=""></option>
|
||||
|
||||
<option id="t20" name="" type="Text" default="Benutzen Sie ein eigenes Gebäude?"></option>
|
||||
<option id="gebyn" name="" type="Select" default="1">
|
||||
<opt id="1" name="Ja">
|
||||
</opt>
|
||||
<opt id="2" name="Nein">
|
||||
</opt>
|
||||
</option>
|
||||
|
||||
|
||||
<option id="t30" name="" type="Text" default="Bitte geben Sie den Neuwert Ihres Gebäudes/Ihrer Gebäude ein (in Euro gerundet auf Tsd.)"></option>
|
||||
<option id="gebwert" name="" type="Input" default="0" require="true" hidden="false">
|
||||
<gebyn>
|
||||
<grenze formel="$Vgebwert$V/1000*0.906">1</grenze>
|
||||
<grenze formel="">2</grenze>
|
||||
</gebyn>
|
||||
</option>
|
||||
|
||||
|
||||
<option id="t40" name="" type="Text" default="Bitte addieren Sie den Wert aller in Ihrem Unternehmen eingesetzten stationären Maschinen, die <b>jünger als fünf Jahre</b> sind (in Euro gerundet auf Tsd.)."></option>
|
||||
<option id="maschwertjuengerfuenf" name="" type="Input" default="0" require="true" hidden="false">
|
||||
<gebyn>
|
||||
<grenze formel="$Vmaschwertjuengerfuenf$V/1000*0.900">1-</grenze>
|
||||
</gebyn>
|
||||
</option>
|
||||
|
||||
<option id="t60" name="" type="Text" default="Bitte addieren Sie den Wert aller in Ihrem Unternehmen eingesetzten stationären Maschinen, die <b>älter als fünf Jahre</b> sind. (in Euro gerundet auf Tsd.)"></option>
|
||||
<option id="maschwertaelterfuenf" name="" type="Input" default="0" require="true" hidden="false">
|
||||
<gebyn>
|
||||
<grenze formel="$Vmaschwertaelterfuenf$V/1000*1.350">1-</grenze>
|
||||
</gebyn>
|
||||
</option>
|
||||
|
||||
<option id="t80" name="" type="Text" default="Bitte addieren Sie den Wert aller in Ihrem Unternehmen eingesetzten elektronischen Geräte, Vorräte und sonstigen Wertgegenstände, die von Bedeutung sind. (in Euro gerundet auf Tsd.)"></option>
|
||||
<option id="allegereate" name="" type="Input" default="0" require="true" hidden="false">
|
||||
<gebyn>
|
||||
<grenze formel="$Vallegereate$V/1000*0.971">1-</grenze>
|
||||
</gebyn>
|
||||
</option>
|
||||
|
||||
<option id="t100" name="" type="Text" default="Zur Berechnung des Versicherungsschutzes für die Betriebsunterbrechung verdoppeln Sie bitte den Gesamtumsatz des vergangenen Jahres und tragen Sie den Wert in das vorgegebene Feld ein. (in Euro gerundet auf Tsd.)"></option>
|
||||
<option id="betriebsunterbrechung" name="" type="Input" default="0" require="true" hidden="false">
|
||||
<gebyn>
|
||||
<grenze formel="$Vbetriebsunterbrechung$V/1000*0.590">1-</grenze>
|
||||
</gebyn>
|
||||
</option>
|
||||
|
||||
<option id="t120" name="" type="Text" default="Zur Berechnung des Versicherungsschutzes für die Transportversicherung tragen Sie bitte den Gesamtumsatz des vergangenen Jahres ein. (in Euro gerundet auf Tsd.)"></option>
|
||||
<option id="umsatzjahrtransport" name="" type="Input" default="0" require="true" hidden="false">
|
||||
<gebyn>
|
||||
<grenze formel="$Vumsatzjahrtransport$V/1000*0.250">1-</grenze>
|
||||
</gebyn>
|
||||
</option>
|
||||
|
||||
<option id="t140" name="" type="Text" default="Zur Berechnung des Versicherungsschutzes für die Betriebshaftpflichtversicherung tragen Sie bitte den Gesamtumsatz des vergangenen Jahres ein. (in Euro gerundet auf Tsd.)"></option>
|
||||
<option id="umsatzjahrbh" name="" type="Input" default="0" require="true" hidden="false">
|
||||
<gebyn>
|
||||
<grenze formel="$Vumsatzjahrbh$V/1000*0.540">1-</grenze>
|
||||
</gebyn>
|
||||
</option>
|
||||
|
||||
</artikel>
|
||||
</kalkulation>
|
||||
2
tests/TestFiles/Option/text.xml
Normal file
2
tests/TestFiles/Option/text.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<option id="t60" name="" type="Text" default="testtext"></option>
|
||||
Loading…
Reference in New Issue
Block a user