biip.rcn
Restricted Circulation Number (RCN) is a subset of GTIN.
Both RCN-8, RCN-12, and RCN-13 are supported. There is no 14 digit version of RCN.
RCN-12 with prefix 2 and RCN-13 with prefix 02 or 20-29 have the same semantics across a geographic region, defined by the local GS1 Member Organization.
RCN-8 with prefix 0 or 2, RCN-12 with prefix 4, and RCN-13 with prefix 04 or 40-49 have semantics that are only defined within a single company.
Use Gtin.parse() to parse potential RCNs. This
subclass is returned if the GS1 Prefix signifies that the value is an RCN.
References
GS1 General Specifications, section 2.1.11-2.1.12
Rcn
dataclass
Bases: Gtin
Data class containing an RCN.
This is a subclass of Gtin. To create an Rcn instance,
use Gtin.parse() with an RCN string as the value
to parse.
Source code in src/biip/rcn.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
check_digit
instance-attribute
Check digit used to check if the GTIN as a whole is valid.
company_prefix
instance-attribute
The GS1 Company Prefix.
Identifying the company that issued the GTIN.
count
class-attribute
instance-attribute
A variable count extracted from the GTIN.
format
instance-attribute
GTIN format, either GTIN-8, GTIN-12, GTIN-13, or GTIN-14.
Classification is done after stripping leading zeros.
item_reference
instance-attribute
The item reference part of the GTIN.
For GTIN-12/13/14, this is the part of the payload that is assigned by the company that owns the company prefix. It is only set if the company prefix is known.
For GTIN-8, this is the part of the payload after the GS1-8 Prefix.
For company RCNs, this is the part of the payload after the GS1 Prefix.
For geographical RCNs, this is a part of the payload, depending on the geographical region's RCN parsing rules.
money
class-attribute
instance-attribute
A Money value created from the variable weight price.
Only set if py-moneyed is
installed and the currency is known.
packaging_level
class-attribute
instance-attribute
Packaging level is the first digit in GTIN-14 codes.
This digit is used for wholesale shipments, e.g. the GTIN-14 product identifier in GS1-128 barcodes, but not in the GTIN-13 barcodes used for retail products.
payload
instance-attribute
The actual payload.
Including packaging level if any, company prefix, and item reference. Excludes the check digit.
prefix
instance-attribute
The GS1 Prefix.
When parsing GTIN-8, this will be a GS1-8 Prefix instead.
Indicating what GS1 country organization that assigned code range.
price
class-attribute
instance-attribute
A variable weight price extracted from the GTIN.
region
class-attribute
instance-attribute
The geographical region.
The region's rules are used to interpret the contents of the RCN.
usage
class-attribute
instance-attribute
Where the RCN can be circulated, in a geographical region or within a company.
weight
class-attribute
instance-attribute
A variable weight value extracted from the GTIN.
as_gtin_12
as_gtin_13
as_gtin_14
as_gtin_8
parse
classmethod
Parse the given value into a Gtin object.
Both GTIN-8, GTIN-12, GTIN-13, and GTIN-14 are supported.
The checksum is guaranteed to be valid if a GTIN object is returned.
Parameters:
-
value(str) –The value to parse.
-
config(ParseConfig | None, default:None) –Configuration options for parsing.
Returns:
-
Gtin–GTIN data structure with the successfully extracted data.
Raises:
-
ParseError–If the parsing fails.
Source code in src/biip/gtin.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
without_variable_measure
Create a new RCN where the variable measure is zeroed out.
This provides us with a number which still includes the item reference, but does not vary with weight/price, and can thus be used to lookup the relevant trade item in a database or similar.
This has no effect on RCNs intended for use within a company, as the semantics of those numbers vary from company to company.
Returns:
-
Gtin–A RCN instance with zeros in the variable measure places.
Raises:
-
EncodeError–If the rules for variable measures in the region are unknown.
Source code in src/biip/rcn.py
RcnRegion
Bases: Enum
Enum of geographical regions with custom RCN rules.
The value of the enum is the lowercase ISO 3166-1 Alpha-2 code.
Source code in src/biip/rcn.py
get_currency_code
Get the ISO-4217 currency code for the region.
Source code in src/biip/rcn.py
RcnUsage
Bases: Enum
Enum of RCN usage restrictions.