Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into sqa-1804-001
This commit is contained in:
@@ -148,9 +148,7 @@ class Menu < ApplicationRecord
|
||||
row = Hash[[sheet.row(3),sheet.row(ii)].transpose]
|
||||
menu_cat = MenuCategory.find_by_code(row["Category Code"])
|
||||
if !menu_cat
|
||||
menu_cat = MenuCategory.create({menu_id: imported_menu.id, code: row["Category Code"], name: row["Category Name"], alt_name: '', order_by: (ii - 3), created_by: created_by, menu_category_id: nil, is_available: 1})
|
||||
# else
|
||||
# status = status + "Category Code already exists."
|
||||
menu_cat = MenuCategory.create({menu_id: imported_menu.id, code: row["Category Code"], name: row["Category Name"], alt_name: '', order_by: (ii - 3), created_by: created_by, menu_category_id: nil, is_available: 1})
|
||||
end
|
||||
|
||||
# Menu Item Attributes
|
||||
@@ -191,20 +189,37 @@ class Menu < ApplicationRecord
|
||||
# status = status + "Item Code already exists for " + row["Item Name"] + "."
|
||||
end
|
||||
|
||||
instance_attr = []
|
||||
menu_inst = MenuItemInstance.find_by_item_instance_code(row["Instance Code"])
|
||||
if !menu_inst
|
||||
instance_name = ''
|
||||
if !row["Instance Name"].nil?
|
||||
instance_name = row["Instance Name"]
|
||||
end
|
||||
imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: instance_name, item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"])
|
||||
# else
|
||||
# status = status + "Instance Code already exists for " + row["Instance Name"] + "."
|
||||
|
||||
if !row["Attributes"].nil?
|
||||
if !row["Instance Attribute"].nil?
|
||||
attributes = row["Attributes"].split(',')
|
||||
instance_attributes = row["Instance Attribute"].split(',')
|
||||
attributes.each do |attr|
|
||||
if attr == instance_attributes[0]
|
||||
ins_attr = MenuItemAttribute.find_by_name(attr)
|
||||
instance_attr.push(ins_attr.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
is_default = 0
|
||||
if !row["Is Default"].nil?
|
||||
is_default = row["Is Default"]
|
||||
end
|
||||
imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: instance_name, item_attributes: instance_attr, price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: is_default)
|
||||
end
|
||||
end
|
||||
end
|
||||
# if status == ''
|
||||
status="Menu Imported!"
|
||||
status="Menu Imported!"
|
||||
# end
|
||||
|
||||
return status
|
||||
|
||||
@@ -89,7 +89,7 @@ class OrderReservation < ApplicationRecord
|
||||
count = 1
|
||||
order.order_reservation_items.each { |i|
|
||||
i.item_instance_code = i.item_instance_code.downcase.to_s
|
||||
items = {"order_item_id": count,"item_instance_code": i.item_instance_code,"quantity": i.qty,"options": []}
|
||||
items = {"order_item_id": count,"item_instance_code": i.item_instance_code,"quantity": i.qty,"options": i.options}
|
||||
count += 1
|
||||
items_arr.push(items)
|
||||
}
|
||||
@@ -178,6 +178,17 @@ class OrderReservation < ApplicationRecord
|
||||
end
|
||||
Rails.logger.debug "Doemal URL" + base_url
|
||||
post_url = base_url + url
|
||||
|
||||
if status == 'processed'
|
||||
status = 'send_to_kitchen'
|
||||
elsif status == 'delivered'
|
||||
status = 'ready_to_deliver'
|
||||
elsif status == 'completed'
|
||||
status = 'delivered'
|
||||
else
|
||||
status = status
|
||||
end
|
||||
|
||||
if waiting_time != ""
|
||||
send_params = {id: ref_no,type: min_type, waiting_time: waiting_time, status: status}
|
||||
elsif reason != ""
|
||||
|
||||
@@ -905,7 +905,7 @@ def self.get_item_query(type)
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
||||
" JOIN menu_item_instances mii ON i.item_instance_code = mii.item_instance_code" +
|
||||
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id" +
|
||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
||||
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||
@@ -941,10 +941,12 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
total_grand_total = 0
|
||||
|
||||
other_charges = self.get_other_charges()
|
||||
product = self.get_product_sale()
|
||||
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
@@ -965,6 +967,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
elsif shift_sale_range.present?
|
||||
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
|
||||
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
@@ -985,6 +988,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
@@ -1003,7 +1007,17 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type)
|
||||
|
||||
end
|
||||
|
||||
return query,other_charges, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
||||
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
||||
end
|
||||
|
||||
def self.get_product_sale()
|
||||
query = Sale.select("i.account_id as account_id, " +
|
||||
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
|
||||
"i.status as status_type,"+
|
||||
" i.unit_price as unit_price,i.product_name as product_name,i.product_code as product_code")
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||
query = query.joins("JOIN products p ON p.`item_code` = i.product_code")
|
||||
query = query.group("i.product_code")
|
||||
end
|
||||
|
||||
#product sale report query
|
||||
|
||||
Reference in New Issue
Block a user