commit for sales

This commit is contained in:
Cherry
2017-06-02 17:48:03 +06:30
parent 47469cf466
commit 9afe39b7e2
10 changed files with 134 additions and 19 deletions

View File

@@ -226,13 +226,15 @@ class Order < ApplicationRecord
end
#Origami: Cashier : to view orders
def self.get_orders
from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc
orders = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
order_items.id as order_items_id,dining_facilities.name as table_or_room_name")
.joins("left join booking_orders on booking_orders.order_id = orders.id
left join bookings on bookings.id = booking_orders.id
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
left join order_items on order_items.order_id = orders.id")
.where("dining_facilities.is_active=?",true)
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
.group("orders.id")
end
end