check the VAT identification number, country version for Luxembourg.

@param pvatId vat id to check
@return true if checksum is ok
4601
private boolean checkLuVatId(final String pvatId) {
    final int numberPart = Integer.parseInt(pvatId.substring(2, 8));
    final int checkSum = Integer.parseInt(pvatId.substring(8));
    final int calculatedCheckSum = numberPart % 89;
    return checkSum == calculatedCheckSum;
  }
294
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = StringUtils.strip(Objects.toString(pvalue, null), stripcharacters);

    return StringUtils.isNotEmpty(valueAsString);
  }
797540
private boolean checkSiVatId(final String pvatId) {
    boolean checkSumOk;
    final int checkSum = pvatId.charAt(9) - '0';
    final int sum = (pvatId.charAt(2) - '0') * 8 + (pvatId.charAt(3) - '0') * 7
        + (pvatId.charAt(4) - '0') * 6 + (pvatId.charAt(5) - '0') * 5 + (pvatId.charAt(6) - '0') * 4
        + (pvatId.charAt(7) - '0') * 3 + (pvatId.charAt(8) - '0') * 2;
    int calculatedCheckSum = MODULO_11 - sum % MODULO_11;
    if (calculatedCheckSum == 11) {
      checkSumOk = false;
    } else {
      if (calculatedCheckSum == 10) {
        calculatedCheckSum = 0;
      }
      checkSumOk = checkSum == calculatedCheckSum;
    }
    return checkSumOk;
  }
762208
public function isVatIncluded()
    {
        if ($this->_blIsVatIncluded !== null) {
            return $this->_blIsVatIncluded;
        }

        $config = \OxidEsales\Eshop\Core\Registry::getConfig();
        /*
         * Do not show "inclusive VAT" when:
         *
         *   B2B mode is activated
         * OR
         *   the VAT will only be calculated in the basket
         * OR
         *   the country does not bill VAT
         *
         * oxcountry__oxvatstatus: Vat status: 0 - Do not bill VAT, 1 - Do not bill VAT only if provided valid VAT ID
         * if country is not available (no session) oxvatstatus->value will return null
         */
        if ($config->getConfigParam('blShowNetPrice') || $config->getConfigParam('bl_perfCalcVatOnlyForBasketOrder')) {
            return $this->_blIsVatIncluded = false;
        }

        $user = $this->getUser();
        if ($user !== false) {
            if ($user->getFieldData('oxustid') && $user->getFieldData('oxustidstatus') == 1) {
                return $this->_blIsVatIncluded = false;
            }
        } else {
            $user = oxNew(\OxidEsales\Eshop\Application\Model\User::class);
        }

        $activeCountry = $user->getActiveCountry();
        if ($activeCountry !== '') {
            $country = oxNew(\OxidEsales\Eshop\Application\Model\Country::class);
            if ($country->load($activeCountry) &&
                $country->oxcountry__oxvatstatus->value !== null &&
                $country->oxcountry__oxvatstatus->value == 0
            ) {
                return $this->_blIsVatIncluded = false;
            }
        }

        return $this->_blIsVatIncluded = true;
    }
15238
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);
    if (StringUtils.isEmpty(valueAsString)) {
      return true;
    }
    if (valueAsString.length() != ISBN10_LENGTH) {
      // ISBN10 size is wrong, but that's handled by size annotation
      return true;
    }
    // calculate and check checksum (ISBN10)
    return CHECK_ISBN.isValidISBN10(valueAsString);
  }
864107
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);
    if (StringUtils.isEmpty(valueAsString)) {
      return true;
    }
    if (!StringUtils.isNumeric(valueAsString)) {
      // EAN8 must be numeric, but that's handled by digits annotation
      return true;
    }
    if (valueAsString.length() != GTIN8_LENGTH) {
      // EAN8 size is wrong, but that's handled by size annotation
      return true;
    }
    // calculate and check checksum (GTIN8/EAN8)
    return CHECK_GTIN8.isValid(valueAsString);
  }
1329801
def vat_id(self):
        
        def _checksum(digits):
            code = ['8', '6', '4', '2', '3', '5', '9', '7']
            remainder = 11-(sum(map(lambda x, y: int(x) * int(y), code, digits)) % 11)
            if remainder == 10:
                return 0
            elif remainder == 11:
                return 5
            return remainder

        vat_id = self.bothify('########')
        return 'CHE' + vat_id + str(_checksum(vat_id))
597430
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);

    if (StringUtils.isEmpty(valueAsString)) {
      // empty field is ok
      return true;
    }
    try {
      String countryCode = BeanUtils.getProperty(pvalue, fieldCountryCode);
      final String phoneNumber = BeanUtils.getProperty(pvalue, fieldPhoneNumber);
      if (StringUtils.isEmpty(phoneNumber)) {
        return true;
      }

      if (allowLowerCaseCountryCode) {
        countryCode = StringUtils.upperCase(countryCode);
      }
      final PathDefinitionInterface pathDefinition = GWT.create(PathDefinitionInterface.class);
      final String url =
          pathDefinition.getRestBasePath() + "/" + PhoneNumber.ROOT + "/" + PhoneNumber.VALIDATE //
              + "?" + Parameters.COUNTRY + "=" + countryCode //
              + "&" + Parameters.PHONE_NUMBER + "=" + urlEncode(phoneNumber) //
              + "&" + Parameters.DIN_5008 + "=" + PhoneNumberValueRestValidator.this.allowDin5008 //
              + "&" + Parameters.E123 + "=" + PhoneNumberValueRestValidator.this.allowE123 //
              + "&" + Parameters.URI + "=" + PhoneNumberValueRestValidator.this.allowUri //
              + "&" + Parameters.MS + "=" + PhoneNumberValueRestValidator.this.allowMs //
              + "&" + Parameters.COMMON + "=" + PhoneNumberValueRestValidator.this.allowCommon;
      final String restResult = CachedSyncHttpGetCall.syncRestCall(url);
      if (StringUtils.equalsIgnoreCase("TRUE", restResult)) {
        return true;
      }
      switchContext(pcontext);
      return false;
    } catch (final Exception ignore) {
      switchContext(pcontext);
      return false;
    }
  }
1316901
public function isValid($value = null, $context = null)
    {
        if (!is_string($value)) {
            $this->error(self::INVALID);

            return false;
        }

        $country = $this->getCountry();

        if (!array_key_exists($country, $this->vatin)) {
            if (array_key_exists($country, $context)) {
                $country = $context[$country];
            } else {
                $country = substr($value, 0, 2);
            }
        }

        if (!array_key_exists($country, $this->vatin)) {
            $this->error(self::UNSUPPORTED);

            return false;
        }

        if (!preg_match($this->vatin[$country], $value)) {
            $this->error(self::NO_MATCH);

            return false;
        }

        if (in_array($country, $this->viesCountries, true)) {
            $client = new Client(
                'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl',
                [
                    'soap_version' => SOAP_1_1
                ]
            );

            $vatNumber = $value;

            if (strpos($vatNumber, $country) === 0) {
                $vatNumber = substr($vatNumber, strlen($country));
            }

            try {
                /** @noinspection PhpUndefinedMethodInspection */
                $response = $client->checkVat(
                    [
                        'countryCode' => $country,
                        'vatNumber'   => $vatNumber
                    ]
                );

                if (!$response->valid) {
                    $this->error(self::NO_MATCH);

                    return false;
                }
            } catch (SoapFault $e) {
                $this->error(self::NO_MATCH);

                return false;
            }
        }

        return true;
    }
1073495
function isValid(checkNumber) {
    if (checkNumber == null) {
      return false;
    }
    var numbers = _splitDigits(checkNumber);
    return numbers.pop() === checkSum(numbers.join(''));
  }
1301595
private function validateOld(string $vatNumber): string
    {
        $checkval = substr($vatNumber, 2);
        $checkval .= "12";
        $checkval = intval($checkval) % 97;

        return $checkval == 0 ? "00" : (string) $checkval;
    }
1102128
private boolean checkDkTin(final String ptin) {
    final int checkSum = ptin.charAt(9) - '0';
    final int sum = ((ptin.charAt(0) - '0') * 4 //
        + (ptin.charAt(1) - '0') * 2 //
        + (ptin.charAt(2) - '0') * 3 //
        + (ptin.charAt(3) - '0') * 7 //
        + (ptin.charAt(4) - '0') * 6 //
        + (ptin.charAt(5) - '0') * 5 //
        + (ptin.charAt(6) - '0') * 4 //
        + (ptin.charAt(7) - '0') * 3 //
        + (ptin.charAt(8) - '0') * 2) //
        % MODULO_11;
    int calculatedCheckSum = MODULO_11 - sum;
    if (calculatedCheckSum == 10) {
      calculatedCheckSum = 0;
    }
    return checkSum == calculatedCheckSum;
  }
