setGrossAmount() public method

public setGrossAmount ( float $grossAmount )
$grossAmount float
コード例 #1
0
 /**
  * @return OrderTotal
  */
 public function create()
 {
     $orderTotal = new OrderTotal();
     $orderTotal->setGrossAmount(0);
     $orderTotal->setTaxRate(0);
     return $orderTotal;
 }
コード例 #2
0
 /**
  * Calculates order's total values
  *
  * @param OrderInterface $order
  *
  * @return OrderTotal
  */
 protected function calculateOrderTotal(OrderInterface $order)
 {
     $totals = $order->getTotals();
     $targetCurrency = $order->getCurrency();
     $orderTotal = new OrderTotal();
     $grossTotal = 0;
     $netTotal = 0;
     $taxTotal = 0;
     $totals->map(function (OrderTotalDetailInterface $orderTotalDetail) use(&$grossTotal, &$netTotal, &$taxTotal, $targetCurrency) {
         $total = $orderTotalDetail->getOrderTotal();
         $baseCurrency = $total->getCurrency();
         $grossAmount = $this->currencyHelper->convert($total->getGrossAmount(), $baseCurrency, $targetCurrency);
         $netAmount = $this->currencyHelper->convert($total->getNetAmount(), $baseCurrency, $targetCurrency);
         $taxAmount = $this->currencyHelper->convert($total->getTaxAmount(), $baseCurrency, $targetCurrency);
         if ($orderTotalDetail->isSubtraction()) {
             $grossTotal -= $grossAmount;
             $netTotal -= $netAmount;
             $taxTotal -= $taxAmount;
         } else {
             $grossTotal += $grossAmount;
             $netTotal += $netAmount;
             $taxTotal += $taxAmount;
         }
     });
     $orderTotal->setCurrency($targetCurrency);
     $orderTotal->setGrossAmount($grossTotal);
     $orderTotal->setNetAmount($netTotal);
     $orderTotal->setTaxAmount($taxTotal);
     return $orderTotal;
 }
コード例 #3
0
 /**
  * Prepares order product totals
  *
  * @param OrderInterface $order
  *
  * @return OrderTotal
  */
 protected function prepareOrderProductTotal(OrderInterface $order)
 {
     $grossAmountTotal = $this->calculateTotalGrossAmount($order);
     $netAmountTotal = $this->calculateTotalNetAmount($order);
     $taxAmountTotal = $this->calculateTotalTaxAmount($order);
     $productTotal = new OrderTotal();
     $productTotal->setGrossAmount($grossAmountTotal);
     $productTotal->setNetAmount($netAmountTotal);
     $productTotal->setTaxAmount($taxAmountTotal);
     $productTotal->setCurrency($order->getCurrency());
     return $productTotal;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function visitOrder(OrderInterface $order)
 {
     if (null === $order->getCoupon()) {
         $orderTotal = new OrderTotal();
         $discount = $this->getDiscountForClient($order->getClient());
         if ($discount > 0) {
             $productTotal = $order->getProductTotal();
             $orderTotal->setCurrency($order->getCurrency());
             $orderTotal->setGrossAmount($productTotal->getGrossAmount() * $discount);
             $orderTotal->setNetAmount($productTotal->getNetAmount() * $discount);
             $orderTotal->setTaxAmount($productTotal->getTaxAmount() * $discount);
             $orderTotalDetail = $this->initResource();
             $orderTotalDetail->setOrderTotal($orderTotal);
             $orderTotalDetail->setModifierType('%');
             $orderTotalDetail->setModifierValue($discount);
             $orderTotalDetail->setOrder($order);
             $orderTotalDetail->setSubtraction(true);
             $order->addTotal($orderTotalDetail);
         }
     }
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function visitOrder(OrderInterface $order)
 {
     if (null !== $order->getCoupon()) {
         $productTotal = $order->getProductTotal();
         $coupon = $order->getCoupon();
         $modifier = $this->calculateModifierValue($coupon, $productTotal->getGrossAmount(), $order->getCurrency());
         if ($modifier > 0) {
             $orderTotal = new OrderTotal();
             $orderTotal->setCurrency($order->getCurrency());
             $orderTotal->setGrossAmount($productTotal->getGrossAmount() * $modifier);
             $orderTotal->setNetAmount($productTotal->getNetAmount() * $modifier);
             $orderTotal->setTaxAmount($productTotal->getTaxAmount() * $modifier);
             $orderTotalDetail = $this->initResource();
             $orderTotalDetail->setOrderTotal($orderTotal);
             $orderTotalDetail->setModifierType($coupon->getModifierType());
             $orderTotalDetail->setModifierValue($modifier);
             $orderTotalDetail->setOrder($order);
             $orderTotalDetail->setSubtraction(true);
             $order->addTotal($orderTotalDetail);
         }
     }
 }
コード例 #6
0
ファイル: OrderFactory.php プロジェクト: raizeta/WellCommerce
 /**
  * Prepares order shipping details
  *
  * @param OrderInterface              $order
  * @param ShippingMethodCostInterface $shippingMethodCost
  */
 protected function prepareShippingTotals(OrderInterface $order, ShippingMethodCostInterface $shippingMethodCost)
 {
     $cost = $shippingMethodCost->getCost();
     $baseCurrency = $cost->getCurrency();
     $shippingTotal = new OrderTotal();
     $shippingTotal->setGrossAmount($this->currencyHelper->convert($cost->getGrossAmount(), $baseCurrency, $order->getCurrency()));
     $shippingTotal->setNetAmount($this->currencyHelper->convert($cost->getNetAmount(), $baseCurrency, $order->getCurrency()));
     $shippingTotal->setTaxAmount($this->currencyHelper->convert($cost->getTaxAmount(), $baseCurrency, $order->getCurrency()));
     $shippingTotal->setTaxRate($this->currencyHelper->convert($cost->getTaxRate()));
     $shippingTotal->setCurrency($order->getCurrency());
     $order->setShippingTotal($shippingTotal);
 }