Skip to content

Commit

Permalink
Generalize/improve "Fix Greece VAT number online check"
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriansaliou committed Feb 12, 2024
1 parent d27b1d9 commit aaef2ea
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/sales_tax.js
Expand Up @@ -15,7 +15,7 @@ var validate_eu_vat = require("jsvat");
var validate_us_vat = require("ein-validator");

var regex_whitespace = /\s/g;
var regex_eu_vat = /^[A-Z]{2}(.+)$/;
var regex_eu_vat = /^([A-Z]{2})(.+)$/;
var regex_gb_vat = /^GB([0-9]{9}([0-9]{3})?|[A-Z]{2}[0-9]{3})$/;
var regex_ca_vat = /^[0-9]{9}$/;

Expand Down Expand Up @@ -276,15 +276,15 @@ SalesTax.prototype.validateTaxNumber = function(
// Split VAT number (n extract actual VAT number)
var splitMatch = cleanTaxNumber.match(regex_eu_vat);

if (countryCode === 'GR') {
// Greece has 'EL' code in EU VAT
countryCode = 'EL';
}

// Check fraud on EU VAT number?
if (splitMatch && splitMatch[1]) {
// Notice: use country code from VAT number during the check, \
// since some country codes are different there, eg. Greece. It \
// is still deemed safe to use the country code from the VAT \
// number, since we performed an offline check of the country \
// code match with the provided country code right before.
if (splitMatch && splitMatch[1] && splitMatch[2]) {
check_fraud_eu_vat(
countryCode, splitMatch[1],
splitMatch[1], splitMatch[2],

function(error, fraudInfo) {
if (error) {
Expand Down

0 comments on commit aaef2ea

Please sign in to comment.