/** * checks if the number is always set to the correct value */ public function testNumberable() { $controller = Sales_Controller_Offer::getInstance(); $record = $controller->create(new Sales_Model_Offer(array('title' => 'auto1'))); $this->assertEquals('AN-00001', $record->number); $record = $controller->create(new Sales_Model_Offer(array('title' => 'auto2'))); $this->assertEquals('AN-00002', $record->number); // set number to 4, should return the formatted number $record = $controller->create(new Sales_Model_Offer(array('title' => 'manu1', 'number' => 4))); $this->assertEquals('AN-00004', $record->number); // the next number should be a number after the manual number $record = $controller->create(new Sales_Model_Offer(array('title' => 'auto3'))); $this->assertEquals('AN-00005', $record->number); // the user manually set this numer, so this should be corrected $record = $controller->create(new Sales_Model_Offer(array('title' => 'manu1', 'number' => 'AN-100'))); $this->assertEquals('AN-00100', $record->number); }
/** * deletes existing records * * @param array $ids * @return string */ public function deleteOffers($ids) { return $this->_delete($ids, Sales_Controller_Offer::getInstance()); }
/** * creates some offers */ protected function _createSharedOffers() { $i = 0; $this->_setReferenceDate(); $customers = Sales_Controller_Customer::getInstance()->getAll('number'); $orderconfirmations = Sales_Controller_OrderConfirmation::getInstance()->getAll('number'); foreach ($customers as $customer) { $oc = $orderconfirmations->getByIndex($i); $i++; $relations = array(array('own_model' => 'Sales_Model_Offer', 'own_backend' => Tasks_Backend_Factory::SQL, 'own_id' => NULL, 'own_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'related_model' => 'Sales_Model_Customer', 'related_backend' => Tasks_Backend_Factory::SQL, 'related_id' => $customer->getId(), 'type' => 'OFFER'), array('own_model' => 'Sales_Model_Offer', 'own_backend' => Tasks_Backend_Factory::SQL, 'own_id' => NULL, 'own_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'related_model' => 'Sales_Model_OrderConfirmation', 'related_backend' => Tasks_Backend_Factory::SQL, 'related_id' => $oc->getId(), 'type' => 'OFFER')); $customer = $customers->getById($relation->own_id); $offer = Sales_Controller_Offer::getInstance()->create(new Sales_Model_Offer(array('number' => $i, 'title' => self::$_de ? 'Angebot für Kunde ' . $customer->name : 'Offer for Customer' . $customer->name, 'description' => 'Created by Tine 2.0 DemoData', 'relations' => $relations))); } }