Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit 5e3feb7

Browse files
authored
🐛 Fix incorrect trimmed products with external concessional (#5)
fixes #1
1 parent a9f9668 commit 5e3feb7

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/Receipt.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function getPositions(): array {
200200

201201
if(preg_match('/(.*) (-?\d+,\d{2}) (.{1})/', $this->expl_receipt[$lineNr], $match)) {
202202
$lastPosition = new Position();
203-
$lastPosition->setName(trim($match[1]));
203+
$lastPosition->setName(explode(' ', trim($match[1]))[0]);
204204
$lastPosition->setPriceTotal((float)str_replace(',', '.', $match[2]));
205205
$lastPosition->setTaxCode($match[3]);
206206
} elseif(preg_match('/ (\d{5,})/', $this->expl_receipt[$lineNr], $match)) {

tests/ReceiptParsingTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public function testNegativeTotalAmount(): void {
2727
public function testReceiptWithCouponLine(): void {
2828
$receipt = Parser::parseFromText(file_get_contents(__DIR__ . '/receipts/coupon.txt'));
2929
$this->assertCount(1, $receipt->getPositions());
30-
$this->assertEquals('GUTSCHEINW50 V300', $receipt->getPositions()[0]->getName());
31-
//TODO: Name is still a bug. See issue #1
30+
$this->assertEquals('GUTSCHEINW50', $receipt->getPositions()[0]->getName());
3231
}
3332

3433
/**

0 commit comments

Comments
 (0)