@@ -173,21 +173,17 @@ public function getPositionByName(string $name): Position
173173 public function getPositions (): array
174174 {
175175 $ positions = [];
176-
177- $ rawPos = explode ("\n" , $ this ->raw_receipt );
178176 $ lastPosition = NULL ;
179177
180178 for ($ lineNr = $ this ->getProductStartLine (); $ lineNr <= $ this ->getProductEndLine (); $ lineNr ++) {
181- $ line = trim ($ rawPos [$ lineNr ]);
182-
183179 if ($ this ->isProductLine ($ lineNr )) {
184180
185181 if ($ lastPosition !== NULL ) {
186182 $ positions [] = $ lastPosition ;
187183 $ lastPosition = NULL ;
188184 }
189185
190- if (preg_match ('/(.*) (-?\d{1,},\d{2}) (.{1})/ ' , $ line , $ match )) {
186+ if (preg_match ('/(.*) (-?\d{1,},\d{2}) (.{1})/ ' , $ this -> expl_receipt [ $ lineNr ] , $ match )) {
191187 $ lastPosition = new Position ();
192188 $ lastPosition ->setName (trim ($ match [1 ]));
193189 $ lastPosition ->setPriceTotal ((float )str_replace (', ' , '. ' , $ match [2 ]));
@@ -196,17 +192,17 @@ public function getPositions(): array
196192
197193 } else if ($ this ->isAmountLine ($ lineNr )) {
198194
199- if (preg_match ('/(-?\d{1,}) Stk x *(-?\d{1,},\d{2})/ ' , $ line , $ match )) {
195+ if (preg_match ('/(-?\d{1,}) Stk x *(-?\d{1,},\d{2})/ ' , $ this -> expl_receipt [ $ lineNr ] , $ match )) {
200196 $ lastPosition ->setAmount ((int )$ match [1 ]);
201197 $ lastPosition ->setPriceSingle ((float )str_replace (', ' , '. ' , $ match [2 ]));
202198 } else throw new ReceiptParseException ("Error while parsing Amount line " );
203199
204200 } else if ($ this ->isWeightLine ($ lineNr )) {
205201
206- if (preg_match ('/(-?\d{1,},\d{3}) kg x *(-?\d{1,},\d{2}) EUR/ ' , $ line , $ match )) {
202+ if (preg_match ('/(-?\d{1,},\d{3}) kg x *(-?\d{1,},\d{2}) EUR/ ' , $ this -> expl_receipt [ $ lineNr ] , $ match )) {
207203 $ lastPosition ->setWeight ((float )str_replace (', ' , '. ' , $ match [1 ]));
208204 $ lastPosition ->setPriceSingle ((float )str_replace (', ' , '. ' , $ match [2 ]));
209- } else if (preg_match ('/Handeingabe E-Bon *(-?\d{1,},\d{3}) kg/ ' , $ line , $ match )) {
205+ } else if (preg_match ('/Handeingabe E-Bon *(-?\d{1,},\d{3}) kg/ ' , $ this -> expl_receipt [ $ lineNr ] , $ match )) {
210206 $ lastPosition ->setWeight ((float )str_replace (', ' , '. ' , $ match [1 ]));
211207 } else throw new ReceiptParseException ("Error while parsing Weight line " );
212208
0 commit comments