Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix price taxation config #209

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changes

- Removed relationship links from responses by default
- Changed price taxation config to `lunar.pricing.stored_inclusive_of_tax` from `lunar-api.general.taxation.prices_with_default_tax`

### ⚠️ Breaking changes

Expand Down
5 changes: 0 additions & 5 deletions config/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
'max_size' => 48,
],

// Tax defaults
'taxation' => [
'prices_with_default_tax' => true,
],

// Purchasable
'purchasable' => [
'non_eloquent_types' => [
Expand Down
7 changes: 4 additions & 3 deletions src/Domain/Prices/Actions/GetPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GetPrice

public function __construct()
{
$this->withTax = Config::get('lunar-api.general.taxation.prices_with_default_tax');
$this->withTax = Config::get('lunar.pricing.stored_inclusive_of_tax');

$this->getPriceWithDefaultTax = new GetPriceWithDefaultTax;
}
Expand All @@ -24,10 +24,11 @@ public function __construct()
*/
public function __invoke(Price $price, Purchasable $purchasable): Price
{
// NOTE: If prices are stored inclusive of tax, we can return the price as is
if ($this->withTax) {
return ($this->getPriceWithDefaultTax)($price, $purchasable);
return $price;
}

return $price;
return ($this->getPriceWithDefaultTax)($price, $purchasable);
}
}