From fb22117f10abe33f69e0348d6be8593eebfdaff0 Mon Sep 17 00:00:00 2001 From: swdee Date: Mon, 9 Mar 2026 10:48:57 +1300 Subject: [PATCH 1/3] fix to remove fallback from LCSC barcode part resolver as the PC code is the ultimate source of truth. --- .../BarcodeScanner/BarcodeScanResultHandler.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php b/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php index 45fdd16ed..260506ae4 100644 --- a/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php +++ b/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php @@ -217,7 +217,6 @@ private function resolvePartFromVendor(EIGP114BarcodeScanResult $barcodeScan) : * Resolve LCSC barcode -> Part. * Strategy: * 1) Try providerReference.provider_id == pc (LCSC "Cxxxxxx") if you store it there - * 2) Fallback to manufacturer_product_number == pm (MPN) * Returns first match (consistent with EIGP114 logic) */ private function resolvePartFromLCSC(LCSCBarcodeScanResult $barcodeScan): ?Part @@ -231,13 +230,8 @@ private function resolvePartFromLCSC(LCSCBarcodeScanResult $barcodeScan): ?Part } } - // Fallback to MPN (pm) - $pm = $barcodeScan->mpn; // e.g. RC0402FR-071ML - if (!$pm) { - return null; - } - - return $this->em->getRepository(Part::class)->getPartByMPN($pm); + // part does not exist in DB + return null; } From 332fae055b6561eb5040194427bf9ae22f977deb Mon Sep 17 00:00:00 2001 From: swdee Date: Thu, 12 Mar 2026 11:30:50 +1300 Subject: [PATCH 2/3] added in fallback of LCSC barcode scan to search on supplier part number, which scans the orderdetails DB table --- .../LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php b/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php index 260506ae4..3cf01249d 100644 --- a/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php +++ b/src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php @@ -142,7 +142,8 @@ public function resolveEntity(BarcodeScanResultInterface $barcodeScan): Part|Par } if ($barcodeScan instanceof LCSCBarcodeScanResult) { - return $this->resolvePartFromLCSC($barcodeScan); + return $this->resolvePartFromLCSC($barcodeScan) + ?? $this->em->getRepository(Part::class)->getPartBySPN($barcodeScan->mpn); } if ($barcodeScan instanceof AmazonBarcodeScanResult) { From e11c73aa6d23a909f1e462570ae924c67cfb49e3 Mon Sep 17 00:00:00 2001 From: swdee Date: Thu, 12 Mar 2026 11:53:49 +1300 Subject: [PATCH 3/3] fix LCSC barecode scan result test erroring on empty part number string test data --- .../BarcodeScanner/BarcodeScanResultHandlerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandlerTest.php b/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandlerTest.php index 95313e139..1cfe76b55 100644 --- a/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandlerTest.php +++ b/tests/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandlerTest.php @@ -115,8 +115,8 @@ public function testEIGPBarcodeResolvePartOrNullReturnsNullWhenNotFound(): void public function testLCSCBarcodeResolvePartOrNullReturnsNullWhenNotFound(): void { $scan = new LCSCBarcodeScanResult( - fields: ['pc' => 'C0000000', 'pm' => ''], - rawInput: '{pc:C0000000,pm:}' + fields: ['pc' => 'C0000000', 'pm' => 'NON_EXISTENT_MPN_12345'], + rawInput: '{pc:C0000000,pm:NON_EXISTENT_MPN_12345}' ); $this->assertNull($this->service->resolvePart($scan));