From 09cc4353ce71f6347630275090aadbed1a85343e Mon Sep 17 00:00:00 2001 From: Jakub Theimer <5587309+theimerj@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:46:07 +0100 Subject: [PATCH 1/4] remove config key --- config/general.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/general.php b/config/general.php index 539f8be1..aa195571 100644 --- a/config/general.php +++ b/config/general.php @@ -23,11 +23,6 @@ 'max_size' => 48, ], - // Tax defaults - 'taxation' => [ - 'prices_with_default_tax' => true, - ], - // Purchasable 'purchasable' => [ 'non_eloquent_types' => [ From 281be308ac4887b5b4d8d126b521202c22d3e462 Mon Sep 17 00:00:00 2001 From: Jakub Theimer <5587309+theimerj@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:46:22 +0100 Subject: [PATCH 2/4] use lunar config and reverse the condition --- src/Domain/Prices/Actions/GetPrice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Domain/Prices/Actions/GetPrice.php b/src/Domain/Prices/Actions/GetPrice.php index e828b84a..b044a27d 100644 --- a/src/Domain/Prices/Actions/GetPrice.php +++ b/src/Domain/Prices/Actions/GetPrice.php @@ -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; } @@ -24,7 +24,7 @@ public function __construct() */ public function __invoke(Price $price, Purchasable $purchasable): Price { - if ($this->withTax) { + if (! $this->withTax) { return ($this->getPriceWithDefaultTax)($price, $purchasable); } From eb7d68765a96bede2f2acd031413aa441bdb406e Mon Sep 17 00:00:00 2001 From: Jakub Theimer <5587309+theimerj@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:48:11 +0100 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47af18af..53eab49b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From fabda2d0f51536a617124a7a60977850001515eb Mon Sep 17 00:00:00 2001 From: Jakub Theimer <5587309+theimerj@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:50:59 +0100 Subject: [PATCH 4/4] swap condition and add note --- src/Domain/Prices/Actions/GetPrice.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Domain/Prices/Actions/GetPrice.php b/src/Domain/Prices/Actions/GetPrice.php index b044a27d..8923c4df 100644 --- a/src/Domain/Prices/Actions/GetPrice.php +++ b/src/Domain/Prices/Actions/GetPrice.php @@ -24,10 +24,11 @@ public function __construct() */ public function __invoke(Price $price, Purchasable $purchasable): Price { - if (! $this->withTax) { - return ($this->getPriceWithDefaultTax)($price, $purchasable); + // NOTE: If prices are stored inclusive of tax, we can return the price as is + if ($this->withTax) { + return $price; } - return $price; + return ($this->getPriceWithDefaultTax)($price, $purchasable); } }