update query in order model for origami

This commit is contained in:
Aung Myo
2017-06-06 10:10:47 +06:30
parent fa0b434888
commit 324f1e3b24
2 changed files with 9 additions and 11 deletions

View File

@@ -116,9 +116,7 @@ GEM
mini_portile2 (2.1.0)
minitest (5.10.2)
multi_json (1.12.1)
multi_xml (0.6.0)
mysql2 (0.4.6)
nio4r (2.1.0)
nokogiri (1.7.2)

View File

@@ -211,15 +211,15 @@ class Order < ApplicationRecord
#Origami: Cashier : to view order type Table
def self.get_order_table
order_table = 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_name")
.joins("left join booking_orders on booking_orders.order_id = orders.id
left join bookings on bookings.id = booking_orders.id
order_table = Order.select("orders.order_id as order_id,sum(order_items.qty*order_items.price) as total_price,
order_items.order_items_id as order_items_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.order_id = orders.order_id
left join bookings on bookings.booking_id = booking_orders.booking_order_id
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
left join order_items on order_items.order_id = orders.id")
left join order_items on order_items.order_id = orders.order_id")
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true)
.group("orders.id, order_items.id,dining_facilities.name")
.group("orders.order_id, order_items.id,dining_facilities.name")
end
def self.get_booking_order_table
@@ -270,8 +270,7 @@ class Order < ApplicationRecord
left join sale_orders on sale_orders.order_id = orders.order_id
left join sales on sales.sale_id = sale_orders.sale_id")
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
.group("orders.id,order_items.id,dining_facilities.name")
.group("orders.order_id,order_items.order_items_id,dining_facilities.name")
end
@@ -285,4 +284,5 @@ class Order < ApplicationRecord
def set_order_date
self.date = Time.now.utc
end
end