Пример #1
0
 /**
  * Process the Products
  *
  * @param Basket $basket
  * @return array
  */
 public function products(Basket $basket)
 {
     $products = [];
     foreach ($basket->products() as $product) {
         $products[] = ['sku' => $product->sku, 'name' => $product->name, 'price' => $product->price, 'rate' => $product->rate, 'quantity' => $product->quantity, 'freebie' => $product->freebie, 'taxable' => $product->taxable, 'delivery' => $product->delivery, 'coupons' => $product->coupons, 'tags' => $product->tags, 'discount' => $product->discount, 'category' => $product->category, 'total_value' => $this->reconciler->value($product), 'total_discount' => $this->reconciler->discount($product), 'total_delivery' => $this->reconciler->delivery($product), 'total_tax' => $this->reconciler->tax($product), 'subtotal' => $this->reconciler->subtotal($product), 'total' => $this->reconciler->total($product)];
     }
     return $products;
 }
 /** @test */
 public function should_reconcile_product_fixture_nine()
 {
     $product = $this->fixtures->nine();
     $value = $this->reconciler->value($product);
     $discount = $this->reconciler->discount($product);
     $delivery = $this->reconciler->delivery($product);
     $tax = $this->reconciler->tax($product);
     $subtotal = $this->reconciler->subtotal($product);
     $total = $this->reconciler->total($product);
     $this->assertEquals(new Money(7500, new Currency('GBP')), $value);
     $this->assertEquals(new Money(0, new Currency('GBP')), $discount);
     $this->assertEquals(new Money(297, new Currency('GBP')), $delivery);
     $this->assertEquals(new Money(0, new Currency('GBP')), $tax);
     $this->assertEquals(new Money(297, new Currency('GBP')), $subtotal);
     $this->assertEquals(new Money(297, new Currency('GBP')), $total);
 }