-
Notifications
You must be signed in to change notification settings - Fork 27
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
base: master
Are you sure you want to change the base?
Changes from all commits
7ed3d0b
68b6c30
f589796
ad6410b
4089ba1
f219ef6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
"extends": "vtex", | ||
"root": true, | ||
"env": { | ||
"node": true, | ||
"es6": true, | ||
"jest": true | ||
"node": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ const CSS_HANDLES = [ | |
'sellingPrice', | ||
'sellingPriceValue', | ||
'sellingPriceWithTax', | ||
'sellingPriceWithTaxWithoutUnit', | ||
'sellingPriceWithUnitMultiplier', | ||
'taxPercentage', | ||
'taxValue', | ||
|
@@ -79,6 +80,9 @@ function SellingPrice({ | |
|
||
const taxValue = commercialOffer.Tax | ||
|
||
const sellingPriceWithTaxWithoutUnit = | ||
sellingPriceValue + (sellingPriceValue * taxPercentage / unitMultiplier) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the correct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @icazevedo 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. 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. Screen.Recording.2023-07-13.at.13.56.37.movThere was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
const hasListPrice = sellingPriceValue !== listPriceValue | ||
const hasMeasurementUnit = measurementUnit && measurementUnit !== 'un' | ||
const hasUnitMultiplier = unitMultiplier !== 1 | ||
|
@@ -110,6 +114,14 @@ function SellingPrice({ | |
<FormattedCurrency value={sellingPriceWithTax} /> | ||
</span> | ||
), | ||
sellingPriceWithTaxWithoutUnit: ( | ||
<span | ||
key="sellingPriceWithTaxWithoutUnit" | ||
className={handles.sellingPriceWithTaxWithoutUnit} | ||
> | ||
<FormattedCurrency value={sellingPriceWithTaxWithoutUnit} /> | ||
</span> | ||
), | ||
sellingPriceWithUnitMultiplier: ( | ||
<span | ||
key="sellingPriceWithUnitMultiplier" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here
There was a problem hiding this comment.
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.