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

This commit is contained in:
Aung Myo
2018-06-21 14:40:04 +06:30
6 changed files with 63 additions and 99 deletions

View File

@@ -446,7 +446,7 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas
$.ajax({
type: "POST",
url: url,
data: {order_id: order_id, status: status, min_type: min_type, expected_time: waiting_time, remark: reason, access_code: access_code},
data: {order_id: order_id, ref_no: ref_no, status: status, min_type: min_type, expected_time: waiting_time, remark: reason, access_code: access_code},
dataType: "json",
success: function(data) {
if (data.status) {

View File

@@ -20,25 +20,34 @@ class Origami::OrderReservationController < BaseOrigamiController
access_code = params[:access_code]
@order_reservation = OrderReservation.find(@id)
if @status == "processed"
result = OrderReservation.create_doemal_order(@order_reservation,current_user)
elsif @status == "delivery"
OrderReservation.update_order_reservation(@id, nil, "ready_to_delivery")
response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"ready_to_delivery")
result = {:status=> true, :message => "ready for delivery" }
elsif @status == "completed"
result = OrderReservation.update_doemal_payment(@order_reservation,current_user)
order_reserve = OrderReservation.find_by_transaction_ref(params[:ref_no])
if !order_reserve.nil?
if !ShiftSale.current_shift.nil?
if @status == "processed"
result = OrderReservation.create_doemal_order(@order_reservation,current_user)
elsif @status == "delivery"
OrderReservation.update_order_reservation(@id, nil, "ready_to_delivery")
response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"ready_to_delivery")
result = {:status=> true, :message => "ready for delivery" }
elsif @status == "completed"
result = OrderReservation.update_doemal_payment(@order_reservation,current_user)
else
if @status == "rejected"
OrderReservation.update_order_reservation(@id, nil, "rejected",nil,remark,access_code,current_user)
response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"rejected")
result = {:status=> true, :message => "rejected" }
else
OrderReservation.update_order_reservation(@id, nil, "accepted", expected_waiting_time)
response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"accepted")
result = {:status=> true, :message => "accepted" }
end
end
else
result = { status: false, message: 'No current shift open for this employee!'}
end
else
if @status == "rejected"
OrderReservation.update_order_reservation(@id, nil, "rejected",nil,remark,access_code,current_user)
response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"rejected")
result = {:status=> true, :message => "rejected" }
else
OrderReservation.update_order_reservation(@id, nil, "accepted", expected_waiting_time)
response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"accepted")
result = {:status=> true, :message => "accepted" }
end
end
result = { status: false, message: 'There is no order for '+params[:ref_no]+'!'}
end
render :json => result.to_json
end

View File

@@ -99,7 +99,7 @@ class Settings::MenusController < ApplicationController
sheet.add_row ["Name",menu.name], :style=>title
sheet.add_row
sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Instance Attribute", "Price", "Is Default"], :style=>header_text
sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Instance Attribute", "Price", "Is Default", "Image Path"], :style=>header_text
menu.menu_categories.each do |mc|
mc.menu_items.each do |mi|
attributes = ""
@@ -135,7 +135,7 @@ class Settings::MenusController < ApplicationController
if mii.item_attributes.length > 0
attribute = MenuItemAttribute.find(mii.item_attributes[0]).name
end
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, attribute, mii.price, mii.is_default], :style=>wrap_text
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, attribute, mii.price, mii.is_default, mi.image_path.to_s.remove("/image/menu_images/")], :style=>wrap_text
end
end
end

View File

@@ -184,7 +184,11 @@ class Menu < ApplicationRecord
account = Account.create({title: row["Account"], account_type: "0"})
end
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: item_attrs, item_options: item_opts, is_sub_item: 0, is_available: 1, created_by: created_by)
image_path = row["Image Path"] ? row["Image Path"] : ""
puts image_path
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: image_path.to_s, description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: item_attrs, item_options: item_opts, is_sub_item: 0, is_available: 1, created_by: created_by)
puts "menu_itm"
puts menu_itm.to_json
# else
# status = status + "Item Code already exists for " + row["Item Name"] + "."
end

View File

