Functional Weave
Code in Python

logistics.sscc@1.0.0

README.md

1,969 bytes · view raw

# logistics.sscc

Builds a Serial Shipping Container Code, the 18-digit number on a GS1
logistics label that identifies one pallet, cage or parcel through the supply
chain. It is:

| digits | part |
|---|---|
| 1 | extension digit, 0-9, the company's own choice |
| 4-12 | GS1 company prefix, as allocated by GS1 |
| the rest, to make 17 | serial reference, zero-padded |
| 1 | GS1 mod-10 check digit |

So a 7-digit prefix leaves 9 digits of serial reference and a 10-digit prefix
leaves 6. A serial reference too large for the room left is an error rather
than being truncated, because a truncated serial silently re-uses another
pallet's number.

## Check digit

The standard GS1 mod-10: weight the 17 data digits 3, 1, 3, 1 ... starting
from the rightmost and moving left, sum, and the check digit brings the sum up
to a multiple of ten. It is the same arithmetic as `validation.gtin`, but that
capability only exports `validateGtin`, which accepts 8, 12, 13 and 14 digits
and so cannot be handed an 18-digit SSCC; the three lines of arithmetic are
repeated here rather than widening another package's API. GS1's own example,
`(00) 1 0614141 123456789 7`, is a vector.

## What it does not do

- It returns the bare 18 digits. The label's human-readable line shows them
  after the application identifier as `(00) 106141411234567897`; the barcode
  (GS1-128) encodes `00` followed by the 18 digits.
- It does not allocate serial references. GS1 asks that an SSCC is not
  re-used for at least a year after the unit was shipped; keeping the counter
  is the caller's job.
- It cannot tell whether a prefix was really allocated to you.

## Source

GS1 General Specifications, the SSCC (logistic units) and check digit
calculation sections, https://www.gs1.org/standards/barcodes-epcrfid-id-keys/gs1-general-specifications ;
GS1 UK, "How do I create SSCCs and logistics labels?",
https://www.gs1uk.org/knowledge-hub/barcodes/how-do-i-create-ssccs-and-logistics-labels