Esempio n. 1
0
 /**
  * @return void
  */
 public function testCustomerOrderShouldReturnGrandTotalWithDiscounts()
 {
     $testOrderCreator = $this->createTestOrderCreator();
     $salesOrderEntity = $testOrderCreator->create();
     $orderItemEntity = $salesOrderEntity->getItems()[0];
     $orderItemDiscountEntity = new SpySalesDiscount();
     $orderItemDiscountEntity->setAmount(50);
     $orderItemDiscountEntity->setFkSalesOrder($salesOrderEntity->getIdSalesOrder());
     $orderItemDiscountEntity->setFkSalesOrderItem($orderItemEntity->getIdSalesOrderItem());
     $orderItemDiscountEntity->setName('Discount order saver tester');
     $orderItemDiscountEntity->setDisplayName('discount');
     $orderItemDiscountEntity->setDescription('Description');
     $orderItemDiscountEntity->save();
     $salesFacade = $this->createSalesFacade();
     $orderListTransfer = new OrderListTransfer();
     $orderListTransfer = $salesFacade->getCustomerOrders($orderListTransfer, $salesOrderEntity->getFkCustomer());
     $orderTransfer = $orderListTransfer->getOrders()[0];
     $grandTotal = $orderTransfer->getTotals()->getGrandTotal();
     $this->assertSame(1350, $grandTotal);
 }
Esempio n. 2
0
 /**
  * @param int $idSalesOrderItem
  * @param array $discount
  *
  * @return void
  */
 public function createDiscountForSalesOrderItem($idSalesOrderItem, array $discount = [])
 {
     $salesOrderDiscountEntity = new SpySalesDiscount();
     $salesOrderDiscountEntity->fromArray($discount);
     $salesOrderDiscountEntity->setFkSalesOrderItem($idSalesOrderItem);
     if ($salesOrderDiscountEntity->getName() === null) {
         $salesOrderDiscountEntity->setName('discount name');
     }
     if ($salesOrderDiscountEntity->getDisplayName() === null) {
         $salesOrderDiscountEntity->setDisplayName('discount display name');
     }
     if ($salesOrderDiscountEntity->getAmount() === null) {
         $salesOrderDiscountEntity->setAmount(33);
     }
     $salesOrderDiscountEntity->save();
 }