Skip to content

Commit

Permalink
Fixed: Incorrect price for selected variant shown (OFBIZ-12236)
Browse files Browse the repository at this point in the history
When the webshop (ecommerce component) has been set up for retail (B2C), with

    the tax setting 'Show prices with VAT tax included' set to 'Y' in store 9000
    the appropriat Tax Auth Geo and Tax Auth set in store 9000
    the flag 'Include Tax In Price' set to 'Y' for the Tax Auth
    the price for a virtual product is shown including VAT.

However, for a selected variant the price shown is without VAT

Thanks: Pierre Smits to raise the issue and Priya Sharma for solved it
  • Loading branch information
nmalin committed Sep 27, 2021
1 parent dabafa7 commit cf70c72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Expand Up @@ -288,8 +288,8 @@ if (inlineProduct) {
}
amt.append(" if (sku == \"" + variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + "\"; ")
variantInfoJS.append(" variantReqAmounts['" + variant.productId + "'] = '" + (variant.requireAmount ?: "N") + "';\n")
variantPriceJS.append(" if (sku == \"" + variant.productId + "\") return \"" + numberFormat.format(variantPriceMap.basePrice) + "\"; ")
variantInfoJS.append(" variantPrices['" + variant.productId + "'] = '" + numberFormat.format(variantPriceMap.basePrice) + "';\n")
variantPriceJS.append(" if (sku == \"" + variant.productId + "\") return \"" + numberFormat.format(variantPriceMap.price) + "\"; ")
variantInfoJS.append(" variantPrices['" + variant.productId + "'] = '" + numberFormat.format(variantPriceMap.price) + "';\n")
}
amt.append(" } ")
variantPriceJS.append(" } ")
Expand Down
Expand Up @@ -446,9 +446,9 @@ if (product) {
}
amt.append(" if (sku == \"" + variant.productId + "\") return \"" + (variant.requireAmount ?: "N") + "\"; ")
variantInfoJS.append(" variantReqAmounts['" + variant.productId + "'] = '" + (variant.requireAmount ?: "N") + "';\n")
if (variantPriceMap && variantPriceMap.basePrice) {
variantPriceJS.append(" if (sku == \"" + variant.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.basePrice, currencyUomId, locale, 10) + "\"; ")
variantInfoJS.append(" variantPrices['" + variant.productId + "'] = '" + UtilFormatOut.formatCurrency(variantPriceMap.basePrice, currencyUomId, locale, 10) + "';\n")
if (variantPriceMap && variantPriceMap.price) {
variantPriceJS.append(" if (sku == \"" + variant.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.price, currencyUomId, locale, 10) + "\"; ")
variantInfoJS.append(" variantPrices['" + variant.productId + "'] = '" + UtilFormatOut.formatCurrency(variantPriceMap.price, currencyUomId, locale, 10) + "';\n")
}

// make a list of virtual variants sku with requireAmount
Expand Down Expand Up @@ -487,8 +487,8 @@ if (product) {
}
}
variantPriceList.add(virtualPriceMap)
variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.basePrice, currencyUomId, locale, 10) + "\"; ")
variantInfoJS.append(" variantPrices['" + virtual.productId + "'] = '" + UtilFormatOut.formatCurrency(variantPriceMap.basePrice, currencyUomId, locale, 10) + "';\n")
variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.price, currencyUomId, locale, 10) + "\"; ")
variantInfoJS.append(" variantPrices['" + virtual.productId + "'] = '" + UtilFormatOut.formatCurrency(variantPriceMap.price, currencyUomId, locale, 10) + "';\n")
} else {
virtualPriceMap = runService('calculatePurchasePrice', priceContext)
variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(variantPriceMap.price, currencyUomId, locale, 10) + "\"; ")
Expand Down Expand Up @@ -545,8 +545,8 @@ if (product) {
BigDecimal calculatedPrice = (BigDecimal)virtualPriceMap.get("price")
// Get the minimum quantity for variants if MINIMUM_ORDER_PRICE is set for variants.
virtualVariantPriceList.add(virtualPriceMap)
variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(virtualPriceMap.basePrice, currencyUomId, locale, 10) + "\"; ")
variantInfoJS.append(" variantPrices['" + virtual.productId + "'] = '" + UtilFormatOut.formatCurrency(virtualPriceMap.basePrice, currencyUomId, locale, 10) + "';\n")
variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(virtualPriceMap.price, currencyUomId, locale, 10) + "\"; ")
variantInfoJS.append(" variantPrices['" + virtual.productId + "'] = '" + UtilFormatOut.formatCurrency(virtualPriceMap.price, currencyUomId, locale, 10) + "';\n")
} else {
virtualPriceMap = runService('calculatePurchasePrice', priceContext)
variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + UtilFormatOut.formatCurrency(virtualPriceMap.price, currencyUomId, locale, 10) + "\"; ")
Expand Down
Expand Up @@ -191,13 +191,13 @@ if (product) {
} else {
virtualPriceMap = runService('calculatePurchasePrice', priceContext)
}
if (virtualPriceMap.basePrice) {
basePrice = numberFormat.format(virtualPriceMap.basePrice)
if (virtualPriceMap.price) {
price = numberFormat.format(virtualPriceMap.price)
} else {
basePrice = UtilProperties.getResourceBundleMap("CommonUiLabels", locale).get("CommonNA")
price = UtilProperties.getResourceBundleMap("CommonUiLabels", locale).get("CommonNA")
}
variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + basePrice + "\"; ")
variantInfoJS.append(" variantPrices['" + virtual.productId + "'] = '" + basePrice + "';\n")
variantPriceJS.append(" if (sku == \"" + virtual.productId + "\") return \"" + price + "\"; ")
variantInfoJS.append(" variantPrices['" + virtual.productId + "'] = '" + price + "';\n")
}
variantPriceJS.append(" } ")

Expand All @@ -208,7 +208,7 @@ if (product) {
context.virtualJavaScript = jsBuf
}
}
variantInfoJS.append(" variantPrices['" + product.productId + "'] = '" + numberFormat.format(priceMap.basePrice) + "';\n")
variantInfoJS.append(" variantPrices['" + product.productId + "'] = '" + numberFormat.format(priceMap.price) + "';\n")
variantInfoJS.append(" });\n</script>\n")
context.variantInfoJavaScript = variantInfoJS

Expand Down

0 comments on commit cf70c72

Please sign in to comment.