Skip to content

Conversation

@DylannCordel
Copy link
Contributor

(and also avoid a ParseInt call for each item tested)

And avoid a `ParseInt` call for each item tested.
DylannCordel added a commit to DylannCordel/storefront-api that referenced this pull request Feb 5, 2020
(and also avoid a ParseInt call for each item tested)

See vuestorefront/vue-storefront#4056
Copy link
Collaborator

@pkarw pkarw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, good one :) Please update changelog

@andrzejewsky andrzejewsky changed the base branch from master to hotfix/v1.11.2 February 9, 2020 18:14
@andrzejewsky
Copy link
Contributor

@DylannCordel just changed base for you - please only update changelog as @pkarw and we can merge it.

@DylannCordel
Copy link
Contributor Author

DylannCordel commented Feb 10, 2020

Thx @andrzejewsky and @pkarw
Changelog has been updated. Same fix on the API has been merged into master branch. If calculateServerSide is set to True, same bug will still be there until people update the API once it will be released. To avoid that without changing the API source code, a trick is to filter tax rules before the calculateProductTax call. It can been done in the <platform>.taxFor method. eg:

  taxFor (product) {
    let product_tax_class_id = parseInt(product.tax_class_id)
    let productTaxRules = this._taxClasses.filter(
      (taxRule) => taxRule.product_tax_class_ids.indexOf(product_tax_class_id) > -1
    );
    // we DO NOT use `this._taxClasses` because `calculateProductTax` is currently bugged.
    // we MUST pre-filter tax rules to only keep matching rules for the current product.
    return calculateProductTax(product, productTaxRules, this._taxCountry, this._taxRegion, this._sourcePriceInclTax)
  }

I let this here if it can be usefull for someone.

@andrzejewsky andrzejewsky merged commit 9348267 into vuestorefront:hotfix/v1.11.2 Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants