Beispiel #1
0
 /**
  * @param TblTempInvoice $tblTempInvoice
  * @param TblCommodity   $tblCommodity
  *
  * @return TblTempInvoiceCommodity|null
  */
 public function actionCreateTempInvoiceCommodity(TblTempInvoice $tblTempInvoice, TblCommodity $tblCommodity)
 {
     $Manager = $this->Connection->getEntityManager();
     $Entity = $Manager->getEntity('TblTempInvoiceCommodity')->findOneBy(array(TblTempInvoiceCommodity::ATTR_TBL_TEMP_INVOICE => $tblTempInvoice->getId(), TblTempInvoiceCommodity::ATTR_SERVICE_BILLING_COMMODITY => $tblCommodity->getId()));
     if (null === $Entity) {
         $Entity = new TblTempInvoiceCommodity();
         $Entity->setTblTempInvoice($tblTempInvoice);
         $Entity->setServiceBillingCommodity($tblCommodity);
         $Manager->saveEntity($Entity);
         Protocol::useService()->createInsertEntry($this->Connection->getDatabase(), $Entity);
     }
     return $Entity;
 }
Beispiel #2
0
 /**
  * @param TblDebtor    $tblDebtor
  * @param TblCommodity $tblCommodity
  *
  * @return bool|TblReference
  */
 public function entityReferenceByDebtorAndCommodity(TblDebtor $tblDebtor, TblCommodity $tblCommodity)
 {
     $Entity = $this->Connection->getEntityManager()->getEntity('TblReference')->findOneBy(array(TblReference::ATTR_TBL_DEBTOR => $tblDebtor->getId(), TblReference::ATTR_SERVICE_BILLING_COMMODITY => $tblCommodity->getId(), TblReference::ATTR_IS_VOID => false));
     return null === $Entity ? false : $Entity;
 }
 /**
  * @param null|TblCommodity $tblCommodity
  */
 public function setTblCommodity(TblCommodity $tblCommodity = null)
 {
     $this->tblCommodity = null === $tblCommodity ? null : $tblCommodity->getId();
 }
Beispiel #4
0
 /**
  * @param TblCommodity $tblCommodity
  * @param TblBasket    $tblBasket
  *
  * @return TblBasket
  */
 public function actionDestroyBasketItemsByCommodity(TblBasket $tblBasket, TblCommodity $tblCommodity)
 {
     $Manager = $this->Connection->getEntityManager();
     $tblBasketItemAllByBasket = Basket::useService()->entityBasketItemAllByBasket($tblBasket);
     /** @var TblBasketItem $tblBasketItem */
     foreach ($tblBasketItemAllByBasket as $tblBasketItem) {
         if ($tblBasketItem->getServiceBillingCommodityItem()->getTblCommodity()->getId() == $tblCommodity->getId()) {
             $Entity = $Manager->getEntity('TblBasketItem')->findOneBy(array('Id' => $tblBasketItem->getId()));
             /**@var Element $Entity */
             Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
             $Manager->bulkKillEntity($Entity);
         }
     }
     $Manager->flushCache();
     return $tblBasket;
 }
 /**
  * @param TblCommodity $tblCommodity
  */
 public function setServiceBillingCommodity(TblCommodity $tblCommodity = null)
 {
     $this->serviceBilling_Commodity = null === $tblCommodity ? null : $tblCommodity->getId();
 }
 /**
  * @param Entity\TblCommodity $tblCommodity
  *
  * @return bool
  */
 public function actionRemoveCommodity(TblCommodity $tblCommodity)
 {
     $Manager = $this->Connection->getEntityManager();
     $EntityItems = $Manager->getEntity('TblCommodityItem')->findBy(array(TblCommodityItem::ATTR_TBL_COMMODITY => $tblCommodity->getId()));
     if (null !== $EntityItems) {
         foreach ($EntityItems as $Entity) {
             Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
             $Manager->killEntity($Entity);
         }
     }
     $Entity = $Manager->getEntity('TblCommodity')->findOneBy(array('Id' => $tblCommodity->getId()));
     if (null !== $Entity) {
         /** @var Element $Entity */
         Protocol::useService()->createDeleteEntry($this->Connection->getDatabase(), $Entity);
         $Manager->killEntity($Entity);
         return true;
     }
     return false;
 }