Exemplo n.º 1
0
 /**
  * This method processes the models and returns the status.
  *
  * @access public
  * @param BT\Exchange $exchange                             the exchange given to process
  * @return integer                                          the status code
  */
 public function process(BT\Exchange $exchange)
 {
     $order = $exchange->getIn()->getBody()->Order;
     $order->terms->pretotal = Trade\Money::make($order->terms->subtotal, $order->currency)->add(Trade\Money::make($order->terms->freight->amount, $order->currency))->add(Trade\Money::make($order->terms->tax->amount, $order->currency))->getConvertedAmount();
     $order->terms->total = $order->terms->pretotal;
     return BT\Task\Status::SUCCESS;
 }
Exemplo n.º 2
0
 /**
  * This method processes the models and returns the status.
  *
  * @access public
  * @param BT\Exchange $exchange                             the exchange given to process
  * @return integer                                          the status code
  */
 public function process(BT\Exchange $exchange)
 {
     $order = $exchange->getIn()->getBody()->Order;
     $tax_amount = Trade\Money::make($order->terms->subtotal, $order->currency)->add(Trade\Money::make($order->terms->freight->amount, $order->currency));
     $tax_rate = Core\Convert::toDouble($this->policy->getValue('rate'));
     $tax_amount = $tax_amount->multiply($tax_rate);
     $order->terms->tax->amount = $tax_amount->getConvertedAmount();
     return BT\Task\Status::SUCCESS;
 }
Exemplo n.º 3
0
 /**
  * This method processes the models and returns the status.
  *
  * @access public
  * @param BT\Exchange $exchange                             the exchange given to process
  * @return integer                                          the status code
  */
 public function process(BT\Exchange $exchange)
 {
     $order = $exchange->getIn()->getBody()->Order;
     $order->market = strtoupper($order->market);
     $order->shipToAddress->country = strtoupper($order->shipToAddress->country);
     $order->currency = strtoupper($order->currency);
     $order->terms->subtotal = Trade\Money::make($order->terms->subtotal, $order->currency)->getConvertedAmount();
     return BT\Task\Status::SUCCESS;
 }
 /**
  * This method processes the models and returns the status.
  *
  * @access public
  * @param BT\Exchange $exchange                             the exchange given to process
  * @return integer                                          the status code
  */
 public function process(BT\Exchange $exchange)
 {
     $order = $exchange->getIn()->getBody()->Order;
     $weight = 0.0;
     foreach ($order->lines->items as $line) {
         $value = $line->item->weightEach->value;
         $uom = $line->item->weightEach->unit;
         if (!preg_match('/^kg(s)?$/i', $uom)) {
             $value = $value * self::KGS_TO_LBS_CONVERSION_RATE;
         } else {
             if (preg_match('/^lb(s)?$/i', $uom)) {
                 return BT\Task\Status::ERROR;
             }
         }
         $weight += $line->quantity * $value;
     }
     $breakpoint = Core\Convert::toDouble($this->policy->getValue('breakpoint'));
     $rate = Core\Convert::toDouble($this->policy->getValue('rate'));
     $surcharge = Trade\Money::make($this->policy->getValue('surcharge'), $order->currency);
     $weight = max(0.0, ceil($weight) - $breakpoint);
     $order->terms->freight->amount = Trade\Money::make($weight, $order->currency)->multiply($rate)->add($surcharge)->getConvertedAmount();
     return BT\Task\Status::SUCCESS;
 }
Exemplo n.º 5
0
 /**
  * This method processes the models and returns the status.
  *
  * @access public
  * @param BT\Exchange $exchange                             the exchange given to process
  * @return integer                                          the status code
  */
 public function process(BT\Exchange $exchange)
 {
     $order = $exchange->getIn()->getBody()->Order;
     $order->terms->freight->amount = Trade\Money::make($order->terms->freight->amount, $order->currency)->add(Trade\Money::make($this->policy->getValue('surcharge'), $order->currency))->getConvertedAmount();
     return BT\Task\Status::SUCCESS;
 }