Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
95.83% |
46 / 48 |
|
96.43% |
27 / 28 |
CRAP | |
0.00% |
0 / 1 |
| AuftragXml | |
95.83% |
46 / 48 |
|
96.43% |
27 / 28 |
31 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAuftragnr | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setValue | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getDatum | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAuftragid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getEndbetrag | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getHerkunft | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getBestellnummer | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setSteuerInkl | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setSteuerZzgl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setSteuerOhne | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setSteuer | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setFreifeld | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| setGewicht | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setDatum | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| setDatumString | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| setLieferart | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setZahlweise | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setBemerkung | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getLieferart | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getZahlweise | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getBemerkung | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setEndebetrag | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| addAuftragspositon | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| setAuftragspositionen | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| countAuftragspositionen | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAposData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Satag\AmicronEntityBundle\Struct\Xml\Import; |
| 4 | |
| 5 | use Satag\AmicronEntityBundle\Traits\DecimalEntity; |
| 6 | use Satag\AmicronEntityBundle\Util\Amicron; |
| 7 | |
| 8 | class AuftragXml |
| 9 | { |
| 10 | use DecimalEntity; |
| 11 | public const STEUER_INKL = 'J'; |
| 12 | public const STEUER_ZZGL = 'N'; |
| 13 | public const STEUER_OHNE = '0'; |
| 14 | |
| 15 | public const HERKUNFT_DATEI = 'D'; |
| 16 | public const HERKUNFT_SHOP1 = 'S1'; |
| 17 | public const HERKUNFT_SHOP2 = 'S2'; |
| 18 | public const HERKUNFT_SHOP3 = 'S3'; |
| 19 | public const HERKUNFT_SHOP4 = 'S4'; |
| 20 | public const HERKUNFT_SHOP5 = 'S5'; |
| 21 | public const HERKUNFT_SHOP6 = 'S6'; |
| 22 | public const HERKUNFT_SHOP7 = 'S7'; |
| 23 | public const HERKUNFT_SHOP8 = 'S8'; |
| 24 | public const HERKUNFT_SHOP9 = 'S9'; |
| 25 | public const HERKUNFT_SHOP10 = 'S10'; |
| 26 | |
| 27 | /** |
| 28 | * @var array<string, int|string> |
| 29 | */ |
| 30 | private array $data = [ |
| 31 | ]; |
| 32 | |
| 33 | /** |
| 34 | * @var array<int, array{Fields: array<string, int|string>}> |
| 35 | */ |
| 36 | private array $aposData = []; |
| 37 | |
| 38 | private ?\DateTime $datum = null; |
| 39 | |
| 40 | private ?float $endbetrag = null; |
| 41 | |
| 42 | /** |
| 43 | * @param self::HERKUNFT_* $herkunft |
| 44 | */ |
| 45 | public function __construct( |
| 46 | protected string $herkunft, |
| 47 | protected string $herkunftAuftragId, |
| 48 | protected ?string $herkunftAuftragBestellnummer = null, |
| 49 | protected ?string $amicronAuftragsnummer = null, |
| 50 | ) { |
| 51 | } |
| 52 | |
| 53 | public function getAuftragnr(): ?string |
| 54 | { |
| 55 | return $this->amicronAuftragsnummer; |
| 56 | } |
| 57 | |
| 58 | public function setValue(string $key, mixed $value): self |
| 59 | { |
| 60 | $this->data[$key] = $value; |
| 61 | |
| 62 | return $this; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @return array<string, int|string> |
| 67 | */ |
| 68 | public function getData(): array |
| 69 | { |
| 70 | return $this->data; |
| 71 | } |
| 72 | |
| 73 | public function getDatum(): ?\DateTime |
| 74 | { |
| 75 | return $this->datum; |
| 76 | } |
| 77 | |
| 78 | public function getAuftragid(): ?string |
| 79 | { |
| 80 | return $this->herkunftAuftragId; |
| 81 | } |
| 82 | |
| 83 | public function getEndbetrag(): ?float |
| 84 | { |
| 85 | return $this->endbetrag; |
| 86 | } |
| 87 | |
| 88 | public function getHerkunft(): string |
| 89 | { |
| 90 | return $this->herkunft; |
| 91 | } |
| 92 | |
| 93 | public function getBestellnummer(): ?string |
| 94 | { |
| 95 | return $this->herkunftAuftragBestellnummer; |
| 96 | } |
| 97 | |
| 98 | public function setSteuerInkl(): self |
| 99 | { |
| 100 | $this->setSteuer(self::STEUER_INKL); |
| 101 | |
| 102 | return $this; |
| 103 | } |
| 104 | |
| 105 | public function setSteuerZzgl(): self |
| 106 | { |
| 107 | return $this->setSteuer(self::STEUER_ZZGL); |
| 108 | } |
| 109 | |
| 110 | public function setSteuerOhne(): self |
| 111 | { |
| 112 | return $this->setSteuer(self::STEUER_OHNE); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * @param self::STEUER_* $steuer |
| 117 | */ |
| 118 | private function setSteuer(string $steuer): self |
| 119 | { |
| 120 | $this->data['STEUERINKL'] = $steuer; |
| 121 | |
| 122 | return $this; |
| 123 | } |
| 124 | |
| 125 | public function setFreifeld(int $nummer, string $inhalt): self |
| 126 | { |
| 127 | if ($nummer < 1 || $nummer > 12) { |
| 128 | throw new \OutOfRangeException('Freifeld ' . $nummer . ' existiert nicht'); |
| 129 | } |
| 130 | $this->data['FREIFELD' . $nummer] = $inhalt; |
| 131 | |
| 132 | return $this; |
| 133 | } |
| 134 | |
| 135 | public function setGewicht(float $kg): self |
| 136 | { |
| 137 | $this->data['GEWICHT'] = (string) round($kg, 6); |
| 138 | |
| 139 | return $this; |
| 140 | } |
| 141 | |
| 142 | public function setDatum(\DateTime $datum): self |
| 143 | { |
| 144 | $this->data['DATUM'] = Amicron::dateStamp($datum); |
| 145 | $this->datum = $datum; |
| 146 | |
| 147 | return $this; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Format: Y.m.d |
| 152 | * |
| 153 | * @return $this |
| 154 | */ |
| 155 | public function setDatumString(string $string): self |
| 156 | { |
| 157 | $datum = \DateTime::createFromFormat('d.m.Y H:i:s', $string . ' 00:00:00'); |
| 158 | if ($datum) { |
| 159 | $this->datum = $datum; |
| 160 | $this->data['DATUM'] = Amicron::dateStamp($datum); |
| 161 | } |
| 162 | |
| 163 | return $this; |
| 164 | } |
| 165 | |
| 166 | public function setLieferart(string $string): self |
| 167 | { |
| 168 | $this->data['LIEFERART'] = $string; |
| 169 | |
| 170 | return $this; |
| 171 | } |
| 172 | |
| 173 | public function setZahlweise(string $string): self |
| 174 | { |
| 175 | $this->data['ZAHLWEISE'] = $string; |
| 176 | |
| 177 | return $this; |
| 178 | } |
| 179 | |
| 180 | public function setBemerkung(string $bemerkung): self |
| 181 | { |
| 182 | $this->data['BEMERKUNG'] = $bemerkung; |
| 183 | |
| 184 | return $this; |
| 185 | } |
| 186 | |
| 187 | public function getLieferart(): string |
| 188 | { |
| 189 | return (string) ($this->data['LIEFERART'] ?? ''); |
| 190 | } |
| 191 | |
| 192 | public function getZahlweise(): string |
| 193 | { |
| 194 | return (string) ($this->data['ZAHLWEISE'] ?? ''); |
| 195 | } |
| 196 | |
| 197 | public function getBemerkung(): string |
| 198 | { |
| 199 | return (string) ($this->data['BEMERKUNG'] ?? ''); |
| 200 | } |
| 201 | |
| 202 | public function setEndebetrag(float $betrag): self |
| 203 | { |
| 204 | $this->data['ENDBETRAG'] = $this->toComma($betrag); |
| 205 | $this->endbetrag = $betrag; |
| 206 | |
| 207 | return $this; |
| 208 | } |
| 209 | |
| 210 | public function addAuftragspositon(AuftragspositionXml $auftragspositionXml): self |
| 211 | { |
| 212 | $this->aposData[] = $auftragspositionXml->getData(); |
| 213 | |
| 214 | return $this; |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * @param AuftragspositionXml[] $auftragspositionen |
| 219 | */ |
| 220 | public function setAuftragspositionen(array $auftragspositionen): self |
| 221 | { |
| 222 | $this->aposData = array_map(static fn (AuftragspositionXml $apos) => $apos->getData(), $auftragspositionen); |
| 223 | |
| 224 | return $this; |
| 225 | } |
| 226 | |
| 227 | public function countAuftragspositionen(): int |
| 228 | { |
| 229 | return \count($this->aposData); |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * @return array<int, array{Fields: array<string, int|string>}> |
| 234 | */ |
| 235 | public function getAposData(): array |
| 236 | { |
| 237 | return $this->aposData; |
| 238 | } |
| 239 | } |