action.skip

Enabling VAT Number Validation

← Setting Up Tax Handling

The EU provides VIES, a VAT number validation service. It allows to validate the VATIN (value added tax identification number) of businesses in the EU.

Note

The EU VAT number validation service is designed for single, sporadic requests. In case your repeated requests are considered abusive use of the service, your IP address will be blocked for a certain period.

The VAT validation only tells whether a given EU VAT information exists. It does not necessarily prove, however, that the given VAT number actually belongs to the current account.

JustOn Billing & Invoice Management uses this service to check the VAT number of an account. The VAT check can be performed

  • Individually for a single account, using a button on the account page, or
  • For multiple accounts using a scheduled batch job.

Info

Switzerland adheres to certain regulations of the European Economic Area, including the reverse charge procedure. As a precondition, suppliers must specify the buyer's VAT ID. The EU VAT number validation service, however, does not cover Swiss VAT IDs. To check Swiss UIDs, you can use the official UID Register or third-party services like vatstack.

VAT validation concepts

By default, JustOn's VAT validation uses the VAT number as specified in the VATIN field of the account as the source field. You can, however, overwrite this behavior by creating a custom field ON_VATNumber on the Account object. Once this field exists, JustOn uses this field as the source. In order to validate the VAT number, the source field must not be empty.

The result of the VAT validation is written to fields on the Account object:

Field Label API Name Data Type Description
VAT Number Valid VATIsValid Checkbox Selected if the VAT number is valid
VAT Validated Name VATValidatedName Text (255) The name linked to the VAT number
VAT Validated Address VATValidatedAddress Long Text Area (32768) The address linked to the VAT number
Last VAT Validation VATLastValidation Date/Time The timestamp of the last validation
Last Successful VAT Validation VATLastValidationSuccess Date/Time The timestamp of the last successful validation
Last VAT Validation Error VATLastError Text (255) The error message if the last validation was not successful

Be aware of the following validation specifics:

  • If the validation was not successful, only the fields Last VAT Validation and Last VAT Validation Error are updated.
  • The fields VAT Number Valid, VAT Validated Name and VAT Validated Address reflect the result of the last successful validation.
  • Modifying the value in the VAT number source field (VATIN or ON_VATNumber) does not automatically update the VAT validation result fields. JustOn therefore recommends to delete the validation result fields after changing the VAT number.
  • Empty VAT number source fields (VATIN or ON_VATNumber) produce an error on manual VAT number check, prompting the user to specify a value, and make JustOn skip the corresponding accounts on automatic VAT number validation.
  • The name and address linked to a VAT may not be available.
  • If required, you can add the fields to the page layout of the Account object.

JustOn provides the remote site setting CheckVatService, which is required to access the VAT number validation service.

Enabling the VAT validation in JustOn involves the following tasks:

Activating CheckVatService Remote Site

JustOn provides the remote site setting CheckVatService, which is required to access the VAT number validation service. To activate the remote site:

  1. Click to enter Setup, then open Remote Site Settings.

    In Salesforce Lightning, navigate to Security > Remote Site Settings.

    In Salesforce Classic, navigate to Security Controls > Remote Site Settings.

  2. Click Edit in the row of CheckVatService.

  3. Select the Active checkbox.
  4. Make sure that the specified URL starts with https.

    As of version 2.75, JustOn uses HTTPS to access the EU VAT validation service. If upgrading from a previous version, you may have to modify the remote site setting CheckVatService, specifying the HTTPS URL.

  5. Click Save.

Adding VAT Validation Fields to Account

The VAT validation allows to use the custom field ON_VATNumber on the Account object to provide the VAT number, instead of the default VATIN field.

  1. Navigate to the fields list of the Account object.
  2. Create the following new field.

    API Name Data Type Description Example Value
    ON_VATNumber Text (255)
    or
    Formula
    Specifies the VAT number. If configured as a formula, it can determine the value based on other fields. DE1234567
    MyVATNumber__c

Using the timestamp fields Last VAT Validation and Last Successful VAT Validation, you can, optionally, create a formula field (VATValidCheck) on the Account object that shows if the validation result is up to date. This field can be used, for example, for an Account list view filter.

  1. Navigate to the fields list of the Account object.
  2. Create the following new field.

    API Name Data Type Description
    VATValidCheck Formula (Checkbox) Shows if the validation result is up to date

    Use the following formula:

    IF(
      AND(
        NOT(ISBLANK(ONB2__VATLastValidation__c)),
        NOT(ISBLANK(ONB2__VATLastValidationSuccess__c)),
        ONB2__VATLastValidation__c == ONB2__VATLastValidationSuccess__c
      ),
      true,
      false
    )
    

For help about creating fields, see Managing Object Fields.

