/**
  * Retrieve a customerInfo model filled with the addresses and the customer data
  * 
  * @param order $order
  * @param int $orderId
  * @return CustomerInfo
  */
 public static function getCustomerInfoModel(order $order, $orderId = null)
 {
     $customerInfo = new CustomerInfo();
     $customerInfo->setBillingAddressInfo(self::getBillingAdressInfo($order, $orderId))->setShippingAddressInfo(self::getShippingAdressInfo($order, $orderId));
     if ($order->info['payment_method'] === 'ratepay_lastschrift' && is_null($orderId)) {
         $payment = Loader::getRatepayPayment($order->info['payment_method']);
         $bankAccount = $payment->getBankData();
         $bankAccountInfo = new BankInfo();
         $bankAccountInfo->setOwner($bankAccount['owner']);
         if (!empty($bankAccount['iban'])) {
             $bankAccountInfo->setIban($bankAccount['iban']);
             if (!empty($bankAccount['bic-swift'])) {
                 $bankAccountInfo->setBic($bankAccount['bic-swift']);
             }
         } else {
             $bankAccountInfo->setAccountNumber($bankAccount['bank-account-number']);
             $bankAccountInfo->setBankCode($bankAccount['bank-code']);
         }
         $bankAccountInfo->setBankName($bankAccount['bank-name']);
         $customerInfo->setBankAccount($bankAccountInfo);
     }
     $customerInfo->setCreditInquiry('yes')->setDateOfBirth(Db::getCustomersDob($orderId, Session::getSessionEntry('customer_id')))->setEmail($order->customer['email_address'])->setFax(Db::getCustomersFax($orderId, Session::getSessionEntry('customer_id')))->setPhone($order->customer['telephone'])->setFirstName(is_null($orderId) ? $order->customer['firstname'] : Db::getRatepayOrderDataEntry($orderId, 'firstname'))->setGender(is_null($orderId) ? $order->customer['gender'] : Db::getRatepayOrderDataEntry($orderId, 'gender'))->setIp(is_null($orderId) ? Data::getCustomerIp() : Db::getRatepayOrderDataEntry($orderId, 'ip_address'))->setLastName(is_null($orderId) ? $order->customer['lastname'] : Db::getRatepayOrderDataEntry($orderId, 'lastname'))->setNationality(is_array($order->customer['country']) ? $order->customer['country']['iso_code_2'] : Db::getRatepayOrderDataEntry($orderId, 'customers_country_code'));
     $vatId = Db::getCustomersVatId($orderId, Session::getSessionEntry('customer_id'));
     if (!empty($order->customer['company']) && !empty($vatId)) {
         $customerInfo->setCompany($order->customer['company'])->setVatId($vatId);
     }
     return $customerInfo;
 }