update price during editing as well

This commit is contained in:
wvengen 2013-12-10 13:30:15 +01:00
parent 62ca3cb634
commit 58de1a231b

View file

@ -46,12 +46,12 @@
:javascript :javascript
var form = $('form.edit_article, form.new_article'); var form = $('form.edit_article, form.new_article');
$('#article_price, #article_tax, #article_deposit', form).on('change', function() { $('#article_price, #article_tax, #article_deposit', form).on('change keyup', function() {
var price = parseFloat($('#article_price', form).val()); var price = parseFloat($('#article_price', form).val());
var tax = parseFloat($('#article_tax', form).val()); var tax = parseFloat($('#article_tax', form).val());
var deposit = parseFloat($('#article_deposit', form).val()); var deposit = parseFloat($('#article_deposit', form).val());
// Article#gross_price and Article#fc_price // Article#gross_price and Article#fc_price
var gross_price = (price + deposit) * (tax / 100 + 1); var gross_price = (price + deposit) * (tax / 100 + 1);
var fc_price = gross_price * (#{FoodsoftConfig[:price_markup].to_f} / 100 + 1); var fc_price = gross_price * (#{FoodsoftConfig[:price_markup].to_f} / 100 + 1);
$('#fc_price').html(I18n.l("currency", fc_price)); $('#fc_price').html($.isNumeric(fc_price) ? I18n.l("currency", fc_price) : '…');
}); });