Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added price with tax without unit multiplier #121

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mihainutiu-vtex
Copy link

@mihainutiu-vtex mihainutiu-vtex commented Jun 15, 2023

What problem is this solving?

I've added a new handle for sellingPriceWithTaxWithoutUnit and listPriceWithTaxWithoutUnit that allows the display of a product that has a unit multiplier and also taxes. The default sellingPriceWithTax calculates the taxes for the entire quantity, not for 1 unit.

How to test it?

You can install [email protected] and change the price block configuration on a PDP. The product you are viewing must have a unit multiplier different from 1 and also active taxes.

You can check out this product that has a 5,0 unit multiplier, 100 ron price and a 10% tax.
You can notice the calculation using the default {sellingPriceWithTax} will display the price for 1 unit but the tax for all 5 units
https://vtexromania.myvtex.com/rama-foto-argintata-jardin-d-eden-christofle/p

Screenshot 2023-06-15 at 13 18 52

Checking the new sellingPriceWithTaxWithoutUnit you will see the correct calculation for 1 unit + 1 unit tax
https://mihaitest--vtexromania.myvtex.com/rama-foto-argintata-jardin-d-eden-christofle/p

Screenshot 2023-06-15 at 13 19 02

@vtex-io-ci-cd
Copy link

vtex-io-ci-cd bot commented Jun 15, 2023

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@mihainutiu-vtex mihainutiu-vtex changed the title added price with tax without unit multiplier feat: added price with tax without unit multiplier Jun 15, 2023
@@ -79,6 +80,9 @@ function SellingPrice({

const taxValue = commercialOffer.Tax

const sellingPriceWithTaxWithoutUnit =
sellingPriceValue + (sellingPriceValue * taxPercentage / unitMultiplier)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the correct sellingPriceWithTax calculation, so it seems like there's no need to create another property for it. I suggest altering the sellingPriceWithTax value to what would be sellingPriceWithTaxWithoutUnit as it would properly represent the selling price of the product with taxes.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @icazevedo
The issue is that the commercial offer Tax that is used in the sellingPriceWithTax will return the tax for the entire multiplied value of the product.

If there is a product that costs 100$ and has a 10% tax and the product has a 5.0 unit multiplier then the commercialOffer.Tax will return the tax for all 5 units.
10% of 100 = 10
commercialOffer.Tax = 50

So when displaying the price of a product without the unit multiplier but with the tax, that value will be wrong (150$ instead of 110$)

Please check the description of this PR, and also the video recording I attached.

You can test on this workspace to see the variable.
on the master workspace you will see the sellingPriceWithTax variable.

Screen.Recording.2023-07-13.at.13.56.37.mov

Copy link
Author

Choose a reason for hiding this comment

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

Regarding modifying the sellingPriceWithTax it would mean modifying the commercialOffer.Tax and I think that would impact existing implementations. This way it will not be a breaking change. Maybe there are some use cases where the original sellingPriceWithTax calculation is used.

react/package.json Outdated Show resolved Hide resolved
@@ -78,6 +79,8 @@ function ListPrice({
const hasMeasurementUnit = measurementUnit && measurementUnit !== 'un'
const hasUnitMultiplier = unitMultiplier !== 1

const listPriceWithTaxWithoutUnit = listPriceValue + (listPriceValue * taxPercentage / unitMultiplier)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here

Copy link
Author

Choose a reason for hiding this comment

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

Hi @icazevedo
Like I mentioned in the other comment, these variables will return a different value. The regular listPriceWithTax will return the tax for all units in a sku with unit multiplier, so it is not enough. We need to be able to display the price of a single unit with taxes only for that unit, not the price for 1 unit but the tax for all units in the SKU.

@mihainutiu-vtex mihainutiu-vtex added the enhancement New feature or request label Jul 17, 2023
@marcelovicentegc
Copy link
Member

I'm closing this PR since it is 6 month old. If this is still relevant, feel free to reopen it.

@mihainutiu-vtex
Copy link
Author

Hi @marcelovicentegc
Yes, it is still relevant and we were waiting for it to be approved. I had published a hkignore 6 months ago to unblock the client but we need this new type of price definition to be available.
Please review and merge.

@mihainutiu-vtex
Copy link
Author

Hi @leo-prange-vtex Please no not close this PR... We have a client waiting for it, they need the new price values that were added in this update.
Can someone help us and validate this PR and merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants