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"} %>