This commit is contained in:
Nweni
2019-11-18 12:22:31 +06:30
parent 9138a1e38e
commit 54ab9e0ca5
12 changed files with 93 additions and 49 deletions

View File

@@ -1,9 +1,9 @@
class HomeController < ApplicationController
# layout "application", except: [:index, :show]
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
include PrecisionHelper
before_action :check_user, only: :dashboard
# Special check for only dashboard
def check_user
if current_user.nil?
@@ -90,9 +90,7 @@ class HomeController < ApplicationController
def dashboard
@from, @to, @from_time, @to_time = get_date_range_from_params
@shop = Shop.first
today = DateTime.now.strftime('%Y-%m-%d')
if !@from.nil? && !@to.nil?
if !@from_time.nil? && @to_time.nil?
@@ -115,12 +113,7 @@ class HomeController < ApplicationController
@top_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"top").sum('i.qty')
@bottom_products = Sale.top_bottom_products(today,current_user,@from,@to,@from_time,@to_time,"bottom").sum('i.qty')
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total)
# .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)
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
@employee_sales = []
if !employee_sales.nil?
employee_sales.each do |emp|
@@ -154,7 +147,6 @@ class HomeController < ApplicationController
end
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to,@from_time,@to_time)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
# @total_other_customer = Sale.total_other_customer(today,current_user)
@total_order = Sale.total_order(today,current_user,@from,@to,@from_time,@to_time)
@total_accounts = Sale.total_account(today,current_user,@from,@to,@from_time,@to_time)
@@ -172,7 +164,7 @@ class HomeController < ApplicationController
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to,@from_time,@to_time)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
# @print_settings = get_precision_delimiter
end
def destroy