Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 2771f2d

Browse files
committed
feat(ExternalTaxRateDraft): add field includedInPrice
closes #451
1 parent 2e9d74b commit 2771f2d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Core/Model/TaxCategory/ExternalTaxRateDraft.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* @method ExternalTaxRateDraft setState(string $state = null)
2121
* @method SubRateCollection getSubRates()
2222
* @method ExternalTaxRateDraft setSubRates(SubRateCollection $subRates = null)
23+
* @method bool getIncludedInPrice()
24+
* @method ExternalTaxRateDraft setIncludedInPrice(bool $includedInPrice = null)
2325
*/
2426
class ExternalTaxRateDraft extends JsonObject
2527
{
@@ -28,6 +30,7 @@ public function fieldDefinitions()
2830
return [
2931
'name' => [self::TYPE => 'string'],
3032
'amount' => [self::TYPE => 'float'],
33+
'includedInPrice' => [self::TYPE => 'bool'],
3134
'country' => [self::TYPE => 'string'],
3235
'state' => [self::TYPE => 'string'],
3336
'subRates' => [static::TYPE => SubRateCollection::class]

tests/integration/Cart/CartTaxModeTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testAddLineItemExternalTaxRate()
7272
->addAction(
7373
CartAddLineItemAction::ofProductIdVariantIdAndQuantity($product->getId(), $variant->getId(), 1)
7474
->setExternalTaxRate(
75-
ExternalTaxRateDraft::ofNameCountryAndAmount($taxRateName, $taxRateCountry, $taxRate)
75+
ExternalTaxRateDraft::ofNameCountryAndAmount($taxRateName, $taxRateCountry, $taxRate)->setIncludedInPrice(true)
7676
)
7777
)
7878
;
@@ -83,6 +83,7 @@ public function testAddLineItemExternalTaxRate()
8383
$this->assertSame($taxRateName, $cart->getLineItems()->current()->getTaxRate()->getName());
8484
$this->assertSame($taxRateCountry, $cart->getLineItems()->current()->getTaxRate()->getCountry());
8585
$this->assertSame($taxRate, $cart->getLineItems()->current()->getTaxRate()->getAmount());
86+
$this->assertTrue($cart->getLineItems()->current()->getTaxRate()->getIncludedInPrice());
8687
}
8788

8889
public function getSubRates()
@@ -182,6 +183,7 @@ public function testAddLineItemExternalTaxSubRatesOnly()
182183
$this->assertSame($taxRateName, $cart->getLineItems()->current()->getTaxRate()->getName());
183184
$this->assertSame($taxRateCountry, $cart->getLineItems()->current()->getTaxRate()->getCountry());
184185
$this->assertSame($taxRate, $cart->getLineItems()->current()->getTaxRate()->getAmount());
186+
$this->assertFalse($cart->getLineItems()->current()->getTaxRate()->getIncludedInPrice());
185187

186188
$subRates = [];
187189
foreach ($cart->getLineItems()->current()->getTaxRate()->getSubRates() as $subRate) {
@@ -208,6 +210,7 @@ public function testAddCustomLineItemExternalTaxRate()
208210
Money::ofCurrencyAndAmount('EUR', 100),
209211
'test',
210212
ExternalTaxRateDraft::ofNameCountryAndAmount($taxRateName, $taxRateCountry, $taxRate)
213+
->setIncludedInPrice(false)
211214
)
212215
)
213216
;
@@ -218,6 +221,7 @@ public function testAddCustomLineItemExternalTaxRate()
218221
$this->assertSame($taxRateName, $cart->getCustomLineItems()->current()->getTaxRate()->getName());
219222
$this->assertSame($taxRateCountry, $cart->getCustomLineItems()->current()->getTaxRate()->getCountry());
220223
$this->assertSame($taxRate, $cart->getCustomLineItems()->current()->getTaxRate()->getAmount());
224+
$this->assertFalse($cart->getCustomLineItems()->current()->getTaxRate()->getIncludedInPrice());
221225
}
222226

223227
/**

0 commit comments

Comments
 (0)