/**
  * Returns billing address
  *
  * @return AddressAdapterInterface|null
  */
 public function getBillingAddress()
 {
     if ($this->order->getBillingAddress()) {
         return $this->addressAdapterFactory->create(['address' => $this->order->getBillingAddress()]);
     }
     return null;
 }
 /**
  * @param \Magento\Sales\Api\Data\OrderInterface $mageOrder
  * @return \Praxigento\Odoo\Data\Odoo\Contact
  */
 public function getAddressBilling(\Magento\Sales\Api\Data\OrderInterface $mageOrder)
 {
     /** @var \Magento\Sales\Api\Data\OrderAddressInterface $addrMage */
     $addrMage = $mageOrder->getBillingAddress();
     $result = $this->_extractContact($addrMage);
     return $result;
 }
 /**
  * Return customer code according to the admin configured format
  *
  * @param \Magento\Quote\Api\Data\CartInterface|\Magento\Sales\Api\Data\OrderInterface $data
  * @return string
  */
 protected function getCustomerCode($data)
 {
     switch ($this->config->getCustomerCodeFormat($data->getStoreId())) {
         case Config::CUSTOMER_FORMAT_OPTION_EMAIL:
             $email = $data->getCustomerEmail();
             return $email ?: Config::CUSTOMER_MISSING_EMAIL;
             break;
         case Config::CUSTOMER_FORMAT_OPTION_NAME_ID:
             $customer = $this->getCustomerById($data->getCustomerId());
             if ($customer && $customer->getId()) {
                 $name = $customer->getFirstname() . ' ' . $customer->getLastname();
                 $id = $customer->getId();
             } else {
                 if (!$data->getIsVirtual()) {
                     $address = $data->getShippingAddress();
                 } else {
                     $address = $data->getBillingAddress();
                 }
                 $name = $address->getFirstname() . ' ' . $address->getLastname();
                 if (!trim($name)) {
                     $name = Config::CUSTOMER_MISSING_NAME;
                 }
                 $id = Config::CUSTOMER_GUEST_ID;
             }
             return sprintf(Config::CUSTOMER_FORMAT_NAME_ID, $name, $id);
             break;
         case Config::CUSTOMER_FORMAT_OPTION_ID:
         default:
             return $data->getCustomerId() ?: strtolower(Config::CUSTOMER_GUEST_ID) . '-' . $data->getId();
             break;
     }
 }