Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
lukepolo authored and StyleCIBot committed Jan 27, 2018
1 parent 3255001 commit 3a80e96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/CartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ public function getDiscount($format = true)
* Gets the tax for the item.
*
* @param int $amountNotTaxable
*
* @param int $totalDiscount
*
* @return int|mixed
*/
public function tax($amountNotTaxable = 0, $totalDiscount = 0)
Expand All @@ -296,18 +296,17 @@ public function tax($amountNotTaxable = 0, $totalDiscount = 0)
$itemCount++;
}

if($totalDiscount !== 0) {
$totalTax = $totalTax - ($totalDiscount - ($totalDiscount/(1 + $this->tax)));
if ($totalDiscount !== 0) {
$totalTax = $totalTax - ($totalDiscount - ($totalDiscount / (1 + $this->tax)));
}

return $totalTax - $amountNotTaxable;
}

$totalTax = $this->tax * ($this->subTotal(false, !config('laracart.discountTaxable', false), true) - $amountNotTaxable);


if($totalDiscount !== 0) {
$totalTax = $totalTax - ($totalDiscount - ($totalDiscount/(1 + $this->tax)));
if ($totalDiscount !== 0) {
$totalTax = $totalTax - ($totalDiscount - ($totalDiscount / (1 + $this->tax)));
}

return $totalTax;
Expand Down
4 changes: 3 additions & 1 deletion src/LaraCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ public function removeFees()
*
* @param bool|true $format
* @param bool|true $withFees
* @param bool $grossTaxes
* @param bool $grossTaxes
*
* @return string
*/
public function taxTotal($format = true, $withFees = true, $grossTaxes = true)
Expand Down Expand Up @@ -600,6 +601,7 @@ public function taxTotal($format = true, $withFees = true, $grossTaxes = true)
}
}
}

return $this->formatMoney($totalTax, null, null, $format);
}

Expand Down
5 changes: 3 additions & 2 deletions tests/TotalsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ public function testTaxationOnCoupons()
$this->assertEquals(6639.12, $this->laracart->total(false));
}

public function testTaxationAndDiscount() {
public function testTaxationAndDiscount()
{
$this->app['config']->set('laracart.tax', .19);
$this->app['config']->set('laracart.tax_by_item', true);
$this->app['config']->set('laracart.discountTaxable', false);
Expand All @@ -322,7 +323,7 @@ public function testTaxationAndDiscount() {
);

$coupon = new \LukePOLO\LaraCart\Coupons\Fixed('50EUR', 50, [
'description' => '50EUR'
'description' => '50EUR',
]);

$this->laracart->addCoupon($coupon);
Expand Down

0 comments on commit 3a80e96

Please sign in to comment.