Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_material_ui

This commit is contained in:
Aung Myo
2017-12-05 10:24:20 +06:30
12 changed files with 92 additions and 18 deletions

View File

@@ -1,5 +1,19 @@
class Api::CheckInProcessController < Api::ApiController
def check_in_time
if params[:dining_id]
dining_facility = DiningFacility.find(params[:dining_id])
booking = dining_facility.get_booking
if !booking.nil?
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time }
else
render :json => { :status => false, :error_message => "No current booking!" }
end
end
end
def check_in_process
if params[:dining_id]
dining_facility = DiningFacility.find(params[:dining_id])

View File

@@ -141,6 +141,6 @@ class Settings::SetMenuItemsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit)
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit, :taxable)
end
end

View File

@@ -157,6 +157,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit)
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit, :taxable)
end
end

View File

@@ -13,7 +13,7 @@ class MenuItem < ApplicationRecord
has_many :menu_item_sets
has_many :item_sets, through: :menu_item_sets
validates_presence_of :item_code, :name, :type, :min_qty, :taxable,:account_id
validates_presence_of :item_code, :name, :type, :min_qty,:account_id
validates_uniqueness_of :item_code
default_scope { order('item_code asc') }

View File

@@ -133,7 +133,7 @@ class Order < ApplicationRecord
OrderItem.processs_item(menu_item[:item_code], item[:item_instance_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
self.employee_name)
self.employee_name, menu_item[:taxable])
#end
end

View File

@@ -20,7 +20,7 @@ class OrderItem < ApplicationRecord
# option_values : [],
# sub_order_items : [],
# }
def self.processs_item (item_code, instance_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by)
def self.processs_item (item_code, instance_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by, taxable)
orderitem = OrderItem.create do |oitem|
oitem.order_id = order_id
@@ -31,6 +31,7 @@ class OrderItem < ApplicationRecord
oitem.account_id = account_id
oitem.qty = qty
oitem.price = price
oitem.taxable = taxable
oitem.options = options
oitem.set_menu_items = set_menu_items
oitem.item_order_by = item_order_by #person who order this. * If emenu - it will be login user on the app

View File

@@ -225,7 +225,11 @@ class Sale < ApplicationRecord
puts "item.sales_item_id ddd"
puts item.sale_item_id
subtotal_price = subtotal_price + item.price
total_taxable = total_taxable + item.taxable_price
# only calc tax when true
if(item.is_taxable)
total_taxable = total_taxable + item.taxable_price
end
# total_taxable = total_taxable + (item.taxable_price * item.qty)
end
@@ -287,7 +291,11 @@ class Sale < ApplicationRecord
if item.remark != 'void' && item.remark != 'foc'
#compute each item and added to total
subtotal_price = subtotal_price + item.price
total_taxable = total_taxable + item.price
# only calc tax when true
if(item.is_taxable)
total_taxable = total_taxable + item.taxable_price
end
end
end

View File

@@ -19,6 +19,13 @@ if (@booking)
@total_amount = 0.00
@total_tax = 0.00
# For YGN BBQ
adult_count = 0
child_count = 0
adult_spent = 0
child_spent = 0
# End YGN BBQ
if @booking.booking_orders
order_items = []
@booking.booking_orders.each do |bo|
@@ -26,21 +33,45 @@ if (@booking)
if (order.status == "new")
order_items = order_items + order.order_items
end
end
end
json.order_items order_items do |item|
json.item_instance_code item.item_code
json.item_name item.item_name
json.price item.price
json.qty item.qty
json.options item.options
json.remark item.remark
json.item_status item.order_item_status
@total_amount = @total_amount + (item.price * item.qty)
# For YGN BBQ
if item.item_code == "P00001"
adult_count += item.qty
adult_spent += (item.price * item.qty)
end
if item.item_code == "P00002"
child_count += item.qty
child_spent += (item.price * item.qty)
end
# End YGN BBQ
json.item_code item.item_code
json.item_instance_code item.item_instance_code
json.item_name item.item_name
json.price item.price
json.qty item.qty
json.options item.options
json.remark item.remark
json.item_status item.order_item_status
@total_amount = @total_amount + (item.price * item.qty)
end
end
# For YGN BBQ
if adult_count > 0
json.per_adult_spent (adult_spent/adult_count) * 0.05
else
json.per_adult_spent 0
end
if child_count > 0
json.per_child_spent (child_spent/child_count) * 0.05
else
json.per_child_spent 0
end
# End YGN BBQ
json.sub_total @total_amount
json.commerical_tax @total_amount * 0.05
json.total @total_amount + (@total_amount * 0.05)

