From: Galen Charlton Date: Mon, 8 Mar 2010 21:14:08 +0000 (+0000) Subject: fix error in Codabar checkdigit algorithm X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=65892ebd1ab911f95c789cac01eb8d20ad2ad2c1 fix error in Codabar checkdigit algorithm --- diff --git a/sql/base/base.sql b/sql/base/base.sql index 95255e2..e2e048b 100644 --- a/sql/base/base.sql +++ b/sql/base/base.sql @@ -687,7 +687,7 @@ CREATE OR REPLACE FUNCTION migration_tools.add_codabar_checkdigit (TEXT) RETURNS my @digits = split //, $barcode; my $total = 0; $total += $digits[$_] foreach (1, 3, 5, 7, 9, 11); - $total += (2 * $digits[$_] > 10) ? (2 * $digits[$_] - 9) : (2 * $digits[$_]) foreach (0, 2, 4, 6, 8, 10, 12); + $total += (2 * $digits[$_] >= 10) ? (2 * $digits[$_] - 9) : (2 * $digits[$_]) foreach (0, 2, 4, 6, 8, 10, 12); my $remainder = $total % 10; my $checkdigit = ($remainder == 0) ? $remainder : 10 - $remainder; return $barcode . $checkdigit;