コード例 #1
0
 private function getTaxRate($state, $zip5, $zip5From, $zip5To, $rate, $applyToShipping)
 {
     $taxRate = new TaxRate();
     $taxRate->setState($state);
     $taxRate->setZip5($zip5);
     $taxRate->setZip5From($zip5From);
     $taxRate->setZip5To($zip5To);
     $taxRate->setRate($rate);
     $taxRate->setApplyToShipping($applyToShipping);
     return $taxRate;
 }
コード例 #2
0
ファイル: TaxRateTest.php プロジェクト: inklabs/kommerce-core
 public function testGetTax()
 {
     $taxRate = new TaxRate();
     $taxRate->setRate(10.0);
     $taxRate->setApplyToShipping(false);
     $this->assertSame(100, $taxRate->getTax(1000, 500));
     $taxRate->setApplyToShipping(true);
     $this->assertSame(150, $taxRate->getTax(1000, 500));
 }
コード例 #3
0
 public function __construct(TaxRate $taxRate)
 {
     $this->entity = $taxRate;
     $this->entityDTO = new TaxRateDTO();
     $this->setId();
     $this->setTime();
     $this->entityDTO->state = $this->entity->getState();
     $this->entityDTO->zip5 = $this->entity->getZip5();
     $this->entityDTO->zip5From = $this->entity->getZip5From();
     $this->entityDTO->zip5To = $this->entity->getZip5To();
     $this->entityDTO->rate = $this->entity->getRate();
     $this->entityDTO->applyToShipping = $this->entity->getApplyToShipping();
 }
コード例 #4
0
ファイル: DummyData.php プロジェクト: inklabs/kommerce-core
 public function getTaxRate()
 {
     $taxRate = new TaxRate();
     $taxRate->setState('CA');
     $taxRate->setZip5(90403);
     $taxRate->setRate(7.5);
     $taxRate->setApplyToShipping(true);
     return $taxRate;
 }
コード例 #5
0
 public function testGetTotalWithZip5TaxAndCouponNoReduceSubtotal()
 {
     $product = new Product();
     $product->setUnitPrice(2000);
     $product->setIsTaxable(true);
     $taxRate = new TaxRate();
     $taxRate->setZip5(92606);
     $taxRate->setRate(8.0);
     $taxRate->setApplyToShipping(false);
     $coupon = $this->dummyData->getCoupon();
     $coupon->setName('20% Off orders under $100');
     $coupon->setType(PromotionType::percent());
     $coupon->setValue(20);
     $coupon->setMinOrderValue(1000);
     $coupon->setMaxOrderValue(10000);
     $coupon->setReducesTaxSubtotal(false);
     $cartItem = new CartItem();
     $cartItem->setProduct($product);
     $cartItem->setQuantity(1);
     $cart = new Cart();
     $cart->addCoupon($coupon);
     $cart->addCartItem($cartItem);
     $cart->setTaxRate($taxRate);
     $expectedCartTotal = new CartTotal();
     $expectedCartTotal->origSubtotal = 2000;
     $expectedCartTotal->subtotal = 2000;
     $expectedCartTotal->taxSubtotal = 2000;
     $expectedCartTotal->shipping = 0;
     $expectedCartTotal->discount = 400;
     $expectedCartTotal->tax = 160;
     $expectedCartTotal->total = 1760;
     $expectedCartTotal->savings = 400;
     $expectedCartTotal->coupons = [$coupon];
     $expectedCartTotal->taxRate = $taxRate;
     $cartCalculator = new CartCalculator(new Pricing());
     $this->assertEquals($expectedCartTotal, $cartCalculator->getTotal($cart));
 }