コード例 #1
0
 /**
  * @return array
  */
 public function validatorDataProvider()
 {
     $offer = new QuoteProductOffer();
     $offer->setQuantity(10);
     $moreOffer = new QuoteProductOffer();
     $moreOffer->setAllowIncrements(true);
     $moreOffer->setQuantity(10);
     return [[null, 'orob2b.sale.quoteproductoffer.configurable.offer.blank', QuoteProductToOrderType::FIELD_QUANTITY], [[], 'orob2b.sale.quoteproductoffer.configurable.offer.blank', QuoteProductToOrderType::FIELD_QUANTITY], [[QuoteProductToOrderType::FIELD_QUANTITY => 10], 'orob2b.sale.quoteproductoffer.configurable.offer.blank', QuoteProductToOrderType::FIELD_QUANTITY], [[QuoteProductToOrderType::FIELD_OFFER => new \stdClass(), QuoteProductToOrderType::FIELD_QUANTITY => 10], 'orob2b.sale.quoteproductoffer.configurable.offer.blank', QuoteProductToOrderType::FIELD_QUANTITY], [[QuoteProductToOrderType::FIELD_OFFER => $offer, QuoteProductToOrderType::FIELD_QUANTITY => $offer->getQuantity() - 5], 'orob2b.sale.quoteproductoffer.configurable.quantity.equal', QuoteProductToOrderType::FIELD_QUANTITY], [[QuoteProductToOrderType::FIELD_OFFER => $offer, QuoteProductToOrderType::FIELD_QUANTITY => $offer->getQuantity() + 5], 'orob2b.sale.quoteproductoffer.configurable.quantity.equal', QuoteProductToOrderType::FIELD_QUANTITY], [[QuoteProductToOrderType::FIELD_OFFER => $moreOffer, QuoteProductToOrderType::FIELD_QUANTITY => $moreOffer->getQuantity() - 5], 'orob2b.sale.quoteproductoffer.configurable.quantity.less', QuoteProductToOrderType::FIELD_QUANTITY], [[QuoteProductToOrderType::FIELD_OFFER => $moreOffer, QuoteProductToOrderType::FIELD_QUANTITY => $moreOffer->getQuantity() + 5], null, null], [[QuoteProductToOrderType::FIELD_OFFER => $moreOffer, QuoteProductToOrderType::FIELD_QUANTITY => $moreOffer->getQuantity()], null, null], [[QuoteProductToOrderType::FIELD_OFFER => $offer, QuoteProductToOrderType::FIELD_QUANTITY => $offer->getQuantity()], null, null]];
 }
コード例 #2
0
 /**
  * @param ObjectManager $manager
  * @param Quote $quote
  * @param string $sku
  * @param array $items
  */
 protected function addQuoteProduct(ObjectManager $manager, Quote $quote, $sku, $items)
 {
     $product = new QuoteProduct();
     if ($this->hasReference($sku)) {
         $product->setProduct($this->getReference($sku));
     } else {
         $product->setProductSku($sku);
     }
     foreach ($items as $item) {
         $productOffer = new QuoteProductOffer();
         $productOffer->setQuantity($item['quantity'])->setPrice((new Price())->setValue($item['price'])->setCurrency($item['currency']));
         if ($this->hasReference($item['unit'])) {
             $productOffer->setProductUnit($this->getReference($item['unit']));
         } else {
             $productOffer->setProductUnitCode($item['unit']);
         }
         $manager->persist($productOffer);
         $product->addQuoteProductOffer($productOffer);
     }
     $manager->persist($product);
     $quote->addQuoteProduct($product);
 }
コード例 #3
0
 /**
  * @param int $productId
  * @param float $quantity
  * @param string $unitCode
  * @param int $priceType
  * @param Price $price
  * @return QuoteProductOffer
  */
 protected function getQuoteProductOffer($productId = null, $quantity = null, $unitCode = null, $priceType = null, Price $price = null)
 {
     $quoteProductOffer = new QuoteProductOffer();
     $quoteProductOffer->setQuoteProduct($this->getQuoteProduct($productId));
     if (null !== $quantity) {
         $quoteProductOffer->setQuantity($quantity);
     }
     if (null !== $unitCode) {
         $quoteProductOffer->setProductUnit($this->getEntity('OroB2B\\Bundle\\ProductBundle\\Entity\\ProductUnit', $unitCode, 'code'));
     }
     if (null !== $priceType) {
         $quoteProductOffer->setPriceType($priceType);
     }
     if (null !== $price) {
         $quoteProductOffer->setPrice($price);
     }
     return $quoteProductOffer;
 }
コード例 #4
0
 /**
  * "Success" form handler
  *
  * @param RFPRequest $entity
  * @return bool
  */
 protected function onSuccess(RFPRequest $entity)
 {
     $quote = new Quote();
     $quote->setRequest($entity)->setOwner($this->user)->setAccount($entity->getAccount())->setAccountUser($entity->getAccountUser())->setOrganization($this->user->getOrganization());
     foreach ($entity->getRequestProducts() as $requestProduct) {
         $quoteProduct = new QuoteProduct();
         $quoteProduct->setProduct($requestProduct->getProduct())->setType(QuoteProduct::TYPE_REQUESTED)->setCommentAccount($requestProduct->getComment());
         foreach ($requestProduct->getRequestProductItems() as $requestProductItem) {
             $quoteProductRequest = new QuoteProductRequest();
             $quoteProductRequest->setQuantity($requestProductItem->getQuantity())->setPrice($requestProductItem->getPrice())->setProductUnit($requestProductItem->getProductUnit())->setRequestProductItem($requestProductItem);
             $quoteProduct->addQuoteProductRequest($quoteProductRequest);
             $quoteProductOffer = new QuoteProductOffer();
             $quoteProductOffer->setQuantity($requestProductItem->getQuantity())->setProductUnit($requestProductItem->getProductUnit())->setPriceType(QuoteProductOffer::PRICE_TYPE_UNIT)->setAllowIncrements(true);
             $quoteProduct->addQuoteProductOffer($quoteProductOffer);
         }
         $quote->addQuoteProduct($quoteProduct);
     }
     try {
         $this->manager->persist($quote);
         $this->manager->flush();
         $this->quote = $quote;
     } catch (DBALException $e) {
         $this->exception = $e;
         return false;
     }
     return true;
 }