diff --git a/README.md b/README.md
index 8c5cf006..97f43595 100755
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ ruby 2.4.1p111
Osaka
- Auth Token => rj0MJ0XI5GsKZehE => New
+ Auth Token => wu8YvlLmah0CL => New ##note : Old => rj0MJ0XI5GsKZehE
=> code2lab => Old
@@ -23,7 +23,7 @@ ruby 2.4.1p111
BITP
- Auth Token => rj0MJ0XI5GsKZehE => New
+ Auth Token => pZBHXEFbGNj/G => New ##note : Old => rj0MJ0XI5GsKZehE
=> code2lab => Old
@@ -103,6 +103,10 @@ Change type in mysql
=> ALTER TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for table
=> ALTER DATABASE [database_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database
+###please open
+sudo cat /etc/sudoers
+### cope and parse
+%superuser ALL=(ALL) NOPASSWD: ALL
* ToDo list
diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js
index da50ac34..35e08b4f 100755
--- a/app/assets/javascripts/OQS.js
+++ b/app/assets/javascripts/OQS.js
@@ -25,6 +25,7 @@
//= require custom.js
$(document).on('turbolinks:load', function() {
+ var oqs_id = "";
$(".nav-completed").on("click", function(){
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
@@ -37,7 +38,8 @@ $(document).on('turbolinks:load', function() {
$(".oqs_append").removeClass('hide');
$(this).addClass('oqs_active');
$(".queue_station").addClass('queue_station_box');
- var oqs_id = $(this).find(".oqs-id").text();
+ oqs_id = $(this).find(".oqs-id").text();
+ console.log(oqs_id);
var url = 'oqs/get_items/'+oqs_id;
show_details(url);
@@ -142,8 +144,7 @@ $(document).on('turbolinks:load', function() {
type: 'GET',
url: '/oqs/' + orderNo,
data: { 'status' : order_status },
- success: function(res){
-
+ success: function(res){
for (i = 0; i < res.length; i++) {
var data = JSON.stringify(res[i]);
var parse_data = JSON.parse(data);
@@ -156,10 +157,19 @@ $(document).on('turbolinks:load', function() {
});
}
}
- var order_item_row = "
' +
+ template: '
' +
'' +
' ' +
'{1} ' +
diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb
index 387b7bf8..4b58e52d 100755
--- a/app/controllers/api/bill_controller.rb
+++ b/app/controllers/api/bill_controller.rb
@@ -46,7 +46,8 @@ class Api::BillController < Api::ApiController
Promotion.promo_activate(@sale)
- BillBroadcastJob.perform_later(table)
+ #BillBroadcastJob.perform_later(table)
+ ActionCable.server.broadcast "bill_channel",table: table
else
@status = false
@error_message = "No Current Open Shift"
diff --git a/app/controllers/api/call_waiters_controller.rb b/app/controllers/api/call_waiters_controller.rb
index bfb1023a..7cf80a5d 100644
--- a/app/controllers/api/call_waiters_controller.rb
+++ b/app/controllers/api/call_waiters_controller.rb
@@ -5,7 +5,8 @@ class Api::CallWaitersController < ActionController::API
@table_id = params[:dining_id]
@time = params[:time]
@table = DiningFacility.find(@table_id)
- CallWaiterJob.perform_later(@table,@time)
+ # CallWaiterJob.perform_later(@table,@time)
+ ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time
# get printer info
@shop = Shop::ShopDetail
diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb
index 883fb1ea..6f32c613 100644
--- a/app/controllers/api/check_in_process_controller.rb
+++ b/app/controllers/api/check_in_process_controller.rb
@@ -25,9 +25,10 @@ class Api::CheckInProcessController < Api::ApiController
alert_time_min = checkout_time[1].to_i
end
end
+ render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes }
+ else
+ render :json => { :status => true }
end
-
- render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes }
else
render :json => { :status => false, :error_message => "No current booking!" }
end
@@ -41,31 +42,36 @@ class Api::CheckInProcessController < Api::ApiController
lookup_checkout_time = Lookup.collection_of("checkout_time")
if !lookup_checkout_time.empty?
- checkout_at = Time.now.utc
+ today = Time.now.utc.getlocal
+ checkout_at = Time.now.utc.getlocal
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
- start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
- end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
- if start_time <= checkout_at && checkout_at <= end_time
+ start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p")
+ end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p")
+ if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
end
end
- dining_facility.status = "occupied"
- dining_facility.save!
+ if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
+ dining_facility.status = "occupied"
+ dining_facility.save!
- if dining_facility.type == "Table"
- type = "TableBooking"
+ if dining_facility.type == "Table"
+ type = "TableBooking"
+ else
+ type = "RoomBooking"
+ end
+
+ booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
+ :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
+ booking.save!
+
+ render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
else
- type = "RoomBooking"
+ render :json => { :status => true }
end
-
- booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
- :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
- booking.save!
-
- render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
else
render :json => { :status => true }
end
diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb
index cab929bd..2e9602c8 100755
--- a/app/controllers/api/orders_controller.rb
+++ b/app/controllers/api/orders_controller.rb
@@ -184,9 +184,9 @@ class Api::OrdersController < Api::ApiController
#checked checkin and checkout time
def checkin_checkout_time(booking_id)
status = true
- if !params[:booking_id].nil?
+ if !booking_id.nil?
today = Time.now.utc
- booking = Booking.find(params[:booking_id])
+ booking = Booking.find(booking_id)
if !booking.nil?
if !booking.checkout_at.nil?
checkout_time = booking.checkout_at.utc
diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb
index 01372dd3..af37253e 100755
--- a/app/controllers/oqs/edit_controller.rb
+++ b/app/controllers/oqs/edit_controller.rb
@@ -10,7 +10,9 @@ class Oqs::EditController < BaseOqsController
qty_weight = params[:qty_weight]
remarks = params[:remarks]
- order_item = OrderItem.find(order_items_id);
+ order_item = OrderItem.find(order_items_id)
+ before_updated_qty = order_item.qty
+
order_item.item_order_by = current_user.name
order_item.qty = qty_weight
order_item.remark = remarks
@@ -45,7 +47,7 @@ class Oqs::EditController < BaseOqsController
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
- order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Updated)" )
+ order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
end
end
end
diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb
index 3ee71e8d..d8642df4 100755
--- a/app/controllers/oqs/home_controller.rb
+++ b/app/controllers/oqs/home_controller.rb
@@ -1,7 +1,7 @@
class Oqs::HomeController < BaseOqsController
def index
- @queue_stations = OrderQueueStation.all
+
# Query for OQS with delivery status false
# @queue_items_details = queue_items_query(false)
@@ -11,26 +11,28 @@ class Oqs::HomeController < BaseOqsController
@filter = params[:filter]
+ @queue_stations = OrderQueueStation.all
+
@queue_completed_item = completed_order(@filter)
- if !@queue_completed_item.empty?
- @queue_completed_item.each do |queue_item|
- if !queue_item.set_menu_items.nil?
- instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
- arr_instance_item_sets = Array.new
- instance_item_sets.each do |instance_item|
- item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
- arr_instance_item_sets.push(item_instance_name)
- end
- queue_item.set_menu_items = arr_instance_item_sets
- end
- end
- end
+ # if !@queue_completed_item.empty?
+ # @queue_completed_item.each do |queue_item|
+ # if !queue_item.set_menu_items.nil?
+ # instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
+ # arr_instance_item_sets = Array.new
+ # instance_item_sets.each do |instance_item|
+ # item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
+ # arr_instance_item_sets.push(item_instance_name)
+ # end
+ # queue_item.set_menu_items = arr_instance_item_sets
+ # end
+ # end
+ # end
if !@filter.nil?
@count = queue_items_count_query(false,@filter)
- @count.each do |count|
+ #@count.each do |count|
- end
+ #end
end
# @queue_stations_items=Array.new
@@ -99,7 +101,6 @@ class Oqs::HomeController < BaseOqsController
end
end
end
-
render :json => items.to_json
end
@@ -194,18 +195,35 @@ class Oqs::HomeController < BaseOqsController
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
+ # def queue_items_count_query(status,filter)
+ # query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
+ # .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
+ # left join orders as od ON od.order_id = assigned_order_items.order_id
+ # left join order_items as odt ON odt.item_instance_code = assigned_order_items.instance_code AND odt.order_id = assigned_order_items.order_id
+ # left join customers as cus ON cus.customer_id = od.customer_id
+ # left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
+ # left join bookings as bk on bk.booking_id = bo.booking_id
+ # left join dining_facilities as df on df.id = bk.dining_facility_id")
+ # .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
+ # query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
+ # .group("oqs.id")
+
+ # end
+
def queue_items_count_query(status,filter)
- query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
- .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
- left join orders as od ON od.order_id = assigned_order_items.order_id
- left join order_items as odt ON odt.item_instance_code = assigned_order_items.instance_code AND odt.order_id = assigned_order_items.order_id
+ # query = OrderQueueStation.all
+ query = OrderQueueStation.select("order_queue_stations.id as station_id,
+ (case when (count(odt.item_code)>0) then count(odt.item_code) else 0 end) as total")
+ .joins(" left join assigned_order_items as aoi on aoi.order_queue_station_id= order_queue_stations.id
+ left join orders as od ON od.order_id = aoi.order_id
+ left join order_items as odt ON odt.item_instance_code = aoi.instance_code AND odt.order_id = aoi.order_id
left join customers as cus ON cus.customer_id = od.customer_id
- left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
+ left join booking_orders as bo on bo.order_id = aoi.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
- .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
+ .where("aoi.delivery_status = #{status} AND aoi.created_at >= '#{Time.now.beginning_of_day.utc}' ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
- .group("oqs.id")
+ .group("order_queue_stations.id")
end
diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb
index aaa6b262..36e5d6d9 100755
--- a/app/controllers/oqs/print_controller.rb
+++ b/app/controllers/oqs/print_controller.rb
@@ -38,7 +38,7 @@ class Oqs::PrintController < ApplicationController
# print when complete click
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
- order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, options )
+ order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options )
# update print status for completed same order items
assigned_items.each do |ai|
diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb
index 14d5c90c..2c5b0b38 100644
--- a/app/controllers/origami/check_in_process_controller.rb
+++ b/app/controllers/origami/check_in_process_controller.rb
@@ -2,31 +2,34 @@ class Origami::CheckInProcessController < BaseOrigamiController
def check_in_process
lookup_checkout_time = Lookup.collection_of("checkout_time")
- checkout_at = Time.now.utc
+ today = Time.now.utc.getlocal
+ checkout_at = Time.now.utc.getlocal
if !lookup_checkout_time.empty?
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
- start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
- end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
- if start_time <= checkout_at && checkout_at <= end_time
+ start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p")
+ end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p")
+ if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
end
end
- end
- @dining_facility = DiningFacility.find(params[:dining_id])
- @dining_facility.status = "occupied"
- @dining_facility.save!
+
+ if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
+ @dining_facility = DiningFacility.find(params[:dining_id])
+ @dining_facility.status = "occupied"
+ @dining_facility.save!
- if @dining_facility.type == "Table"
- type = "TableBooking"
- else
- type = "RoomBooking"
+ if @dining_facility.type == "Table"
+ type = "TableBooking"
+ else
+ type = "RoomBooking"
+ end
+
+ @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
+ :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
+ @booking.save!
+ end
end
-
- @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
- :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
- @booking.save!
-
respond = {:status => 'ok'}
respond_to do |format|
format.json { render json: respond }
diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb
index 536defe7..0dda31f5 100755
--- a/app/controllers/origami/home_controller.rb
+++ b/app/controllers/origami/home_controller.rb
@@ -6,7 +6,7 @@ class Origami::HomeController < BaseOrigamiController
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
- @orders = Order.all.order('date desc')
+ @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@shop = Shop::ShopDetail
# @shift = ShiftSale.current_open_shift(current_user.id)
@@ -17,7 +17,7 @@ class Origami::HomeController < BaseOrigamiController
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
- @orders = Order.all.order('date desc')
+ @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@status_order = ""
@status_sale = ""
@@ -84,7 +84,10 @@ class Origami::HomeController < BaseOrigamiController
end
end
end
-
+
+ #for bank integration
+ @checkout_time = Lookup.collection_of('checkout_time')
+ @checkout_alert_time = Lookup.collection_of('checkout_alert_time')
end
private
diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb
index 85047ef0..22a1e802 100755
--- a/app/controllers/origami/orders_controller.rb
+++ b/app/controllers/origami/orders_controller.rb
@@ -3,7 +3,7 @@ class Origami::OrdersController < BaseOrigamiController
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
- @orders = Order.all.order('status desc')
+ @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@order = Order.find(params[:order_id])
sale_order = SaleOrder.find_by_order_id(@order.order_id)
if sale_order
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index 06a0fc4a..0622f173 100755
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -45,8 +45,8 @@ class Origami::PaymentsController < BaseOrigamiController
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
- # current_balance = SaleAudit.paymal_search(sale_id)
- current_balance = 0
+ current_balance = SaleAudit.paymal_search(sale_id)
+ # current_balance = 0
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb
index bd375d63..cda8c299 100755
--- a/app/controllers/origami/rooms_controller.rb
+++ b/app/controllers/origami/rooms_controller.rb
@@ -3,7 +3,7 @@ class Origami::RoomsController < BaseOrigamiController
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
- @orders = Order.all.order('date desc')
+ @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
# @shift = ShiftSale.current_open_shift(current_user.id)
end
@@ -11,7 +11,7 @@ class Origami::RoomsController < BaseOrigamiController
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
- @orders = Order.all.order('date desc')
+ @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@room = DiningFacility.find(params[:room_id])
diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb
index bdf481c2..f64cef88 100755
--- a/app/controllers/origami/sales_controller.rb
+++ b/app/controllers/origami/sales_controller.rb
@@ -3,7 +3,7 @@ class Origami::SalesController < BaseOrigamiController
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
- @orders = Order.all.order('date desc')
+ @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@sale = Sale.find(params[:sale_id])
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
@booking = BookingOrder.find_by_order_id(@order).booking_id
diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb
index 6d0fbe02..cb2cc830 100755
--- a/app/controllers/origami/shifts_controller.rb
+++ b/app/controllers/origami/shifts_controller.rb
@@ -4,6 +4,12 @@ class Origami::ShiftsController < BaseOrigamiController
def show
@shift = ShiftSale.current_open_shift(current_user.id)
+ #for bank integration
+ bank_integration = Lookup.collection_of('bank_integration')
+ @bank_integration = 0
+ if !bank_integration[0].nil?
+ @bank_integration = bank_integration[0][1]
+ end
end
def new
diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb
index 4571ba87..655083df 100755
--- a/app/controllers/origami/table_invoices_controller.rb
+++ b/app/controllers/origami/table_invoices_controller.rb
@@ -1,6 +1,7 @@
class Origami::TableInvoicesController < BaseOrigamiController
def index
@table = DiningFacility.find(params[:table_id])
+ shop = Shop::ShopDetail
puts "table bookig lenght"
@sale_array = Array.new
@table.bookings.each do |booking|
@@ -9,7 +10,18 @@ class Origami::TableInvoicesController < BaseOrigamiController
if booking.sale_id.nil?
else
sale = Sale.find(booking.sale_id)
-
+ # rounding adjustment
+ if shop.is_rounding_adj
+ a = sale.grand_total % 25 # Modulus
+ b = sale.grand_total / 25 # Division
+ #not calculate rounding if modulus is 0 and division is even
+ #calculate rounding if modulus is zero or not zero and division are not even
+ if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
+ new_total = Sale.get_rounding_adjustment(sale.grand_total)
+ sale.rounding_adjustment = new_total-sale.grand_total
+ end
+ end
+ #end rounding adjustment
if sale.sale_status != "completed"
@sale_array.push(sale)
end
@@ -19,12 +31,24 @@ class Origami::TableInvoicesController < BaseOrigamiController
def show
@table = DiningFacility.find(params[:table_id])
+ shop = Shop::ShopDetail
@sale_array = Array.new
@table.bookings.each do |booking|
if booking.sale_id.nil?
else
- sale = Sale.find(booking.sale_id)
-
+ sale = Sale.find(booking.sale_id)
+ # rounding adjustment
+ if shop.is_rounding_adj
+ a = sale.grand_total % 25 # Modulus
+ b = sale.grand_total / 25 # Division
+ #not calculate rounding if modulus is 0 and division is even
+ #calculate rounding if modulus is zero or not zero and division are not even
+ if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
+ new_total = Sale.get_rounding_adjustment(sale.grand_total)
+ sale.rounding_adjustment = new_total-sale.grand_total
+ end
+ end
+ #end rounding adjustment
if sale.sale_status != "completed" && sale.sale_status != 'void'
@sale_array.push(sale)
end
diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb
index 0d368224..52b2068c 100755
--- a/app/controllers/origami/void_controller.rb
+++ b/app/controllers/origami/void_controller.rb
@@ -87,7 +87,7 @@ class Origami::VoidController < BaseOrigamiController
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
- rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
+ rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb
index b8386d88..50fc6a52 100755
--- a/app/models/dining_facility.rb
+++ b/app/models/dining_facility.rb
@@ -155,7 +155,15 @@ class DiningFacility < ApplicationRecord
def self.check_in_booking(table_id)
table = DiningFacility.find(table_id)
#Send to background job for processing
- CheckInBookingJob.perform_later(table)
+ # CheckInBookingJob.perform_later(table)
+ ActionCable.server.broadcast "check_in_booking_channel",table: table
+ end
+
+ def self.checkin_time
+ table = DiningFacility.get_checkin_booking
+ if table.length > 0
+ ActionCable.server.broadcast "checkin_channel",table: table
+ end
end
end
diff --git a/app/models/order.rb b/app/models/order.rb
index 3580e5f1..eb856faa 100755
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -276,16 +276,42 @@ class Order < ApplicationRecord
#Process order items and send to order queue
def process_order_queue
#Send to background job for processing
- OrderQueueProcessorJob.perform_later(self.id, self.table_id)
- end
+ cup_status = `#{"sudo service cups status"}`
+ print_status = check_cup_status(cup_status)
+
+ if print_status
+ OrderQueueProcessorJob.perform_later(self.id, self.table_id)
+ else
+ cup_start = `#{"sudo service cups start"}`
+ cup_status = `#{"sudo service cups status"}`
+ print_status = check_cup_status(cup_status)
+
+ if print_status
+ OrderQueueProcessorJob.perform_later(self.id, self.table_id)
+ else
+ msg = ' Print Error ! Please contact to service'
+ ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
+ OrderQueueProcessorJob.perform_later(self.id, self.table_id)
+ end
+ end
+
+ end
+
+ def check_cup_status(status)
+ if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
+ return true
+ end
+ return false
+ end
#send order items and send to order queue
def send_order_broadcast(booking)
table = DiningFacility.find(booking.dining_facility_id)
type = 'order'
#Send to background job for processing
- OrderBroadcastJob.perform_later(table,type)
+ # OrderBroadcastJob.perform_later(table,type)
+ ActionCable.server.broadcast "order_channel",table: table,type:type
end
#Origami: Cashier : to view order Table
diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb
index 85264737..04ad5896 100755
--- a/app/models/printer/order_queue_printer.rb
+++ b/app/models/printer/order_queue_printer.rb
@@ -1,6 +1,6 @@
class Printer::OrderQueuePrinter < Printer::PrinterWorker
- def print_order_item(print_settings,oqs, order_id, order_item_id, print_status, options="")
+ def print_order_item(print_settings,oqs, order_id, order_item_id, print_status, before_updated_qty="", options="")
#Use CUPS service
#Generate PDF
#Print
@@ -14,7 +14,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
- pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
+ pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
# check for item not to show
# if order_item[0].price != 0
@@ -22,15 +22,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
order_slim_pdf.each do |order_item_slim|
if order_item_slim[0] == 'OrderSlimPdf'
if order_item_slim[1] == '1'
- pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
+ pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
else
- pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
+ pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
end
elsif order_item_slim[0] == 'OrderSetPdf'
if order_item_slim[1] == '1'
- pdf = OrderSetItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
+ pdf = OrderSetItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
else
- pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
+ pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
end
end
end
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 22d1be1a..a5ffa8d9 100755
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -128,7 +128,9 @@ class Sale < ApplicationRecord
booking.checkout_by = requested_by.name
booking.save
- InventoryJob.perform_now(self.id)
+ # InventoryJob.perform_now(self.id)
+ saleObj = Sale.find(self.id)
+ InventoryDefinition.calculate_product_count(saleObj)
return true, self.id
end
@@ -741,7 +743,7 @@ def self.get_item_query()
query = Sale.select("acc.title as account_name,mi.account_id, i.item_instance_code as item_code,i.account_id as account_id, " +
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item,i.qty as qty," +
"i.remark as status_type,"+
- " i.unit_price as unit_price,i.price as price,i.product_name as product_name, mc.name as" +
+ " mii.price as unit_price,i.price as price,i.product_name as product_name, mc.name as" +
" menu_category_name,mc.id as menu_category_id ")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index b92a781c..661eb57b 100755
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -398,6 +398,7 @@ class SalePayment < ApplicationRecord
end
else
status = false
+ sale_count += 1
end
end
end
@@ -408,7 +409,8 @@ class SalePayment < ApplicationRecord
type = 'payment'
#Send to background job for processing
- OrderBroadcastJob.perform_later(table,type)
+ # OrderBroadcastJob.perform_later(table,type)
+ ActionCable.server.broadcast "order_channel",table: table,type:type
end
end
diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb
index 9483b847..26253b6e 100755
--- a/app/pdf/order_item_pdf.rb
+++ b/app/pdf/order_item_pdf.rb
@@ -1,7 +1,7 @@
class OrderItemPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
- def initialize(print_settings,order_item, print_status, options, alt_name)
+ def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.margin = 0
@@ -46,7 +46,7 @@ class OrderItemPdf < Prawn::Document
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
# order items
- order_items(order_item, options, alt_name, print_settings.precision)
+ order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
end
# Write Order Information to PDF
@@ -74,7 +74,7 @@ class OrderItemPdf < Prawn::Document
end
# Write Order items to PDF
- def order_items(order_item, options, alt_name, precision)
+ def order_items(order_item, options, alt_name, precision, before_updated_qty)
y_position = cursor
#Add Order Item
@@ -82,6 +82,7 @@ class OrderItemPdf < Prawn::Document
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
+ add_updated_qty_text(before_updated_qty, order_item.qty, precision)
move_down 5
end
@@ -127,4 +128,17 @@ class OrderItemPdf < Prawn::Document
end
+ #add updated qty text
+ def add_updated_qty_text(before_updated_qty, updated_qty, precision)
+ if before_updated_qty.to_i > 0 && !before_updated_qty.nil?
+ move_down 5
+
+ # add option
+ y_position = cursor
+ bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
+ text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ end
+ end
+ end
+
end
diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb
index 6887d201..f419f185 100644
--- a/app/pdf/order_item_slim_pdf.rb
+++ b/app/pdf/order_item_slim_pdf.rb
@@ -1,7 +1,7 @@
class OrderItemSlimPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
- def initialize(print_settings,order_item_slim, print_status, options, alt_name)
+ def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.margin = 0
@@ -46,7 +46,7 @@ class OrderItemSlimPdf < Prawn::Document
order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at)
# order items slim
- order_items_slim(order_item_slim, options, alt_name, print_settings.precision)
+ order_items_slim(order_item_slim, options, alt_name, print_settings.precision, before_updated_qty)
end
# Write Order Information to PDF
@@ -74,7 +74,7 @@ class OrderItemSlimPdf < Prawn::Document
end
# Write Order items to PDF
- def order_items_slim(order_item_slim, options, alt_name, precision)
+ def order_items_slim(order_item_slim, options, alt_name, precision, before_updated_qty)
y_position = cursor
#Add Order Item
@@ -82,6 +82,7 @@ class OrderItemSlimPdf < Prawn::Document
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
+ add_updated_qty_text(before_updated_qty, order_item_slim.qty, precision)
move_down 1
end
@@ -126,4 +127,17 @@ class OrderItemSlimPdf < Prawn::Document
end
+ #add updated qty text
+ def add_updated_qty_text(before_updated_qty, updated_qty, precision)
+ if before_updated_qty.to_i > 0 && !before_updated_qty.nil?
+ move_down 1
+
+ # add option
+ y_position = cursor
+ bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
+ text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ end
+ end
+ end
+
end
diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb
index 30a800b4..8f915ad0 100644
--- a/app/pdf/order_set_item_pdf.rb
+++ b/app/pdf/order_set_item_pdf.rb
@@ -1,7 +1,7 @@
class OrderSetItemPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
- def initialize(print_settings,order_set_item, print_status, options, alt_name)
+ def initialize(print_settings,order_set_item, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.margin = 0
@@ -46,7 +46,7 @@ class OrderSetItemPdf < Prawn::Document
order_info(order_set_item.order_id, order_set_item.order_by,order_set_item.order_at)
# order items
- order_set_items(order_set_item, options, alt_name, print_settings.precision)
+ order_set_items(order_set_item, options, alt_name, print_settings.precision, before_updated_qty)
end
# Write Order Information to PDF
@@ -74,7 +74,7 @@ class OrderSetItemPdf < Prawn::Document
end
# Write Order items to PDF
- def order_set_items(order_set_item, options, alt_name, precision)
+ def order_set_items(order_set_item, options, alt_name, precision, before_updated_qty)
y_position = cursor
#Add Order Item
@@ -82,6 +82,7 @@ class OrderSetItemPdf < Prawn::Document
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
+ add_updated_qty_text(before_updated_qty, order_set_item.qty, precision)
move_down 5
end
@@ -143,4 +144,17 @@ class OrderSetItemPdf < Prawn::Document
end
+ #add updated qty text
+ def add_updated_qty_text(before_updated_qty, updated_qty, precision)
+ if before_updated_qty.to_i > 0 && !before_updated_qty.nil?
+ move_down 5
+
+ # add option
+ y_position = cursor
+ bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
+ text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
+ end
+ end
+ end
+
end
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb
index f42f0c12..3b012690 100755
--- a/app/views/origami/home/show.html.erb
+++ b/app/views/origami/home/show.html.erb
@@ -431,7 +431,9 @@
<% else %>
-
+ <% if !@checkout_time.empty? && !@checkout_alert_time.empty? %>
+
+ <% end %>
<% end %>
">
<%= @membership.discount%>
@@ -475,12 +477,14 @@
receipt_no = ($("#receipt_no").html()).trim();
}
- // console.log(checkReceiptNoInFirstBillData(receipt_no));
+ discount="<%= @membership.discount%>"
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
- if(checkReceiptNoInFirstBillData(receipt_no,"")){
- $("#pay").show();
- }else{
- $("#pay").hide();
+ if (discount) {
+ if(checkReceiptNoInFirstBillData(receipt_no,"")){
+ $("#pay").show();
+ }else{
+ $("#pay").hide();
+ }
}
}
/* end check first bill or not*/
diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb
index b08328b6..c1a581dc 100755
--- a/app/views/origami/orders/show.html.erb
+++ b/app/views/origami/orders/show.html.erb
@@ -107,7 +107,7 @@
order_status = order.status
end
%>
- <%= order.order_id %> | <%= order_status %>
+ <%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %>
<% end %>
@@ -129,7 +129,7 @@