@@ -65,7 +65,7 @@ properly.
65
65
... '313': '123.456', # str
66
66
... '391': ('123', Decimal('123.456')), # currency number combo
67
67
... }, parentheses=True)
68
- '(310)2001723(311)0000456(312)5033333(313)3123456 (391)3123123456'
68
+ '(3102)001723(3110)000456(3125)033333(3133)123456 (391)3123123456'
69
69
70
70
We generate dates in various formats, depending on the AI.
71
71
@@ -88,6 +88,8 @@ We generate dates in various formats, depending on the AI.
88
88
'(7011)181119'
89
89
>>> gs1_128.encode({'7011': datetime.datetime(2018, 11, 19, 12, 45)}, parentheses=True)
90
90
'(7011)1811191245'
91
+ >>> gs1_128.encode({'01': '98456789014533', '310': Decimal('0.035')}, parentheses=True)
92
+ '(01)98456789014533(3103)000035'
91
93
92
94
If we try to encode an invalid EAN we will get an error.
93
95
@@ -104,7 +106,7 @@ pprint.pprint(gs1_128.info('(01)38425876095074(17)181119(37)1 '))
104
106
{'01': '38425876095074', '17': datetime.date(2018, 11, 19), '37': 1}
105
107
>>> pprint.pprint(gs1_128.info('013842587609507417181119371'))
106
108
{'01': '38425876095074', '17': datetime.date(2018, 11, 19), '37': 1}
107
- >>> pprint.pprint(gs1_128.info('(02)98412345678908(310)3017230 (37)32'))
109
+ >>> pprint.pprint(gs1_128.info('(02)98412345678908(3103)017230 (37)32'))
108
110
{'02': '98412345678908', '310': Decimal('17.230'), '37': 32}
109
111
>>> pprint.pprint(gs1_128.info('(01)58425876097843(10)123456 (17)181119(37)18'))
110
112
{'01': '58425876097843', '10': '123456', '17': datetime.date(2018, 11, 19), '37': 18}
@@ -124,8 +126,16 @@ InvalidComponent: ...
124
126
We can decode decimal values from various formats.
125
127
126
128
>>> pprint.pprint(gs1_128.info('(310)5033333'))
129
+ Traceback (most recent call last):
130
+ ...
131
+ InvalidComponent: ...
132
+ >>> pprint.pprint(gs1_128.info('(3105)033333'))
133
+ {'310': Decimal('0.33333')}
134
+ >>> pprint.pprint(gs1_128.info('(01)98456789014533(3103)000035'))
135
+ {'01': '98456789014533', '310': Decimal('0.035')}
136
+ >>> pprint.pprint(gs1_128.info('(3105)033333'))
127
137
{'310': Decimal('0.33333')}
128
- >>> pprint.pprint(gs1_128.info('(310)0033333 '))
138
+ >>> pprint.pprint(gs1_128.info('(3100)033333 '))
129
139
{'310': Decimal('33333')}
130
140
>>> pprint.pprint(gs1_128.info('(391)3123123456'))
131
141
{'391': ('123', Decimal('123.456'))}
0 commit comments