Updated order and line item display
[depot.git] / app / views / orders / index.html.erb
index 39e117ecda9b3a5ac7514eb0116bac0f57f0bf10..640e77e3bea4078a5276769b9bdb2afc8f469eea 100644 (file)
@@ -6,6 +6,7 @@
     <th>Address</th>
     <th>Email</th>
     <th>Pay type</th>
+    <th>Total value</th>
   </tr>
 
 <% for order in @orders %>
     <td><%=h order.address %></td>
     <td><%=h order.email %></td>
     <td><%=h order.pay_type %></td>
+    <td><%= number_to_currency (order.line_items.inject(0) {|sum,item| sum + item.total_price}), :unit => "£" %></td>
     <td><%= link_to 'Show', order %></td>
     <td><%= link_to 'Edit', edit_order_path(order) %></td>
     <td><%= link_to 'Destroy', order, :confirm => 'Are you sure?', :method => :delete %></td>
   </tr>
+  <% for li in order.line_items %>
+    <tr>
+      <td> </td>
+      <td colspan="3"><i><%= li.quantity%> &times;
+        <%= h li.product.title %> =
+        <%= number_to_currency li.total_price, :unit => "£" %>
+      </i></td>
+    </tr>
+  <% end %>
+
 <% end %>
 </table>