diff --git a/app/models/sale.rb b/app/models/sale.rb index 5d3c6b4d..970896bf 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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," + "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" + - " 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 ") .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" + diff --git a/app/views/reports/product_sale/index.html.erb b/app/views/reports/product_sale/index.html.erb index 3f27205a..f614fbb9 100755 --- a/app/views/reports/product_sale/index.html.erb +++ b/app/views/reports/product_sale/index.html.erb @@ -58,14 +58,14 @@ <% total_qty = 0 %> <% @sale_data.each do |sale| %> - <% grand_total += sale.grand_total %> - <% if sale.status_type != "Discount" && sale.status_type != "foc" - total_qty += sale.total_item - end %> - <% if sale.status_type == "foc" && sale.price > 0 - total_qty += sale.total_item - end %> - + <% grand_total += sale.grand_total %> + <% if sale.status_type != "Discount" && sale.status_type != "foc" + total_qty += sale.total_item + end %> + <% if sale.status_type == "foc" && sale.price > 0 + total_qty += sale.total_item + end %> + <% if !sale.status_type %>   <% if !cate_arr.include?(sale.menu_category_id) %> @@ -81,8 +81,9 @@ <%= number_with_precision(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%> <%= number_with_precision(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-' %> - - + + + <% end %> <% end %> diff --git a/app/views/reports/product_sale/index.xls.erb b/app/views/reports/product_sale/index.xls.erb index f0410810..eb7f50f8 100755 --- a/app/views/reports/product_sale/index.xls.erb +++ b/app/views/reports/product_sale/index.xls.erb @@ -23,31 +23,40 @@ <% total_qty = 0 %> <% @sale_data.each do |sale| %> + <% grand_total += sale.grand_total %> <% if sale.status_type != "Discount" && sale.status_type != "foc" total_qty += sale.total_item - grand_total += sale.grand_total end %> <% if sale.status_type == "foc" && sale.price > 0 total_qty += sale.total_item - grand_total += sale.grand_total end %> - -   - <%= sale.menu_category_name %> - <%= sale.item_code rescue '-' %> - <%= sale.product_name rescue '-' %> - <%= sale.total_item rescue '-' %> - <%= sale.unit_price rescue '-' %> - <%= sale.grand_total rescue '-' %> - + <% if !sale.status_type %> + +   + <% if !cate_arr.include?(sale.menu_category_id) %> + <%= sale.menu_category_name %> + <% cate_arr.push(sale.menu_category_id) %> + <% else %> + <% cate_arr = Array.new %> +   + <% end %> + <%= sale.item_code rescue '-' %> + <%= sale.product_name rescue '-' %> + <%= sale.total_item rescue ' ' %> + <%= sale.unit_price rescue ' ' %> + <%= sale.grand_total rescue ' ' %> + + + + <% end %> <% end %> Total - <%= total_qty %> + <%= total_qty rescue ' ' %> - <%= grand_total rescue '-' %> + <%= grand_total rescue ' ' %> <% end %>