fixed conflict after merge with dev
This commit is contained in:
@@ -91,23 +91,12 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def dashboard
|
||||
@from, @to, @from_time, @to_time = get_date_range_from_params
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
@orders = Sale.where("payment_status = 'new' and sale_status = 'bill'")
|
||||
@sales = Sale.completed
|
||||
@from, @to = get_date_range_from_params
|
||||
|
||||
if !@from.nil? && !@to.nil?
|
||||
@orders = @orders.date_between(@from, @to)
|
||||
@sales = @sales.date_between(@from, @to)
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@shop = Shop.first
|
||||
|
||||
@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
|
||||
@orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'")
|
||||
@sales = Sale.receipt_date_between(@from, @to).completed
|
||||
|
||||
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)
|
||||
@@ -116,15 +105,11 @@ class HomeController < ApplicationController
|
||||
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)")
|
||||
|
||||
@top_products = Sale.top_bottom_products(current_user,@from,@to,"top")
|
||||
@bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom")
|
||||
@hourly_sales = Sale.hourly_sales(current_user,@from,@to)
|
||||
employee_sales = Sale.employee_sales(current_user,@from,@to)
|
||||
|
||||
@employee_sales = []
|
||||
if !employee_sales.nil?
|
||||
@@ -137,38 +122,34 @@ class HomeController < ApplicationController
|
||||
end
|
||||
end
|
||||
end
|
||||
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time,@shop).sum(:balance)
|
||||
|
||||
@inventories = StockJournal.inventory_balances(@from,@to).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)
|
||||
|
||||
@total_trans = Sale.total_trans(current_user,@from,@to)
|
||||
@total_card = Sale.total_card_sale(current_user,@from,@to)
|
||||
@total_credit = Sale.credit_payment(current_user,@from,@to)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_payment_methods = Sale.total_payment_methods(current_user,@from,@to)
|
||||
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay"
|
||||
pay = Sale.payment_sale(@shop,'card', today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
pay = Sale.payment_sale(payment.payment_method, current_user,@from,@to)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
@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)
|
||||
|
||||
@summ_sale = Sale.summary_sale_receipt(current_user,@from,@to)
|
||||
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
|
||||
# @total_other_customer = Sale.total_other_customer(today,current_user)
|
||||
|
||||
@total_order = Sale.total_order(@shop, today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_order = Sale.total_order(current_user,@from,@to)
|
||||
@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)
|
||||
|
||||
acc = Sale.account_data(account.account_id,current_user,@from,@to)
|
||||
if !acc.nil? && acc.cnt_acc > 0
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
@@ -176,8 +157,8 @@ class HomeController < ApplicationController
|
||||
@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)
|
||||
@total_foc_items = Sale.total_foc_items(@shop,today,current_user,@from,@to,@from_time,@to_time)
|
||||
@top_items = Sale.top_items(current_user,@from,@to)
|
||||
@total_foc_items = Sale.total_foc_items(current_user,@from,@to)
|
||||
|
||||
# get printer info
|
||||
# @print_settings = get_precision_delimiter
|
||||
@@ -239,23 +220,18 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def get_date_range_from_params
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
from_time = params[:from_time]
|
||||
to_time = params[:to_time]
|
||||
|
||||
if from.present? && to.present?
|
||||
# f_date = DateTime.parse(from)
|
||||
# t_date = DateTime.parse(to)
|
||||
# f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||
# t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||
# from = f_time.beginning_of_day.utc.getlocal
|
||||
# to = t_time.end_of_day.utc.getlocal
|
||||
|
||||
from = DateTime.parse(from).utc.getlocal.strftime('%Y-%m-%d')
|
||||
to = DateTime.parse(to).utc.getlocal.strftime('%Y-%m-%d')
|
||||
if params[:from].present? && params[:to].present?
|
||||
if params[:from_time].present? && params[:to_time].present?
|
||||
from = Time.parse("#{params[:from]} #{params[:from_time]}")
|
||||
to = Time.parse("#{params[:to]} #{params[:to_time]}")
|
||||
else
|
||||
from = Time.parse(params[:from])
|
||||
to = Time.parse(params[:to]).end_of_day
|
||||
end
|
||||
|
||||
return from, to, from_time, to_time
|
||||
else
|
||||
from = Time.now.beginning_of_day
|
||||
to = Time.now.end_of_day
|
||||
end
|
||||
return from, to
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user