Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,21 @@ public void CanBuildBarcodeString(string expectedBarcode, HibcBarcode barcode)
UnitOfMeasure = 9,
Quantity = 100
}
},
},
// HIBC 2.3.2.4 has note about Q, saying that that Q should (not shall!) be used with UOM of 9. So Q with other UOMs is also valid.
{
"]d1+EFOR78712011/$26485266/16D20240626/Q10S",
new HibcBarcode(AimSymbologyIdentifier.ParseString("]d1"))
{
LabelerIdentificationCode = "EFOR",
ProductCode = TestProductCode.CreateProductCode<HibcProductCode>("7871201"),
UnitOfMeasure = 1, // Valid UOM other than 9 with Q
Quantity = 10,
BatchNumber = "26485266",
ProductionDate = new TestBarcodeDateTime(new DateTime(2024, 06, 26), "20240626", "yyyyMMdd")

}
}
};

public static TheoryData<string, HibcBarcode> ValidHibcBuildingBarcodes() => new()
Expand Down Expand Up @@ -480,11 +494,14 @@ public void InvalidBarcodeStringThrowsException(string barcode, string expectedM
"+A123BJC5D6E71G+$$52001510X3+ ",
$"Failed to parse HIBC Barcode :{Environment.NewLine}Link Character did not match: expected 'G' but got '+'."
},


// Disabled this test because HIBC spec 2.3.2.4 says that Q should (not shall) be used with UOM of 9.
// It does not explicitly forbid other UOM values with Q.
//
// Using Quantity /Q requires UnitOfMeasure of 9!
{
"+A99912341/$10X3/16D20111231/14D20200131/Q500R",
$"Failed to parse HIBC Barcode :{Environment.NewLine}Using Quantity /Q requires UnitOfMeasure of 9!"
},
//{
// "+A99912341/$10X3/16D20111231/14D20200131/Q500R",
// $"Failed to parse HIBC Barcode :{Environment.NewLine}Using Quantity /Q requires UnitOfMeasure of 9!"
//},
};
}
14 changes: 10 additions & 4 deletions BarcodeParserBuilder/Barcodes/HIBC/HibcBarcodeParserBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ protected static IList<string> BuildSegments(HibcBarcode? barcode)
if (string.IsNullOrWhiteSpace(barcodeString))
return null;

barcodeString = symbologyIdentifier?.StripSymbologyIdentifier(barcodeString!) ?? barcodeString!;
barcodeString = symbologyIdentifier?.StripSymbologyIdentifier(barcodeString!) ?? barcodeString!;

if (string.IsNullOrWhiteSpace(barcodeString))
return null;

if (!Regex.IsMatch(barcodeString, HibcCheckCharacterCalculator.AllowedCharacterRegex))
throw new HIBCParseException("Invalid HIBC Character detected.");

Expand Down Expand Up @@ -288,8 +292,8 @@ protected static IList<string> BuildSegments(HibcBarcode? barcode)

break;
case 'Q': // Quantity /Q as of Spec 2.6 version
if (barcode.UnitOfMeasure != 9)
throw new HIBCParseException($"Using Quantity /Q requires UnitOfMeasure of 9!");
//if (barcode.UnitOfMeasure != 9)
// throw new HIBCParseException($"Using Quantity /Q requires UnitOfMeasure of 9!");
segmentData = segmentData[1..];
barcode.Quantity = int.Parse(segmentData);
break;
Expand All @@ -305,7 +309,9 @@ protected static IList<string> BuildSegments(HibcBarcode? barcode)
continue;

var isMultiDataLine = segmentData.StartsWith("$$", StringComparison.Ordinal);
segmentData = segmentData[(isMultiDataLine ? 2 : 1)..];
segmentData = segmentData[(isMultiDataLine ? 2 : 1)..];
if (segmentData.Length == 0)
continue;
var isSerialLine = segmentData.First() == '+';
if (isSerialLine)
segmentData = segmentData[1..];
Expand Down