Skip to content

Commit

Permalink
Merge pull request #78 from lukepolo/coupon_taxation
Browse files Browse the repository at this point in the history
Coupon taxation
  • Loading branch information
lukepolo committed Feb 10, 2016
2 parents 448de3e + df73033 commit 10316f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/LaraCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,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);
}

Expand Down Expand Up @@ -556,9 +562,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);
Expand Down
7 changes: 5 additions & 2 deletions tests/TotalsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 10316f5

Please sign in to comment.