Skip to content

Commit daf138b

Browse files
committed
Fixed erroneous calculation in calculate_checksum
1 parent 13538c8 commit daf138b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

barcode/ean.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ def calculate_checksum(self):
8484

8585
def sum_(x, y):
8686
return int(x) + int(y)
87-
88-
evensum = reduce(sum_, self.ean[-2::-2])
89-
oddsum = reduce(sum_, self.ean[-1::-2])
87+
ean_without_checksum = self.ean[:self.digits]
88+
89+
evensum = reduce(sum_, ean_without_checksum[-2::-2])
90+
oddsum = reduce(sum_, ean_without_checksum[-1::-2])
9091
return (10 - ((evensum + oddsum * 3) % 10)) % 10
9192

9293
def build(self):

0 commit comments

Comments
 (0)