[-] BO : #PSFV-652 - Fix bug with price and decimal (TE/TI conversion)

This commit is contained in:
mDeflotte
2012-03-14 16:08:00 +00:00
parent 18e195b613
commit 5f0f5d4070
4 changed files with 13 additions and 8 deletions
@@ -193,12 +193,13 @@
<option value="-1">{l s='Reduction'}</option>
</select>
<span id="span_impact">&nbsp;&nbsp;{l s='of'}&nbsp;&nbsp;{if $currency->format % 2 != 0}{$currency->sign} {/if}
<input type="text" size="6" name="attribute_price" id="attribute_price" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.'); calcImpactPriceTI();"/>{if $currency->format % 2 == 0} {$currency->sign}{/if}
<input type="hidden" id="attribute_priceTEReal" name="attribute_price" value="0.00" />
<input type="text" size="6" id="attribute_price" value="0.00" onkeyup="$('#attribute_priceTEReal').val(this.value.replace(/,/g, '.')); if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.'); calcImpactPriceTI();"/>{if $currency->format % 2 == 0} {$currency->sign}{/if}
{if $country_display_tax_label}
{l s='(tax excl.)'}
<span {if $tax_exclude_option}style="display:none"{/if}> {l s='or'}
{if $currency->format % 2 != 0}{$currency->sign} {/if}
<input type="text" size="6" name="attribute_priceTI" id="attribute_priceTI" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.'); calcImpactPriceTE();"/>
<input type="text" size="6" name="attribute_priceTI" id="attribute_priceTI" value="0.00" onkeyup="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, '.'); calcImpactPriceTE();"/>
{if $currency->format % 2 == 0} {$currency->sign}{/if} {l s='(tax incl.)'}
</span> {l s='final product price will be set to'}
{if $currency->format % 2 != 0}{$currency->sign} {/if}
@@ -121,7 +121,8 @@ jQuery(document).ready(Customer.init);
<tr>
<td class="col-left"><label>{l s='Pre-tax retail price:'}</label></td>
<td style="padding-bottom:5px;">
{$currency->prefix}<input size="11" maxlength="14" id="priceTE" name="price" type="text" value="{$product->price|string_format:'%.2f'}" onchange="this.value = this.value.replace(/,/g, '.');" onkeyup="$('#priceType').val('TE');if (isArrowKey(event)) return; calcPriceTI();" />{$currency->suffix}
<input type="hidden" id="priceTEReal" name="price" value="{$product->price}" />
{$currency->prefix}<input size="11" maxlength="14" id="priceTE" name="price_displayed" type="text" value="{$product->price|string_format:'%.2f'}" onchange="noComma('priceTE'); $('#priceTEReal').val(this.value);" onkeyup="$('#priceType').val('TE'); $('#priceTEReal').val(this.value.replace(/,/g, '.')); if (isArrowKey(event)) return; calcPriceTI();" />{$currency->suffix}
<p class="preference_description">{l s='The pre-tax retail price to sell this product'}</p>
</td>
</tr>
+1
View File
@@ -53,6 +53,7 @@ virtual_product_nb_days, is_shareable)
getE('attribute_upc').value = upc;
getE('attribute_wholesale_price').value = Math.abs(wholesale_price);
getE('attribute_price').value = ps_round(Math.abs(price_impact), 2);
getE('attribute_priceTEReal').value = Math.abs(price_impact);
getE('attribute_weight').value = Math.abs(weight_impact);
getE('attribute_unity').value = Math.abs(unit_impact);
if ($('#attribute_ecotax').length != 0)
+7 -5
View File
@@ -61,7 +61,7 @@ function calcPrice()
function calcPriceTI()
{
var tax = getTax();
var priceTE = parseFloat(document.getElementById('priceTE').value.replace(/,/g, '.'));
var priceTE = parseFloat(document.getElementById('priceTEReal').value.replace(/,/g, '.'));
var newPrice = priceTE * ((tax / 100) + 1);
document.getElementById('priceTI').value = (isNaN(newPrice) == true || newPrice < 0) ? '' :
ps_round(newPrice, 2);
@@ -79,8 +79,9 @@ function calcPriceTE()
var tax = getTax();
var priceTI = parseFloat(document.getElementById('priceTI').value.replace(/,/g, '.'));
var newPrice = ps_round(priceTI - getEcotaxTaxIncluded(), 2) / ((tax / 100) + 1);
document.getElementById('priceTE').value = (isNaN(newPrice) == true || newPrice < 0) ? '' :
document.getElementById('priceTE').value = (isNaN(newPrice) == true || newPrice < 0) ? '' :
ps_round(newPrice.toFixed(2), 2);
document.getElementById('priceTEReal').value = (isNaN(newPrice) == true || newPrice < 0) ? 0 : ps_round(newPrice, 9);
document.getElementById('finalPrice').innerHTML = (isNaN(newPrice) == true || newPrice < 0) ? '' :
ps_round(priceTI.toFixed(2), 2);
document.getElementById('finalPriceWithoutTax').innerHTML = (isNaN(newPrice) == true || newPrice < 0) ? '' :
@@ -91,9 +92,9 @@ function calcPriceTE()
function calcImpactPriceTI()
{
var tax = getTax();
var priceTE = parseFloat(document.getElementById('attribute_price').value.replace(/,/g, '.'));
var priceTE = parseFloat(document.getElementById('attribute_priceTEReal').value.replace(/,/g, '.'));
var newPrice = priceTE * ((tax / 100) + 1);
$('#attribute_priceTI').val((isNaN(newPrice) == true || newPrice < 0) ? '' : ps_round(newPrice.toFixed(6), 6).toFixed(2));
$('#attribute_priceTI').val((isNaN(newPrice) == true || newPrice < 0) ? '' : ps_round(newPrice, 2).toFixed(2));
var total = ps_round((parseFloat($('#attribute_priceTI').val())*parseInt($('#attribute_price_impact').val())+parseFloat($('#finalPrice').html())), 2);
if (isNaN(total) || total < 0)
$('#attribute_new_total_price').html('0.00');
@@ -107,7 +108,8 @@ function calcImpactPriceTE()
var priceTI = parseFloat(document.getElementById('attribute_priceTI').value.replace(/,/g, '.'));
priceTI = (isNaN(priceTI)) ? 0 : ps_round(priceTI);
var newPrice = ps_round(priceTI, 2) / ((tax / 100) + 1);
$('#attribute_price').val((isNaN(newPrice) == true || newPrice < 0) ? '' :ps_round(newPrice.toFixed(6), 6));
$('#attribute_price').val((isNaN(newPrice) == true || newPrice < 0) ? '' :ps_round(newPrice, 2).toFixed(2));
$('#attribute_priceTEReal').val((isNaN(newPrice) == true || newPrice < 0) ? 0 : ps_round(newPrice, 9));
var total = ps_round((parseFloat($('#attribute_priceTI').val())*parseInt($('#attribute_price_impact').val())+parseFloat($('#finalPrice').html())), 2);
if (isNaN(total) || total < 0)
$('#attribute_new_total_price').html('0.00');