CasewareDocs

VatRegNoChecker

Using this command you can check whether a given European VAT identification number is valid or not.

Use the MacroCommands method NewVatRegNoChecker to get a reference to a builder object.

Note:

The check is based on the construction rules of the Austrian Federal Ministry of Finance as of April 2013.

Dim checker As Object

Set checker = SmartContext.MacroCommands.NewVatRegNoChecker

NewVatRegNoChecker returns an object that implements the interface IVatRegNoChecker.

The interface has properties and methods similar to those available in TaxAudit:

Properties and methods
Property Description
Property Value As String Gets/sets a string containing the value to be checked. The default value is the empty string.
ISS code:
Dim checker As Object
Set checker = SmartContext.MacroCommands.NewVatRegNoChecker
Checker.Value = "DE813047374"
Property CountryCode As String This read-only property gets the language-independent country code.
Calls the PerformTask method before getting the actual value of the property.
The default value is the empty string.
ISS code: See the PerformTask method below.
Property Country As String Gets the country name of the value.
Calls the PerformTask method before getting the actual value of the property.
The default value is the empty string.
ISS code: See the PerformTask method below.
Note: The current implementation always returns the German name of the country.
Property StructureValidity As Boolean Gets a Boolean that specifies whether the structure of Value is valid.
Calls the PerformTask method before getting the actual value of the property.
The default value is the empty string.
ISS code: See the PerformTask method below.
Property RuleValidity As Long Gets a value of the enumerated type VatConstructionRulesValidationResult that specifies whether Value fulfills the VAT construction rules of the respective country.

Possible values:

RulesFulfilled = 0 The number fulfills all construction rules.
RulesNotFulfilled = 1 The number does not fulfill the construction rules.
RulesNotAvailable = 2 The construction rules of the country issuing this registration number are not available.

The dafault value is 2 (RulesNotAvailable).

Calls the PerformTask method before getting the actual value of the property.
The default value is the empty string.
ISS code: See the PerformTask method below.
Sub PerformTask Runs the task and stores the results in CountryCode, Country, StructureValidity and RuleValidity.
The method sets CountryCode, Country, StructureValidity and RuleValidity to their default state before performing the check.
If Value does not start with a known country code, the method keeps the default values in the output properties.
The checks are case-insensitive and ignore the following set of separators: any character that is not a letter, decimal digits, * or + (as in TaxAudit).

ISS code:
Option explicit
Sub Main
Dim checker As Object
Set checker = SmartContext.MacroCommands.NewVatRegNoChecker

checker.Value = "de 81 30 47 37 4"
checker.PerformTask

Dim countryCode As String
countryCode = checker.CountryCode 'Should be DE


Dim country As String
country = checker.Country 'Should be DEUTSCHLAND

Dim sv As Boolean
sv = checker.StructureValidity 'Should be true

Dim rv As Long
rv = checker.RuleValidity 'Should be 0 (Rules fulfilled)
LogVatRegNoCheckerResult checker


checker.Value = "XT12345678" 'Unknown country code
checker.PerformTask

countryCode = checker.CountryCode 'Should be empty
country = checker.Country 'Should be empty
sv = checker.StructureValidity 'Should be False
rv = checker.RuleValidity 'Should be 2 (RulesNotAvailable

LogVatRegNocheckerResult checker
End Sub

Sub LogVatRegNoCheckerResult(ByVal task As Object)
SmartContext.Log.LogMessage "Value = {0}, CountryCode = {1},
Country = {2}, S-Validity = {3}, R-Validity = {4}", task.Value
task.CountryCode, taskCountry, task.StructureValidity,
task.RuleValidity
End Sub
VatRegNoChecker | Caseware Docs