dashboard chart data

This commit is contained in:
yamin
2017-09-22 10:34:14 +06:30
parent e3a76f7095
commit a53a5a39b1
6 changed files with 14346 additions and 36 deletions

View File

@@ -59,6 +59,17 @@ class HomeController < ApplicationController
def dashboard
@shop = Shop.first
today = DateTime.now.strftime('%Y-%m-%d')
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
@top_products = Sale.top_products(today)
@hourly_sales = Sale.hourly_sales(today)
.group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
.sum(:grand_total)
@employee_sales = Sale.employee_sales(today).sum(:grand_total)
@inventories = StockJournal.inventory_balances(today).sum(:balance)
end
def destroy