product sale checked

This commit is contained in:
phyusin
2018-03-29 10:47:29 +06:30
parent 56870f94b0
commit 1c13b04697
3 changed files with 34 additions and 24 deletions

View File

@@ -942,7 +942,7 @@ def self.get_menu_item_query(order_by)
"(CASE WHEN si.qty IS NOT NULL THEN (SUM(si.qty) * si.unit_price) ELSE 0 END) as grand_total," + "(CASE WHEN si.qty IS NOT NULL THEN (SUM(si.qty) * si.unit_price) ELSE 0 END) as grand_total," +
"mii.price as unit_price, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END) as product_name, "mii.price as unit_price, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END) as product_name,
mc.name as" + mc.name as" +
" menu_category_name,mc.id as menu_category_id, si.remark as status_type, " menu_category_name,mc.id as menu_category_id, si.status as status_type,
si.price as price ") si.price as price ")
.joins(" LEFT JOIN menu_item_instances mii ON menu_items.id = mii.menu_item_id" + .joins(" LEFT JOIN menu_item_instances mii ON menu_items.id = mii.menu_item_id" +
" LEFT JOIN menu_categories mc ON mc.id = menu_items.menu_category_id" + " LEFT JOIN menu_categories mc ON mc.id = menu_items.menu_category_id" +

View File

@@ -58,14 +58,14 @@
<% total_qty = 0 %> <% total_qty = 0 %>
<% @sale_data.each do |sale| %> <% @sale_data.each do |sale| %>
<% grand_total += sale.grand_total %> <% grand_total += sale.grand_total %>
<% if sale.status_type != "Discount" && sale.status_type != "foc" <% if sale.status_type != "Discount" && sale.status_type != "foc"
total_qty += sale.total_item total_qty += sale.total_item
end %> end %>
<% if sale.status_type == "foc" && sale.price > 0 <% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item total_qty += sale.total_item
end %> end %>
<% if !sale.status_type %>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %> <% if !cate_arr.include?(sale.menu_category_id) %>
@@ -81,8 +81,9 @@
<td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> <td><%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
<td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td> <td><%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %></td>
</tr> </tr>
<!-- sub total --> <!-- sub total -->
<!-- end sub total --> <!-- end sub total -->
<% end %>
<% end %> <% end %>
<tr> <tr>
<td colspan="3"></td> <td colspan="3"></td>

View File

@@ -23,31 +23,40 @@
<% total_qty = 0 %> <% total_qty = 0 %>
<% @sale_data.each do |sale| %> <% @sale_data.each do |sale| %>
<% grand_total += sale.grand_total %>
<% if sale.status_type != "Discount" && sale.status_type != "foc" <% if sale.status_type != "Discount" && sale.status_type != "foc"
total_qty += sale.total_item total_qty += sale.total_item
grand_total += sale.grand_total
end %> end %>
<% if sale.status_type == "foc" && sale.price > 0 <% if sale.status_type == "foc" && sale.price > 0
total_qty += sale.total_item total_qty += sale.total_item
grand_total += sale.grand_total
end %> end %>
<tr> <% if !sale.status_type %>
<td>&nbsp;</td> <tr>
<td><%= sale.menu_category_name %></td> <td>&nbsp;</td>
<td><%= sale.item_code rescue '-' %></td> <% if !cate_arr.include?(sale.menu_category_id) %>
<td><%= sale.product_name rescue '-' %></td> <td><%= sale.menu_category_name %></td>
<td><%= sale.total_item rescue '-' %></td> <% cate_arr.push(sale.menu_category_id) %>
<td><%= sale.unit_price rescue '-' %></td> <% else %>
<td><%= sale.grand_total rescue '-' %></td> <% cate_arr = Array.new %>
</tr> <td>&nbsp;</td>
<% end %>
<td><%= sale.item_code rescue '-' %></td>
<td><%= sale.product_name rescue '-' %></td>
<td><%= sale.total_item rescue ' ' %></td>
<td><%= sale.unit_price rescue ' ' %></td>
<td><%= sale.grand_total rescue ' ' %></td>
</tr>
<!-- sub total -->
<!-- end sub total -->
<% end %>
<% end %> <% end %>
<tr> <tr>
<td colspan="3"></td> <td colspan="3"></td>
<td><strong>Total</strong></td> <td><strong>Total</strong></td>
<td><strong><%= total_qty %></strong></td> <td><strong><%= total_qty rescue ' ' %></strong></td>
<td></td> <td></td>
<td><strong><%= grand_total rescue '-' %></strong></td> <td><strong><%= grand_total rescue ' ' %></strong></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>