mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-18 05:08:13 +01:00
Allow to scan gtin barcodes and find parts via it
This commit is contained in:
@@ -92,6 +92,9 @@ final class BarcodeScanHelper
|
||||
if ($type === BarcodeSourceType::EIGP114) {
|
||||
return $this->parseEIGP114Barcode($input);
|
||||
}
|
||||
if ($type === BarcodeSourceType::GTIN) {
|
||||
return $this->parseGTINBarcode($input);
|
||||
}
|
||||
|
||||
//Null means auto and we try the different formats
|
||||
$result = $this->parseInternalBarcode($input);
|
||||
@@ -117,9 +120,19 @@ final class BarcodeScanHelper
|
||||
return $result;
|
||||
}
|
||||
|
||||
//If the result is a valid GTIN barcode, we can parse it directly
|
||||
if (GTINBarcodeScanResult::isValidGTIN($input)) {
|
||||
return $this->parseGTINBarcode($input);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException('Unknown barcode');
|
||||
}
|
||||
|
||||
private function parseGTINBarcode(string $input): GTINBarcodeScanResult
|
||||
{
|
||||
return new GTINBarcodeScanResult($input);
|
||||
}
|
||||
|
||||
private function parseEIGP114Barcode(string $input): EIGP114BarcodeScanResult
|
||||
{
|
||||
return EIGP114BarcodeScanResult::parseFormat06Code($input);
|
||||
|
||||
Reference in New Issue
Block a user