diff --git a/build/logs/clover.xml b/build/logs/clover.xml index 207e19b..136798b 100644 --- a/build/logs/clover.xml +++ b/build/logs/clover.xml @@ -1,21 +1,21 @@ - - + + - + - - - - - - - + + + + + + + - + @@ -32,39 +32,39 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -83,50 +83,50 @@ - - - - - + + + + + - - - - - - - - - + + + + + + + + + - - - - + + + + - + - - - - - - - - - - - - + + + + + + + + + + + + - + - + @@ -154,7 +154,7 @@ - + @@ -181,36 +181,36 @@ - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - + + + @@ -219,23 +219,23 @@ - - - + + + - - - - + + + + - - + + @@ -251,23 +251,23 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - - + + + @@ -293,14 +293,14 @@ - - - - - - - - + + + + + + + + @@ -331,24 +331,24 @@ - - - - - - - - + + + + + + + + - - - - - + + + + + @@ -363,72 +363,72 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + + @@ -448,79 +448,79 @@ - - - + + + - - + + - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - + + + + + + + + + - + - + @@ -529,52 +529,52 @@ - + - - - - - - - - - - - + + + + + + + + + + + - + - + - + - + - + @@ -582,7 +582,7 @@ - + @@ -594,49 +594,49 @@ - + - - - - - - - + + + + + + + - - - + + + - - - + + + - - - + + + - - - - - - - + + + + + + + - + - + - - + + - + @@ -677,8 +677,8 @@ - - + + diff --git a/tests/TotalsTest.php b/tests/TotalsTest.php index 64b7bbb..23a3291 100644 --- a/tests/TotalsTest.php +++ b/tests/TotalsTest.php @@ -265,4 +265,43 @@ public function testDoubleDiscounts() $this->assertEquals(19.95, $this->laracart->taxTotal(false)); $this->assertEquals(114.95, $this->laracart->total(false)); } + + public function testTaxationOnCoupons() + { + // Add to cart + $this->laracart->add( + 1, + 'test', + 52, + 107.44, + [ + 'tax' => 0.21, + ] + ); + + $this->assertEquals(5586.88, $this->laracart->subTotal(false)); + $this->assertEquals(0, $this->laracart->totalDiscount(false)); + $this->assertEquals(1173.24, $this->laracart->taxTotal(false)); + $this->assertEquals(6760.12, $this->laracart->total(false)); + + // Test discount % + $coupon = new LukePOLO\LaraCart\Coupons\Percentage('7,5%', 0.075); + $this->laracart->addCoupon($coupon); + + $this->assertEquals(5586.88, $this->laracart->subTotal(false)); + $this->assertEquals(419.02, $this->laracart->totalDiscount(false)); + $this->assertEquals(1085.25, $this->laracart->taxTotal(false)); + $this->assertEquals(6253.11, $this->laracart->total(false)); + + $this->laracart->removeCoupons(); + + // Test discount fixed + $coupon = new LukePOLO\LaraCart\Coupons\Fixed('100 euro', 100); + $this->laracart->addCoupon($coupon); + + $this->assertEquals(5586.88, $this->laracart->subTotal(false)); + $this->assertEquals(100, $this->laracart->totalDiscount(false)); + $this->assertEquals(1152.24, $this->laracart->taxTotal(false)); + $this->assertEquals(6639.12, $this->laracart->total(false)); + } }