Skip to content

Conversation

@thomasthune
Copy link

Makes code more readable as well as fixes bug where special_price tax is not added to the product.

Flip priceTax and ProductInclTax calculation as to only calculate price tax once. Use const rateFactor instread of calculating it each time.

Example

  product.priceInclTax = (priceExclTax + priceExclTax * (parseFloat(rate.rate) / 100))
  product.priceTax = (priceExclTax * (parseFloat(rate.rate) / 100))

becomes

  product.priceTax = priceExclTax * rateFactor
  product.priceInclTax = priceExclTax + product.priceTax

@pkarw
Copy link
Collaborator

pkarw commented Jul 30, 2018

Thanks! That makes sense. However I'm wondering about the parseFloat removal ..

@pkarw
Copy link
Collaborator

pkarw commented Jul 30, 2018

@thomasthune
Copy link
Author

Will do, didn't get the error locally though 🤔
About removing the extra parseFloat(); price, special_price and the rate, are at the only 3 numbers that are actually strings (as far as i can see). Converting them to number means that the rest of whats happening is math involving numbers, and hence any extra parseFloat() would be superfluous.
Please correct me if I'm wrong. 😄

Will push update for linting during the day.

@thomasthune thomasthune force-pushed the bugfix/special-price-tax-calculation branch from fa2bb5e to 994c1e3 Compare July 31, 2018 08:23
@pkarw
Copy link
Collaborator

pkarw commented Jul 31, 2018

Thanks! That make sense, thanks for clarifying

@pkarw pkarw merged commit 5c0a374 into vuestorefront:develop Jul 31, 2018
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.

2 participants