Class VATidLVCheckDigit

java.lang.Object
org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit
org.apache.commons.validator.routines.checkdigit.VATidLVCheckDigit
All Implemented Interfaces:
Serializable, CheckDigit

public final class VATidLVCheckDigit extends ModulusCheckDigit
Latvian VAT identification number (VATIN) Check Digit calculation/validation.

pievienotāsvērtības nodokļa reģistrācijas numurs (PVN) - there are different calculations for legal persons and natural persons

Since:
1.10.0
See Also:
  • Method Details

    • getInstance

      public static CheckDigit getInstance()
      Gets the singleton instance of this validator.
      Returns:
      A singleton instance of the class.
    • weightedValue

      protected int weightedValue(int charValue, int leftPos, int rightPos)
      Calculates the weighted value of a character in the code at a specified position.

      For VATID digits are weighted by their position from left to right.

      Specified by:
      weightedValue in class ModulusCheckDigit
      Parameters:
      charValue - The numeric value of the character.
      leftPos - The position of the character in the code, counting from left to right
      rightPos - The positionof the character in the code, counting from right to left
      Returns:
      The weighted value of the character.
    • calculate

      public String calculate(String code) throws CheckDigitException
      Calculate a modulus Check Digit for a code which does not yet have one.

      Overridden to calculate Check Digit for legal persons and natural persons.

      Specified by:
      calculate in interface CheckDigit
      Overrides:
      calculate in class ModulusCheckDigit
      Parameters:
      code - The code for which to calculate the Check Digit; the check digit should not be included
      Returns:
      The calculated Check Digit
      Throws:
      CheckDigitException - if an error occurs calculating the check digit
    • isValid

      public boolean isValid(String code)
      Validate a modulus check digit for a code.

      Overridden to validate vatin codes for legal persons and natural persons.

      Specified by:
      isValid in interface CheckDigit
      Overrides:
      isValid in class ModulusCheckDigit
      Parameters:
      code - The code to validate
      Returns:
      true if the check digit is valid, otherwise false