Merge pull request #18656 from woocommerce/fix/18653

Increase precision from 4 to 6
This commit is contained in:
Claudiu Lodromanean 2018-01-30 07:32:56 -08:00 committed by GitHub
commit 30c612643c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View File

@ -204,7 +204,7 @@ final class WooCommerce {
$this->define( 'WC_PLUGIN_BASENAME', plugin_basename( WC_PLUGIN_FILE ) );
$this->define( 'WC_VERSION', $this->version );
$this->define( 'WOOCOMMERCE_VERSION', $this->version );
$this->define( 'WC_ROUNDING_PRECISION', 4 );
$this->define( 'WC_ROUNDING_PRECISION', 6 );
$this->define( 'WC_DISCOUNT_ROUNDING_MODE', 2 );
$this->define( 'WC_TAX_ROUNDING_MODE', 'yes' === get_option( 'woocommerce_prices_include_tax', 'no' ) ? 2 : 1 );
$this->define( 'WC_DELIMITER', '|' );

View File

@ -978,7 +978,7 @@ function wc_get_price_excluding_tax( $product, $args = array() ) {
if ( $product->is_taxable() && wc_prices_include_tax() ) {
$tax_rates = WC_Tax::get_base_tax_rates( $product->get_tax_class( 'unfiltered' ) );
$taxes = WC_Tax::calc_tax( $price * $qty, $tax_rates, true );
$price = WC_Tax::round( $price * $qty - array_sum( $taxes ) );
$price = WC_Tax::round( $price * $qty - wc_round_tax_total( array_sum( $taxes ) ) );
} else {
$price = $price * $qty;
}

View File

@ -42,7 +42,7 @@ class WC_Test_WooCommerce extends WC_Unit_Test_Case {
$this->assertEquals( str_replace( 'tests/unit-tests/core/', '', plugin_dir_path( __FILE__ ) ) . 'woocommerce.php', WC_PLUGIN_FILE );
$this->assertEquals( $this->wc->version, WC_VERSION );
$this->assertEquals( WC_VERSION, WOOCOMMERCE_VERSION );
$this->assertEquals( 4, WC_ROUNDING_PRECISION );
$this->assertEquals( 6, WC_ROUNDING_PRECISION );
$this->assertEquals( 2, WC_DISCOUNT_ROUNDING_MODE );
$this->assertEquals( 'wc_session_id', WC_SESSION_CACHE_GROUP );
$this->assertContains( WC_TAX_ROUNDING_MODE, array( 2, 1, 'auto' ) );

View File

@ -423,7 +423,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
* Test the rounding method.
*/
public function test_round() {
$this->assertEquals( WC_Tax::round( '2.1234567' ), '2.1235' );
$this->assertEquals( WC_Tax::round( '2.123456789' ), '2.123457' );
}
/**