[Rails] Fertilizer recipe solver for the FAPG.
1
<div class="table-responsive">
2
<table class="table table-sm align-middle mb-0">
3
<thead class="table-light">
4
<tr>
5
<th>Fertilizer product</th>
6
<th class="text-muted">Component</th>
7
<th class="text-end">Qty (kg)</th>
8
<th class="text-end">Per portion (kg)</th>
9
</tr>
10
</thead>
11
<tbody>
12
<% pcount = [[portions.to_i, 2].max, 10].min %>
13
<% recipe&.each do |component, kg| %>
14
<% prod_name = commercial_name_for(component) %>
15
<tr>
16
<td><strong><%= prod_name %></strong></td>
17
<td class="text-muted"><small><%= component.name %></small></td>
18
<td class="text-end fw-semibold"><%= fmt_kg(kg) %></td>
19
<td class="text-end"><%= fmt_kg(kg / pcount.to_f) %></td>
20
</tr>
21
<% end %>
22
<% if recipe.blank? %>
23
<tr><td colspan="4" class="text-center text-muted">No supplementation required.</td></tr>
24
<% end %>
25
</tbody>
26
</table>
27
</div>
28
29
<div class="card-footer small text-muted">
30
Volume: <%= number_with_delimiter(volume) %> L —
31
Portions: <%= pcount %>
32
</div>
33