public function testSetPrice() { $price = Price::create(22, 'EUR'); $item = new QuoteProductOffer(); $item->setPrice($price); $this->assertEquals($price, $item->getPrice()); $this->assertEquals(22, $this->getProperty($item, 'value')); $this->assertEquals('EUR', $this->getProperty($item, 'currency')); }
/** * @param QuoteProductOffer|null $offer * @return array */ protected function createResponseData(QuoteProductOffer $offer = null) { if (!$offer) { return []; } $price = $offer->getPrice(); if (!$price) { return []; } $formatter = $this->get('oro_locale.formatter.number'); return ['id' => $offer->getId(), 'unit' => $offer->getProductUnitCode(), 'qty' => $offer->getQuantity(), 'price' => $formatter->formatCurrency($price->getValue(), $price->getCurrency())]; }
/** * @param QuoteProductOffer $quoteProductOffer * @param float|null $quantity * @return OrderLineItem */ protected function createOrderLineItem(QuoteProductOffer $quoteProductOffer, $quantity = null) { $quoteProduct = $quoteProductOffer->getQuoteProduct(); if ($quoteProduct->getProductReplacement()) { $product = $quoteProduct->getProductReplacement(); } else { $product = $quoteProduct->getProduct(); } $orderLineItem = new OrderLineItem(); $orderLineItem->setProduct($product)->setProductUnit($quoteProductOffer->getProductUnit())->setQuantity($quantity ?: $quoteProductOffer->getQuantity())->setPriceType($quoteProductOffer->getPriceType())->setPrice($quoteProductOffer->getPrice())->setFromExternalSource(true); return $orderLineItem; }