Enabling Individual VAT Number Validation

If you are upgrading JustOn from an older version, you may have to add the VAT Validation button to the Account page layout in order to enable the individual VAT number check for a single account.

Adding the button involves two steps:

Creating VAT Validation Button

To create the VAT Validation button:

  1. Navigate to the object management settings of the Account object.
  2. Click Buttons, Links, and Actions.
  3. Click New Buttons or Link.
  4. Create the following button, then click Save.

    Detail Value
    Label VAT Validation
    Display Type Detail Page Button
    Behavior Display in existing window without sidebar
    Content Source Visualforce Page
    Content VATValidation [ONB2_VATValidation]

    For help about creating buttons, see Managing Buttons or Links.

Adding VAT Validation Button to Account Layout

To add the VAT Validation button to the page layout:

  1. Navigate to the object management settings of the Account object.
  2. Click Page Layouts.
  3. In the Account Layout row, click Edit.
  4. Add the VAT Validation button to the page layout.

    In Salesforce Lightning, drag the button from the Mobile & Lightning Actions palette to the Salesforce Mobile and Lightning Experience Actions section.

    In Salesforce Classic, drag the button from the Buttons palette to the Custom Buttons area.

  5. Click Save.

    For help about modifying page layouts, see Managing Pages.

This enables users to validate the VAT number for an individual account (see Account - VAT Number Validation).

Enabling Automatic VAT Number Validation

JustOn allows to schedule a job for validating the VAT number of multiple accounts automatically. For accounts to be considered by the job, the VAT number source field (VATIN or ON_VATNumber) must not be empty. That is, accounts for which the VAT number source field is not set are skipped, but no error is produced.

VAT Validation Custom Setting

The VAT validation job is controlled by the custom setting VAT Validation.

Field Name API Name Data Type Description
Validity Period ValidityPeriod__c Number(18,0) The validity period of the VAT validation result in days. Defaults to 0 if empty. If 0, the VAT validation batch job validates only VAT numbers that are not yet validated.
  • If there is no VAT Validation setting record with the name Default, or if the validity period is 0, JustOn executes the VAT number validation only for accounts that are not yet validated, that is, for which the field Last Successful VAT Validation is not set.
  • If there is a validity period specified, the job refreshes the VAT number validation of accounts for which the last check was performed more than the specified number of days ago.

To configure the VAT Validation job, you define a VAT Validation setting named Default:

  1. Click to enter Setup, then open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of VAT Validation.

  3. Click New.
  4. Specify the details as necessary.

    • Name: Default
    • Validity Period: The validity period of the VAT validation result in days
  5. Click Save.

Scheduling VAT Validation Job

You can set up a job in order to have VAT numbers validated automatically on a regular basis. To schedule the VAT validation, you can use either JustOn's Scheduled Jobs page, Salesforce's Schedule Apex functionality or the Salesforce Developer Console. For details, see Scheduling a Job.

Via JustOn's Scheduled Jobs page:

  1. Open the Scheduled Jobs page.

    Use the following URL https://login.salesforce.com/apex/ONB2__JobsSetup, or, if you are already logged in, append apex/ONB2__JobsSetup to your org's domain name.

    You can access the Scheduled Jobs page via the JustOn configuration app ( > JustOn Configuration > Jobs Setup).

  2. From the Apex Job drop-down list, select VAT Validation Job.

    The Job Name field is automatically set to BatchVATValidationJob.

  3. From the Start Time drop-down list, select the preferred execution time.

  4. Optionally, edit the displayed cron expression to adjust the execution time.
  5. Click Schedule.

    This sets up the VAT validation to be executed at the specified time. For accounts to be considered by the job, the VAT number source field (VATIN or ON_VATNumber) must not be empty.

Info

From the Scheduled Jobs page, you can also run the job immediately.

Via Salesforce's Schedule Apex functionality:

  1. Click to enter Setup, then open Apex Classes.

    In Salesforce Lightning, navigate to Custom Code > Apex Classes.

    In Salesforce Classic, navigate to Develop > Apex Classes.

  2. Click Schedule Apex on top of the list.

  3. Specify the details as required.

    • Job Name: VATValidationChain
    • Apex Class: VATValidationChain
    • Frequency: Weekly or Monthly (with an according weekday or day of month setting)
    • Start
    • End
    • Preferred Start Time
  4. Click Save.

    This sets up the VAT validation to be executed at the specified time. For accounts to be considered by the job, the VAT number source field (VATIN or ON_VATNumber) must not be empty.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.

You can also invoke the VAT validation using the following code in the Salesforce Developer Console:

new ONB2.ChainRunner()
.execute(
    new ONB2.ChainFactory().getByName('VATValidationChain')
);