Skip to content

Commit

Permalink
[1.x] Add hasTax (#149)
Browse files Browse the repository at this point in the history
* `hasTax()` for price (#126)

* Update Price.php

* Update ProductPriceTest.php

* Update Price.php

* Update Price.php

Co-authored-by: Taylor Otwell <[email protected]>

* Apply fixes from StyleCI

Co-authored-by: Lars Klopstra <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
4 people authored Jan 6, 2022
1 parent 3d6e6e8 commit 6d554fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public function tax()
return $this->formatAmount((int) ($this->rawTax() * 100));
}

/**
* Determine if the price has tax.
*
* @return bool
*/
public function hasTax()
{
return $this->rawTax() > 0;
}

/**
* Get the raw tax amount.
*
Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/ProductPriceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ public function test_it_implements_arrayable_and_jsonable()
$this->assertSame(json_encode($data), $product->toJson());
}

public function test_it_can_check_if_has_tax()
{
$product = $this->product();

$this->assertTrue($product->price()->hasTax());
}

/**
* Get a test product price object.
*
Expand Down

0 comments on commit 6d554fa

Please sign in to comment.