/**
  * create customers and their addresses
  * 
  * @param number $count
  * @return Tinebase_Record_RecordSet
  */
 protected function _createCustomers($count = 4)
 {
     if (!$this->_contactRecords) {
         // each customer may have 5 contacts
         $this->_createContacts($count * 5);
     }
     $this->_customerController = Sales_Controller_Customer::getInstance();
     $this->_customerRecords = new Tinebase_Record_RecordSet('Sales_Model_Customer');
     $this->_addressController = Sales_Controller_Address::getInstance();
     $this->_addressRecords = new Tinebase_Record_RecordSet('Sales_Model_Address');
     $countAll = 0;
     // customers
     $customers = array(array('name' => 'Customer1', 'url' => 'www.customer1.de', 'discount' => 0), array('name' => 'Customer2', 'url' => 'www.customer2.de', 'discount' => 5), array('name' => 'Customer3', 'url' => 'www.customer3.de', 'discount' => 10), array('name' => 'Customer4', 'url' => 'www.customer4.de', 'discount' => 0));
     $i = 0;
     foreach ($customers as $customer) {
         if ($countAll == $count) {
             break;
         }
         $countAll++;
         $customer['cpextern_id'] = $this->_contactRecords->getByIndex($i)->getId();
         $i++;
         $customer['cpintern_id'] = $this->_contactRecords->getByIndex($i)->getId();
         $i++;
         $customer['iban'] = Tinebase_Record_Abstract::generateUID(20);
         $customer['bic'] = Tinebase_Record_Abstract::generateUID(12);
         $customer['credit_term'] = 30;
         $customer['currency'] = 'EUR';
         $customer['currency_trans_rate'] = 1;
         $this->_customerRecords->addRecord($this->_customerController->create(new Sales_Model_Customer($customer)));
     }
     foreach ($this->_customerRecords as $customer) {
         foreach (array('postal', 'billing', 'delivery') as $type) {
             $caddress = $this->_contactRecords->getByIndex($i);
             $address = new Sales_Model_Address(array('customer_id' => $customer->getId(), 'type' => $type, 'prefix1' => $caddress->title, 'prefix2' => $caddress->n_fn, 'street' => $caddress->adr_two_street, 'postalcode' => $caddress->adr_two_postalcode, 'locality' => $caddress->adr_two_locality, 'region' => $caddress->adr_two_region, 'countryname' => $caddress->adr_two_countryname, 'custom1' => $type == 'billing' ? Tinebase_Record_Abstract::generateUID(5) : NULL));
             $this->_addressRecords->addRecord($this->_addressController->create($address));
             $i++;
         }
     }
     $this->_customerRecords->sort('name', 'ASC');
     return $this->_customerRecords;
 }