update fc price dynamically in article edit form
This commit is contained in:
parent
84191ddcd0
commit
05b934e79f
1 changed files with 13 additions and 1 deletions
|
@ -39,10 +39,22 @@
|
|||
%span.add-on= t 'number.currency.format.unit'
|
||||
= f.input_field :deposit, class: 'input-mini'
|
||||
%span#gross_price{style: 'margin-left: 10px'}
|
||||
= Article.human_attribute_name(:gross_price) + ' ' + number_to_currency(@article.gross_price) rescue nil
|
||||
= Article.human_attribute_name(:fc_price)
|
||||
%span#fc_price= number_to_currency(@article.fc_price) rescue nil
|
||||
|
||||
= f.input :order_number
|
||||
.modal-footer
|
||||
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
|
||||
= f.submit class: 'btn btn-primary'
|
||||
|
||||
:javascript
|
||||
var form = $('form.edit_article, form.new_article');
|
||||
$('#article_price, #article_tax, #article_deposit', form).on('change', function() {
|
||||
var price = parseFloat($('#article_price', form).val());
|
||||
var tax = parseFloat($('#article_tax', form).val());
|
||||
var deposit = parseFloat($('#article_deposit', form).val());
|
||||
// Article#gross_price and Article#fc_price
|
||||
var gross_price = (price + deposit) * (tax / 100 + 1);
|
||||
var fc_price = gross_price * (#{FoodsoftConfig[:price_markup].to_f} / 100 + 1);
|
||||
$('#fc_price').html(I18n.l("currency", fc_price));
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue