本文整理汇总了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);
}
示例2: create
/**
* @role create
*/
public function create()
{
$tax = Tax::getNewInstance($this->request->get('name'));
$tax->position->set(1000);
return $this->saveTax($tax);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
}