taxRegistrationFactory = $taxRegistrationFactory; } /** * Generate a VAT TaxRegistration from a Customer Address * * @param AddressInterface $address * @return TaxRegistration * @throws \InvalidArgumentException When address without VAT is specified */ public function buildFromCustomerAddress(AddressInterface $address) { if (!$address->getVatId()) { throw new \InvalidArgumentException('Address does not contain VAT'); } /** @var TaxRegistration $registration */ $registration = $this->taxRegistrationFactory->create(); $registration->setRegistrationNumber($address->getVatId()) ->setImpositionType('VAT'); if ($address->getCountryId()) { $registration->setCountryCode($address->getCountryId()); } return $registration; } /** * Generate a VAT TaxRegistration from an Order Address * * @param OrderAddressInterface $address * @return TaxRegistration * @throws \InvalidArgumentException When address without VAT is specified */ public function buildFromOrderAddress(OrderAddressInterface $address) { if (!$address->getVatId()) { throw new \InvalidArgumentException('Address does not contain VAT'); } /** @var TaxRegistration $registration */ $registration = $this->taxRegistrationFactory->create(); $registration->setRegistrationNumber($address->getVatId()) ->setImpositionType('VAT'); if ($address->getCountryId()) { $registration->setCountryCode($address->getCountryId()); } return $registration; } }