Merge branch 'quick_service' of bitbucket.org:code2lab/sxrestaurant into split_bill

This commit is contained in:
phyusin
2018-02-22 18:52:55 +06:30
9 changed files with 191 additions and 30 deletions

View File

@@ -77,11 +77,17 @@ $(document).on('turbolinks:load', function() {
});
}
}
if (data[field]["table_type"]=null) {
table_type = data[field]["table_type"] +'-'+data[field]["zone"]
}else{
table_type = "No Table"
}
row ='<div class="card queue_station animated " data-order-no="'+data[field]["order_id"]+'">'
+'<div class="card-block">'
+'<div class="row">'
+'<span class="col-md-4 order-zone-type font-13">'+data[field]["table_type"]+'-'+ data[field]["zone"] +'</span>'
+'<span class="col-md-4 order-zone-type font-13">'+table_type +'</span>'
+'<span class="order-zone hidden font-14">'+ data[field]["zone"] +'</span>'
+'<span class="col-md-8"><small class="float-right font-13">'+data[field]["order_id"]+'</small></span>'
+'</div>'

View File

@@ -33,17 +33,17 @@ class Origami::SaleEditController < BaseOrigamiController
saleObj = Sale.find(saleitemObj.sale_id)
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
order = Order.find(order_id)
puts saleitemObj.to_json
order.order_items.each do |o|
if saleitemObj.product_code == o.item_code
o.qty = saleitemObj.qty * -1
o.price = saleitemObj.price * -1
o.save
booking = Booking.find_by_sale_id(saleitemObj.sale_id)
booking.booking_orders.each do |bo|
order = Order.find(bo.order_id)
order.order_items.each do |o|
if saleitemObj.product_code == o.item_code
o.qty = saleitemObj.qty * -1
o.price = saleitemObj.price * -1
o.save
end
end
end
action_by = current_user.id
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMVOID" )
@@ -123,6 +123,18 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
order = Order.find(order_id)
order.order_items.each do |o|
if saleitemObj.product_code == o.item_code
o.qty = update_qty
o.price = update_price
o.save
end
end
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
ProductCommission.edit_product_commission(saleitemObj)

View File

@@ -79,6 +79,130 @@ class MenuItem < ApplicationRecord
end
def self.get_items(menu)
item = Array.new
if menu.menu_items
menu.menu_items do |item|
if item.is_available
# Format for attributes json
attr_format = []
# Format for attributes json
if item.item_attributes.count > 0
item.item_attributes.each do|attr_id|
menu_attr = MenuItemAttribute.find(attr_id)
if attr_format.count == 0
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
next
end
attr_format.each do |af|
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
if menu_attr.attribute_type == af[:type]
af[:values].push(menu_attr.name)
end
else
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
attr_format.push(new_attr)
break
end
end
end
end
# Format for option json
opt_format = []
# Format for attributes json
if item.item_options.count > 0
item.item_options.each do|opt|
menu_opt = MenuItemOption.find(opt)
if opt_format.count == 0
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
next
end
opt_format.each do |of|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
if menu_opt.option_type == of[:type]
of[:values].push(menu_opt.name)
end
else
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
opt_format.push(new_opt)
break
end
end
end
end
#Menu Item Information
menu_items.id item.id
menu_items.code item.item_code
menu_items.name item.name
menu_items.alt_name item.alt_name
menu_items.image item.image_path.url
menu_items.description item.description
menu_items.information item.information
menu_items.type item.type
menu_items.account_id item.account_id
menu_items.min_qty item.min_qty
menu_items.is_available item.is_available
menu_items.is_sub_item item.is_sub_item
menu_items.unit item.unit
# Item Sets of Menu Item
item_sets = Array.new()
item.item_sets do |its|
sets.id its.id
sets.name its.name
sets.alt_name its.alt_name
sets.min_selectable_qty its.min_selectable_qty
sets.max_selectable_qty its.max_selectable_qty
instances = Array.new()
its.menu_item_instances do |i|
instan.id i.id
instances.push(instan)
end
item_sets.push(sets)
end
menu_items.attributes attr_format
menu_items.options opt_format
instances = Array new()
item.menu_item_instances do |is|
if is.is_available
# Convert id to name for attributes
instance_attr = []
is.item_attributes.each do |ia|
# mItemAttr = MenuItemAttribute.find(is)
# instance_attr.push(ia)
mItemAttr = MenuItemAttribute.find(ia).name
instance_attr.push(mItemAttr)
end
instance.id is.id
instance.code is.item_instance_code
instance.name is.item_instance_name
instance.price is.price
instance.is_available is.is_available
instance.is_default is.is_default
instance.is_on_promotion is.is_on_promotion
instance.promotion_price is.promotion_price
instance.values instance_attr
# json.item_sets is.item_sets
end
instances.push(instance)
end
end
item.push(menu_items)
end
return item
end
end
# private
# def generate_menu_item_code

View File

