fixed conflict after merge with dev branch for report query updated

This commit is contained in:
Nweni
2019-11-27 14:09:16 +06:30
75 changed files with 1509 additions and 1940 deletions

View File

@@ -93,29 +93,39 @@ class HomeController < ApplicationController
def dashboard
@from, @to, @from_time, @to_time = get_date_range_from_params
today = DateTime.now.strftime('%Y-%m-%d')
if !@from.nil? && !@to.nil?
if !@from_time.nil? && @to_time.nil?
@orders = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
else
@orders = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
end
else
@orders = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
end
if !@from.nil? && !@to.nil?
if !@from_time.nil? && @to_time.nil?
@sales = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
else
@sales = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
end
else
@sales = Sale::where("shop_code='#{@shop.shop_code}' and payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
end
@top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top",@shop).sum('i.qty')
@bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom",@shop).sum('i.qty')
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time,@shop).sum(:grand_total)
@orders = Sale.where("payment_status = 'new' and sale_status = 'bill'")
@sales = Sale.completed
if !@from.nil? && !@to.nil?
@orders = @orders.date_between(@from, @to)
@sales = @sales.date_between(@from, @to)
if !@from_time.nil? && @to_time.nil?
@orders = @orders.time_between(@from_time, @to_time)
@sales = @sales.time_between(@from_time, @to_time)
end
else
@orders = @orders.date_on(today)
@sales = @sales.date_on(today)
end
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user.id)
@orders = @orders.where(shift_sale_id: shift.id)
@sales = @sales.where(shift_sale_id: shift.id)
end
end
@top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top", @shop)
@bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom", @shop)
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time, @shop)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)
logger.debug 'hourly_sales<>><><><<<<<<>><<<><><><><><><><><><<>><'
logger.debug @hourly_sales.to_json
employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time, @shop)
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time,@shop)
@employee_sales = []
if !employee_sales.nil?
employee_sales.each do |emp|
@@ -129,10 +139,12 @@ class HomeController < ApplicationController
end
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time,@shop).sum(:balance)
@total_trans = Sale.total_trans(today,current_user,@from,@to,@from_time,@to_time,@shop)
@total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time,@shop)
@total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time,@shop)
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user,@from,@to,@from_time,@to_time)
@@ -150,16 +162,18 @@ class HomeController < ApplicationController
@summ_sale = Sale.summary_sale_receipt(@shop,today,current_user,@from,@to,@from_time,@to_time)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time)
@total_order = Sale.total_order(@shop,today,current_user,@from,@to,@from_time,@to_time)
@total_accounts = Sale.total_account(@shop,today,current_user,@from,@to,@from_time,@to_time)
@total_order = Sale.total_order(@shop, today,current_user,@from,@to,@from_time,@to_time)
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
@account_data = Array.new
if !@total_accounts.nil?
@total_accounts.each do |account|
acc = Sale.account_data(@shop,account.account_id, today,current_user,@from,@to,@from_time,@to_time)
if !acc.nil?
acc = Sale.account_data(@shop, account.account_id, today,current_user,@from,@to,@from_time,@to_time)
if !acc.nil? && acc.cnt_acc > 0
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
end
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
end
@top_items = Sale.top_items(@shop,today,current_user,@from,@to,@from_time,@to_time)