@@ -164,37 +164,37 @@ class Sale < ApplicationRecord
#fOR Quick Service pay and create
def self.request_bill(order,current_user,current_login_employee)
@sale = Sale.new
sale_order=SaleOrder.new
sale_order=SaleOrder.new
if !ShiftSale.current_shift.nil?
order_id = order.order_id # order_id
bk_order = BookingOrder.find_by_order_id(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
if check_booking.sale_id.nil?
# Create Sale if it doesn't exist
# puts "current_login_employee"
# puts current_login_employee.name
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee,current_user,order.source)
@sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
else
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
end
if !ShiftSale.current_shift.nil?
order_id = order.order_id # order_id
bk_order = BookingOrder.find_by_order_id(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
if check_booking.sale_id.nil?
# Create Sale if it doesn't exist
# puts "current_login_employee"
# puts current_login_employee.name
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee,current_user,order.source)
@sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
else
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
end
# Bind shift sale id to sale
# @sale_data.shift_sale_id = shift.id
# @sale_data.save
# Bind shift sale id to sale
# @sale_data.shift_sale_id = shift.id
# @sale_data.save
# Promotion Activation
Promotion.promo_activate(@sale)
@status = true
return @status, @sale
else
@status = false
@message = "No Current Open Shift for This Employee"
end
# Promotion Activation
Promotion.promo_activate(@sale)
@status = true
return @status, @sale
else
@status = false
@message = "No Current Open Shift for This Employee"
end
end
#This is when spilt bill is request - then we cannot link order to invoice
#Cos there will be multiple orders - and items are spilt from there.

View File

@@ -825,55 +825,6 @@ delete from sym_node;
values('order_queue_stations','sx_2_cloud', 200, current_timestamp, current_timestamp);
# End Oqs Channel
### Batch Monitoring ######
#Monitor#
insert into sym_monitor (monitor_id, node_group_id, external_id, type, threshold, run_period, run_count, severity_level, enabled, create_time, last_update_by, last_update_time)
value ('SystemBatchErrorMonitor', 'All', 'All', 'batchError', 1, 1, 1, 300, 1, now(), 'admin', now());
insert into sym_monitor (monitor_id, node_group_id, external_id, type, threshold, run_period, run_count, severity_level, enabled, create_time, last_update_by, last_update_time)
value ('SystemBatchUnsendMonitor', 'All', 'All', 'batchUnsent', 10, 1, 1, 100, 1, now(), 'admin', now());
insert into sym_monitor (monitor_id, node_group_id, external_id, type, threshold, run_period, run_count, severity_level, enabled, create_time, last_update_by, last_update_time)
value ('SystemLogMonitor', 'All', 'All', 'log', 1, 1, 1, 300, 1, now(), 'admin', now());
#Parameter#
insert into sym_parameter (external_id, node_group_id, param_key, param_value, create_time, last_update_by, last_update_time)
value ('All', 'All', 'smtp.allow.untrusted.cert', 'true', now(), 'admin', now());
insert into sym_parameter (external_id, node_group_id, param_key, param_value, create_time, last_update_by, last_update_time)
value ('All', 'All', 'smtp.auth', 'true', now(), 'admin', now());
insert into sym_parameter (external_id, node_group_id, param_key, param_value, create_time, last_update_by, last_update_time)
value ('All', 'All', 'smtp.from', 'sym_alert@smartsales.asia', now(), 'admin', now());
insert into sym_parameter (external_id, node_group_id, param_key, param_value, create_time, last_update_by, last_update_time)
value ('All', 'All', 'smtp.host', 'smtp.mailgun.org', now(), 'admin', now());
insert into sym_parameter (external_id, node_group_id, param_key, param_value, create_time, last_update_by, last_update_time)
value ('All', 'All', 'smtp.password', '1cc051ec3edf699d17b78e5cd14ceb6b', now(), 'admin', now());
insert into sym_parameter (external_id, node_group_id, param_key, param_value, create_time, last_update_by, last_update_time)
value ('All', 'All', 'smtp.port', '465', now(), 'admin', now());
insert into sym_parameter (external_id, node_group_id, param_key, param_value, create_time, last_update_by, last_update_time)
value ('All', 'All', 'smtp.starttls', 'false', now(), 'admin', now());
insert into sym_parameter (external_id, node_group_id, param_key, param_value, create_time, last_update_by, last_update_time)
value ('All', 'All', 'smtp.transport', 'smtps', now(), 'admin', now());
insert into sym_parameter (external_id, node_group_id, param_key, param_value, create_time, last_update_by, last_update_time)
value ('All', 'All', 'smtp.user', 'postmaster@smartsales.asia', now(), 'admin', now());
insert into sym_notification (notification_id, node_group_id, external_id, severity_level, type, expression, enabled, create_time, last_update_by, last_update_time)
value ('notify_info', 'ALL', 'ALL', 100, 'email', 'info@connect.smartsales.asia', 1, now(), 'admin', now());
insert into sym_notification (notification_id, node_group_id, external_id, severity_level, type, expression, enabled, create_time, last_update_by, last_update_time)
value ('notify_severe', 'ALL', 'ALL', 300, 'email', 'info@connect.smartsales.asia', 1, now(), 'admin', now());
### End of Batch Monitoring ####
insert into sym_node (node_id,node_group_id,external_id,sync_enabled,sync_url,schema_version,symmetric_version,database_type,database_version,heartbeat_time,timezone_offset,batch_to_send_count,batch_in_error_count,created_at_node_id)
values ('000','sx','000',1,null,null,null,null,null,current_timestamp,null,0,0,'000');