/** * Creates new item for test purpose. * * @return ItemInterface */ public function createNewTestItem() { $item = $this->itemFactory->createEntity(); $item->setName('Product1'); $item->setNumber('123'); $item->setQuantity(2); $item->setQuantityUnit('Pcs'); $item->setUseProductsPrice(true); $item->setTax(20); $item->setPrice($this->productPrice->getPrice()); $item->setDiscount(10); $item->setDescription('This is a description'); $item->setWeight(15.8); $item->setWidth(5); $item->setHeight(6); $item->setLength(7); $item->setCreated(new DateTime()); $item->setChanged(new DateTime()); $item->setProduct($this->product); $item->setSupplier($this->account); $item->setSupplierName($this->account->getName()); return $item; }
/** * Simple helper function for calculating item-price * * @param ItemInterface $item * @param ProductPrice $productPriceEntity * * @return float */ private function calcTotalPriceForItem($item, $productPriceEntity) { $expectedPrice = $item->getQuantity() * $productPriceEntity->getPrice(); $expectedPrice -= $expectedPrice / 100 * $item->getDiscount(); return $expectedPrice; }