Kercode/tutti_gruppi

View on GitHub
app/views/groupment/order_groupment_quantity.html.erb

Summary

Maintainability
Test Coverage
<table class="container-fluid text-center">
  <thead>
    <tr>
      <% @member_gpmt.each do |member| %>
        <th> <%= member.authentication.fullname %></th>
      <% end %>
      <th> Nom du produit </th>
      <th> nb. total </th>
    </tr>
  </thead>
  <tbody>
  <% @products.each do |product| %>
      <% quantitytotal = 0 %>
      <tr>
        <% @member_gpmt.each do |member| %>
          <% quantity = 0 %>
          <% if Order.find_by(authentication_id:member.authentication_id, date: Date.today.beginning_of_month..Date.today.end_of_month, accept: true)  %>
            <% order = Order.find_by(authentication_id:member.authentication_id, date: Date.today.beginning_of_month..Date.today.end_of_month)  %>
            <% orderitem = OrderItem.where(order_id: order.id, product_id: product.id) %>
            <% orderitem.each do |oi| %>
              <% quantity = oi.quantity %>
              <% quantitytotal += oi.quantity %>
            <% end %>
          <% end %>
          <td class="border_command"> <%= quantity %> </td>
        <% end %>
        <td class="border_command">  <%= t("product.#{product.name}") %> </td>
        <td class="border_command"> <%= quantitytotal %> </td>
      </tr>
  <% end %>
  </tbody>
</table>

<%= link_to 'Back', manager_groupment_path || root_path, id: 'btns' %>