From 7e1a12f03651b8b418aea897e99dc9bdb99b36c6 Mon Sep 17 00:00:00 2001 From: AdiCherukuri Date: Wed, 10 Feb 2016 13:35:32 -0600 Subject: [PATCH] Tax total now reflects tax on LaraCart fees. --- src/LaraCart.php | 9 ++++++--- tests/TotalsTest.php | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/LaraCart.php b/src/LaraCart.php index f1f381e..c518eb4 100644 --- a/src/LaraCart.php +++ b/src/LaraCart.php @@ -430,6 +430,12 @@ public function taxTotal($format = true) } } + foreach ($this->getFees() as $fee) { + if ($fee->taxable) { + $totalTax += $fee->amount * $this->cart->tax; + } + } + return $this->formatMoney($totalTax, null, null, $format); } @@ -538,9 +544,6 @@ public function feeTotals($format = true) foreach ($this->getFees() as $fee) { $feeTotal += $fee->amount; - if ($fee->taxable) { - $feeTotal += $fee->amount * $this->cart->tax; - } } return $this->formatMoney($feeTotal, null, null, $format); diff --git a/tests/TotalsTest.php b/tests/TotalsTest.php index 747ac82..3365f4f 100644 --- a/tests/TotalsTest.php +++ b/tests/TotalsTest.php @@ -83,8 +83,11 @@ public function testTaxableFees() { $this->laracart->addFee('test_2', 1, true); - $this->assertEquals('$1.07', $this->laracart->feeTotals()); - $this->assertEquals('1.07', $this->laracart->feeTotals(false)); + $this->assertEquals('$1.00', $this->laracart->feeTotals()); + $this->assertEquals(1, $this->laracart->feeTotals(false)); + + $this->assertEquals("$0.07", $this->laracart->taxTotal()); + $this->assertEquals("0.07", $this->laracart->taxTotal(false)); } /**