View File

@@ -16,6 +16,8 @@
<%= f.input :is_available,:input_html => {:class => "col-md-9"} %>
<%= f.input :taxable,:input_html => {:class => "col-md-9"} %>
<%= f.input :is_sub_item,:input_html => {:class => "col-md-9"} %>
<%= f.input :unit, :collection => Lookup.collection_of("unit") ,:input_html => {:class => "col-md-9"} %>

View File

@@ -16,6 +16,8 @@
<%= f.input :is_available,:input_html => {:class => "col-md-9"} %>
<%= f.input :taxable,:input_html => {:class => "col-md-9"} %>
<%= f.input :is_sub_item,:input_html => {:class => "col-md-9"} %>
<%= f.input :unit, :collection => Lookup.collection_of("unit") ,:input_html => {:class => "col-md-9"} %>

View File

@@ -68,7 +68,8 @@ scope "(:locale)", locale: /en|mm/ do
end
namespace :origami do
post "check_in/:dining_id" => "check_in_process#check_in_process"
get "check_in/:dining_id" => "check_in_process#check_in_time"
post "check_in" => "check_in_process#check_in_process"
post "request_time" => "check_in_process#request_time"
post "call_waiter" => "call_waiters#index"
end

View File

@@ -130,13 +130,17 @@ food = Account.create({title: "Food", account_type: "0"})
beverage = Account.create({title: "Beverage", account_type: "1"})
product = Account.create({title: "Product", account_type: "2"})
# YGN BBQ
person = Account.create({title: "Person", account_type: "3"})
# END
#Default Menu Options
menu_options = MenuItemOption.create([{option_type: "Spicy", name: "Less Spicy", value: "less_spicy"},{option_type: "Spicy", name: "Spicy", value: "spicy"},{option_type: "Spicy", name: "Super Spicy", value: "super_spicy"}])
menu_options = MenuItemOption.create([{option_type: "Oil", name: "Less Oil", value: "less_oil"},{name: "No MSG", value: "no_msg"},{option_type: "Sweet", name: "Less Sweet", value: "less_sweet"}])
menu_pkg_options = MenuItemOption.create([{option_type: "Package", name: "Bottle", value: "Bottle"},{option_type: "Package", name: "Can", value: "can"}])
# #Default Menu Category
menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base", alt_name: "Soup_base", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"})
menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Person", alt_name: "Person", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"})
# menu_category2 = MenuCategory.create({menu: menu, code:"C005", name: "Beef & Mutton", alt_name: "Beef_and_mutton", order_by: 2,created_by: "SYSTEM DEFAULT"})
# menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Pork", alt_name: "Pork", order_by: 3,created_by: "SYSTEM DEFAULT"})
# menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Chicken", alt_name: "Chicken", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"})
@@ -154,6 +158,17 @@ menu_pkg_options = MenuItemOption.create([{option_type: "Package", name: "Bottle
# menu_category2_menu_item1 = SimpleMenuItem.create({item_code:"I008", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food})
# menu_category2_menu_item2 = SimpleMenuItem.create({item_code:"I009", name: "Default Menu Item Name 2", alt_name: "Alternate Menu Item Name 2",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 3 , account: food})
# YGN BBQ
menu_item_attribute_adult = MenuItemAttribute.create({attribute_type:"person", name: "Adult", value: "adult"})
menu_item_attribute_child = MenuItemAttribute.create({attribute_type:"person", name: "Child", value: "child"})
menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"P00001", name: "Adult", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['1']", created_by: "System" })
menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0001", menu_item: menu_category1_menu_item0, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" })
menu_category1_menu_item1 = SimpleMenuItem.create({item_code:"P00002", name: "Child", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['2']", created_by: "System" })
menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0002", menu_item: menu_category1_menu_item1, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" })
# END
menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size", name: "Small", value: "small"})
menu_item_attribute_size_medium = MenuItemAttribute.create({attribute_type:"size",name: "Medium", value: "medium"})
menu_item_attribute_size_large = MenuItemAttribute.create({attribute_type:"size", name: "Large", value: "large"})