Пример #1
0
 /**
  * @param TblCommodity  $tblCommodity
  * @param TblItem       $tblItem
  * @param TblBasket     $tblBasket
  * @param TblBasketItem $tblBasketItem
  * @param TblInvoice    $tblInvoice
  */
 private function actionCreateInvoiceItem(TblCommodity $tblCommodity, TblItem $tblItem, TblBasket $tblBasket, TblBasketItem $tblBasketItem, TblInvoice $tblInvoice)
 {
     $Entity = new TblInvoiceItem();
     $Entity->setCommodityName($tblCommodity->getName());
     $Entity->setCommodityDescription($tblCommodity->getDescription());
     $Entity->setItemName($tblItem->getName());
     $Entity->setItemDescription($tblItem->getDescription());
     if ($tblCommodity->getTblCommodityType()->getName() == 'Einzelleistung') {
         $Entity->setItemPrice($tblBasketItem->getPrice());
     } else {
         $Entity->setItemPrice($tblBasketItem->getPrice() / Basket::useService()->countPersonByBasket($tblBasket));
     }
     $Entity->setItemQuantity($tblBasketItem->getQuantity());
     $Entity->setTblInvoice($tblInvoice);
     $this->Connection->getEntityManager()->saveEntity($Entity);
     Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
     $tblItemAccountList = Commodity::useService()->entityItemAccountAllByItem($tblItem);
     /** @var TblItemAccount $tblItemAccount */
     foreach ($tblItemAccountList as $tblItemAccount) {
         $EntityItemAccount = new TblInvoiceAccount();
         $EntityItemAccount->setTblInvoiceItem($Entity);
         $EntityItemAccount->setServiceBilling_Account($tblItemAccount->getServiceBilling_Account());
         $this->Connection->getEntityManager()->saveEntity($EntityItemAccount);
         Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $EntityItemAccount);
     }
 }