Merge pull request #373 from woocommerce/pcp-333-fix-tax-mismatch

Use subtotal_tax instead of adding taxes ourselves
This commit is contained in:
Emili Castells 2021-11-23 12:33:46 +01:00 committed by GitHub
commit 2638486331
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -64,7 +64,7 @@ class AmountFactory {
);
$taxes = new Money(
(float) $cart->get_cart_contents_tax() + (float) $cart->get_discount_tax(),
$cart->get_subtotal_tax(),
$currency
);

View file

@ -43,6 +43,9 @@ class AmountFactoryTest extends TestCase
$cart
->shouldReceive('get_discount_tax')
->andReturn(7);
$cart
->shouldReceive('get_subtotal_tax')
->andReturn(8);
expect('get_woocommerce_currency')->andReturn($expectedCurrency);
@ -61,7 +64,7 @@ class AmountFactoryTest extends TestCase
$this->assertEquals($expectedCurrency, $result->breakdown()->shipping()->currency_code());
$this->assertEquals((float) 5, $result->breakdown()->item_total()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->item_total()->currency_code());
$this->assertEquals((float) 13, $result->breakdown()->tax_total()->value());
$this->assertEquals((float) 8, $result->breakdown()->tax_total()->value());
$this->assertEquals($expectedCurrency, $result->breakdown()->tax_total()->currency_code());
}
@ -95,6 +98,9 @@ class AmountFactoryTest extends TestCase
$cart
->shouldReceive('get_discount_tax')
->andReturn(0);
$cart
->shouldReceive('get_subtotal_tax')
->andReturn(11);
expect('get_woocommerce_currency')->andReturn($expectedCurrency);