diff --git a/src/Option/Type/Base.php b/src/Option/Type/Base.php
index 17900e1..3c21163 100644
--- a/src/Option/Type/Base.php
+++ b/src/Option/Type/Base.php
@@ -285,4 +285,13 @@ class Base
{
$this->amount = $amount;
}
+
+ public function toArray() : array {
+ return [
+ 'id' => $this->getId(),
+ 'name' => $this->getName(),
+ 'type' => $this->getType(),
+ 'valid' => $this->isValid()
+ ];
+ }
}
\ No newline at end of file
diff --git a/src/Option/Type/Checkbox.php b/src/Option/Type/Checkbox.php
index 2f2754b..f1dc357 100644
--- a/src/Option/Type/Checkbox.php
+++ b/src/Option/Type/Checkbox.php
@@ -27,7 +27,21 @@ class Checkbox extends Base
*/
public function processValue()
{
-
+ if(is_array($this->rawValue)) {
+ /** @var \PSC\Library\Calc\Option\Type\Checkbox\Opt $item */
+ foreach($this->options as $item) {
+ if(in_array($item->getId(), $this->rawValue)) {
+ $item->setIsSelected(true);
+ }
+ }
+ }elseif($this->rawValue != "") {
+ /** @var \PSC\Library\Calc\Option\Type\Checkbox\Opt $item */
+ foreach($this->options as $item) {
+ if($item->getId() == $this->rawValue) {
+ $item->setIsSelected(true);
+ }
+ }
+ }
}
/**
@@ -40,10 +54,24 @@ class Checkbox extends Base
public function getSelectedOptions()
{
+ $tmp = [];
+
/** @var Opt $opt */
foreach($this->getOptions() as $opt) {
- if($opt->isSelected()) return $opt;
+ if($opt->isSelected()) $tmp[] = $opt;
}
+
+ return $tmp;
+ }
+
+ public function getValue()
+ {
+ $tmp = array();
+ foreach($this->getSelectedOptions() as $option) {
+ $tmp[] = $option->getLabel();
+ }
+
+ return implode(", ", $tmp);
}
}
\ No newline at end of file
diff --git a/tests/Customer/K/CalcTest.php b/tests/Customer/K/CalcTest.php
new file mode 100644
index 0000000..3e3ae0d
--- /dev/null
+++ b/tests/Customer/K/CalcTest.php
@@ -0,0 +1,46 @@
+parse(simplexml_load_string(file_get_contents(__DIR__ . '/papierContainer.xml')));
+
+ $this->engine = new Engine();
+ $this->engine->setPaperContainer($paperContainer);
+ $this->engine->setPaperRepository($repository);
+ $this->engine->setFormulas(file_get_contents(__DIR__ . '/formels.txt'));
+ $this->engine->setParameters(file_get_contents(__DIR__ . '/parameters.txt'));
+ $this->engine->setTemplates(file_get_contents(__DIR__ . '/calcTemplates.xml'));
+
+ $this->engine->loadString(file_get_contents(__DIR__ . '/calc.xml'));
+
+ }
+
+ public function tearDown()
+ {
+ $this->engine = null;
+ }
+
+ public function testCalcPlan()
+ {
+ $this->engine->setVariable('anz_ausfuhren', 2500);
+ /** @var Select $option */
+ $option = $this->engine->getArticle()->getOptionById('tarif');
+ var_dump($option->getSelectedOption());
+ }
+}
\ No newline at end of file
diff --git a/tests/Customer/K/calc.xml b/tests/Customer/K/calc.xml
new file mode 100644
index 0000000..d6eecd6
--- /dev/null
+++ b/tests/Customer/K/calc.xml
@@ -0,0 +1,529 @@
+
+
+
+ Import Filing CHIEF
+ Testkalkulation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ //Neue Lizenz CSP Badge 28.22.2020
+
+
+
+
+
+
+
+
+
+
+
+
+ //Diese Option gibt es für Deutschland noch nicht!!
+ //Zum Start noch nicht verfügbar
+
+
+
+ //Diese Option gibt es nur für die Schweiz
+
+
+ //Diese Option gibt es nur für Belgien
+
+
+ //Diese Option gibt es nur für Deutschland
+
+
+ //Diese Option gibt es nur für Deutschland -> Tarifwechsel, nicht in Starter möglich
+
+
+
+ //Diese Option gibt es nur für Niederlande
+
+
+ //Diese Option gibt es nur für UK
+
+
+
+
+
+ //Diese Option gibt es OHNE Aufpreis; Projektarbeit, deshalb keine Bestellung möglich
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ //Berechnung des Tarifmodells - Nach der Berechnung des Monatspreises
+
+
+
+
+
+
+
+
+
+
+
+
+
+ // 1. Nur für Jahressumme
+
+
+
+
+
+
+
+ // CSP Badge pro Monat (28.11.2020)
+
+
+
+
+
+ // CSP Badge pro Transaktion = 1$ (28.11.2020)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ // 2. Nur für Jahressumme
+
+
+ // Jahressumme nur für Angebotsausgabe
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/Customer/K/calcTemplates.xml b/tests/Customer/K/calcTemplates.xml
new file mode 100644
index 0000000..093d936
--- /dev/null
+++ b/tests/Customer/K/calcTemplates.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/tests/Customer/K/formels.txt b/tests/Customer/K/formels.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tests/Customer/K/papierContainer.xml b/tests/Customer/K/papierContainer.xml
new file mode 100644
index 0000000..8ec6de3
--- /dev/null
+++ b/tests/Customer/K/papierContainer.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/tests/Customer/K/parameters.txt b/tests/Customer/K/parameters.txt
new file mode 100644
index 0000000..0d2b4f7
--- /dev/null
+++ b/tests/Customer/K/parameters.txt
@@ -0,0 +1,80 @@
+// AEB Exportfilling
+
+//Tairfe pro Monat Export
+$tarif_starter=33;
+$tarif_basic=92;
+$tarif_business=356;
+$tarif_enterprise=1843;
+
+//Tairfe pro Monat Export Brexit
+$tarif_starter_brexit=33;
+$tarif_basic_brexit=92;
+$tarif_business_brexit=356;
+$tarif_enterprise_brexit=1843;
+
+//Schwellwerte für Tarifwechsel Export
+//bis jetzt nich verwendbar in Grenzen
+$schwellwert_starter=158;
+$schwellwert_basic=1374;
+$schwellwert_business=13749;
+$schwellwert_enterprise_ab=13750;
+
+//enthaltene Ausfuhren Export
+$enthaltene_ausfuhren_starter=25;
+$enthaltene_ausfuhren_basic=250;
+$enthaltene_ausfuhren_business=2500;
+$enthaltene_ausfuhren_enterprise=25000;
+
+//enthaltene Ausfuhren Export Brexit
+$enthaltene_ausfuhren_starter_brexit=50;
+$enthaltene_ausfuhren_basic_brexit=250;
+$enthaltene_ausfuhren_business_brexit=2500;
+$enthaltene_ausfuhren_enterprise_brexit=25000;
+
+// Setup-Kosten
+$setup_exportfilling=600;
+
+//SAP Setup einmalig Export filing Chief
+$sap_export_filing_chief_ecc=5700;
+$sap_export_filing_chief_hana=7600;
+
+//SAP monatlich Export filing Chief
+$sap_export_filing_chief_monatlich=225;
+
+// Setup-Kosten Export Brexit
+$setup_export_starter_brexit=0;
+$setup_export_basic_brexit=0;
+$setup_export_business_brexit=0;
+$setup_export_enterprise_brexit=600;
+
+//Kosten zusätzliche Ausfuhren Export
+$kosten_ausfuhren_starter=3.60;
+$kosten_ausfuhren_basic=2.82;
+$kosten_ausfuhren_business=1.59;
+$kosten_ausfuhren_enterprise=0.88;
+
+//Kosten zusätzliche Ausfuhren Export Brexit
+$kosten_ausfuhren_starter_brexit=3.60;
+$kosten_ausfuhren_basic_brexit=2.82;
+$kosten_ausfuhren_business_brexit=1.59;
+$kosten_ausfuhren_enterprise_brexit=0.88;
+
+//AEB Importfilling
+//Tarife pro Monat Import
+$tarif_basic_import=92;
+$tarif_business_import=626;
+$tarif_enterprise_import=1843;
+
+//enthaltene Ausfuhren Import
+$enthaltene_ausfuhren_basic_import=100;
+$enthaltene_ausfuhren_business_import=2500;
+$enthaltene_ausfuhren_enterprise_import=10000;
+
+//Kosten zusätzliche Ausfuhren Import
+$kosten_ausfuhren_basic_import=5.34;
+$kosten_ausfuhren_business_import=3.89;
+$kosten_ausfuhren_enterprise_import=2.21;
+
+// Lizenzkosten CSP Badge Licence
+$csp_badge_licence=127.5;
+$csp_per_declaration=1;
\ No newline at end of file
diff --git a/tests/Customer/L/CalcTest.php b/tests/Customer/L/CalcTest.php
new file mode 100644
index 0000000..a4467bd
--- /dev/null
+++ b/tests/Customer/L/CalcTest.php
@@ -0,0 +1,53 @@
+parse(simplexml_load_string(file_get_contents(__DIR__ . '/papierContainer.xml')));
+
+ $this->engine = new Engine();
+ $this->engine->setPaperContainer($paperContainer);
+ $this->engine->setPaperRepository($repository);
+ $this->engine->setFormulas(file_get_contents(__DIR__ . '/formels.txt'));
+ $this->engine->setParameters(file_get_contents(__DIR__ . '/parameters.txt'));
+ $this->engine->setTemplates(file_get_contents(__DIR__ . '/calcTemplates.xml'));
+
+ $this->engine->loadString(file_get_contents(__DIR__ . '/calc.xml'));
+
+ }
+
+ public function tearDown()
+ {
+ $this->engine = null;
+ }
+
+ public function testCalcPlan()
+ {
+ $article = $this->engine->getArticle();
+ $option = $article->getOptionById('kalender_typ2');
+ $this->assertEquals("BASIC, PERFORMANCE", $option->getValue());
+ }
+
+ public function testCalcVarPlan()
+ {
+ $this->engine->setVariable('kalender_typ2', ["1", "4"]);
+ $article = $this->engine->getArticle();
+ $option = $article->getOptionById('kalender_typ2');
+ $this->assertEquals("BASIC, PRIMARY", $option->getValue());
+ }
+}
\ No newline at end of file
diff --git a/tests/Customer/L/calc.xml b/tests/Customer/L/calc.xml
new file mode 100644
index 0000000..569fff4
--- /dev/null
+++ b/tests/Customer/L/calc.xml
@@ -0,0 +1,33 @@
+
+
+
+ Kalkulation EduPlaner
+ Gratis Schulplaner
+
+
+
+
+ // EINGABE *******************************************************************************
+
+
+
+
+
+
+
+ // KALKULATION ***************************************************************************
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/Customer/L/calcTemplates.xml b/tests/Customer/L/calcTemplates.xml
new file mode 100644
index 0000000..093d936
--- /dev/null
+++ b/tests/Customer/L/calcTemplates.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/tests/Customer/L/formels.txt b/tests/Customer/L/formels.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tests/Customer/L/papierContainer.xml b/tests/Customer/L/papierContainer.xml
new file mode 100644
index 0000000..8ec6de3
--- /dev/null
+++ b/tests/Customer/L/papierContainer.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/tests/Customer/L/parameters.txt b/tests/Customer/L/parameters.txt
new file mode 100644
index 0000000..e69de29