1232193
private boolean checkPlTaxNumber(final String ptaxNumber) {
    final int checkSum = ptaxNumber.charAt(ptaxNumber.length() - 1) - '0';
    int calculatedCheckSum;
    if (StringUtils.length(ptaxNumber) == 11) {
      // PESEL
      final int sum = (ptaxNumber.charAt(0) - '0') * 1 //
          + (ptaxNumber.charAt(1) - '0') * 3 //
          + (ptaxNumber.charAt(2) - '0') * 7 //
          + (ptaxNumber.charAt(3) - '0') * 9 //
          + (ptaxNumber.charAt(4) - '0') * 1 //
          + (ptaxNumber.charAt(5) - '0') * 3 //
          + (ptaxNumber.charAt(6) - '0') * 7 //
          + (ptaxNumber.charAt(7) - '0') * 9 //
          + (ptaxNumber.charAt(8) - '0') * 1 //
          + (ptaxNumber.charAt(9) - '0') * 3;
      calculatedCheckSum = sum % 10;
      if (calculatedCheckSum != 0) {
        calculatedCheckSum = 10 - sum % 10;
      }
    } else {
      // NIP
      final int sum = (ptaxNumber.charAt(0) - '0') * 6 //
          + (ptaxNumber.charAt(1) - '0') * 5 //
          + (ptaxNumber.charAt(2) - '0') * 7 //
          + (ptaxNumber.charAt(3) - '0') * 2 //
          + (ptaxNumber.charAt(4) - '0') * 3 //
          + (ptaxNumber.charAt(5) - '0') * 4 //
          + (ptaxNumber.charAt(6) - '0') * 5 //
          + (ptaxNumber.charAt(7) - '0') * 6 //
          + (ptaxNumber.charAt(8) - '0') * 7;
      calculatedCheckSum = sum % MODULO_11;
    }
    return checkSum == calculatedCheckSum;
  }
638448
public boolean matchesGlobalId(byte[] globalTransactionId) {
        if (globalTransactionId.length != Xid.MAXGTRIDSIZE) {
            return false;
        }
        for (int i = 8; i < globalTransactionId.length; i++) {
            if (globalTransactionId[i] != baseId[i]) {
                return false;
            }
        }
        // for recovery, only match old transactions
        long id = extractLong(globalTransactionId, 0);
        return (id < start);
    }
209077
private boolean checkAtVatId(final String pvatId) {
    final int checkSum = pvatId.charAt(10) - '0';
    final int sum = pvatId.charAt(3) - '0' + squareSum((pvatId.charAt(4) - '0') * 2)
        + pvatId.charAt(5) - '0' + squareSum((pvatId.charAt(6) - '0') * 2) + pvatId.charAt(7) - '0'
        + squareSum((pvatId.charAt(8) - '0') * 2) + pvatId.charAt(9) - '0';
    final int calculatedCheckSum = (96 - sum) % 10;
    return checkSum == calculatedCheckSum;
  }
321928
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString;
    if (ignoreSeparators) {
      valueAsString =
          Objects.toString(pvalue, StringUtils.EMPTY).replaceAll("-", StringUtils.EMPTY);
    } else {
      valueAsString = Objects.toString(pvalue, null);
    }
    if (StringUtils.isEmpty(valueAsString)) {
      return true;
    }
    if (!StringUtils.isNumeric(valueAsString)) {
      return false;
    }
    if (valueAsString.length() == Isbn10Validator.ISBN10_LENGTH) {
      // we do have 10 digits, lets test the checksum
      return CHECK_ISBN10.isValid(valueAsString);
    }
    if (valueAsString.length() == Isbn13Validator.ISBN13_LENGTH) {
      // we do have 13 digits, lets test the checksum
      return CHECK_ISBN13.isValid(valueAsString);
    }
    // other sizes are wrong, but this is reported by AlternateSize
    return true;
  }
886844
private boolean checkDkVatId(final String pvatId) {
    final int sum = (pvatId.charAt(2) - '0') * 2 + (pvatId.charAt(3) - '0') * 7
        + (pvatId.charAt(4) - '0') * 6 + (pvatId.charAt(5) - '0') * 5 + (pvatId.charAt(6) - '0') * 4
        + (pvatId.charAt(7) - '0') * 3 + (pvatId.charAt(8) - '0') * 2 + pvatId.charAt(9) - '0';
    return sum % MODULO_11 == 0;
  }