change query in sale item report

This commit is contained in:
phyusin
2018-01-05 13:33:23 +06:30
parent 09db9656c5
commit ae6caefaa0
3 changed files with 9 additions and 7 deletions

View File

@@ -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|

View File

@@ -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()

View File

@@ -110,9 +110,8 @@
</tr>
<!-- sub total -->
<% @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 sub total -->
<% end %>
<!-- end sub total -->
<% end %>
<!--Other Charges -->
<% if @other_charges.present? %>
<tr>