Skip to content

Commit

Permalink
[TIX] Fixed return message on error
Browse files Browse the repository at this point in the history
Empty array response is not allowed even if an error occurs
  • Loading branch information
pointia authored Dec 3, 2018
1 parent 683c120 commit ae37ce1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Plugin/UidPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,17 @@ public function beforeCheckVatNumber(
$countryCodeFromVAT = $this->helper->getCountryCodeFromVAT($vatNumber);
if (!empty($vatNumber) && !is_numeric($countryCodeFromVAT) && $countryCode != $countryCodeFromVAT) {
$this->addErrorMessage(__('Your selected country does not match the countrycode in VAT.'));
return [];
}
$newVatNumber = $vatNumber;
$newRequesterVatNumber = $requesterVatNumber;
if ($requesterVatNumber !== '' && $this->helper->isCountryCodeInVAT($requesterVatNumber)) {
$newRequesterVatNumber = substr(str_replace(' ', '', trim($requesterVatNumber)), 2);
}
else {
if ($requesterVatNumber !== '' && $this->helper->isCountryCodeInVAT($requesterVatNumber)) {
$requesterVatNumber = substr(str_replace(' ', '', trim($requesterVatNumber)), 2);
}

if ($this->helper->isCountryCodeInVAT($newVatNumber)) {
$newVatNumber = substr(str_replace(' ', '', trim($vatNumber)), 2);
if ($this->helper->isCountryCodeInVAT($vatNumber)) {
$vatNumber = substr(str_replace(' ', '', trim($vatNumber)), 2);
}
}
return [$countryCode, $newVatNumber, $requesterCountryCode, $newRequesterVatNumber];
return [$countryCode, $vatNumber, $requesterCountryCode, $requesterVatNumber];
}

/**
Expand Down

0 comments on commit ae37ce1

Please sign in to comment.