当前位置: 首页>>代码示例>>PHP>>正文


PHP Tax::getNewInstance方法代码示例

本文整理汇总了PHP中Tax::getNewInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Tax::getNewInstance方法的具体用法?PHP Tax::getNewInstance怎么用?PHP Tax::getNewInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tax的用法示例。


在下文中一共展示了Tax::getNewInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetAllTaxes

 public function testGetAllTaxes()
 {
     $allTaxesCount = Tax::getTaxes()->getTotalRecordCount();
     $taxEnabled = Tax::getNewInstance('testing');
     $taxEnabled->save();
     $taxDisabled = Tax::getNewInstance('testing');
     $taxDisabled->save();
     $this->assertEqual(Tax::getTaxes()->getTotalRecordCount(), $allTaxesCount + 2);
 }
开发者ID:saiber,项目名称:livecart,代码行数:9,代码来源:TaxTest.php

示例2: create

 /**
  * @role create
  */
 public function create()
 {
     $tax = Tax::getNewInstance($this->request->get('name'));
     $tax->position->set(1000);
     return $this->saveTax($tax);
 }
开发者ID:saiber,项目名称:www,代码行数:9,代码来源:TaxController.php

示例3: testTaxClassesWithDefaultZoneAndMultipleTaxes

 public function testTaxClassesWithDefaultZoneAndMultipleTaxes()
 {
     $order = CustomerOrder::getNewInstance($this->user);
     $zone = $order->getDeliveryZone();
     $this->assertTrue($zone->isDefault());
     // default tax level
     TaxRate::getNewInstance($zone, $this->tax, 10)->save();
     $newTax = Tax::getNewInstance('test');
     $newTax->save();
     // diferent tax rate for books
     $books = TaxClass::getNewInstance('Books');
     $books->save();
     $booksRate = TaxRate::getNewInstance($zone, $this->tax, 5);
     $booksRate->taxClass->set($books);
     $booksRate->save();
     $booksRate = TaxRate::getNewInstance($zone, $newTax, 20);
     $booksRate->taxClass->set($books);
     $booksRate->save();
     // price = 100
     $cd = $this->product;
     $book = Product::getNewInstance(Category::getRootNode());
     $book->setPrice('USD', 50);
     $book->isEnabled->set(true);
     $book->taxClass->set($books);
     $book->save();
     $order->addProduct($cd, 1, true);
     $order->addProduct($book, 1, true);
     $order->currency->set($this->currency);
     $order->save();
     $this->assertEqual($order->getTaxAmount(), 19.41);
     $this->assertEqual($order->getTotal(true), 150);
     $service = ShippingService::getNewInstance($order->getDeliveryZone(), 'def', ShippingService::SUBTOTAL_BASED);
     $service->save();
     $shippingRate = ShippingRate::getNewInstance($service, 0, 10000000);
     $shippingRate->flatCharge->set(100);
     $shippingRate->save();
     $shipment = $order->getShipments()->get(0);
     $rates = $order->getDeliveryZone()->getShippingRates($shipment);
     $shipment->setAvailableRates($rates);
     $shipment->setRateId($rates->get(0)->getServiceID());
     $shipment->save();
     $this->assertEqual($order->getTotal(true), 250);
     $this->assertEqual((string) $order->getTaxAmount(), (string) 28.5);
 }
开发者ID:saiber,项目名称:livecart,代码行数:44,代码来源:TaxRateTest.php

示例4: createOrderWithZone

 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();
 }
开发者ID:saiber,项目名称:livecart,代码行数:33,代码来源:OrderTest.php

示例5: testGetTaxRates

 public function testGetTaxRates()
 {
     $zone = DeliveryZone::getNewInstance();
     $zone->name->set(':TEST_ZONE');
     $zone->save();
     $tax = Tax::getNewInstance('VAT');
     $tax->save();
     $taxRate = TaxRate::getNewInstance($zone, $tax, 15);
     $taxRate->save();
     $taxRates = $zone->getTaxRates();
     $this->assertEquals($taxRates->getTotalRecordCount(), 1);
     $this->assertTrue($taxRates->get(0) === $taxRate);
 }
开发者ID:saiber,项目名称:livecart,代码行数:13,代码来源:DeliveryZoneTest.php

示例6: testTaxRounding

 public function testTaxRounding()
 {
     $tax = Tax::getNewInstance('VAT');
     $tax->save();
     TaxRate::getNewInstance(DeliveryZone::getDefaultZoneInstance(), $tax, 19)->save();
     foreach (array(2 => true, 1 => false) as $shipments => $isSeparate) {
         $this->initOrder();
         foreach (array(635.99, 228.69, 61.59) as $key => $price) {
             $this->products[$key]->setPrice('USD', $price);
             if (!$isSeparate) {
                 $this->products[$key]->isSeparateShipment->set(false);
             }
             $this->order->addProduct($this->products[$key], 1, false);
         }
         $this->order->save();
         $this->assertEquals(count($this->order->getShipments()), $shipments);
         $this->assertEquals($this->order->getTotal(), 926.27);
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:19,代码来源:ShipmentTaxTest.php


注:本文中的Tax::getNewInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。