我需要你的支持ruby on rails。我试图根据新的和编辑计算价格和数量的结果。查看是否有效。 我使用Simple_form,计算输入数量和价格。自动并且必须保留结果。发送代码。
<%= simple_form_for(@ticket) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :fecha %>
<%= f.input :impuesto, :input_html => { value: '18.00'} %>
<%= f.association :customer, label_method: "#{:nombre}", value_method: :id, prompt: "Debes buscar la empresa" %>
<%= f.association :status %>
<div>
<table id="items">
<tr>
<th class="text-center" width="60px">ITEM</th>
<th class="text-center" width="160px">CODIGO</th>
<th class="text-center" width="225px">DESCRIPCION</th>
<th class="text-center" width="100px">CANTIDAD</th>
<th class="text-center" width="110px">PRECIO</th>
<th class="text-center" width="150px">TOTAL <%= @empresa.moneda1 %></th>
<th></th>
</tr>
</table>
<%= simple_nested_form_for @ticket, :wrapper => false do |g| %>
<table id="detail_tickets">
<%= g.simple_fields_for :detail_tickets do |p| %>
<tr class="fields">
<th align="center" width="60px" class="text-center"><%= p.input :item, label: false %></th>
<th align="center" width="160px"><%= p.input :code, label: false %></th>
<th align="center" width="225px" class="description"><%= p.input :description, label: false, :input_html => {:rows => 3} %></th>
<th align="center" width="100px" class="text-center"><%= p.input :cantidad, label: false %></th>
<th align="center" width="110px" class="text-right"><%= p.input :price, label: false %></th>
<% @total_price = params[:cantidad].to_s.to_d * params[:price].to_s.to_d %>
<th align="right" width="150px" class="text-right"><%= @total_price %></th>
<th align="center" width="63px" class="text-center"><%= p.link_to_remove "", class: "btn btn-danger fa fa-trash" %></th>
</tr>
<% end %>
</table>
<table id="items">
<tr>
<th width="700px"></th>
<th class="text-center" width="110px">VALOR DE VENTA : </th>
<th class="text-center" width="150px"></th>
</tr>
<tr>
<th width="700px"></th>
<th class="text-center" width="110px">I.G.V. : </th>
<th class="text-center" width="150px"></th>
</tr>
<tr>
<th width="700px"></th>
<th class="text-center" width="110px">TOTAL : </th>
<th class="text-center" width="150px"></th>
</tr>
</table>
<br>
<br>
<p><%= g.link_to_add "Adicionar Producto", :detail_tickets, :data => { :target => "#detail_tickets" }, class: "btn btn-primary" %></p>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
<% end %>