Merge remote-tracking branch 'origin/master'

This commit is contained in:
Jan Böhmer 2026-03-15 21:47:21 +01:00
commit 44bb132de1
2 changed files with 5 additions and 10 deletions

View file

@ -217,8 +217,8 @@ final readonly class BarcodeScanResultHandler
* Resolve LCSC barcode -> Part. * Resolve LCSC barcode -> Part.
* Strategy: * Strategy:
* 1) Try providerReference.provider_id == pc (LCSC "Cxxxxxx") if you store it there * 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) * Returns first match (consistent with EIGP114 logic)
* 2) Fallback to search across supplier part number (SPN)
*/ */
private function resolvePartFromLCSC(LCSCBarcodeScanResult $barcodeScan): ?Part private function resolvePartFromLCSC(LCSCBarcodeScanResult $barcodeScan): ?Part
{ {
@ -231,13 +231,8 @@ final readonly class BarcodeScanResultHandler
} }
} }
// Fallback to MPN (pm) // fallback to search by SPN
$pm = $barcodeScan->mpn; // e.g. RC0402FR-071ML return $this->em->getRepository(Part::class)->getPartBySPN($pc);
if (!$pm) {
return null;
}
return $this->em->getRepository(Part::class)->getPartByMPN($pm);
} }

View file

@ -115,8 +115,8 @@ final class BarcodeScanResultHandlerTest extends KernelTestCase
public function testLCSCBarcodeResolvePartOrNullReturnsNullWhenNotFound(): void public function testLCSCBarcodeResolvePartOrNullReturnsNullWhenNotFound(): void
{ {
$scan = new LCSCBarcodeScanResult( $scan = new LCSCBarcodeScanResult(
fields: ['pc' => 'C0000000', 'pm' => ''], fields: ['pc' => 'C0000000', 'pm' => 'NON_EXISTENT_MPN_12345'],
rawInput: '{pc:C0000000,pm:}' rawInput: '{pc:C0000000,pm:NON_EXISTENT_MPN_12345}'
); );
$this->assertNull($this->service->resolvePart($scan)); $this->assertNull($this->service->resolvePart($scan));