code: private boolean checkPlTin(final String ptin) {
      final int checkSum = ptin.charAt(ptin.length() - 1) - '0';
      int calculatedCheckSum;
      if (StringUtils.length(ptin) == 11) {
        // PESEL
        final int sum = (ptin.charAt(0) - '0') * 1 //
            + (ptin.charAt(1) - '0') * 3 //
            + (ptin.charAt(2) - '0') * 7 //
            + (ptin.charAt(3) - '0') * 9 //
            + (ptin.charAt(4) - '0') * 1 //
            + (ptin.charAt(5) - '0') * 3 //
            + (ptin.charAt(6) - '0') * 7 //
            + (ptin.charAt(7) - '0') * 9 //
            + (ptin.charAt(8) - '0') * 1 //
            + (ptin.charAt(9) - '0') * 3;
        calculatedCheckSum = sum % 10;
        if (calculatedCheckSum != 0) {
          calculatedCheckSum = 10 - sum % 10;
        }
      } else {
        // NIP
        final int sum = (ptin.charAt(0) - '0') * 6 //
            + (ptin.charAt(1) - '0') * 5 //
            + (ptin.charAt(2) - '0') * 7 //
            + (ptin.charAt(3) - '0') * 2 //
            + (ptin.charAt(4) - '0') * 3 //
            + (ptin.charAt(5) - '0') * 4 //
            + (ptin.charAt(6) - '0') * 5 //
            + (ptin.charAt(7) - '0') * 6 //
            + (ptin.charAt(8) - '0') * 7;
        calculatedCheckSum = sum % MODULO_11;
      }
      return checkSum == calculatedCheckSum;
    }
docs: check the Tax Identification Number number, country version for Poland.
  
  @param ptin vat id to check
  @return true if checksum is ok