String message = null;

	public boolean doEanDigitCheck(String value) throws Exception {
         int len = 13;
         int codLen = value.length();
         String code = value;
         if( codLen == len ) {
            code = value.substring( 0, code.length() - 1 );
         }

         if( code.length() != len - 1 ) {
            throw new IllegalArgumentException("Invalid length for string: '${value}', length must be ${len - 1}");
         }

         int check = Integer.parseInt(value.substring(len-1));
         
         int sum = 0;
         code.eachWithIndex() { aux, f ->
            int factor = f % 2 == 0 ? 1 : 3;
            sum += Integer.parseInt(aux) * factor;
         }

         int calcDig = (sum % 10);
         if( calcDig == 0 ) {
            calcDig = 10;
         }
         int chk = 10 - calcDig;
         message = "${chk} <> ${check}";
         return chk == check;
	}

return doEanDigitCheck(value);