Merge branch 'r-1902001-01-dev' of gitlab.com:code2lab/SXRestaurant into r-1902001-01-dev

This commit is contained in:
NyanLinHtut
2019-11-18 15:48:50 +06:30
4 changed files with 8 additions and 27 deletions

View File

@@ -1878,27 +1878,6 @@ end
query = query.first
end
def self.total_account(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
query = Sale.select("distinct b.id as account_id, b.title as title")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.joins("JOIN accounts as b ON b.id = a.account_id")
.where('sales.sale_status = "completed"')
if (!from.nil? && !to.nil?) && (from != "" && to!="")
query = query.date_between(from, to)
if !from_time.nil? && !to_time.nil?
query = query.time_between(from_time, to_time)
end
else
query = query.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)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
return query
end
def self.account_data(account_id, today, current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")