Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_material_ui
This commit is contained in:
@@ -7,10 +7,11 @@ class AssignedOrderItem < ApplicationRecord
|
||||
belongs_to :order
|
||||
belongs_to :order_queue_station
|
||||
|
||||
def self.assigned_order_item (order, item_code, order_queue_station )
|
||||
def self.assigned_order_item (order, item_code, instance_code, order_queue_station )
|
||||
assigned_order_item = AssignedOrderItem.new()
|
||||
assigned_order_item.order = order
|
||||
assigned_order_item.item_code = item_code
|
||||
assigned_order_item.instance_code = instance_code
|
||||
assigned_order_item.order_queue_station = order_queue_station
|
||||
assigned_order_item.print_status = false
|
||||
assigned_order_item.delivery_status = false
|
||||
@@ -23,7 +24,7 @@ class AssignedOrderItem < ApplicationRecord
|
||||
oqs.id as station_id, oqs.station_name,
|
||||
oqs.is_active, oqpz.zone_id,
|
||||
df.name as zone, df.type as table_type,
|
||||
odt.order_id, odt.item_code, odt.item_name,
|
||||
odt.order_id, odt.item_code, odt.item_instance_code, odt.item_name,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options,
|
||||
cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
|
||||
@@ -70,7 +70,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
# else
|
||||
|
||||
if (order_item.price != 0)
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
|
||||
oqs_order_items.push(order_item)
|
||||
end
|
||||
# end
|
||||
|
||||
@@ -605,7 +605,7 @@ end
|
||||
|
||||
def self.get_item_query()
|
||||
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code, " +
|
||||
"(SUM(i.qty * i.unit_price)) as grand_total,SUM(i.qty) as total_item," +
|
||||
"(i.qty * i.unit_price) as grand_total,(i.qty) as total_item," +
|
||||
" i.unit_price as unit_price,i.product_name as product_name, mc.name as" +
|
||||
" menu_category_name,mc.id as menu_category_id ")
|
||||
|
||||
@@ -617,7 +617,7 @@ def self.get_item_query()
|
||||
|
||||
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||
query = query.where("i.unit_price > 0")
|
||||
query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id")
|
||||
query = query.group("i.item_instance_code").order("mi.account_id, mi.menu_category_id")
|
||||
end
|
||||
|
||||
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
|
||||
@@ -904,7 +904,7 @@ end
|
||||
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
|
||||
" i.price as unit_price,mi.name as product_name")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
|
||||
.where("(i.qty > 0 ) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'"+
|
||||
"and payment_status='paid' and sale_status= 'completed'")
|
||||
.group('mi.name')
|
||||
.order("SUM(i.qty) DESC").limit(5)
|
||||
@@ -918,10 +918,11 @@ end
|
||||
|
||||
def self.employee_sales(today)
|
||||
query = Sale.select("e.name as employee_name,grand_total")
|
||||
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
|
||||
.where('sales.payment_status="paid" and sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
|
||||
.joins("join employees e on e.id=sales.cashier_id")
|
||||
.group('e.name')
|
||||
.order('e.name ASC')
|
||||
.joins("join sale_payments sp on sp.sale_id=sales.sale_id")
|
||||
.group("sp.payment_method","e.name")
|
||||
.order('e.name')
|
||||
end
|
||||
|
||||
def self.total_sale(today)
|
||||
|
||||
Reference in New Issue
Block a user