shop code filter for all reports and transactions
This commit is contained in:
@@ -2,7 +2,7 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@account = Account.all
|
||||
@account = Account.where("shop_code='#{@shop.shop_code}'")
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
shift_sale_range = ''
|
||||
@@ -10,25 +10,25 @@ class Reports::HourlySaleitemController < BaseReportController
|
||||
shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
@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,@shop.shop_code)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'")
|
||||
|
||||
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
@@ -57,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 }}
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
|
||||
Reference in New Issue
Block a user