Exemple #1
0
 /**
  * Adds equipment to invoice
  *
  * @param 		RM_Holder_iHolderable $obEntity
  * @return 		int
  */
 public function addEntity(RM_Holder_iHolderable $obEntity)
 {
     if (!$this->canChangeItemState()) {
         return FALSE;
     }
     $this->_items();
     if ($this->is_deleted || $this->state == RM_Holder_Invoice_State::CLOSED) {
         throw new RM_Base_Exception_BadUsage(__METHOD__ . ': you can\'t add "entity" to closed invoice');
     }
     if ($this->_mapper->_checkInvoiceNotSaved($this)) {
         $this->RM_Base_Exception_BadUsage(__METHOD__ . ': you can\'t add "entity" to not saved invoice');
     }
     if ($this->_mapper->_checkInOtherOpenedInvoice($this, $obEntity)) {
         throw new RM_Base_Exception_BadUsage(__METHOD__ . ': you can\'t add "entity" from other open invoice');
     }
     $obEntity->setInvoice($this);
     $obEntity->save();
     return $this->_mapper->createInvoiceItem($this->_items, $this, $obEntity);
 }