From 743d0f8e6b220fa2d54d978b622e90da8ae7c12c Mon Sep 17 00:00:00 2001 From: Josh Rehders Date: Mon, 27 Mar 2023 20:21:25 +0200 Subject: [PATCH] fix checksum issue --- barcode/ean.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/barcode/ean.py b/barcode/ean.py index c89408f..dafe929 100755 --- a/barcode/ean.py +++ b/barcode/ean.py @@ -90,9 +90,9 @@ def calculate_checksum(self): def sum_(x, y): return int(x) + int(y) - evensum = reduce(sum_, self.ean[-2::-2]) - oddsum = reduce(sum_, self.ean[-1::-2]) - return (10 - ((evensum + oddsum * 3) % 10)) % 10 + evensum = reduce(sum_, self.ean[1:12:2]) + oddsum = reduce(sum_, self.ean[0:11:2]) + return (10 - ((oddsum + evensum * 3) % 10)) % 10 def build(self): """Builds the barcode pattern from `self.ean`.