From 983a7e200fa2e3c8ab0672b65d588d9e83fe0d16 Mon Sep 17 00:00:00 2001 From: Richard Sisco Date: Wed, 13 Jun 2018 10:48:08 -0500 Subject: [PATCH] AVS-421_88 - Fix Submit VAT Number - Refactor VAT ID code to match the behavior described in the config comment --- Framework/Interaction/Tax.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Framework/Interaction/Tax.php b/Framework/Interaction/Tax.php index e780cf12..737a7372 100644 --- a/Framework/Interaction/Tax.php +++ b/Framework/Interaction/Tax.php @@ -837,12 +837,19 @@ protected function retrieveGetTaxRequestFields(StoreInterface $store, $address, */ protected function getBusinessIdentificationNumber($store, $address, $customer) { - if ($customer && $customer->getTaxvat()) { - return $customer->getTaxvat(); + if (!$this->config->getUseBusinessIdentificationNumber($store)) { + // 'Include VAT Tax' setting is disabled + return null; } - if ($this->config->getUseBusinessIdentificationNumber($store)) { + if ($address->getVatId()) { + // Using the VAT ID has been assigned to the address return $address->getVatId(); } + if ($customer && $customer->getTaxvat()) { + // Using the VAT ID assigned to the customer account + return $customer->getTaxvat(); + } + // No VAT ID available to use return null; }