示例#1
0
 public function setUp()
 {
     parent::setUp();
     $this->deliveryZone = DeliveryZone::getNewInstance();
     $this->deliveryZone->name->set('test zone');
     $this->deliveryZone->save();
 }
示例#2
0
 public function setUp()
 {
     parent::setUp();
     ActiveRecord::clearPool();
     ActiveRecord::executeUpdate('DELETE FROM Tax');
     ActiveRecord::executeUpdate('DELETE FROM TaxRate');
     ActiveRecord::executeUpdate('DELETE FROM DeliveryZone');
     ActiveRecord::executeUpdate('DELETE FROM Currency');
     ActiveRecord::executeUpdate('DELETE FROM ShippingService');
     ActiveRecord::executeUpdate('DELETE FROM DeliveryZone');
     ActiveRecord::executeUpdate('DELETE FROM TaxClass');
     $this->deliveryZone = DeliveryZone::getNewInstance();
     $this->deliveryZone->setValueByLang('name', 'en', 'test zone');
     $this->deliveryZone->isEnabled->set(true);
     $this->deliveryZone->save();
     DeliveryZoneCountry::getNewInstance($this->deliveryZone, 'US')->save();
     $this->tax = Tax::getNewInstance('test type');
     $this->tax->save();
     $this->currency = ActiveRecord::getInstanceByIdIfExists('Currency', 'USD');
     $this->currency->isEnabled->set(true);
     $this->currency->decimalCount->set(2);
     $this->currency->save();
     $this->product = Product::getNewInstance(Category::getRootNode());
     $this->product->setPrice('USD', 100);
     $this->product->isEnabled->set(true);
     $this->product->save();
     $this->user = User::getNewInstance('*****@*****.**');
     $this->user->save();
     $this->address = UserAddress::getNewInstance();
     $this->address->countryID->set('US');
     $this->address->save();
     $this->getApplication()->getConfig()->setRuntime('DELIVERY_TAX_CLASS', null);
 }
示例#3
0
 public function setUp()
 {
     parent::setUp();
     $this->deliveryZone = DeliveryZone::getNewInstance();
     $this->deliveryZone->setValueByLang('name', 'en', 'test zone');
     $this->deliveryZone->isEnabled->set(true);
     $this->deliveryZone->save();
 }
 public function setUp()
 {
     parent::setUp();
     $this->zone = DeliveryZone::getNewInstance();
     $this->zone->name->set(':TEST_ZONE');
     $this->zone->isEnabled->set(1);
     $this->zone->isFreeShipping->set(1);
     $this->zone->save();
 }
示例#5
0
 public function setUp()
 {
     parent::setUp();
     $this->deliveryZone = DeliveryZone::getNewInstance();
     $this->deliveryZone->name->set('test zone');
     $this->deliveryZone->save();
     $this->shippingService = ShippingService::getNewInstance($this->deliveryZone, 'test category', ShippingService::SUBTOTAL_BASED);
     $this->shippingService->save();
 }
示例#6
0
 /**
  * @role create
  */
 public function create()
 {
     $zone = DeliveryZone::getNewInstance();
     $zone->name->set($this->translate('_new_delivery_zone'));
     $zone->save();
     return new JSONResponse(array('zone' => $zone->toArray()), 'success', $this->translate('_new_delivery_zone_was_successfully_created'));
 }
示例#7
0
 private function createOrderWithZone(DeliveryZone $zone = null)
 {
     if (is_null($zone)) {
         $zone = DeliveryZone::getNewInstance();
     }
     $zone->name->set('Latvia');
     $zone->isEnabled->set(true);
     $zone->save();
     $this->newZone = $zone;
     $country = DeliveryZoneCountry::getNewInstance($zone, 'LV');
     $country->save();
     $tax = Tax::getNewInstance('VAT');
     $tax->save();
     $taxRate = TaxRate::getNewInstance($zone, $tax, 20);
     $taxRate->save();
     $service = ShippingService::getNewInstance($zone, 'def', ShippingService::SUBTOTAL_BASED);
     $service->save();
     $this->newService = $service;
     $shippingRate = ShippingRate::getNewInstance($service, 0, 10000000);
     $shippingRate->flatCharge->set(100);
     $shippingRate->save();
     $this->newRate = $shippingRate;
     // user address
     $address = UserAddress::getNewInstance();
     $address->countryID->set('LV');
     $billingAddress = BillingAddress::getNewInstance($this->user, $address);
     $billingAddress->save();
     // set up order
     $this->order->user->set($this->user);
     $this->order->billingAddress->set($address);
     $this->order->shippingAddress->set($address);
     $this->order->save();
 }
示例#8
0
 public function testFindZoneWithMasks()
 {
     $zone1 = DeliveryZone::getNewInstance();
     $zone1->name->set('With ZIP');
     $zone1->isEnabled->set(true);
     $zone1->save();
     DeliveryZoneZipMask::getNewInstance($zone1, 'asd')->save();
     DeliveryZoneCountry::getNewInstance($zone1, 'LT')->save();
     $zone2 = DeliveryZone::getNewInstance();
     $zone2->name->set('Without ZIP');
     $zone2->isEnabled->set(true);
     $zone2->save();
     DeliveryZoneCountry::getNewInstance($zone2, 'LT')->save();
     $address = UserAddress::getNewInstance();
     $address->countryID->set('LT');
     $this->assertSame(DeliveryZone::getZoneByAddress($address), $zone2);
     $address->postalCode->set('asd');
     $this->assertSame(DeliveryZone::getZoneByAddress($address), $zone1);
 }
示例#9
0
 public function testQuebecToUSATaxes()
 {
     $gst = Tax::getNewInstance('GST');
     $gst->save();
     $pst = Tax::getNewInstance('PST');
     $pst->save();
     // shipment delivery zone
     $zone = DeliveryZone::getNewInstance();
     $zone->name->set('Quebec');
     $zone->isEnabled->set(true);
     $zone->save();
     // two taxes are applied to delivery charge
     TaxRate::getNewInstance($zone, $gst, 5)->save();
     TaxRate::getNewInstance($zone, $pst, 7.5)->save();
     $delZone = $zone;
     $this->config->setRuntime('DELIVERY_TAX', $zone->getID());
     // shipping amount zone
     $zone = DeliveryZone::getNewInstance();
     $zone->name->set('Canada');
     $zone->isEnabled->set(true);
     $zone->save();
     $service = ShippingService::getNewInstance($zone, 'def', ShippingService::SUBTOTAL_BASED);
     $service->save();
     DeliveryZoneCountry::getNewInstance($zone, 'US')->save();
     $shippingRate = ShippingRate::getNewInstance($service, 0, 10000000);
     $shippingRate->flatCharge->set(16.95);
     $shippingRate->save();
     $product = $this->products[0];
     $product->setPrice('USD', 50);
     $this->order->addProduct($product, 1, false);
     $this->order->save();
     // set shipping rate
     $shipment = $this->order->getShipments()->get(0);
     $rates = $this->order->getDeliveryZone()->getShippingRates($shipment);
     $shipment->setAvailableRates($rates);
     $shipment->setRateId($rates->get(0)->getServiceID());
     $shipment->save();
     $this->order->finalize();
     $this->assertSame($this->order->getDeliveryZone(), $zone);
     $this->assertEquals($this->order->getTotal(), 69.13);
 }