diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 7e7469f9..4a6a4440 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -25,7 +25,7 @@ class Reports::SaleitemController < BaseReportController @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} @menu_cate_count = Hash.new {|hash, key| hash[key] = 0} - @sale_data.each {|cate| @menu_cate_count[cate.menu_category_id] += 1} + @sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1} @totalByAccount = Hash.new {|hash, key| hash[key] = 0} @@ -64,6 +64,9 @@ class Reports::SaleitemController < BaseReportController date_arr.push(str) end + @totalByAccount = Hash.new {|hash, key| hash[key] = 0} + @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total} + out = {:status => 'ok', :message => date_arr} respond_to do |format| diff --git a/app/models/sale.rb b/app/models/sale.rb index 7adb1324..69aa930a 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -665,7 +665,7 @@ def self.get_item_query() # "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ") query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id") # query = query.where("i.item_instance_code IS NOT NULL") - query = query.group("i.product_name").order("acc.title desc") + query = query.group("acc.title,mi.account_id,i.product_name").order("acc.title desc, mi.account_id desc") end def self.get_other_charges() diff --git a/app/views/reports/saleitem/index.html.erb b/app/views/reports/saleitem/index.html.erb index d0def563..f780acdb 100644 --- a/app/views/reports/saleitem/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -110,9 +110,8 @@ - <% @menu_cate_count.each do |key,value| %> - <% if sale.menu_category_id == key %> - + <% @menu_cate_count.each do |key,value| %> + <% if sale.account_id == key %> <% count = count + 1 %> <% sub_total += sale.grand_total %> <% sub_qty += sale.total_item %> @@ -128,10 +127,10 @@ <% sub_qty = 0 %> <% count = 0%> <% end %> - <% end %> <% end %> - <% end %> + + <% end %> <% if @other_charges.present? %>