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: new sellingPrice value considering unit multiplier and tax percentage for product price #114

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"es6": true,
"jest": true
}
}
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- SellingPriceWithUnitMultiplierAndTax variable for ICU

## [1.31.0] - 2023-03-28

### Added
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ In addition to that, keep in mind the message variables for each block since you
| `sellingPriceValue` | `string` | Selling price value. |
| `sellingPriceWithTax` | `string` | Selling price with tax. |
| `sellingPriceWithUnitMultiplier` | `string` | Selling price multiplied by unit multiplier. |
| `sellingPriceWithUnitMultiplierAndTax` | `string` | Selling price multiplied by unit multiplier and added tax. |
| `taxPercentage` | `string` | Tax percentage. |
| `hasListPrice` | `boolean` | Whether the product has a list price (`true`) or not (`false`). |
| `taxValue` | `string` | Tax value. |
Expand Down
2 changes: 1 addition & 1 deletion messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"admin/selling-price-range-message.title": "Preço de venda (faixa)",
"admin/selling-price-range-no-range-message.description": "Mensagem a ser mostrada quando não houver diferença de preço entre SKUs.\nValores disponíveis para interpolação: '{sellingPriceValue}, {sellingPriceWithTax}'",
"admin/selling-price-range-no-range-message.title": "Preço de venda (sem faixa)"
}
}
14 changes: 13 additions & 1 deletion react/SellingPrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const CSS_HANDLES = [
'sellingPriceValue',
'sellingPriceWithTax',
'sellingPriceWithUnitMultiplier',
'sellingPriceWithUnitMultiplierAndTax',
'taxPercentage',
'taxValue',
'measurementUnit',
Expand Down Expand Up @@ -75,7 +76,10 @@ function SellingPrice({
productContextValue?.selectedItem?.measurementUnit ?? ''

const unitMultiplier = productContextValue?.selectedItem?.unitMultiplier ?? 1
const sellingPriceWithUnitMultiplier = commercialOffer.Price * unitMultiplier
const sellingPriceWithUnitMultiplier = sellingPriceValue * unitMultiplier

const sellingPriceWithUnitMultiplierAndTax =
(sellingPriceValue + sellingPriceValue * (taxPercentage/unitMultiplier)) * unitMultiplier

const taxValue = commercialOffer.Tax

Expand Down Expand Up @@ -118,6 +122,14 @@ function SellingPrice({
<FormattedCurrency value={sellingPriceWithUnitMultiplier} />
</span>
),
sellingPriceWithUnitMultiplierAndTax: (
<span
key="sellingPriceWithUnitMultiplierAndTax"
className={handles.sellingPriceWithUnitMultiplierAndTax}
>
<FormattedCurrency value={sellingPriceWithUnitMultiplierAndTax} />
</span>
),
taxPercentage: (
<span key="taxPercentage" className={handles.taxPercentage}>
<FormattedNumber value={taxPercentage} style="percent" />
Expand Down