From 5d10d4b6a17f176e57ac84647ab69298ed84c018 Mon Sep 17 00:00:00 2001 From: Thein Lin Kyaw Date: Fri, 29 Nov 2019 17:47:16 +0630 Subject: [PATCH] fix origami dashboard --- app/models/sale.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/models/sale.rb b/app/models/sale.rb index 18be54a9..85a81950 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1583,6 +1583,8 @@ end if !from.nil? && !to.nil? query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1606,6 +1608,8 @@ end if !from.nil? && !to.nil? query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1637,6 +1641,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1654,6 +1660,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1675,6 +1683,8 @@ end if (!from.nil? && !to.nil?) query = query.merge(Sale.receipt_date_between(from, to)) + else + query = query.merge(Sale.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day)) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1692,6 +1702,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1711,6 +1723,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1738,6 +1752,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1784,6 +1800,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1802,6 +1820,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1866,6 +1886,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1884,6 +1906,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1902,6 +1926,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -1921,6 +1947,8 @@ end if (!from.nil? && !to.nil?) query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor') @@ -2073,6 +2101,8 @@ def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil) .paid.completed if !from.nil? && !to.nil? query = query.receipt_date_between(from, to) + else + query = query.receipt_date_between(Time.now.beginning_of_day, Time.now.end_of_day) end if !shift.nil?