Skip to content

Commit 44bb132

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 95f3fc6 + 60c5e24 commit 44bb132

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandler.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ private function resolvePartFromVendor(EIGP114BarcodeScanResult $barcodeScan) :
217217
* Resolve LCSC barcode -> Part.
218218
* Strategy:
219219
* 1) Try providerReference.provider_id == pc (LCSC "Cxxxxxx") if you store it there
220-
* 2) Fallback to manufacturer_product_number == pm (MPN)
221220
* Returns first match (consistent with EIGP114 logic)
221+
* 2) Fallback to search across supplier part number (SPN)
222222
*/
223223
private function resolvePartFromLCSC(LCSCBarcodeScanResult $barcodeScan): ?Part
224224
{
@@ -231,13 +231,8 @@ private function resolvePartFromLCSC(LCSCBarcodeScanResult $barcodeScan): ?Part
231231
}
232232
}
233233

234-
// Fallback to MPN (pm)
235-
$pm = $barcodeScan->mpn; // e.g. RC0402FR-071ML
236-
if (!$pm) {
237-
return null;
238-
}
239-
240-
return $this->em->getRepository(Part::class)->getPartByMPN($pm);
234+
// fallback to search by SPN
235+
return $this->em->getRepository(Part::class)->getPartBySPN($pc);
241236
}
242237

243238

tests/Services/LabelSystem/BarcodeScanner/BarcodeScanResultHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ public function testEIGPBarcodeResolvePartOrNullReturnsNullWhenNotFound(): void
115115
public function testLCSCBarcodeResolvePartOrNullReturnsNullWhenNotFound(): void
116116
{
117117
$scan = new LCSCBarcodeScanResult(
118-
fields: ['pc' => 'C0000000', 'pm' => ''],
119-
rawInput: '{pc:C0000000,pm:}'
118+
fields: ['pc' => 'C0000000', 'pm' => 'NON_EXISTENT_MPN_12345'],
119+
rawInput: '{pc:C0000000,pm:NON_EXISTENT_MPN_12345}'
120120
);
121121

122122
$this->assertNull($this->service->resolvePart($scan));

0 commit comments

Comments
 (0)