biip.checksums
Checksum algorithms used by GS1 standards.
gs1_price_weight_check_digit
Get GS1 check digit for a price or weight field.
Parameters:
-
value
(str
) –The numeric string to calculate the check digit for.
Returns:
-
int
–The check digit.
Raises:
-
ValueError
–If the value isn't numeric.
References
GS1 General Specification, section 7.9.2-7.9.4
Examples:
>>> from biip.checksums import gs1_price_weight_check_digit
>>> gs1_price_weight_check_digit("2875")
9
>>> gs1_price_weight_check_digit("14685")
6
Source code in src/biip/checksums.py
gs1_standard_check_digit
Get GS1 check digit for numeric string.
Parameters:
-
value
(str
) –The numeric string to calculate the check digit for.
Returns:
-
int
–The check digit.
Raises:
-
ValueError
–If the value isn't numeric.
References
GS1 General Specification, section 7.9.1
Examples:
>>> from biip.checksums import gs1_standard_check_digit
>>> gs1_standard_check_digit("950110153100") # GTIN-13
0
>>> gs1_standard_check_digit("9501234") # GTIN-8
6