Example #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;
 }
Example #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;
     $currency = $this->policy->getValue('currency');
     if ($order->currency == $currency) {
         return BT\Task\Status::SUCCESS;
     }
     return BT\Task\Status::FAILED;
 }
Example #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;
 }
Example #4
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;
     $shippingMethods = $this->policy->getValue('methods');
     if ($order->transactions->items->count() > 0 && $shippingMethods->hasValue($order->transactions->items[0]->method)) {
         return BT\Task\Status::SUCCESS;
     }
     return BT\Task\Status::FAILED;
 }
Example #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;
     $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;
 }
 /**
  * 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;
     $shippingMethods = $this->policy->getValue('methods');
     if ($shippingMethods->hasValue($order->shippingMethod->type) && OrderCalc\Engine\ToolKit::isEmpty($order->shippingMethod->location)) {
         return BT\Task\Status::SUCCESS;
     }
     return BT\Task\Status::FAILED;
 }
 /**
  * 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;
     $amount = Core\Convert::toDouble($this->policy->getValue('amount'));
     if ($order->terms->subtotal < $amount) {
         return BT\Task\Status::SUCCESS;
     }
     return BT\Task\Status::FAILED;
 }
 /**
  * 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;
     $country = $this->policy->getValue('country');
     if ($order->market == $country && $order->shipToAddress->country == $country) {
         return BT\Task\Status::SUCCESS;
     }
     return BT\Task\Status::FAILED;
 }
 /**
  * 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;
     $zip_codes = $this->policy->getValue('zip-codes');
     if ($zip_codes->hasValue($order->shipToAddress->zip)) {
         return BT\Task\Status::SUCCESS;
     }
     return BT\Task\Status::FAILED;
 }
Example #10
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->discount->amount = 0.0;
     $order->terms->freight->amount = 0.0;
     $order->terms->tax->amount = 0.0;
     $order->terms->pretotal = 0.0;
     $order->terms->total = 0.0;
     return BT\Task\Status::SUCCESS;
 }
Example #11
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)
 {
     $body = $exchange->getIn()->getBody();
     if ($body instanceof Common\Mutable\HashMap) {
         $writer = new Config\JSON\Writer($body);
         $writer->config($this->policy->toDictionary());
         $writer->export($exchange->getOut());
         return BT\Task\Status::SUCCESS;
     }
     return BT\Task\Status::FAILED;
 }
 /**
  * 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;
     $zip = Core\Convert::toInteger($order->shipToAddress->zip);
     $begin = Core\Convert::toInteger($this->policy->getValue('begin'));
     $end = Core\Convert::toInteger($this->policy->getValue('end'));
     if ($zip >= $begin && $zip <= $end) {
         return BT\Task\Status::SUCCESS;
     }
     return BT\Task\Status::FAILED;
 }
Example #13
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;
     $status = $order->customer->status;
     if (in_array($status, array('Suspended', 'Terminated'))) {
         // TODO abstract out to a config file
         return BT\Task\Status::ERROR;
     }
     $type = $order->customer->type;
     if (in_array($type, array('LegacySuspended', 'LegacyTerminated'))) {
         // TODO abstract out to a config file
         return BT\Task\Status::ERROR;
     }
     return BT\Task\Status::SUCCESS;
 }
Example #14
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)
 {
     $body = $exchange->getIn()->getBody();
     if ($body instanceof IO\File) {
         try {
             $reader = new Config\JSON\Reader($body, array('assoc' => false));
             $models = new Common\Mutable\HashMap();
             $models->putEntry('Order', OrderCalc\Engine\Model\Marshaller::unmarshal($reader));
             $exchange->getIn()->setBody($models);
             return BT\Task\Status::SUCCESS;
         } catch (Throwable\Runtime\Exception $ex) {
             $exchange->getOut()->setBody($ex);
             return BT\Task\Status::ERROR;
         }
     }
     return BT\Task\Status::FAILED;
 }
 /**
  * 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;
 }
Example #16
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->total = $this->roundToNearest5($order->terms->pretotal, $order->currency);
     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;
     $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;
 }