biip.sscc
Serial Shipping Container Code (SSCC).
SSCCs are used to identify logistic units, e.g. a pallet shipped between two parties.
If you only want to parse SSCCs, you can import the SSCC parser directly
instead of using biip.parse()
.
>>> from biip.sscc import Sscc
If parsing succeeds, it returns a Sscc
object.
>>> sscc = Sscc.parse("376130321109103420")
>>> sscc
Sscc(value='376130321109103420', prefix=GS1Prefix(value='761',
usage='GS1 Schweiz, Suisse, Svizzera'), extension_digit=3,
payload='37613032110910342', check_digit=0)
Biip can format the SSCC in HRI format for printing on a label.
>>> sscc.as_hri()
'3 761 3032110910342 0'
>>> sscc.as_hri(company_prefix_length=8)
'3 761 30321 10910342 0'
- class biip.sscc.Sscc(value, prefix, extension_digit, payload, check_digit)
Data class containing an SSCC.
- value: str
Raw unprocessed value.
- prefix: Optional[biip.gs1._prefixes.GS1Prefix]
The GS1 prefix, indicating what GS1 country organization that assigned code range.
- extension_digit: int
Extension digit used to increase the capacity of the serial reference.
- payload: str
The actual payload, including extension digit, company prefix, and item reference. Excludes the check digit.
- check_digit: int
Check digit used to check if the SSCC as a whole is valid.
- classmethod parse(value)
Parse the given value into a
Sscc
object.- Parameters
value (
str
) – The value to parse.- Return type
- Returns
SSCC data structure with the successfully extracted data. The checksum is guaranteed to be valid if an SSCC object is returned.
- Raises
ParseError – If the parsing fails.
- as_hri(*, company_prefix_length=None)
Render as a human readable interpretation (HRI).
The HRI is often printed directly below barcodes.
- Parameters
company_prefix_length (
Optional
[int
]) – Length of the assigned GS1 Company prefix. 7-10 characters. If not specified, the GS1 Company Prefix and the Serial Reference are rendered as a single group.- Raises
ValueError – If an illegal company prefix length is used.
- Return type
str
- Returns
A human-readable string where the logic parts are separated by whitespace.