' +
+ '
× ' +
'
' +
'
{1} ' +
'
{2} ' +
diff --git a/app/assets/javascripts/channels/check_in_booking.js b/app/assets/javascripts/channels/check_in_booking.js
new file mode 100644
index 00000000..4f5300ee
--- /dev/null
+++ b/app/assets/javascripts/channels/check_in_booking.js
@@ -0,0 +1,14 @@
+App.checkin = App.cable.subscriptions.create('CheckInBookingChannel', {
+// App.messages = App.cable.subscriptions.create('MessagesChannel', {
+
+ connected: function() {},
+
+ disconnected: function() {},
+
+ received: function(data) {
+ $('.table_'+data.table.id).removeClass('green');
+ $('.table_'+data.table.id).addClass('blue');
+ $('.new_text_'+data.table.id).removeClass('hide')
+ }
+});
+
diff --git a/app/assets/javascripts/channels/checkin.js b/app/assets/javascripts/channels/checkin.js
index 859cb733..d4a71d5e 100644
--- a/app/assets/javascripts/channels/checkin.js
+++ b/app/assets/javascripts/channels/checkin.js
@@ -5,21 +5,22 @@ App.order = App.cable.subscriptions.create('CheckinChannel', {
disconnected: function() {},
- received: function(data) {
- if((data.table != undefined) && (data.table.length > 0)){
- $.each(data.table,function(key,value){
- if($('.table_'+value.table_id).hasClass('blue')){
- $('.table_'+value.table_id).removeClass('blue');
- $('.table_'+value.table_id).addClass('orange');
- }
- else if($('.table_'+value.table_id).hasClass('red')){
- $('.table_'+value.table_id).removeClass('red');
- $('.table_'+value.table_id).addClass('orange');
- }
- $('.new_text_'+value.table_id).removeClass('hide');
- });
-
- }
+ received: function(data) {
+ $.each(data.table,function(key,value){
+ if($('.table_'+value.table_id).hasClass('blue')){
+ $('.table_'+value.table_id).removeClass('blue');
+ $('.table_'+value.table_id).addClass('orange');
+ }
+ else if($('.table_'+value.table_id).hasClass('red')){
+ $('.table_'+value.table_id).removeClass('red');
+ $('.table_'+value.table_id).addClass('orange');
+ }
+ else {
+ $('.table_'+value.table_id).removeClass('green');
+ $('.table_'+value.table_id).addClass('orange');
+ }
+ $('.new_text_'+value.table_id).removeClass('hide');
+ });
}
});
diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss
index ca36f61e..30d8a090 100755
--- a/app/assets/stylesheets/origami.scss
+++ b/app/assets/stylesheets/origami.scss
@@ -362,8 +362,31 @@ tr.discount-item-row:hover {
/* End Payment Page */
-/*Logout Icon*/
+/* Logout Icon */
+
i.logout_icon{
position: relative;
top: 5px;
-}
\ No newline at end of file
+}
+
+/* End Logout Icon */
+
+/* Notify */
+
+#notify-wrapper {
+ position: absolute;
+ top: 55px;
+ left: 10px;
+ z-index: 9999;
+ opacity: 0.8;
+}
+
+[data-notify="container"] {
+ margin-bottom: 5px !important;
+ margin-left:5px !important;
+ position:relative !important;
+ top: 25% !important;
+ width: 100% !important;
+}
+
+/* End Notify */
diff --git a/app/channels/check_in_booking_channel.rb b/app/channels/check_in_booking_channel.rb
new file mode 100644
index 00000000..f9df89ba
--- /dev/null
+++ b/app/channels/check_in_booking_channel.rb
@@ -0,0 +1,10 @@
+class CheckInBookingChannel < ApplicationCable::Channel
+ def subscribed
+ stream_from "check_in_booking_channel"
+ end
+
+ def unsubscribed
+ stop_all_streams
+ # Any cleanup needed when channel is unsubscribed
+ end
+end
diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb
index cfce827f..4f1c4ae2 100644
--- a/app/controllers/api/check_in_process_controller.rb
+++ b/app/controllers/api/check_in_process_controller.rb
@@ -5,8 +5,12 @@ class Api::CheckInProcessController < Api::ApiController
dining_facility = DiningFacility.find(params[:dining_id])
booking = dining_facility.get_current_checkout_booking
if !booking.nil?
+
+ DiningFacility.check_in_booking(params[:dining_id])
+
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!" }
@@ -18,20 +22,16 @@ class Api::CheckInProcessController < Api::ApiController
if params[:dining_id]
dining_facility = DiningFacility.find(params[:dining_id])
if dining_facility.status == "available"
- dining_charge = DiningCharge.select('charge_type','charge_block')
- .where('dining_facility_id = ?',params[:dining_id])
- .first()
+ lookup_checkout_time = Lookup.collection_of("checkout_time")
checkout_at = Time.now.utc
- if !dining_charge.nil?
- hr = (dining_charge.charge_block.utc.strftime("%H").to_i).to_int
- min = (dining_charge.charge_block.utc.strftime("%M").to_i).to_int
- # if dining_charge.charge_type == 'hr'
- checkout_at = checkout_at + hr.hour + min.minutes
- # else
-
- # end
+ if !lookup_checkout_time.nil?
+ if lookup_checkout_time[0][0] == 'hr'
+ checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
+ else
+ checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
+ end
end
dining_facility.status = "occupied"
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 6f754591..fcca34a7 100755
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -23,7 +23,6 @@ class ApplicationController < ActionController::Base
end
def lookup_domain
-
if request.subdomain.present? && request.subdomain != "www"
from = request.subdomain.downcase + "." + request.domain.downcase
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb
index 9a58c3fd..ec415bad 100755
--- a/app/controllers/base_origami_controller.rb
+++ b/app/controllers/base_origami_controller.rb
@@ -2,7 +2,7 @@ class BaseOrigamiController < ActionController::Base
include LoginVerification
layout "origami"
- before_action :checkin_process
+ # before_action :checkin_process
#before_action :check_installation
protect_from_forgery with: :exception
@@ -15,7 +15,7 @@ class BaseOrigamiController < ActionController::Base
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
- def checkin_process
- CheckinJob.set(wait: 1.minute).perform_later()
- end
+ # def checkin_process
+ # CheckinJob.set(wait: 1.minute).perform_later()
+ # end
end
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index c0775008..d3666a60 100755
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -72,7 +72,8 @@ class HomeController < ApplicationController
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)
- @employee_sales = Sale.employee_sales(today).sum('payment_amount')
+ @employee_sales = Sale.employee_sales(today)
+ .sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
@inventories = StockJournal.inventory_balances(today).sum(:balance)
@total_sale = Sale.total_sale(today)
diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb
index bc77e51c..37f58d8f 100644
--- a/app/controllers/origami/check_in_process_controller.rb
+++ b/app/controllers/origami/check_in_process_controller.rb
@@ -1,20 +1,15 @@
class Origami::CheckInProcessController < BaseOrigamiController
def check_in_process
- dining_charge = DiningCharge.select('charge_type','charge_block')
- .where('dining_facility_id = ?',params[:dining_id])
- .first()
-
+ lookup_checkout_time = Lookup.collection_of("checkout_time")
checkout_at = Time.now.utc
- if !dining_charge.nil?
- hr = (dining_charge.charge_block.utc.strftime("%H").to_i).to_int
- min = (dining_charge.charge_block.utc.strftime("%M").to_i).to_int
- # if dining_charge.charge_type == 'hr'
- checkout_at = checkout_at + hr.hour + min.minutes
- # else
-
- # end
+ if !lookup_checkout_time.nil?
+ if lookup_checkout_time[0][0] == 'hr'
+ checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
+ else
+ checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
+ end
end
@dining_facility = DiningFacility.find(params[:dining_id])
@dining_facility.status = "occupied"
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index 2c81cef6..efb8f0cf 100755
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -44,7 +44,7 @@ class Origami::PaymentsController < BaseOrigamiController
# printer = Printer::ReceiptPrinter.new(print_settings)
- # printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt")
+ # printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt")
end
def create
@@ -264,8 +264,13 @@ class Origami::PaymentsController < BaseOrigamiController
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
# discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
+<<<<<<< HEAD
# printer = Printer::ReceiptPrinter.new(print_settings)
# printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
+=======
+ printer = Printer::ReceiptPrinter.new(print_settings)
+ printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil)
+>>>>>>> master
end
end
diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb
index 3c895b91..e5350706 100755
--- a/app/controllers/origami/sales_controller.rb
+++ b/app/controllers/origami/sales_controller.rb
@@ -5,6 +5,10 @@ class Origami::SalesController < BaseOrigamiController
@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')
@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
+ @table_id = Booking.find(@booking).dining_facility_id
+ @dining = DiningFacility.find(@table_id)
end
def add_to_existing_invoice
diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb
index 2e213323..7e7469f9 100755
--- a/app/controllers/reports/saleitem_controller.rb
+++ b/app/controllers/reports/saleitem_controller.rb
@@ -18,7 +18,7 @@ class Reports::SaleitemController < BaseReportController
@sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED)
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
-puts @sale_data.to_json
+
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
diff --git a/app/jobs/check_in_booking_job.rb b/app/jobs/check_in_booking_job.rb
new file mode 100644
index 00000000..7f8d39d3
--- /dev/null
+++ b/app/jobs/check_in_booking_job.rb
@@ -0,0 +1,9 @@
+class CheckInBookingJob < ApplicationJob
+ queue_as :default
+
+ def perform(table)
+ ActionCable.server.broadcast "check_in_booking_channel",table: table
+ end
+end
+
+
diff --git a/app/jobs/checkin_job.rb b/app/jobs/checkin_job.rb
index 3a0d329f..298a42f5 100644
--- a/app/jobs/checkin_job.rb
+++ b/app/jobs/checkin_job.rb
@@ -1,9 +1,11 @@
class CheckinJob < ApplicationJob
queue_as :default
- def perform()
+ def self.perform()
table = DiningFacility.get_checkin_booking
- ActionCable.server.broadcast "checkin_channel",table: table
+ if table.length > 0
+ ActionCable.server.broadcast "checkin_channel",table: table
+ end
end
diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb
index 89f5796e..bd6f3436 100755
--- a/app/models/dining_facility.rb
+++ b/app/models/dining_facility.rb
@@ -78,8 +78,17 @@ class DiningFacility < ApplicationRecord
def get_checkout_booking
booking = self.get_current_checkout_booking
if booking
+ lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
+ free_time_min = 0
+ if !lookup_checkout_time.nil?
+ if lookup_checkout_time[0][0] == 'min'
+ free_time_min = (lookup_checkout_time[0][1]).to_i
+ else
+ free_time_min = 15
+ end
+ end
+
now = Time.now.utc
- puts now
hr = (now.strftime("%H").to_i).to_int
min = (now.strftime("%M").to_i).to_int
if !booking.checkout_at.nil?
@@ -89,7 +98,7 @@ class DiningFacility < ApplicationRecord
checkout_at_min -= min
if (checkout_at_hr < hr)
return booking
- elsif (checkout_at_hr == hr && checkout_at_min <= 15)
+ elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
return booking
else
return nil
@@ -104,18 +113,28 @@ class DiningFacility < ApplicationRecord
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
arr_booking = Array.new
if bookings
+ lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
+ free_time_min = 0
+ if !lookup_checkout_time.nil?
+ if lookup_checkout_time[0][0] == 'min'
+ free_time_min = (lookup_checkout_time[0][1]).to_i
+ else
+ free_time_min = 15
+ end
+ end
+
bookings.each do |booking|
- now = Time.now.utc.getlocal
+ now = Time.now.utc
hr = (now.strftime("%H").to_i).to_int
min = (now.strftime("%M").to_i).to_int
if !booking.checkout_at.nil?
- checkout_at = booking.checkout_at.utc.getlocal
+ checkout_at = booking.checkout_at.utc
checkout_at_hr = (checkout_at.strftime("%H").to_i).to_int
checkout_at_min = (checkout_at.strftime("%M").to_i).to_int
checkout_at_min -= min
if (checkout_at_hr < hr)
arr_booking.push({'table_id' => booking.dining_facility_id})
- elsif (checkout_at_hr == hr && checkout_at_min <= 15)
+ elsif (checkout_at_hr == hr && checkout_at_min <= free_time_min)
arr_booking.push({'table_id' => booking.dining_facility_id})
end
end
@@ -123,4 +142,11 @@ class DiningFacility < ApplicationRecord
end
return arr_booking
end
+
+ #send order items and send to order queue
+ def self.check_in_booking(table_id)
+ table = DiningFacility.find(table_id)
+ #Send to background job for processing
+ CheckInBookingJob.perform_later(table)
+ end
end
diff --git a/app/models/sale.rb b/app/models/sale.rb
index e92b1bb5..1598563f 100755
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -984,12 +984,11 @@ end
end
def self.employee_sales(today)
- query = Sale.select('(CASE WHEN (sp.payment_method="mpu" or sp.payment_method="visa" or sp.payment_method="master" or sp.payment_method="jcb") THEN "card" ELSE sp.payment_method END) as payment_name, (CASE WHEN sp.payment_method="cash" THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount')
- .joins("join employees e on e.id=sales.cashier_id")
- .joins("join sale_payments sp on sp.sale_id=sales.sale_id")
- .where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'")
- .group('payment_method','e.name')
- .order('e.name')
+ query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id")
+ .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
+ .where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'")
+ .group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb') THEN 'card' ELSE sp.payment_method END)","e.name")
+ .order("e.name")
end
def self.total_sale(today)
@@ -1043,11 +1042,16 @@ end
end
def self.total_customer(today)
- query = Sale.select("(CASE WHEN (c.customer_type='Dinein' or c.customer_type='Takeaway') THEN count(sales.customer_id) ELSE count(distinct sales.customer_id) END) as total_cus")
- .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
- .order('sales.sale_id ASC')
- .first()
+ dinein_cnt = self.total_dinein(today)
+ takeaway_cnt = self.total_takeaway(today)
+ membership_cnt = self.total_membership(today)
+
+ total_cus = 0
+ if !dinein_cnt.nil? || !takeaway_cnt.nil? || !membership_cnt.nil?
+ total_cus = dinein_cnt.total_dinein_cus.to_int + takeaway_cnt.total_take_cus.to_int + membership_cnt.total_memb_cus.to_int
+ end
+
+ return total_cus
end
def self.total_dinein(today)
@@ -1067,12 +1071,12 @@ end
def self.total_membership(today)
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
- .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is not null',today)
+ .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
.first()
end
def self.total_other_customer(today)
- query = Sale.select("count(distinct sales.customer_id) as total_cus")
+ query = Sale.select("count(sales.customer_id) as total_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
.first()
@@ -1111,8 +1115,8 @@ end
def self.total_foc_items(today)
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
- .where("sales.sale_status = 'completed' and a.remark='foc' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
- .count()
+ .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
+ .sum("a.qty")
end
private
diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb
index 2cd728d4..465af104 100755
--- a/app/models/sale_item.rb
+++ b/app/models/sale_item.rb
@@ -27,10 +27,14 @@ class SaleItem < ApplicationRecord
end
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
+ # Original Item to add remark
+ item.remark = type
+ item.save
+
sale_item = SaleItem.new
sale_item.product_code = item.product_code
sale_item.item_instance_code = item.item_instance_code
- sale_item.product_name = item.product_name + "(#{type})"
+ sale_item.product_name = item.product_name + " (#{type.upcase})"
sale_item.product_alt_name = item.product_alt_name
sale_item.account_id = item.account_id
sale_item.remark = type
diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb
index a42bce49..3ed5e068 100755
--- a/app/views/home/dashboard.html.erb
+++ b/app/views/home/dashboard.html.erb
@@ -56,7 +56,7 @@
<% if current_user.role == 'administrator' || current_user.role == 'manager' %>
-
+
-
+
<% if !@summ_sale.nil? %>
@@ -185,7 +185,7 @@
<% if !@total_customer.nil? %>
<%= t("views.right_panel.detail.total") %> <%= t :customer %> :
- <%= @total_customer.total_cus %>
+ <%= @total_customer %>
<% end %>
<% if !@total_dinein.nil? %>
@@ -254,7 +254,7 @@
<% if !@total_foc_items.nil? %>
<%= t("views.right_panel.detail.total") %> <%= t("views.btn.foc") %> <%= t("views.right_panel.detail.item") %> :
- <%= @total_foc_items %>
+ <%= @total_foc_items.to_int %>
<% end %>
diff --git a/app/views/layouts/origami.html.erb b/app/views/layouts/origami.html.erb
index 9f175511..744ab87a 100755
--- a/app/views/layouts/origami.html.erb
+++ b/app/views/layouts/origami.html.erb
@@ -41,6 +41,10 @@
<%= render 'layouts/right_sidebar' %>
+
+
+
+
<% flash.each do |type, message| %>
diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb
index 25c1e1cc..d8909915 100755
--- a/app/views/origami/addorders/detail.html.erb
+++ b/app/views/origami/addorders/detail.html.erb
@@ -12,7 +12,7 @@