fixed hourly sale report
This commit is contained in:
@@ -9,6 +9,7 @@ class Reports::DailysaleController < BaseReportController
|
||||
@to = to
|
||||
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
|
||||
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
|
||||
@@ -27,8 +27,6 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
account_type = params[:account_type]
|
||||
@type = params[:sale_type]
|
||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type)
|
||||
# logger.debug 'product>>>>>>>>>>>>>>>>>>>>>>>>>>'
|
||||
# logger.debug @sale_data.group(:date_format)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
|
||||
@@ -59,7 +57,7 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
# @hourly_total_qty = @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"date" => key , "total_qty" => qty.sum{|d| d.qty.to_i}}}
|
||||
@hourly_total_qty = @sale_data.group_by(&:date_format).map { |k,v|{"date" => k , "total_qty" => v.count }}
|
||||
|
||||
puts @hourly_total_qty.to_json
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
|
||||
@@ -2862,15 +2862,16 @@ def self.get_hourly_item_query(type)
|
||||
"i.unit_price,i.price as price,i.product_name as product_name, " +
|
||||
"i.menu_category_name,i.menu_category_code as menu_category_id, " +
|
||||
"date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')
|
||||
as date_format")
|
||||
as date_format," +
|
||||
"hour(CONVERT_TZ(receipt_date,'+00:00', '+06:30')) as hour")
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
||||
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
||||
query = query.joins(" JOIN accounts acc ON acc.id = i.account_id")
|
||||
query = query.where("#{sale_type}")
|
||||
query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
|
||||
.order("date_format asc")
|
||||
query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price,hour")
|
||||
.order("hour asc")
|
||||
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user