@@ -46,10 +46,10 @@ class OrderQueueStation < ApplicationRecord
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# else
# if (order_item.price != 0)
if (order_item.qty > 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
oqs_order_items.push(order_item)
# end
end
# end
end
end
@@ -81,10 +81,10 @@ class OrderQueueStation < ApplicationRecord
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# else
# if (order_item.price != 0)
if (order_item.qty > 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
oqs_order_items.push(order_item)
# end
end
# end
end
end

View File

@@ -242,7 +242,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id
left join menu_items as item ON item.item_code = order_items.item_code")
.where("order_items.order_items_id = '#{ id }' and order_items.qty > 0")
.where("order_items.order_items_id = '#{ id }'")
.group("order_items.item_code")
elsif type == "order_summary"
OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
@@ -252,7 +252,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id
left join menu_items as item ON item.item_code = order_items.item_code")
.where("orders.order_id = '#{ id }' and order_items.qty > 0")
.where("orders.order_id = '#{ id }'")
.group("order_items.order_items_id")
else
# order summary for booking
@@ -263,7 +263,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id
left join menu_items as item ON item.item_code = order_items.item_code")
.where("b.booking_id = '#{ id }' and order_items.qty > 0")
.where("b.booking_id = '#{ id }'")
end
end

View File

@@ -92,7 +92,12 @@ class Sale < ApplicationRecord
self.cashier_id = open_cashier[0].id
self.cashier_name = open_cashier[0].name
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
self.shift_sale_id = shift_id.id
if shift_id
self.shift_sale_id = shift_id.id
else
self.shift_sale_id = current_shift.id
end
else
self.cashier_id = current_shift.employee_id
self.cashier_name = Employee.find(current_shift.employee_id).name

View File

@@ -36,7 +36,7 @@ class OrderSummaryPdf < Prawn::Document
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
if order[0].dining.present?
if order[0].dining.to_i > 0
text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20

View File

@@ -72,7 +72,12 @@
<div class="card queue_station" data-order-no="<%= qid.order_id %>">
<div class="card-block">
<div class="row">
<span class="col-md-4 order-zone-type font-13"><%= qid.type %>-<%= qid.zone %></span>
<%if qid.type.present?%>
<span class="col-md-4 order-zone-type font-13"><%= qid.type %>-<%= qid.zone %></span>
<%else%>
<span class="col-md-4 order-zone-type font-13"></span>
<%end%>
<span class="order-zone hidden font-13"><%= qid.zone %></span>
<span class="col-md-8"><small class="float-right font-13"><%= qid.order_id %></small></span>
</div>

View File

@@ -46,7 +46,7 @@
<!--if type quick_service or cashier for table -->
<% if type %>
<% if !menu.code.include? "SPL" %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<li class="nav-item menu_category sub_click first_<%=menu.id%>" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
@@ -58,7 +58,7 @@
<% else %>
<% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<li class="nav-item menu_category sub_click first_<%=menu.id%>" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
@@ -67,7 +67,7 @@
</li>
<% end%>
<% else %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<li class="nav-item menu_category sub_click first_<%=menu.id%>" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
@@ -82,8 +82,8 @@
<%end %>
</ul>
</div>
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10">
<div class="card-columns custom-card-columns menu_items_list" style="column-gap: 10px;">
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10" >
<div class="card-columns custom-card-columns menu_items_list" style="column-gap: ;">
<!-- append data -->
<% @menu.each do |menu| %>
<% if !menu.valid_time.nil? %>
@@ -132,15 +132,19 @@
<!-- <i class="material-icons">reply</i> -->
Back
</button>
<% if current_user.role != "waiter"%>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-7" id='pending_order'>Pending Order
</button>
<%end%>
<%elsif !modify_order && type%>
<button type="button" class="btn btn-lg btn-default waves-effect col-md-2" id='back' style=" padding: .5rem 0.15rem !important;">
<!-- <i class="material-icons">reply</i> -->
Back
</button>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-6" id='pending_order' style="padding: .5rem 0.15rem !important;">Pending Order
</button>
<% if current_user.role != "waiter"%>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-6" id='pending_order' style="padding: .5rem 0.15rem !important;">Pending Order
</button>
<%end%>
<a class="btn btn-lg bg-blue waves-effect select_table col-md-3" data-toggle="modal" data-target="#TableModal" style=" padding: .5rem 0.15rem !important;">Select</a>
<input type="hidden" name="table_id" value="" id="table_id">
@@ -218,8 +222,9 @@
<button type="button" class="btn btn-primary action-btn create col-md-11" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Update Order & Pay</button>
<%elsif !modify_order && type%>
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
<button type="button" class="btn btn-primary action-btn create col-md-4" id="create_pay_order" disabled="disabled" style="padding-top:4px !important;padding-bottom:4px !important;"><i class="material-icons" style="font-size:34px;width:34px">attach_money</i></button>
<% if current_user.role != "waiter"%>
<button type="button" class="btn btn-primary action-btn create col-md-4" id="create_pay_order" disabled="disabled" style="padding-top:4px !important;padding-bottom:4px !important;"><i class="material-icons" style="font-size:34px;width:34px">attach_money</i></button>
<%end%>
<button type="button" class="btn btn-primary action-btn create col-md-7" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
<%else%>
<button type="button" class="btn btn-primary action-btn create col-md-11" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
@@ -467,6 +472,10 @@
</div>
<% end %>
<script>
jQuery(function(){
id = "<%=@menu[0].id%>";
jQuery('.first_'+id).click();
});
$(document).ready(function () {
$(".tables").on('click', function () {
$('.tables').css('background-color','');