-
This commit is contained in:
5
Gemfile
5
Gemfile
@@ -1,6 +1,6 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
ruby '2.4.1'
|
#ruby '2.4.1'
|
||||||
#ruby '2.5.7'
|
#ruby '2.5.7'
|
||||||
|
|
||||||
git_source(:github) do |repo_name|
|
git_source(:github) do |repo_name|
|
||||||
@@ -44,9 +44,6 @@ gem 'rack-cors'
|
|||||||
# Multi-tenancy for shops
|
# Multi-tenancy for shops
|
||||||
gem 'acts_as_tenant'
|
gem 'acts_as_tenant'
|
||||||
|
|
||||||
# Activerecord-Import is a library for bulk inserting data using ActiveRecord.
|
|
||||||
gem 'activerecord-import'
|
|
||||||
|
|
||||||
# image upload
|
# image upload
|
||||||
gem 'carrierwave', '~> 1.0'
|
gem 'carrierwave', '~> 1.0'
|
||||||
gem 'mini_magick'
|
gem 'mini_magick'
|
||||||
|
|||||||
@@ -41,8 +41,6 @@ GEM
|
|||||||
activemodel (= 5.1.7)
|
activemodel (= 5.1.7)
|
||||||
activesupport (= 5.1.7)
|
activesupport (= 5.1.7)
|
||||||
arel (~> 8.0)
|
arel (~> 8.0)
|
||||||
activerecord-import (1.0.3)
|
|
||||||
activerecord (>= 3.2)
|
|
||||||
activesupport (5.1.7)
|
activesupport (5.1.7)
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
@@ -322,7 +320,6 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
activerecord-import
|
|
||||||
acts_as_tenant
|
acts_as_tenant
|
||||||
aescrypt
|
aescrypt
|
||||||
axlsx (= 2.0.1)
|
axlsx (= 2.0.1)
|
||||||
|
|||||||
@@ -1097,16 +1097,28 @@ $(function() {
|
|||||||
var total_price = 0;
|
var total_price = 0;
|
||||||
var total_qty = 0;
|
var total_qty = 0;
|
||||||
var taxable_amount = 0;
|
var taxable_amount = 0;
|
||||||
|
var exclusive_total =0;
|
||||||
|
var inclusive_total =0;
|
||||||
|
var inclusive_tax =$('#inclusive_tax').val();
|
||||||
|
var exclusive_tax =$('#exclusive_tax').val();
|
||||||
var item_row = $('.summary-items tbody tr');
|
var item_row = $('.summary-items tbody tr');
|
||||||
|
|
||||||
$(item_row).each(function(i){
|
$(item_row).each(function(i){
|
||||||
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
|
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
|
||||||
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
|
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
|
||||||
total_qty += qty;
|
total_qty += qty;
|
||||||
total_price += qty*unit_price;
|
total_price += qty*unit_price;
|
||||||
});
|
});
|
||||||
|
if (inclusive_tax >0){
|
||||||
|
inclusive_total = total_price / inclusive_tax;
|
||||||
|
}
|
||||||
|
if (exclusive_tax >0){
|
||||||
|
exclusive_total = total_price * exclusive_tax;
|
||||||
|
}
|
||||||
|
total_price = total_price + exclusive_total + inclusive_total;
|
||||||
var fixed_total_price = parseFloat(total_price).toFixed(2);
|
var fixed_total_price = parseFloat(total_price).toFixed(2);
|
||||||
var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2);
|
var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2);
|
||||||
|
$('#total_tax').empty();
|
||||||
|
$('#total_tax').append(exclusive_total + inclusive_total);
|
||||||
|
|
||||||
$('#sub_total').empty();
|
$('#sub_total').empty();
|
||||||
$('#sub_total').append(fixed_total_price);
|
$('#sub_total').append(fixed_total_price);
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ $(document).ready(function(){
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/origami/" + unique_id,
|
url: "/origami/" + unique_id,
|
||||||
data: { 'booking_id' : unique_id },
|
data: { 'booking_id' : unique_id },
|
||||||
success:function(result){
|
success:function(result){
|
||||||
for (i = 0; i < result.length; i++) {
|
for (i = 0; i < result.length; i++) {
|
||||||
var data = JSON.stringify(result[i]);
|
var data = JSON.stringify(result[i]);
|
||||||
var parse_data = JSON.parse(data);
|
var parse_data = JSON.parse(data);
|
||||||
var show_date = "";
|
var show_date = "";
|
||||||
|
|
||||||
// Receipt Header
|
// Receipt Header
|
||||||
receipt_no = result[i].receipt_no;
|
receipt_no = result[i].receipt_no;
|
||||||
@@ -81,14 +81,14 @@ $(document).ready(function(){
|
|||||||
if(result[i].receipt_date != null){
|
if(result[i].receipt_date != null){
|
||||||
receipt_date = new Date(result[i].receipt_date);
|
receipt_date = new Date(result[i].receipt_date);
|
||||||
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
|
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
|
||||||
}
|
}
|
||||||
|
|
||||||
//Receipt Charges
|
//Receipt Charges
|
||||||
sub_total += parseFloat(parse_data.price);
|
sub_total += parseFloat(parse_data.price);
|
||||||
|
|
||||||
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
|
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
|
||||||
tax_amount = parse_data.tax_amount;
|
tax_amount = parse_data.tax_amount;
|
||||||
grand_total_amount = parse_data.grand_total_amount;
|
grand_total_amount = parse_data.grand_total_amount;
|
||||||
|
|
||||||
// Ordered Items
|
// Ordered Items
|
||||||
var order_items_rows = "<tr>" +
|
var order_items_rows = "<tr>" +
|
||||||
@@ -135,7 +135,7 @@ $(document).ready(function(){
|
|||||||
// Discount for Payment
|
// Discount for Payment
|
||||||
$('#discount').click(function() {
|
$('#discount').click(function() {
|
||||||
var order_id=$(".selected-item").find(".orders-id").text().substr(0,16);
|
var order_id=$(".selected-item").find(".orders-id").text().substr(0,16);
|
||||||
|
|
||||||
if(order_id!=""){
|
if(order_id!=""){
|
||||||
window.location.href = '/origami/' + order_id + '/discount'
|
window.location.href = '/origami/' + order_id + '/discount'
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For Percentage Discount
|
// For Percentage Discount
|
||||||
if(discount_type == 1){
|
if(discount_type == 1){
|
||||||
discount_amount=(sub_total*discount_value)/100;
|
discount_amount=(sub_total*discount_value)/100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
$('#customer').click(function() {
|
$('#customer').click(function() {
|
||||||
var sale = $(".selected-item").find(".orders-id").text().substr(0,16);
|
var sale = $(".selected-item").find(".orders-id").text().substr(0,16);
|
||||||
if (sale.substring(0, 3)=="SAL") {
|
if (sale.includes("SAL")) {
|
||||||
var sale_id = sale
|
var sale_id = sale
|
||||||
}else{
|
}else{
|
||||||
var sale_id = $(".selected-item").find(".order-cid").text();
|
var sale_id = $(".selected-item").find(".order-cid").text();
|
||||||
@@ -205,7 +205,7 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
$('#re-print').click(function() {
|
$('#re-print').click(function() {
|
||||||
var sale_id = $(".selected-item").find(".orders-id").text().substr(0,16);
|
var sale_id = $(".selected-item").find(".orders-id").text().substr(0,16);
|
||||||
|
|
||||||
window.location.href = '/origami/'+ sale_id + "/reprint"
|
window.location.href = '/origami/'+ sale_id + "/reprint"
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
class Api::ApiController < ActionController::API
|
class Api::ApiController < ActionController::API
|
||||||
|
|
||||||
include MultiTenancy
|
include MultiTenancy
|
||||||
include TokenVerification
|
include TokenVerification
|
||||||
include ActionController::MimeResponds
|
include ActionController::MimeResponds
|
||||||
include ActionView::Rendering
|
include ActionView::Rendering
|
||||||
|
include Customers
|
||||||
|
|
||||||
# before_action :lookup_domain
|
# before_action :lookup_domain
|
||||||
helper_method :current_token, :current_login_employee, :get_cashier
|
helper_method :current_token, :current_login_employee, :get_cashier
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Api::BillController < Api::ApiController
|
|||||||
if !ShiftSale.current_shift.nil?
|
if !ShiftSale.current_shift.nil?
|
||||||
#create Bill by Booking ID
|
#create Bill by Booking ID
|
||||||
table = 0
|
table = 0
|
||||||
if (params[:booking_id])
|
if params[:booking_id].present?
|
||||||
booking = Booking.find(params[:booking_id])
|
booking = Booking.find(params[:booking_id])
|
||||||
if booking.booking_orders.count > 0
|
if booking.booking_orders.count > 0
|
||||||
if booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && booking.checkout_at.nil?
|
if booking.checkin_at.utc.strftime("%Y-%m-%d %H:%M") > Time.now.utc.strftime("%Y-%m-%d %H:%M") && booking.checkout_at.nil?
|
||||||
@@ -51,13 +51,6 @@ class Api::BillController < Api::ApiController
|
|||||||
@status = false
|
@status = false
|
||||||
@error_message = "There is no order for '#{params[:booking_id]}'"
|
@error_message = "There is no order for '#{params[:booking_id]}'"
|
||||||
end
|
end
|
||||||
# elsif (params[:order_id])
|
|
||||||
# order = Order.find(params[:order_id])
|
|
||||||
# @status, @sale_id = Sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier, order.source)
|
|
||||||
#
|
|
||||||
# # for Job
|
|
||||||
# booking = Booking.find_by_sale_id(@sale_id)
|
|
||||||
# table = DiningFacility.find(booking.dining_facility_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bind shift sale id to sale
|
# Bind shift sale id to sale
|
||||||
@@ -147,7 +140,7 @@ class Api::BillController < Api::ApiController
|
|||||||
@order = Order.new
|
@order = Order.new
|
||||||
@order.source = "cashier"
|
@order.source = "cashier"
|
||||||
@order.order_type = "Takeaway"
|
@order.order_type = "Takeaway"
|
||||||
@order.customer_id = "CUS-000000000002" # for no customer id from mobile
|
@order.customer_id = takeaway.customer_id # for no customer id from mobile
|
||||||
@order.items = params[:order_items]
|
@order.items = params[:order_items]
|
||||||
@order.guest = params[:guest_info]
|
@order.guest = params[:guest_info]
|
||||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||||
|
|||||||
@@ -67,15 +67,10 @@ class Api::OrdersController < Api::ApiController
|
|||||||
|
|
||||||
if checkin_checkout_time(params[:booking_id])
|
if checkin_checkout_time(params[:booking_id])
|
||||||
|
|
||||||
if params[:booking_id].present?
|
table = DiningFacility.find(params[:table_id]) if params[:table_id].present?
|
||||||
booking = Booking.find(params[:booking_id])
|
|
||||||
end
|
booking = table.current_checkin_booking if table
|
||||||
if params[:table_id].present?
|
booking ||= Booking.find(params[:booking_id]) if params[:booking_id].present?
|
||||||
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
|
|
||||||
table = DiningFacility.find(params[:table_id])
|
|
||||||
booking = table.get_current_booking
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#for extratime
|
#for extratime
|
||||||
is_extra_time = false
|
is_extra_time = false
|
||||||
@@ -98,7 +93,7 @@ class Api::OrdersController < Api::ApiController
|
|||||||
@order = Order.new
|
@order = Order.new
|
||||||
@order.source = params[:order_source]
|
@order.source = params[:order_source]
|
||||||
@order.order_type = params[:order_type]
|
@order.order_type = params[:order_type]
|
||||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
@order.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||||
@order.items = params[:order_items]
|
@order.items = params[:order_items]
|
||||||
@order.guest = params[:guest_info]
|
@order.guest = params[:guest_info]
|
||||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||||
@@ -118,6 +113,7 @@ class Api::OrdersController < Api::ApiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
@status, @booking = @order.generate
|
@status, @booking = @order.generate
|
||||||
|
|
||||||
if @status && @booking
|
if @status && @booking
|
||||||
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||||
end
|
end
|
||||||
@@ -195,7 +191,7 @@ class Api::OrdersController < Api::ApiController
|
|||||||
#checked checkin and checkout time
|
#checked checkin and checkout time
|
||||||
def checkin_checkout_time(booking_id)
|
def checkin_checkout_time(booking_id)
|
||||||
status = true
|
status = true
|
||||||
if !booking_id.nil?
|
if booking_id.present?
|
||||||
if booking = Booking.find(booking_id)
|
if booking = Booking.find(booking_id)
|
||||||
if booking.checkout_at.present?
|
if booking.checkout_at.present?
|
||||||
if booking.checkout_at.utc <= Time.now.utc
|
if booking.checkout_at.utc <= Time.now.utc
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ class Api::Restaurant::ZonesController < Api::ApiController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
if (params[:filter] && params[:filter] = "all" )
|
if (params[:filter] && params[:filter] = "all" )
|
||||||
@all_tables = Table.active
|
@all_tables = Table.includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active
|
||||||
@all_rooms = Room.active
|
@all_rooms = Room.includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active
|
||||||
else
|
else
|
||||||
@zones = Zone.includes([:tables, :rooms]).where("is_active = true")
|
@zones = Zone.includes([:tables, :rooms]).where("is_active = true")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
include MultiTenancy
|
include MultiTenancy
|
||||||
include LoginVerification
|
include LoginVerification
|
||||||
|
include Customers
|
||||||
|
|
||||||
#before_action :check_installation
|
#before_action :check_installation
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
class BaseCrmController < ActionController::Base
|
class BaseCrmController < ActionController::Base
|
||||||
|
|
||||||
include MultiTenancy
|
include MultiTenancy
|
||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "CRM"
|
layout "CRM"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
class BaseInventoryController < ActionController::Base
|
class BaseInventoryController < ActionController::Base
|
||||||
|
|
||||||
include MultiTenancy
|
include MultiTenancy
|
||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "inventory"
|
layout "inventory"
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
class BaseOqsController < ActionController::Base
|
class BaseOqsController < ActionController::Base
|
||||||
|
|
||||||
include MultiTenancy
|
include MultiTenancy
|
||||||
include LoginVerification
|
include LoginVerification
|
||||||
|
|
||||||
layout "OQS"
|
layout "OQS"
|
||||||
|
|
||||||
before_action :check_user
|
before_action :check_user
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
class BaseOrigamiController < ActionController::Base
|
class BaseOrigamiController < ActionController::Base
|
||||||
|
|
||||||
include MultiTenancy
|
include MultiTenancy
|
||||||
include LoginVerification
|
include LoginVerification
|
||||||
|
include Customers
|
||||||
|
|
||||||
layout "origami"
|
layout "origami"
|
||||||
|
|
||||||
before_action :check_user
|
before_action :check_user
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
class BaseReportController < ActionController::Base
|
class BaseReportController < ActionController::Base
|
||||||
|
|
||||||
include MultiTenancy
|
include MultiTenancy
|
||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "application"
|
layout "application"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
class BaseWaiterController < ActionController::Base
|
class BaseWaiterController < ActionController::Base
|
||||||
|
|
||||||
include MultiTenancy
|
include MultiTenancy
|
||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "waiter"
|
layout "waiter"
|
||||||
|
|||||||
18
app/controllers/concerns/customers.rb
Normal file
18
app/controllers/concerns/customers.rb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
module Customers
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
helper_method :walkin, :takeaway if respond_to? :helper_method
|
||||||
|
end
|
||||||
|
|
||||||
|
def walkin
|
||||||
|
return @walkin if defined? @walkin
|
||||||
|
@walkin = Customer.walkin
|
||||||
|
end
|
||||||
|
|
||||||
|
def takeaway
|
||||||
|
return @takeaway if defined? @takeaway
|
||||||
|
@takeaway = Customer.takeaway
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -24,7 +24,7 @@ module NumberFormattable
|
|||||||
@delimiter = @number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'}.value.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } rescue nil
|
@delimiter = @number_formats.find { |f| f.name.parameterize.underscore == 'delimiter'}.value.gsub(/\\u(\h{4})/) { |m| [$1].pack("H*").unpack("n*").pack("U*") } rescue nil
|
||||||
end
|
end
|
||||||
if @delimiter.nil?
|
if @delimiter.nil?
|
||||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
@print_settings = PrintSetting.get_precision_delimiter if !defined? @print_settings
|
||||||
if @print_settings && @print_settings.delimiter
|
if @print_settings && @print_settings.delimiter
|
||||||
@delimiter = ","
|
@delimiter = ","
|
||||||
else
|
else
|
||||||
@@ -42,7 +42,7 @@ module NumberFormattable
|
|||||||
end
|
end
|
||||||
|
|
||||||
def number_format(number, options = {})
|
def number_format(number, options = {})
|
||||||
options[:precision] = options[:precision] || precision
|
options[:precision] = options[:precision] || precision
|
||||||
# options[:delimiter] = options[:delimiter] || delimiter
|
# options[:delimiter] = options[:delimiter] || delimiter
|
||||||
options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros
|
options[:strip_insignificant_zeros] = options[:strip_insignificant_zeros] || strip_insignificant_zeros
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
# paymal_customer = Customer.search_paypar_account_no(filter)
|
# paymal_customer = Customer.search_paypar_account_no(filter)
|
||||||
# search account no from paypar
|
# search account no from paypar
|
||||||
if type == "card"
|
if type == "card"
|
||||||
|
|
||||||
response = Customer.search_paypar_account_no(filter)
|
response = Customer.search_paypar_account_no(filter)
|
||||||
if !@crm_customers.present?
|
if !@crm_customers.present?
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
@@ -70,7 +70,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
else
|
else
|
||||||
flash[:member_error]="Need to press sync button "
|
flash[:member_error]="Need to press sync button "
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -82,8 +82,9 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
@membership_types = Lookup.collection_of("member_group_type")
|
@membership_types = Lookup.collection_of("member_group_type")
|
||||||
|
|
||||||
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
# @taxes = TaxProfile.where(:group_type => 'cashier')
|
||||||
@taxes = TaxProfile.unscope(:order).select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name")
|
@taxes = TaxProfile.unscope(:order).select("tax_profiles.id, CONCAT(tax_profiles.name, '(', lookups.name, ')') as name")
|
||||||
.order("group_type ASC,order_by ASC")
|
.joins(:lookup)
|
||||||
|
.order("group_type ASC, order_by ASC")
|
||||||
|
|
||||||
@filter = filter
|
@filter = filter
|
||||||
|
|
||||||
@@ -95,7 +96,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
lookup_customer = Lookup.collection_of('customer_settings')
|
lookup_customer = Lookup.collection_of('customer_settings')
|
||||||
if !lookup_customer.empty?
|
if !lookup_customer.empty?
|
||||||
lookup_customer.each do |create_setting|
|
lookup_customer.each do |create_setting|
|
||||||
if create_setting[0].downcase == "create"
|
if create_setting[0].downcase == "create"
|
||||||
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
|
if create_setting[1] == '0' && current_login_employee.role == 'cashier'
|
||||||
@create_flag = false
|
@create_flag = false
|
||||||
end
|
end
|
||||||
@@ -135,7 +136,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
params[:type] = nil
|
params[:type] = nil
|
||||||
params[:customer_id] = params[:id]
|
params[:customer_id] = params[:id]
|
||||||
@credit_sales = SalePayment.get_credit_sales(params)
|
@credit_sales = SalePayment.get_credit_sales(params)
|
||||||
|
|
||||||
#get customer amount
|
#get customer amount
|
||||||
@customer = Customer.find(params[:id])
|
@customer = Customer.find(params[:id])
|
||||||
@response = Customer.get_membership_transactions(@customer)
|
@response = Customer.get_membership_transactions(@customer)
|
||||||
@@ -158,8 +159,9 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
def edit
|
def edit
|
||||||
@customer = Customer.find(params[:id])
|
@customer = Customer.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync
|
def sync
|
||||||
@customer = Customer.find(params[:id])
|
@customer = Customer.find(params[:id])
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
name = @customer.name
|
name = @customer.name
|
||||||
phone = @customer.contact_no
|
phone = @customer.contact_no
|
||||||
@@ -169,17 +171,15 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
nrc = @customer.nrc_no
|
nrc = @customer.nrc_no
|
||||||
card_no = @customer.card_no
|
card_no = @customer.card_no
|
||||||
paypar_account_no = @customer.paypar_account_no
|
paypar_account_no = @customer.paypar_account_no
|
||||||
id = @crm_customer.membership_id
|
id = @customer.membership_id
|
||||||
member_group_id = @customer.membership_type
|
member_group_id = @customer.membership_type
|
||||||
if !id.present? && !member_group_id.nil?
|
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||||
merchant_uid = memberaction.merchant_account_id.to_s
|
merchant_uid = memberaction.merchant_account_id.to_s
|
||||||
auth_token = memberaction.auth_token.to_s
|
auth_token = memberaction.auth_token.to_s
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
member_params = { name: name,phone: phone,email: email,
|
member_params = { name: name,phone: phone,email: email,
|
||||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||||
member_group_id: member_group_id,
|
member_group_id: member_group_id,
|
||||||
id:id,
|
id:id,
|
||||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||||
@@ -193,7 +193,6 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
member_group_id: member_group_id,
|
member_group_id: member_group_id,
|
||||||
id:id,
|
id:id,
|
||||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url,
|
response = HTTParty.post(url,
|
||||||
@@ -221,7 +220,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
Rails.logger.debug "--------Sync Member response -------"
|
Rails.logger.debug "--------Sync Member response -------"
|
||||||
Rails.logger.debug response.to_json
|
Rails.logger.debug response.to_json
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
|
|
||||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||||
|
|
||||||
format.html { redirect_to crm_customers_path }
|
format.html { redirect_to crm_customers_path }
|
||||||
@@ -252,9 +251,9 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
end
|
end
|
||||||
# POST /crm/customers
|
# POST /crm/customers
|
||||||
# POST /crm/customers.json
|
# POST /crm/customers.json
|
||||||
def create
|
def create
|
||||||
# Remove "" default first
|
# Remove "" default first
|
||||||
params[:customer][:tax_profiles].delete_at(0)
|
params[:customer][:tax_profiles].delete_at(0)
|
||||||
@checked_contact = Customer.find_by_contact_no(customer_params[:contact_no])
|
@checked_contact = Customer.find_by_contact_no(customer_params[:contact_no])
|
||||||
if @checked_contact.nil?
|
if @checked_contact.nil?
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -272,7 +271,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
nrc = customer_params[:nrc_no]
|
nrc = customer_params[:nrc_no]
|
||||||
card_no = customer_params[:card_no]
|
card_no = customer_params[:card_no]
|
||||||
paypar_account_no = customer_params[:paypar_account_no]
|
paypar_account_no = customer_params[:paypar_account_no]
|
||||||
member_group_id = params[:member_group_id]
|
member_group_id = params[:member_group_id]
|
||||||
|
|
||||||
if member_group_id.present?
|
if member_group_id.present?
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
@@ -282,7 +281,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
member_params = { name: name,phone: phone,email: email,
|
member_params = { name: name,phone: phone,email: email,
|
||||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||||
member_group_id: member_group_id,
|
member_group_id: member_group_id,
|
||||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||||
|
|
||||||
@@ -333,7 +332,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
end
|
end
|
||||||
# format.json { render :index, status: :created, location: @crm_customers }
|
# format.json { render :index, status: :created, location: @crm_customers }
|
||||||
else
|
else
|
||||||
customer = Customer.find(@crm_customers.customer_id)
|
customer = Customer.find(@crm_customers.customer_id)
|
||||||
|
|
||||||
# Check membership id and bind to user
|
# Check membership id and bind to user
|
||||||
if response["membership_id"] != nil
|
if response["membership_id"] != nil
|
||||||
@@ -399,7 +398,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
# PATCH/PUT /crm/customers/1
|
# PATCH/PUT /crm/customers/1
|
||||||
# PATCH/PUT /crm/customers/1.json
|
# PATCH/PUT /crm/customers/1.json
|
||||||
def update
|
def update
|
||||||
# Remove "" default first
|
# Remove "" default first
|
||||||
params[:customer][:tax_profiles].delete_at(0)
|
params[:customer][:tax_profiles].delete_at(0)
|
||||||
@checked_contact = nil
|
@checked_contact = nil
|
||||||
@existed_contact = Customer.find_by_customer_id_and_contact_no(customer_params[:id], customer_params[:contact_no])
|
@existed_contact = Customer.find_by_customer_id_and_contact_no(customer_params[:id], customer_params[:contact_no])
|
||||||
@@ -409,7 +408,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
if !@existed_contact.nil? || @checked_contact.nil?
|
if !@existed_contact.nil? || @checked_contact.nil?
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @crm_customer.update(customer_params)
|
if @crm_customer.update(customer_params)
|
||||||
# update tax profile
|
# update tax profile
|
||||||
@crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
|
@crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
|
||||||
name = customer_params[:name]
|
name = customer_params[:name]
|
||||||
phone = customer_params[:contact_no]
|
phone = customer_params[:contact_no]
|
||||||
@@ -420,7 +419,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
card_no = customer_params[:card_no]
|
card_no = customer_params[:card_no]
|
||||||
paypar_account_no = customer_params[:paypar_account_no]
|
paypar_account_no = customer_params[:paypar_account_no]
|
||||||
id = @crm_customer.membership_id
|
id = @crm_customer.membership_id
|
||||||
member_group_id = params[:member_group_id]
|
member_group_id = params[:member_group_id]
|
||||||
|
|
||||||
if !id.present? && !member_group_id.nil?
|
if !id.present? && !member_group_id.nil?
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
@@ -430,7 +429,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
member_params = { name: name,phone: phone,email: email,
|
member_params = { name: name,phone: phone,email: email,
|
||||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||||
member_group_id: member_group_id,
|
member_group_id: member_group_id,
|
||||||
id:id,
|
id:id,
|
||||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||||
@@ -471,7 +470,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
Rails.logger.debug "--------Update Member response -------"
|
Rails.logger.debug "--------Update Member response -------"
|
||||||
Rails.logger.debug response.to_json
|
Rails.logger.debug response.to_json
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
|
|
||||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||||
|
|
||||||
format.html { redirect_to crm_customers_path }
|
format.html { redirect_to crm_customers_path }
|
||||||
@@ -496,7 +495,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
member_params = { name: name,phone: phone,email: email,
|
member_params = { name: name,phone: phone,email: email,
|
||||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||||
member_group_id: member_group_id,
|
member_group_id: member_group_id,
|
||||||
id:id,
|
id:id,
|
||||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||||
@@ -601,7 +600,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
flash[:member_notice]='Membership was successfully updated'
|
flash[:member_notice]='Membership was successfully updated'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -617,6 +616,5 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
|
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
|
||||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :image_path)
|
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :image_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
@webview = true
|
@webview = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@tables = Table.all.active.order('zone_id asc').group("zone_id")
|
@tables = Table.active.order('zone_id asc').group("zone_id")
|
||||||
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
|
@rooms = Room.active.order('zone_id asc').group("zone_id")
|
||||||
@all_table = Table.all.active.order('status desc')
|
@all_table = Table.active.order('status desc')
|
||||||
@all_room = Room.all.active.order('status desc')
|
@all_room = Room.active.order('status desc')
|
||||||
end
|
end
|
||||||
|
|
||||||
def detail
|
def detail
|
||||||
@@ -126,67 +126,68 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
}
|
}
|
||||||
# begin
|
# begin
|
||||||
if params[:order_source] == "quick_service" && params[:table_id].to_i == 0
|
if params[:order_source] == "quick_service" && params[:table_id].to_i == 0
|
||||||
customer_id = "CUS-000000000002" # for no customer id from mobile
|
customer_id = takeaway.customer_id # for no customer id from mobile
|
||||||
else
|
else
|
||||||
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||||
end
|
end
|
||||||
|
|
||||||
@order = Order.new
|
Order.transaction do
|
||||||
@order.source = params[:order_source]
|
@order = Order.new
|
||||||
@order.order_type = params[:order_type]
|
@order.source = params[:order_source]
|
||||||
@order.customer_id = customer_id
|
@order.order_type = params[:order_type]
|
||||||
@order.items = items_arr
|
@order.customer_id = customer_id
|
||||||
@order.guest = params[:guest_info]
|
@order.items = items_arr
|
||||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
@order.guest = params[:guest_info]
|
||||||
@order.new_booking = true
|
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||||
@order.waiters = current_login_employee.name
|
|
||||||
@order.employee_name = current_login_employee.name
|
|
||||||
|
|
||||||
@order.is_extra_time = is_extra_time
|
|
||||||
@order.extra_time = extra_time
|
|
||||||
|
|
||||||
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
|
||||||
@order.new_booking = true
|
@order.new_booking = true
|
||||||
else
|
@order.waiters = current_login_employee.name
|
||||||
@order.new_booking = false
|
@order.employee_name = current_login_employee.name
|
||||||
@order.booking_id = booking.booking_id
|
|
||||||
end
|
|
||||||
|
|
||||||
@status, @booking = @order.generate
|
@order.is_extra_time = is_extra_time
|
||||||
|
@order.extra_time = extra_time
|
||||||
|
|
||||||
if @status && @booking
|
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
||||||
#send order broadcast to order_channel
|
@order.new_booking = true
|
||||||
if @order.table_id.to_i > 0
|
else
|
||||||
table = DiningFacility.find(@booking.dining_facility_id)
|
@order.new_booking = false
|
||||||
type = 'order'
|
@order.booking_id = booking.booking_id
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
|
||||||
ActionCable.server.broadcast "order_channel", table: table,type:type,from:from
|
|
||||||
end
|
end
|
||||||
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
|
|
||||||
process_order_queue(@order.order_id,@order.table_id,@order.source)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# Order.send_customer_view(@booking)
|
|
||||||
|
|
||||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
@status, @booking = @order.generate
|
||||||
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
|
|
||||||
|
|
||||||
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
if @status && @booking
|
||||||
|
#send order broadcast to order_channel
|
||||||
# for second display
|
if @order.table_id.to_i > 0
|
||||||
if @order.source == 'quick_service'
|
table = DiningFacility.find(@booking.dining_facility_id)
|
||||||
|
type = 'order'
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
|
ActionCable.server.broadcast "order_channel", table: table,type:type,from:from
|
||||||
end
|
end
|
||||||
#end
|
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
|
||||||
result = {:status=> @status, :data => @sale }
|
process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# Order.send_customer_view(@booking)
|
||||||
|
|
||||||
|
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||||
|
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
|
||||||
|
|
||||||
|
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
||||||
|
|
||||||
|
# for second display
|
||||||
|
if @order.source == 'quick_service'
|
||||||
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
|
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
|
||||||
|
end
|
||||||
|
#end
|
||||||
|
result = {:status=> @status, :data => @sale }
|
||||||
|
render :json => result.to_json
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result = {:status=> @status, :data => 0 }
|
||||||
render :json => result.to_json
|
render :json => result.to_json
|
||||||
end
|
end
|
||||||
else
|
|
||||||
result = {:status=> @status, :data => 0 }
|
|
||||||
render :json => result.to_json
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# render json for http status code
|
# render json for http status code
|
||||||
@@ -235,15 +236,9 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||||
|
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
if ENV["SERVER_MODE"] != 'cloud'
|
||||||
cup_status = `#{"sudo service cups status"}`
|
if Printer::PrinterWorker.printers.blank?
|
||||||
if !check_cup_status(cup_status)
|
msg = 'Print Error ! Please contact to service'
|
||||||
cup_start = `#{"sudo service cups start"}`
|
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: ''
|
||||||
cup_status = `#{"sudo service cups status"}`
|
|
||||||
if !check_cup_status(cup_status)
|
|
||||||
from = ''
|
|
||||||
msg = 'Print Error ! Please contact to service'
|
|
||||||
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: from
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
@page = params[:dir_page]
|
@page = params[:dir_page]
|
||||||
|
|
||||||
if(@sale_id[0,3] == "SAL")
|
if @sale_id.include? "SAL"
|
||||||
@booking = Booking.find_by_sale_id(@sale_id)
|
@booking = Booking.find_by_sale_id(@sale_id)
|
||||||
if @booking.dining_facility_id.to_i > 0
|
if @booking.dining_facility_id.to_i > 0
|
||||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||||
@@ -117,7 +117,7 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
|
|
||||||
def update_sale_by_customer
|
def update_sale_by_customer
|
||||||
|
|
||||||
id = params[:sale_id][0,3]
|
id = params[:sale_id]
|
||||||
customer_id = params[:customer_id]
|
customer_id = params[:customer_id]
|
||||||
customer = Customer.find(customer_id)
|
customer = Customer.find(customer_id)
|
||||||
order_source = params[:type]
|
order_source = params[:type]
|
||||||
@@ -129,7 +129,7 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
if(id == "SAL")
|
if id.include? "SAL"
|
||||||
sale = Sale.find(params[:sale_id])
|
sale = Sale.find(params[:sale_id])
|
||||||
status = sale.update_attributes(customer_id: customer_id)
|
status = sale.update_attributes(customer_id: customer_id)
|
||||||
sale.sale_orders.each do |sale_order|
|
sale.sale_orders.each do |sale_order|
|
||||||
@@ -153,7 +153,7 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
|
|
||||||
if status == true
|
if status == true
|
||||||
render json: JSON.generate({:status => true})
|
render json: JSON.generate({:status => true})
|
||||||
if(id == "SAL")
|
if id.include? "SAL"
|
||||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
sale.compute_by_sale_items(sale.total_discount, nil, order_source)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
# @menus = Menu.all
|
# @menus = Menu.all
|
||||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||||
# end
|
# end
|
||||||
if(params[:id][0,3] == "BKI")
|
if params[:id].include? "BKI"
|
||||||
@table_id = nil
|
@table_id = nil
|
||||||
@table = nil
|
@table = nil
|
||||||
@booking = Booking.find(params[:id])
|
@booking = Booking.find(params[:id])
|
||||||
@@ -113,7 +113,7 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
order = Order.new
|
order = Order.new
|
||||||
order.source = params[:order_source]
|
order.source = params[:order_source]
|
||||||
order.order_type = params[:order_type]
|
order.order_type = params[:order_type]
|
||||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
order.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||||
order.items = items_arr
|
order.items = items_arr
|
||||||
order.guest = params[:guest_info]
|
order.guest = params[:guest_info]
|
||||||
order.table_id = params[:table_id] # this is dining facilities's id
|
order.table_id = params[:table_id] # this is dining facilities's id
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@webview = check_mobile
|
@webview = check_mobile
|
||||||
@tables = Table.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).all.active.order('status desc')
|
@tables = Table.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active.order('status desc')
|
||||||
@rooms = Room.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).all.active.order('status desc')
|
@rooms = Room.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active.order('status desc')
|
||||||
@complete = Sale.completed_sale("cashier")
|
@complete = Sale.completed_sale("cashier")
|
||||||
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
@orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
class Origami::HomeController < ApplicationController
|
class Origami::HomeController < ApplicationController
|
||||||
def index
|
def index
|
||||||
if params[:booking_id] != nil
|
if params[:booking_id] != nil
|
||||||
type=params[:booking_id].split('-')[0];
|
|
||||||
# Sale
|
# Sale
|
||||||
if type == "SAL"
|
if params[:booking_id].include? "SAL"
|
||||||
@selected_item = Sale.find(params[:booking_id])
|
@selected_item = Sale.find(params[:booking_id])
|
||||||
@selected_item_type="Sale"
|
@selected_item_type="Sale"
|
||||||
# Booking
|
# Booking
|
||||||
@@ -25,9 +24,8 @@ class Origami::HomeController < ApplicationController
|
|||||||
|
|
||||||
def selection(selected_id, is_ajax)
|
def selection(selected_id, is_ajax)
|
||||||
str = []
|
str = []
|
||||||
type=selected_id.split('-')[0];
|
|
||||||
# Sale
|
# Sale
|
||||||
if type == "SAL"
|
if selected_id.include? "SAL"
|
||||||
@order_details = SaleItem.get_order_items_details(params[:booking_id])
|
@order_details = SaleItem.get_order_items_details(params[:booking_id])
|
||||||
@order_details.each do |ord_detail|
|
@order_details.each do |ord_detail|
|
||||||
str.push(ord_detail)
|
str.push(ord_detail)
|
||||||
@@ -48,9 +46,7 @@ class Origami::HomeController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_sale_by_customer
|
def update_sale_by_customer
|
||||||
|
if id.inlude? "SAL"
|
||||||
id = params[:sale_id][0,3]
|
|
||||||
if(id == "SAL")
|
|
||||||
sale = Sale.find(params[:sale_id])
|
sale = Sale.find(params[:sale_id])
|
||||||
else
|
else
|
||||||
sale = Order.find(params[:sale_id])
|
sale = Order.find(params[:sale_id])
|
||||||
|
|||||||
@@ -10,38 +10,18 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
member_info = nil
|
member_info = nil
|
||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
booking = Booking.find_by_sale_id(sale_id)
|
booking = sale_data.booking
|
||||||
# if bookings.count > 1
|
|
||||||
# # for Multiple Booking
|
if current_user.role == 'cashier'
|
||||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
cashier_terminal = current_user.cashier_terminal
|
||||||
# else
|
elsif booking.dining_facility
|
||||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
cashier_terminal = booking.cashier_terminal_by_dining_facility
|
||||||
# end
|
|
||||||
shift = ShiftSale.current_open_shift(current_user.id)
|
|
||||||
if !shift.nil?
|
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
|
||||||
else
|
|
||||||
if booking.dining_facility_id.to_i > 0
|
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
|
||||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
|
||||||
else
|
|
||||||
shift = ShiftSale.find(sale_data.shift_sale_id)
|
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#shop detail
|
cashier_terminal ||= sale_data.cashier_terminal_by_shift_sale
|
||||||
## shop_detail = Shop.current_shop
|
|
||||||
# customer= Customer.where('customer_id=' +.customer_id)
|
customer = sale_data.customer
|
||||||
customer = Customer.find(sale_data.customer_id)
|
|
||||||
# rounding adjustment
|
|
||||||
if shop_detail.is_rounding_adj
|
|
||||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
|
||||||
rounding_adj = new_total - sale_data.grand_total
|
|
||||||
sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
|
||||||
end
|
|
||||||
#end rounding adjustment
|
|
||||||
#record for sale audit
|
#record for sale audit
|
||||||
action_by = current_user.name
|
action_by = current_user.name
|
||||||
type = "FIRST_BILL"
|
type = "FIRST_BILL"
|
||||||
@@ -110,25 +90,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
latest_order_no = nil
|
latest_order_no = nil
|
||||||
is_kbz = params[:is_kbz]
|
is_kbz = params[:is_kbz]
|
||||||
|
|
||||||
if(Sale.exists?(sale_id))
|
if saleObj = Sale.find(sale_id)
|
||||||
saleObj = Sale.find(sale_id)
|
|
||||||
sale_items = SaleItem.get_all_sale_items(sale_id)
|
sale_items = SaleItem.get_all_sale_items(sale_id)
|
||||||
#shop_detail = Shop.current_shop
|
|
||||||
# rounding adjustment
|
|
||||||
if !path.include? ("credit_payment")
|
|
||||||
if shop_detail.is_rounding_adj
|
|
||||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
|
||||||
rounding_adj = new_total - saleObj.grand_total
|
|
||||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
#end rounding adjustment
|
|
||||||
|
|
||||||
# if pay_from = 'kbzpay'
|
|
||||||
# salePayment = SalePayment.find(sale_payment_id)
|
|
||||||
# salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid')
|
|
||||||
# else
|
|
||||||
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
|
||||||
if is_kbz == 'false'
|
if is_kbz == 'false'
|
||||||
Rails.logger.info '################ CASH PAYMENT #################'
|
Rails.logger.info '################ CASH PAYMENT #################'
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
@@ -138,129 +102,107 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
||||||
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
# end
|
|
||||||
|
|
||||||
if !path.include? ("credit_payment")
|
if !path.include? ("credit_payment")
|
||||||
rebate_amount = nil
|
rebate_amount = nil
|
||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
# bookings = Booking.where("sale_id='#{sale_id}'")
|
# bookings = Booking.where("sale_id='#{sale_id}'")
|
||||||
bookings = saleObj.bookings[0]
|
booking = saleObj.booking
|
||||||
|
|
||||||
shift = ShiftSale.current_open_shift(current_user.id)
|
if current_user.role == 'cashier'
|
||||||
if !shift.nil?
|
cashier_terminal = current_user.cashier_terminal
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
elsif booking.dining_facility
|
||||||
else
|
cashier_terminal = booking.cashier_terminal_by_dining_facility
|
||||||
if bookings.dining_facility_id.to_i > 0
|
end
|
||||||
table = bookings.dining_facility
|
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
|
||||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
|
||||||
|
|
||||||
type = 'payment'
|
cashier_terminal ||= saleObj.cashier_terminal_by_shift_sale
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
|
||||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
if booking.dining_facility
|
||||||
else
|
ActionCable.server.broadcast(
|
||||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
"order_channel",
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
table: booking.dining_facility,
|
||||||
end
|
type: 'payment',
|
||||||
|
from: getCloudDomain
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# For Print
|
# For Print
|
||||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
|
||||||
unique_code = "ReceiptBillPdf"
|
unique_code = "ReceiptBillA5Pdf"
|
||||||
print_settings = PrintSetting.all
|
else
|
||||||
if !print_settings.nil?
|
unique_code = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code
|
||||||
print_settings.each do |setting|
|
end
|
||||||
if setting.unique_code == 'ReceiptBillPdf'
|
|
||||||
unique_code = "ReceiptBillPdf"
|
customer = saleObj.customer
|
||||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
|
||||||
unique_code = "ReceiptBillStarPdf"
|
# get member information
|
||||||
end
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
end
|
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||||
|
|
||||||
|
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||||
|
member_info = Customer.get_member_account(customer)
|
||||||
|
|
||||||
|
if member_info["status"] == true
|
||||||
|
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||||
|
current_balance = SaleAudit.paymal_search(sale_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#orders print out
|
||||||
|
if type == "quick_service"
|
||||||
|
if booking.dining_facility_id.present?
|
||||||
|
table_id = booking.dining_facility_id
|
||||||
|
else
|
||||||
|
table_id = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if !receipt_bill_a5_pdf.empty?
|
latest_order = booking.booking_orders.order("order_id DESC").limit(1).first()
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
if !latest_order.nil?
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
latest_order_no = latest_order.order_id
|
||||||
if receipt_bilA5[1] == '1'
|
|
||||||
unique_code = "ReceiptBillA5Pdf"
|
|
||||||
# else
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
customer= Customer.find(saleObj.customer_id)
|
booking.booking_orders.each do |order|
|
||||||
|
# Order.pay_process_order_queue(order.order_id, table_id)
|
||||||
|
oqs = OrderQueueStation.new
|
||||||
|
oqs.pay_process_order_queue(order.order_id, table_id)
|
||||||
|
|
||||||
# get member information
|
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
|
||||||
rebate = MembershipSetting.find_by_rebate(1)
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
|
||||||
|
|
||||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
|
||||||
member_info = Customer.get_member_account(customer)
|
|
||||||
|
|
||||||
if member_info["status"] == true
|
|
||||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
|
||||||
current_balance = SaleAudit.paymal_search(sale_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#orders print out
|
end
|
||||||
if type == "quick_service"
|
|
||||||
booking = Booking.find_by_sale_id(sale_id)
|
|
||||||
if booking.dining_facility_id.to_i>0
|
|
||||||
table_id = booking.dining_facility_id
|
|
||||||
else
|
|
||||||
table_id = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
latest_order = booking.booking_orders.order("order_id DESC").limit(1).first()
|
|
||||||
if !latest_order.nil?
|
|
||||||
latest_order_no = latest_order.order_id
|
|
||||||
end
|
|
||||||
|
|
||||||
booking.booking_orders.each do |order|
|
|
||||||
# Order.pay_process_order_queue(order.order_id, table_id)
|
|
||||||
oqs = OrderQueueStation.new
|
|
||||||
oqs.pay_process_order_queue(order.order_id, table_id)
|
|
||||||
|
|
||||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id)
|
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
|
||||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
|
|
||||||
end
|
|
||||||
|
|
||||||
|
#for card sale data
|
||||||
|
card_data = Array.new
|
||||||
|
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
||||||
|
if !card_sale_trans_ref_no.nil?
|
||||||
|
card_sale_trans_ref_no.each do |cash_sale_trans|
|
||||||
|
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
||||||
|
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
||||||
|
card_no = cash_sale_trans.pan.last(4)
|
||||||
|
card_no = card_no.rjust(19,"**** **** **** ")
|
||||||
|
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#for card sale data
|
#card_balance amount for Paymal payment
|
||||||
card_data = Array.new
|
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
|
||||||
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
|
||||||
if !card_sale_trans_ref_no.nil?
|
|
||||||
card_sale_trans_ref_no.each do |cash_sale_trans|
|
|
||||||
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
|
||||||
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
|
||||||
card_no = cash_sale_trans.pan.last(4)
|
|
||||||
card_no = card_no.rjust(19,"**** **** **** ")
|
|
||||||
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#card_balance amount for Paymal payment
|
# get printer info
|
||||||
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
# Calculate Food and Beverage Total
|
||||||
|
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)
|
||||||
|
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||||
|
|
||||||
# get printer info
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||||
# Calculate Food and Beverage Total
|
|
||||||
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)
|
|
||||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
|
||||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
|
||||||
|
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
@@ -353,7 +295,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
@shop = shop_detail #show shop info
|
@shop = shop_detail #show shop info
|
||||||
|
|
||||||
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
|
@customer_lists = Customer.where(name: ["WALK-IN", "TAKEAWAY"])
|
||||||
|
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
|
|
||||||
@@ -767,7 +709,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
id = params[:sale_id]
|
id = params[:sale_id]
|
||||||
if id.start_with?("SAL")
|
if id.include? "SAL"
|
||||||
@sale = Sale.find(id)
|
@sale = Sale.find(id)
|
||||||
if @sale.sale_status == "new"
|
if @sale.sale_status == "new"
|
||||||
@bookings = @sale.bookings.first
|
@bookings = @sale.bookings.first
|
||||||
@@ -22,7 +22,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
else
|
else
|
||||||
redirect_to "/origami/#{params[:type]}" and return
|
redirect_to "/origami/#{params[:type]}" and return
|
||||||
end
|
end
|
||||||
elsif (id.start_with?("BKI") || id.start_with?("CBKI"))
|
elsif id.include? "BKI"
|
||||||
@bookings = Booking.find(id)
|
@bookings = Booking.find(id)
|
||||||
@order = @bookings.orders.where(status: "new").first
|
@order = @bookings.orders.where(status: "new").first
|
||||||
@order_items = @bookings.order_items
|
@order_items = @bookings.order_items
|
||||||
|
|||||||
@@ -10,30 +10,27 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
today = DateTime.now
|
today = DateTime.now
|
||||||
day = Date.today.wday
|
day = Date.today.wday
|
||||||
# if params[:menu] == "true"
|
|
||||||
@menus = []
|
@menus = []
|
||||||
@menu = []
|
@menu = []
|
||||||
# else
|
|
||||||
# @menus = Menu.all
|
|
||||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
|
||||||
# end
|
|
||||||
@zone = Zone.all
|
@zone = Zone.all
|
||||||
@customer = Customer.all
|
@customer = Customer.all
|
||||||
@tables = Table.all.active.order('status desc')
|
@tables = Table.active.order('status desc')
|
||||||
@rooms = Room.all.active.order('status desc')
|
@rooms = Room.active.order('status desc')
|
||||||
@cashier_type = "quick_service"
|
@cashier_type = "quick_service"
|
||||||
display_type = Lookup.find_by_lookup_type("display_type")
|
display_type = Lookup.find_by_lookup_type("display_type")
|
||||||
if !display_type.nil? && display_type.value.to_i ==2
|
if !display_type.nil? && display_type.value.to_i == 2
|
||||||
@display_type = display_type.value
|
@display_type = display_type.value
|
||||||
else
|
else
|
||||||
@display_type = nil
|
@display_type = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
#checked quick_service only
|
#checked quick_service only
|
||||||
@quick_service_only = false
|
@quick_service_only = Lookup.collection_of('quickservice_add_order').any? { |x| x == ["quickserviceaddorder", "1"] }
|
||||||
|
|
||||||
lookup_dine_in = Lookup.collection_of('quickservice_add_order')
|
lookup_dine_in = Lookup.collection_of('quickservice_add_order')
|
||||||
puts 'lookup_dine_in!!!!'
|
# puts 'lookup_dine_in!!!!'
|
||||||
puts lookup_dine_in
|
# puts lookup_dine_in
|
||||||
if !lookup_dine_in.empty?
|
if !lookup_dine_in.empty?
|
||||||
lookup_dine_in.each do |dine_in|
|
lookup_dine_in.each do |dine_in|
|
||||||
if dine_in[0].downcase == "quickserviceaddorder"
|
if dine_in[0].downcase == "quickserviceaddorder"
|
||||||
@@ -43,7 +40,23 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
divided_value =0
|
||||||
|
exclusive =0
|
||||||
|
tax_profiles = TaxProfile.where(group_type: "quick_service")
|
||||||
|
if !tax_profiles.empty?
|
||||||
|
tax_profiles.each do |tax|
|
||||||
|
#include or execulive
|
||||||
|
if tax.inclusive
|
||||||
|
tax_incl_exec = "inclusive"
|
||||||
|
rate = tax.rate
|
||||||
|
divided_value += (100 + rate)/rate
|
||||||
|
else
|
||||||
|
exclusive +=tax.rate / 100
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@inclusive_tax =divided_value
|
||||||
|
@exclusive_tax =exclusive
|
||||||
render "origami/addorders/detail"
|
render "origami/addorders/detail"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -58,7 +71,7 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
# @menus = Menu.all
|
# @menus = Menu.all
|
||||||
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||||
# end
|
# end
|
||||||
if(params[:id][0,3] == "BKI")
|
if params[:id].include? "BKI"
|
||||||
@table_id = nil
|
@table_id = nil
|
||||||
@table = nil
|
@table = nil
|
||||||
@booking = Booking.find(params[:id])
|
@booking = Booking.find(params[:id])
|
||||||
@@ -115,13 +128,13 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
order = Order.new
|
order = Order.new
|
||||||
order.source = params[:order_source]
|
order.source = params[:order_source]
|
||||||
order.order_type = params[:order_type]
|
order.order_type = params[:order_type]
|
||||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
order.customer_id = params[:customer_id].present? ? params[:customer_id] : walkin.customer_id # for no customer id from mobile
|
||||||
order.items = items_arr
|
order.items = items_arr
|
||||||
order.guest = params[:guest_info]
|
order.guest = params[:guest_info]
|
||||||
order.table_id = params[:table_id] # this is dining facilities's id
|
order.table_id = params[:table_id] # this is dining facilities's id
|
||||||
order.waiters = current_login_employee.name
|
order.waiters = current_login_employee.name
|
||||||
order.employee_name = current_login_employee.name
|
order.employee_name = current_login_employee.name
|
||||||
|
|
||||||
order.is_extra_time = is_extra_time
|
order.is_extra_time = is_extra_time
|
||||||
order.extra_time = extra_time
|
order.extra_time = extra_time
|
||||||
|
|
||||||
|
|||||||
@@ -18,96 +18,78 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
else
|
else
|
||||||
table = DiningFacility.find_by(id: booking.dining_facility_id)
|
table = DiningFacility.find_by(id: booking.dining_facility_id)
|
||||||
|
|
||||||
if sale_data = booking.sale
|
if booking.sale_id.nil?
|
||||||
@status = true
|
if sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count])
|
||||||
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count])
|
# in-duty update
|
||||||
@status = true
|
in_duties = InDuty.where("booking_id=?", booking.id)
|
||||||
# in-duty update
|
if !in_duties.empty?
|
||||||
in_duties = InDuty.where("booking_id=?", booking.id)
|
in_duties.each do |in_duty|
|
||||||
if !in_duties.empty?
|
induty = InDuty.find(in_duty.id)
|
||||||
in_duties.each do |in_duty|
|
induty.sale_id = sale_data.sale_id
|
||||||
induty = InDuty.find(in_duty.id)
|
induty.out_time = Time.now.utc
|
||||||
induty.sale_id = sale_data.sale_id
|
induty.save
|
||||||
induty.out_time = Time.now.utc
|
|
||||||
induty.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Bind shift sale id to sale
|
|
||||||
# @sale_data.shift_sale_id = shift.id
|
|
||||||
# @sale_data.save
|
|
||||||
|
|
||||||
action_by = current_user.name
|
|
||||||
type = "REQUEST_BILL"
|
|
||||||
|
|
||||||
remark = "Request bill Receipt No #{sale_data.receipt_no}"
|
|
||||||
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
|
|
||||||
|
|
||||||
# Promotion Activation
|
|
||||||
Promotion.promo_activate(sale_data)
|
|
||||||
|
|
||||||
#bill channel
|
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
from = request.subdomain + "." + request.domain
|
|
||||||
else
|
|
||||||
from = ""
|
|
||||||
end
|
|
||||||
|
|
||||||
if order.source == "cashier" || order.source == "quick_service"
|
|
||||||
ActionCable.server.broadcast "bill_channel",table: table, from: from
|
|
||||||
end
|
|
||||||
if order.source == "quick_service" || order.source == "food_court"
|
|
||||||
result = {:status=> @status, :data => sale_data.sale_id }
|
|
||||||
render :json => result.to_json
|
|
||||||
else
|
|
||||||
#check checkInOut pdf print
|
|
||||||
checkout_time = Lookup.collection_of('checkout_time')
|
|
||||||
if !booking.dining_facility_id.nil?
|
|
||||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
|
||||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
|
||||||
|
|
||||||
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
|
||||||
unique_code = "CheckInOutPdf"
|
|
||||||
printer = PrintSetting.find_by_unique_code(unique_code)
|
|
||||||
|
|
||||||
# print when complete click
|
|
||||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
|
||||||
|
|
||||||
if !printer.nil?
|
|
||||||
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
action_by = current_user.name
|
||||||
|
type = "REQUEST_BILL"
|
||||||
|
|
||||||
|
remark = "Request bill Receipt No #{sale_data.receipt_no}"
|
||||||
|
sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type )
|
||||||
|
|
||||||
|
# Promotion Activation
|
||||||
|
Promotion.promo_activate(sale_data)
|
||||||
|
|
||||||
|
#bill channel
|
||||||
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
|
from = request.subdomain + "." + request.domain
|
||||||
|
else
|
||||||
|
from = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
if ["quick_service", "cashier"].include? order.source
|
||||||
|
ActionCable.server.broadcast "bill_channel", table: table, from: from
|
||||||
|
end
|
||||||
|
|
||||||
|
unless ["quick_service", "food_court"].include? order.source
|
||||||
|
#check checkInOut pdf print
|
||||||
|
checkout_time = Lookup.collection_of('checkout_time')
|
||||||
|
if !booking.dining_facility_id.nil?
|
||||||
|
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||||
|
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||||
|
|
||||||
|
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
||||||
|
unique_code = "CheckInOutPdf"
|
||||||
|
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
|
||||||
|
# print when complete click
|
||||||
|
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||||
|
|
||||||
|
if !printer.nil?
|
||||||
|
order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@status = true
|
||||||
|
sale_id = sale_data.sale_id
|
||||||
|
else
|
||||||
|
@status = false
|
||||||
|
sale_id = nil
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@status = true
|
||||||
|
sale_id = booking.sale_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@status = true
|
|
||||||
else
|
else
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "No Current Open Shift for This Employee"
|
@error_message = "No Current Open Shift for This Employee"
|
||||||
end
|
end
|
||||||
|
if ["quick_service", "food_court"].include? order.source
|
||||||
# Not Use for these printed bill cannot give customer
|
result = {:status=> @status, :data => sale_data.sale_id }
|
||||||
# unique_code = "ReceiptBillPdf"
|
render :json => result.to_json
|
||||||
# #shop detail
|
end
|
||||||
# shop_details = Shop.current_shop
|
|
||||||
# # customer= Customer.where('customer_id=' +.customer_id)
|
|
||||||
# customer= Customer.find(@sale_data.customer_id)
|
|
||||||
# # get member information
|
|
||||||
# member_info = Customer.get_member_account(customer)
|
|
||||||
# # get printer info
|
|
||||||
# print_settings=PrintSetting.find_by_unique_code(unique_code)
|
|
||||||
|
|
||||||
# # find order id by sale id
|
|
||||||
# # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
|
||||||
|
|
||||||
# # Calculate price_by_accounts
|
|
||||||
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
|
||||||
|
|
||||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
|
||||||
|
|
||||||
|
|
||||||
# printer.print_receipt_bill(print_settings, false, nil,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
class Origami::RoomInvoicesController < BaseOrigamiController
|
class Origami::RoomInvoicesController < BaseOrigamiController
|
||||||
def index
|
def index
|
||||||
@room = DiningFacility.find(params[:room_id])
|
@room = DiningFacility.find(params[:room_id])
|
||||||
puts "room bookig lenght"
|
|
||||||
@sale_array = Array.new
|
@sale_array = Array.new
|
||||||
@room.bookings.each do |booking|
|
@room.bookings.each do |booking|
|
||||||
puts booking.sale_id
|
puts booking.sale_id
|
||||||
|
|||||||
@@ -26,52 +26,33 @@ class Origami::SalesController < BaseOrigamiController
|
|||||||
dining = params[:dining_id]
|
dining = params[:dining_id]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
tax_type = params[:tax_type]
|
tax_type = params[:tax_type]
|
||||||
sale_data = []
|
|
||||||
table = DiningFacility.find(dining)
|
|
||||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
|
||||||
table.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ").each do |booking|
|
|
||||||
if booking.sale_id.nil?
|
|
||||||
order_array = []
|
|
||||||
booking.booking_orders.each do |booking_order|
|
|
||||||
|
|
||||||
booking.booking_status = 'moved'
|
Sale.transaction do
|
||||||
order = Order.find(booking_order.order_id)
|
table = DiningFacility.find(dining)
|
||||||
order.status = 'billed'
|
booking = table.current_checkin_booking
|
||||||
order.order_items.each do |item|
|
|
||||||
item.order_item_status = 'billed'
|
|
||||||
end
|
|
||||||
# create sale item
|
|
||||||
saleobj = Sale.find(sale_id)
|
|
||||||
order.order_items.each do |orer_item|
|
|
||||||
saleobj.add_item (orer_item)
|
|
||||||
if !orer_item.set_menu_items.nil?
|
|
||||||
saleobj.add_sub_item(orer_item.set_menu_items)
|
|
||||||
end
|
|
||||||
sale_data.push(orer_item)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Re-compute for add
|
sale = Sale.find(sale_id)
|
||||||
saleobj.compute(order.source,tax_type)
|
existing = sale.booking
|
||||||
saleobj.save
|
|
||||||
order.save
|
|
||||||
booking.save
|
|
||||||
|
|
||||||
order_array.push(order.order_id)
|
sale.sale_items << booking.order_items.to_sale_items
|
||||||
end
|
sale.orders << booking.orders
|
||||||
|
|
||||||
receipt_no = Sale.find(sale_id).receipt_no
|
sale.compute(booking.orders[0].source, tax_type)
|
||||||
action_by = current_user.name
|
|
||||||
type = "ADD_TO_EXISTING"
|
|
||||||
|
|
||||||
remark = "#{action_by} add to existing order #{order_array} to Receipt No=>#{receipt_no} in #{table.name}"
|
type = "ADD_TO_EXISTING"
|
||||||
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
receipt_no = sale.receipt_no
|
||||||
|
action_by = current_user.name
|
||||||
|
order_ids = booking.orders.map(&:order_id)
|
||||||
|
|
||||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
remark = "#{action_by} add to existing order #{order_ids.to_s} to Receipt No=>#{receipt_no} in #{table.name}"
|
||||||
booking_order.each do |bo|
|
sale_audit = SaleAudit.record_audit_sale(sale_id, remark, action_by, type)
|
||||||
bo.booking_id = existing_booking.booking_id
|
|
||||||
bo.save
|
booking.orders.update_all(status: "billed")
|
||||||
end
|
booking.order_items.update_all(order_item_status: "billed")
|
||||||
end
|
BookingOrder.where(booking_id: booking.booking_id).update_all(booking_id: existing)
|
||||||
|
|
||||||
|
booking.booking_status = "moved"
|
||||||
|
booking.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,390 +16,118 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
@sale_data = Array.new
|
@sale_data = Array.new
|
||||||
@current_user = current_user
|
@current_user = current_user
|
||||||
|
|
||||||
table_bookings = Booking.where("dining_facility_id = #{dining_id} and sale_id IS NOT NULL")
|
@sale_data = @table.current_sales
|
||||||
if !table_bookings.nil?
|
|
||||||
table_bookings.each do |table_booking|
|
|
||||||
if table_booking.sale.sale_status != 'waste' && table_booking.sale.sale_status != 'spoile'
|
|
||||||
@sale_data.push(table_booking.sale)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if @booking
|
if @booking
|
||||||
@booking.booking_orders.each do |booking_order|
|
@orders = @booking.orders
|
||||||
arr_order_items = Array.new
|
@order = @orders[0]
|
||||||
@order = Order.find(booking_order.order_id)
|
@order_items = []
|
||||||
if (@order.status == "new")
|
order_items = []
|
||||||
@orders.push(@order)
|
|
||||||
|
|
||||||
@order.order_items.each do |item|
|
@booking.order_items.each do |item|
|
||||||
if !item.set_menu_items.nil?
|
if item.set_menu_items.present?
|
||||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
set_menu_items = JSON.parse(item.set_menu_items)
|
||||||
arr_instance_item_sets = Array.new
|
item.set_menu_items = set_menu_items.map { |x| x["item_instance_name"] }
|
||||||
instance_item_sets.each do |instance_item|
|
item.price = item.price + set_menu_items.inject(0.0) { |sum, x| sum + x["item_instance_name"].to_f }
|
||||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
end
|
||||||
item.price = item.price.to_f + instance_item["price"].to_f
|
|
||||||
arr_instance_item_sets.push(item_instance_name)
|
|
||||||
end
|
|
||||||
item.set_menu_items = arr_instance_item_sets
|
|
||||||
end
|
|
||||||
|
|
||||||
arr_item = Hash.new
|
@order_items += item.qty.to_i.times.map { i = item.as_json; i["qty"] = 1; order_items << i; { item.order_id => i } }
|
||||||
if item.qty.to_i > 1
|
end
|
||||||
i = 1
|
|
||||||
while i <= item.qty.to_i do
|
@order_items << { 'all_order' => order_items }
|
||||||
arr_item = {'order_items_id' => item.order_items_id,
|
else
|
||||||
'order_id' => item.order_id,
|
@booking = nil
|
||||||
'order_item_status' => item.order_item_status,
|
end
|
||||||
'item_order_by' => item.item_order_by,
|
|
||||||
'item_code' => item.item_code,
|
|
||||||
'item_instance_code' => item.item_instance_code,
|
|
||||||
'item_name' => item.item_name,
|
|
||||||
'alt_name' => item.alt_name,
|
|
||||||
'account_id' => item.account_id,
|
|
||||||
'qty' => '1.0',
|
|
||||||
'price' => item.price,
|
|
||||||
'remark' => item.remark,
|
|
||||||
'options' => item.options,
|
|
||||||
'set_menu_items' => item.set_menu_items,
|
|
||||||
'taxable' => item.taxable,
|
|
||||||
'completed_by' => item.completed_by,
|
|
||||||
'created_at' => item.created_at,
|
|
||||||
'updated_at' => item.updated_at}
|
|
||||||
i += 1
|
|
||||||
@order_items.push({@order.order_id => arr_item})
|
|
||||||
arr_order_items.push(arr_item)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
arr_order_items.push(item)
|
|
||||||
@order_items.push({@order.order_id => item})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@order_items.push({'all_order' => arr_order_items})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@booking = nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
cashier_type = params[:cashier_type]
|
cashier_type = params[:cashier_type]
|
||||||
|
dining_id = params[:dining_id]
|
||||||
order_ids = params[:order_ids]
|
order_ids = params[:order_ids]
|
||||||
arr_order_ids = nil
|
arr_order_ids = JSON.parse(params[:arr_order_ids]) if params[:arr_order_ids].present?
|
||||||
if !params[:arr_order_ids].nil?
|
orders = JSON.parse(params[:orders]) if params[:orders].present?
|
||||||
arr_order_ids = JSON.parse(params[:arr_order_ids])
|
order_items = JSON.parse(params[:order_items]) if params[:order_items].present?
|
||||||
end
|
|
||||||
orders = nil
|
|
||||||
if !params[:orders].empty?
|
|
||||||
orders = JSON.parse(params[:orders])
|
|
||||||
end
|
|
||||||
order_items = nil
|
|
||||||
if !params[:order_items].empty?
|
|
||||||
order_items = JSON.parse(params[:order_items])
|
|
||||||
end
|
|
||||||
|
|
||||||
status = false
|
|
||||||
if !ShiftSale.current_shift.nil?
|
if !ShiftSale.current_shift.nil?
|
||||||
#create Bill by Booking ID
|
#create Bill by Booking ID
|
||||||
table = 0
|
table = DiningFacility.find_by(id: params[:dining_id]) if params[:dining_id].present?
|
||||||
if !params[:booking_id].empty?
|
|
||||||
booking = Booking.find(params[:booking_id])
|
|
||||||
# for Multiple Cashier by Zone
|
|
||||||
if booking.dining_facility_id.to_i>0
|
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
|
||||||
else
|
|
||||||
table = nil
|
|
||||||
cashier_zone = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
Booking.transaction do
|
||||||
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
if params[:booking_id].present?
|
||||||
|
booking = Booking.find(params[:booking_id])
|
||||||
if sale_data = booking.sale
|
|
||||||
status = true
|
|
||||||
elsif sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type,params[:current_checkin_induties_count])
|
|
||||||
status = true
|
|
||||||
else
|
else
|
||||||
status = false
|
type = "TableBooking" if params[:type] == "Table"
|
||||||
end
|
type ||= "RoomBooking"
|
||||||
else
|
|
||||||
if params[:type] == "Table"
|
|
||||||
type = "TableBooking"
|
|
||||||
else
|
|
||||||
type = "RoomBooking"
|
|
||||||
end
|
|
||||||
|
|
||||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
split_orders = []
|
||||||
:checkin_at => Time.now.utc, :checkin_by => current_user.name,
|
new_order = nil
|
||||||
:booking_status => "assign" })
|
|
||||||
|
|
||||||
if !orders.nil?
|
booking = Booking.create({:dining_facility_id => table.id, :type => type, :checkin_at => Time.now.utc, :checkin_by => current_user.name, :booking_status => "assign" })
|
||||||
orders.each do |order|
|
|
||||||
BookingOrder.find_by_order_id(order["id"]).delete
|
if orders.present?
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order["id"]})
|
split_orders += orders.map { |x| x["id"] }
|
||||||
end
|
end
|
||||||
elsif !order_items.nil?
|
|
||||||
order_item_count = 0
|
|
||||||
order_id_count = 0
|
|
||||||
order_id = nil
|
|
||||||
|
|
||||||
arr_order_ids.each do |order|
|
if order_items.present?
|
||||||
order.each do |odr|
|
order_items = order_items.inject([]) do |arr, v|
|
||||||
data = Order.find(odr[0])
|
v["qty"] = v["qty"].to_i
|
||||||
if data.order_items.count == odr[1]
|
if i = arr.find { |x| x["id"] == v["id"] }
|
||||||
order_id = odr[0]
|
i["qty"] = i["qty"] + v["qty"]
|
||||||
order_id_count += 1
|
|
||||||
else
|
else
|
||||||
order_item_count += 1
|
arr << v
|
||||||
|
end
|
||||||
|
arr
|
||||||
|
end
|
||||||
|
|
||||||
|
Order.includes(:order_items).where(order_id: order_ids).each do |order|
|
||||||
|
if order.order_items.any? { |x| order_items.none? { |y| x.order_items_id == y["id"] && x.qty == y["qty"] } }
|
||||||
|
new_order ||= Order.create({ source: "cashier", order_type: order.order_type, customer_id: order.customer_id, item_count: order_items.length, waiters: current_user.name })
|
||||||
|
order.order_items.each do |order_item|
|
||||||
|
if split_item = order_items.find { |x| x["id"] == order_item.order_items_id }
|
||||||
|
if split_item["qty"] == order_item.qty
|
||||||
|
new_order.order_items << order_item
|
||||||
|
else
|
||||||
|
order_item.qty = order_item.qty - split_item["qty"]
|
||||||
|
order_item.save
|
||||||
|
order_item_dup = order_item.dup
|
||||||
|
order_item_dup.qty = split_item["qty"]
|
||||||
|
new_order.order_items << order_item_dup
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
split_orders << order
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# puts order_id
|
if new_order.present?
|
||||||
# puts order_ids.count
|
booking.orders << new_order
|
||||||
# puts order_id_count
|
|
||||||
# puts order_items.count
|
|
||||||
# puts order_item_count
|
|
||||||
|
|
||||||
if !order_id.nil?
|
|
||||||
if order_id_count > 1
|
|
||||||
puts "order_id_count > 1"
|
|
||||||
|
|
||||||
updated_order_id = Array.new
|
|
||||||
arr_order_ids.each do |order|
|
|
||||||
order.each do |odr|
|
|
||||||
data = Order.find(odr[0])
|
|
||||||
if data.order_items.count != odr[1]
|
|
||||||
updated_order_id.push(odr[0])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# puts "updated_order_id"
|
|
||||||
# puts updated_order_id
|
|
||||||
|
|
||||||
if !updated_order_id.empty?
|
|
||||||
order_ids.each do |odr_id|
|
|
||||||
unless updated_order_id.include?(odr_id)
|
|
||||||
BookingOrder.find_by_order_id(odr_id).delete
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
order_items.each do |order_item|
|
|
||||||
if updated_order_id.include?(order_item["order_id"])
|
|
||||||
update_order_item(order_id, order_item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
order_ids.each do |odr_id|
|
|
||||||
new_order_status = true
|
|
||||||
order_items.each do |order_item|
|
|
||||||
orderItem = OrderItem.find_by_order_id(odr_id)
|
|
||||||
if !orderItem.nil?
|
|
||||||
if order_item["id"] == orderItem.order_items_id
|
|
||||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
|
||||||
new_order_status = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# puts new_order_status
|
|
||||||
|
|
||||||
if new_order_status
|
|
||||||
BookingOrder.find_by_order_id(odr_id).delete
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
|
||||||
else
|
|
||||||
customer = Customer.find(params[:customer_id])
|
|
||||||
order_type = "dine_in"
|
|
||||||
if !customer.nil?
|
|
||||||
if customer.customer_type == "Takeaway"
|
|
||||||
order_type = "takeaway"
|
|
||||||
elsif customer.customer_type == "Delivery"
|
|
||||||
order_type = "delivery"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# begin
|
|
||||||
order = create_order(params,order_type,order_items.count,current_user)
|
|
||||||
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
|
||||||
|
|
||||||
order_items.each do |order_item|
|
|
||||||
update_order_item(order.order_id, order_item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
# puts "order_id_count < 1"
|
|
||||||
new_order_status = true
|
|
||||||
order_items.each do |order_item|
|
|
||||||
orderItem = OrderItem.find(order_item["id"])
|
|
||||||
if !orderItem.nil?
|
|
||||||
if order_item["id"] == orderItem.order_items_id
|
|
||||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
|
||||||
new_order_status = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# puts new_order_status
|
|
||||||
|
|
||||||
if new_order_status
|
|
||||||
BookingOrder.find_by_order_id(order_id).delete
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
|
|
||||||
order_items.each do |order_item|
|
|
||||||
update_order_item(order_id, order_item)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
customer = Customer.find(params[:customer_id])
|
|
||||||
order_type = "dine_in"
|
|
||||||
if !customer.nil?
|
|
||||||
if customer.customer_type == "Takeaway"
|
|
||||||
order_type = "takeaway"
|
|
||||||
elsif customer.customer_type == "Delivery"
|
|
||||||
order_type = "delivery"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# begin
|
|
||||||
order = create_order(params,order_type,order_items.count,current_user)
|
|
||||||
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
|
||||||
|
|
||||||
order_items.each do |order_item|
|
|
||||||
update_order_item(order.order_id, order_item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if order_ids.count == 1 && order_item_count == 1
|
|
||||||
if order_id_count == 0
|
|
||||||
customer = Customer.find(params[:customer_id])
|
|
||||||
order_type = "dine_in"
|
|
||||||
if !customer.nil?
|
|
||||||
if customer.customer_type == "Takeaway"
|
|
||||||
order_type = "takeaway"
|
|
||||||
elsif customer.customer_type == "Delivery"
|
|
||||||
order_type = "delivery"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# begin
|
|
||||||
order = create_order(params,order_type,order_items.count,current_user)
|
|
||||||
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
|
||||||
|
|
||||||
order_items.each do |order_item|
|
|
||||||
update_order_item(order.order_id, order_item)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
BookingOrder.find_by_order_id(order_ids[0]).delete
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
|
|
||||||
order_items.each do |order_item|
|
|
||||||
update_order_item(order_ids[0], order_item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
customer = Customer.find(params[:customer_id])
|
|
||||||
order_type = "dine_in"
|
|
||||||
if !customer.nil?
|
|
||||||
if customer.customer_type == "Takeaway"
|
|
||||||
order_type = "takeaway"
|
|
||||||
elsif customer.customer_type == "Delivery"
|
|
||||||
order_type = "delivery"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# begin
|
|
||||||
order = create_order(params,order_type,order_items.count,current_user)
|
|
||||||
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
|
||||||
|
|
||||||
order_items.each do |order_item|
|
|
||||||
update_order_item(order.order_id, order_item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type ,params[:current_checkin_induties_count])
|
if split_orders.present?
|
||||||
status = true
|
BookingOrder.where(order_id: split_orders).update_all(booking_id: booking.booking_id)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
Promotion.promo_activate(sale_data)
|
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
from = request.subdomain + "." + request.domain
|
|
||||||
else
|
|
||||||
from = ""
|
|
||||||
end
|
|
||||||
ActionCable.server.broadcast "bill_channel",table: table,from:from
|
|
||||||
|
|
||||||
render :json => { status: status }
|
|
||||||
else
|
|
||||||
render :json => { status: false, error_message: 'No Current Open Shift!'}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_order(params,order_type,items_count,current_user)
|
|
||||||
order = Order.new
|
|
||||||
order.source = "cashier"
|
|
||||||
order.order_type = order_type
|
|
||||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
|
||||||
order.item_count = items_count
|
|
||||||
order.status = "new"
|
|
||||||
order.table_id = params[:dining_id] # this is dining facilities's id
|
|
||||||
order.waiters = current_user.name
|
|
||||||
order.employee_name = current_user.name
|
|
||||||
order.guest_info = nil
|
|
||||||
order.save!
|
|
||||||
|
|
||||||
return order
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_order_item(order_id, order_item)
|
|
||||||
orderItem = OrderItem.find(order_item["id"])
|
|
||||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
|
||||||
set_menu_items_obj = Array.new
|
|
||||||
if !orderItem.set_menu_items.nil?
|
|
||||||
instance_item_sets = JSON.parse(orderItem.set_menu_items)
|
|
||||||
instance_item_sets.each_with_index do |instance_item, instance_index|
|
|
||||||
instance_item_sets[instance_index]["quantity"] = (instance_item["quantity"].to_i - order_item['qty'].to_i).to_s
|
|
||||||
set_menu_items_obj.push({'item_instance_code' => instance_item["item_instance_code"], 'quantity' => order_item['qty'].to_i, 'price' => instance_item["price"]})
|
|
||||||
end
|
|
||||||
orderItem.set_menu_items = instance_item_sets.to_json
|
|
||||||
end
|
end
|
||||||
|
|
||||||
same_order = OrderItem.find_by_order_id(order_id)
|
if booking.sale.nil?
|
||||||
if same_order.nil?
|
sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type, params[:current_checkin_induties_count])
|
||||||
OrderItem.processs_item(orderItem.item_code,
|
Promotion.promo_activate(sale_data)
|
||||||
orderItem.item_instance_code,
|
end
|
||||||
orderItem.item_name,
|
|
||||||
orderItem.alt_name,
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
orderItem.account_id,
|
from = request.subdomain + "." + request.domain
|
||||||
order_item['qty'],
|
else
|
||||||
orderItem.price,
|
from = ""
|
||||||
orderItem.options,
|
end
|
||||||
set_menu_items_obj.to_json,
|
|
||||||
order_id,
|
ActionCable.server.broadcast "bill_channel", table: table, from:from
|
||||||
orderItem.item_order_by,
|
|
||||||
orderItem.taxable)
|
render :json => { status: true }
|
||||||
else
|
end
|
||||||
same_order.qty = same_order.qty.to_f + order_item['qty'].to_f
|
else
|
||||||
same_order.set_menu_items = set_menu_items_obj.to_json
|
render :json => { status: false, error_message: 'No Current Open Shift!'}
|
||||||
same_order.save
|
end
|
||||||
end
|
|
||||||
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
|
|
||||||
else
|
|
||||||
orderItem.order_id = order_id
|
|
||||||
end
|
|
||||||
orderItem.save!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_sale
|
def update_sale
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
def new
|
def new
|
||||||
@webview = false
|
@webview = false
|
||||||
if check_mobile
|
if check_mobile
|
||||||
@webview = true
|
@webview = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@survey = Survey.new
|
@survey = Survey.new
|
||||||
@id = params[:id]
|
@id = params[:id]
|
||||||
@cashier_type = params[:type]
|
@cashier_type = params[:type]
|
||||||
|
|
||||||
if(@id[0,3] == "SAL")
|
if @id.include? "SAL"
|
||||||
@sale = Sale.find(@id)
|
@sale = Sale.find(@id)
|
||||||
@receipt_no = @sale.receipt_no
|
@receipt_no = @sale.receipt_no
|
||||||
@grand_total = @sale.grand_total
|
@grand_total = @sale.grand_total
|
||||||
@@ -27,14 +27,14 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
@dining_facility = nil
|
@dining_facility = nil
|
||||||
@table_type = nil
|
@table_type = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@dining_facility = DiningFacility.find(@id)
|
@dining_facility = DiningFacility.find(@id)
|
||||||
@table_type = @dining_facility.type
|
@table_type = @dining_facility.type
|
||||||
@receipt_no = nil
|
@receipt_no = nil
|
||||||
@grand_total = nil
|
@grand_total = nil
|
||||||
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
|
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -63,13 +63,13 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
shift = ShiftSale.find(sale.shift_sale_id)
|
shift = ShiftSale.find(sale.shift_sale_id)
|
||||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
|
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @type == "quick_service" || @type == "food_court"
|
if @type == "quick_service" || @type == "food_court"
|
||||||
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
|
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
|
||||||
else
|
else
|
||||||
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if params[:survey_id].nil? || params[:survey_id] == ""
|
if params[:survey_id].nil? || params[:survey_id] == ""
|
||||||
@survey = Survey.new(survey_params)
|
@survey = Survey.new(survey_params)
|
||||||
@@ -106,5 +106,5 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
def survey_params
|
def survey_params
|
||||||
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
|
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
class Origami::TableInvoicesController < BaseOrigamiController
|
class Origami::TableInvoicesController < BaseOrigamiController
|
||||||
def index
|
def index
|
||||||
@table = DiningFacility.find(params[:table_id])
|
@table = DiningFacility.find(params[:table_id])
|
||||||
shop = Shop.current_shop
|
shop = Shop.current_shop
|
||||||
puts "table bookig lenght"
|
|
||||||
@sale_array = Array.new
|
@sale_array = Array.new
|
||||||
@table.bookings.each do |booking|
|
@table.bookings.each do |booking|
|
||||||
puts booking.sale_id
|
puts booking.sale_id
|
||||||
@@ -34,30 +33,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
|||||||
@table = DiningFacility.find(params[:table_id])
|
@table = DiningFacility.find(params[:table_id])
|
||||||
@membership = MembershipSetting::MembershipSetting
|
@membership = MembershipSetting::MembershipSetting
|
||||||
@payment_methods = PaymentMethodSetting.all
|
@payment_methods = PaymentMethodSetting.all
|
||||||
shop = Shop.current_shop
|
@sale_array = @table.current_sales
|
||||||
@sale_array = Array.new
|
|
||||||
@table.bookings.each do |booking|
|
|
||||||
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
|
|
||||||
sale.update_attributes(grand_total: new_total,old_grand_total: sale.grand_total,rounding_adjustment:sale.rounding_adjustment)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
#end rounding adjustment
|
|
||||||
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != "waste" && sale.sale_status != "spoile"
|
|
||||||
@sale_array.push(sale)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@sale = Sale.find(params[:invoice_id])
|
@sale = Sale.find(params[:invoice_id])
|
||||||
@date = @sale.created_at
|
@date = @sale.created_at
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ class ApplicationRecord < ActiveRecord::Base
|
|||||||
super
|
super
|
||||||
|
|
||||||
return unless subclass.superclass == self
|
return unless subclass.superclass == self
|
||||||
return unless subclass.column_names.include? 'shop_id'
|
return unless subclass.column_names.include? 'shop_code'
|
||||||
|
|
||||||
subclass.class_eval do
|
subclass.class_eval do
|
||||||
acts_as_tenant(:shop)
|
acts_as_tenant(:shop, foreign_key: 'shop_code', primary_key: 'shop_code')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,9 +6,57 @@ class Booking < ApplicationRecord
|
|||||||
|
|
||||||
belongs_to :dining_facility, :optional => true
|
belongs_to :dining_facility, :optional => true
|
||||||
belongs_to :sale, :optional => true
|
belongs_to :sale, :optional => true
|
||||||
|
has_one :cashier_terminal_by_dining_facility, through: :dining_facility, source: :cashier_terminal
|
||||||
|
has_one :current_shift_by_dining_facility, through: :dining_facility, source: :current_shift
|
||||||
has_many :booking_orders
|
has_many :booking_orders
|
||||||
has_many :orders, :through => :booking_orders
|
has_many :orders, :through => :booking_orders
|
||||||
has_many :order_items, :through => :orders
|
has_many :order_items, :through => :orders do
|
||||||
|
def to_sale_items
|
||||||
|
sale_items = []
|
||||||
|
proxy_association.load_target.select(&:order_items_id).each do |order_item|
|
||||||
|
menu_category = order_item.menu_category || OpenStruct.new(name: 'Product', code: '') #get menu category for menu items
|
||||||
|
|
||||||
|
sale_items << SaleItem.new({
|
||||||
|
menu_category_name: menu_category.name,
|
||||||
|
menu_category_code: menu_category.code,
|
||||||
|
product_name: order_item.item_name,
|
||||||
|
product_code: order_item.item_code,
|
||||||
|
product_alt_name: order_item.alt_name,
|
||||||
|
account_id: order_item.account_id,
|
||||||
|
is_taxable: order_item.taxable,
|
||||||
|
item_instance_code: order_item.item_instance_code,
|
||||||
|
qty: order_item.qty,
|
||||||
|
unit_price: order_item.price,
|
||||||
|
price: order_item.qty * order_item.price,
|
||||||
|
taxable_price: order_item.qty * order_item.price,
|
||||||
|
status: order_item.remark
|
||||||
|
})
|
||||||
|
|
||||||
|
if order_item.set_menu_items
|
||||||
|
JSON.parse(order_item.set_menu_items).each do |item|
|
||||||
|
instance = MenuItemInstance.find_by_item_instance_code(item["item_instance_code"])
|
||||||
|
menu_item = instance.menu_item
|
||||||
|
menu_category = menu_item.menu_category #get menu category for menu items
|
||||||
|
sale_items << SaleItem.new({
|
||||||
|
menu_category_name: menu_category.name,
|
||||||
|
menu_category_code: menu_category.code,
|
||||||
|
product_name: instance.item_instance_name,
|
||||||
|
product_code: menu_item.item_code,
|
||||||
|
product_alt_name: menu_item.alt_name,
|
||||||
|
account_id: menu_item.account_id,
|
||||||
|
is_taxable: menu_item.taxable,
|
||||||
|
item_instance_code: item["item_instance_code"],
|
||||||
|
qty: item["quantity"],
|
||||||
|
unit_price: item["price"],
|
||||||
|
price: item["quantity"].to_f * item["price"].to_f,
|
||||||
|
taxable_price: item["quantity"].to_f * item["price"].to_f
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sale_items
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scope :active, -> {where("booking_status != 'moved'")}
|
scope :active, -> {where("booking_status != 'moved'")}
|
||||||
scope :today, -> {where("created_at >= #{Time.now.utc}")}
|
scope :today, -> {where("created_at >= #{Time.now.utc}")}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
class CashierTerminal < ApplicationRecord
|
class CashierTerminal < ApplicationRecord
|
||||||
has_many :cashier_terminal_by_zones
|
has_many :cashier_terminal_by_zones
|
||||||
has_many :zones, through: :cashier_terminal_by_zones
|
has_many :zones, through: :cashier_terminal_by_zones
|
||||||
|
has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) }, class_name: "ShiftSale"
|
||||||
|
|
||||||
scope :available, -> {where(is_currently_login: false)}
|
scope :available, -> {where(is_currently_login: false)}
|
||||||
scope :is_active, -> {where(is_active: true)}
|
scope :is_active, -> {where(is_active: true)}
|
||||||
|
|
||||||
# validations
|
# validations
|
||||||
validates_presence_of :name, :printer_name
|
validates_presence_of :name, :printer_name
|
||||||
|
|||||||
@@ -11,12 +11,20 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
validates_presence_of :name, :contact_no, :email #,:card_no
|
validates_presence_of :name, :contact_no, :email #,:card_no
|
||||||
validates :contact_no, numericality: true #uniqueness: true,
|
validates :contact_no, numericality: true #uniqueness: true,
|
||||||
validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
|
# validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
|
||||||
# validates :card_no, uniqueness: true
|
# validates :card_no, uniqueness: true
|
||||||
# validates :paypar_account_no, uniqueness: true
|
# validates :paypar_account_no, uniqueness: true
|
||||||
|
|
||||||
paginates_per 50
|
paginates_per 50
|
||||||
|
|
||||||
|
def self.walkin
|
||||||
|
self.find_by(name: "WALK-IN")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.takeaway
|
||||||
|
self.find_by(name: "TAKEAWAY")
|
||||||
|
end
|
||||||
|
|
||||||
def self.get_member_account(customer)
|
def self.get_member_account(customer)
|
||||||
membership = MembershipSetting.active.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.active.find_by_membership_type("paypar_url")
|
||||||
memberaction = MembershipAction.active.find_by_membership_type("get_all_member_account")
|
memberaction = MembershipAction.active.find_by_membership_type("get_all_member_account")
|
||||||
@@ -26,7 +34,7 @@ class Customer < ApplicationRecord
|
|||||||
# urltest =self.url_exist?(url)
|
# urltest =self.url_exist?(url)
|
||||||
if !membership.nil? && !memberaction.nil?
|
if !membership.nil? && !memberaction.nil?
|
||||||
begin
|
begin
|
||||||
response = HTTParty.get(url, :body => {
|
response = HTTParty.get(url, :body => {
|
||||||
membership_id: customer.membership_id,
|
membership_id: customer.membership_id,
|
||||||
merchant_uid:merchant_uid,
|
merchant_uid:merchant_uid,
|
||||||
type: "summary",
|
type: "summary",
|
||||||
@@ -39,7 +47,7 @@ class Customer < ApplicationRecord
|
|||||||
:timeout => 10)
|
:timeout => 10)
|
||||||
rescue HTTParty::Error
|
rescue HTTParty::Error
|
||||||
response = {status: false, message: "Server Error"}
|
response = {status: false, message: "Server Error"}
|
||||||
|
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false , message: "Server Time out"}
|
response = { status: false , message: "Server Time out"}
|
||||||
|
|
||||||
@@ -107,7 +115,7 @@ class Customer < ApplicationRecord
|
|||||||
auth_token = memberaction.auth_token.to_s
|
auth_token = memberaction.auth_token.to_s
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
@customers = Customer.where("membership_type IS NOT NULL AND membership_id IS NULL")
|
@customers = Customer.where("membership_type IS NOT NULL AND membership_id IS NULL")
|
||||||
|
|
||||||
@customers.each do |customer|
|
@customers.each do |customer|
|
||||||
member_params = { name: customer.name,phone: customer.contact_no,
|
member_params = { name: customer.name,phone: customer.contact_no,
|
||||||
@@ -125,7 +133,7 @@ class Customer < ApplicationRecord
|
|||||||
paypar_account_no: customer.paypar_account_no,
|
paypar_account_no: customer.paypar_account_no,
|
||||||
card_no:customer.card_no,member_group_id: customer.membership_type,
|
card_no:customer.card_no,member_group_id: customer.membership_type,
|
||||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url,
|
response = HTTParty.post(url,
|
||||||
@@ -136,7 +144,7 @@ class Customer < ApplicationRecord
|
|||||||
})
|
})
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false, message: "Server Time out" }
|
response = { status: false, message: "Server Time out" }
|
||||||
|
|
||||||
rescue OpenURI::HTTPError
|
rescue OpenURI::HTTPError
|
||||||
response = { status: false, message: "Can't connect server"}
|
response = { status: false, message: "Can't connect server"}
|
||||||
|
|
||||||
@@ -154,12 +162,12 @@ class Customer < ApplicationRecord
|
|||||||
def self.update_rebate
|
def self.update_rebate
|
||||||
sales = Sale.where("rebate_status = 'false'")
|
sales = Sale.where("rebate_status = 'false'")
|
||||||
sales.each do |sale|
|
sales.each do |sale|
|
||||||
if sale.customer.membership_id
|
if sale.customer.membership_id
|
||||||
response = self.rebat(Sale.find(sale.sale_id))
|
response = self.rebat(Sale.find(sale.sale_id))
|
||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
if !response.nil?
|
if !response.nil?
|
||||||
remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.amount_received} "
|
remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.amount_received} "
|
||||||
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
|
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
|
||||||
end
|
end
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
status = sale.update_attributes(rebate_status: "true")
|
status = sale.update_attributes(rebate_status: "true")
|
||||||
@@ -172,7 +180,7 @@ class Customer < ApplicationRecord
|
|||||||
rebate_prices,campaign_method = SaleItem.calculate_rebate_by_account(sObj.sale_items)
|
rebate_prices,campaign_method = SaleItem.calculate_rebate_by_account(sObj.sale_items)
|
||||||
generic_customer_id = sObj.customer.membership_id
|
generic_customer_id = sObj.customer.membership_id
|
||||||
|
|
||||||
|
|
||||||
if generic_customer_id.present?
|
if generic_customer_id.present?
|
||||||
paypar = sObj.sale_payments
|
paypar = sObj.sale_payments
|
||||||
payparcost = 0
|
payparcost = 0
|
||||||
@@ -189,7 +197,7 @@ class Customer < ApplicationRecord
|
|||||||
end
|
end
|
||||||
# overall_dis = SaleItem.get_overall_discount(sObj.id)
|
# overall_dis = SaleItem.get_overall_discount(sObj.id)
|
||||||
overall_dis = sObj.total_discount
|
overall_dis = sObj.total_discount
|
||||||
|
|
||||||
if credit != 1
|
if credit != 1
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
|
memberaction = MembershipAction.find_by_membership_type("get_member_campaign")
|
||||||
@@ -200,8 +208,8 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
# Control for Paypar Cloud
|
# Control for Paypar Cloud
|
||||||
begin
|
begin
|
||||||
response = HTTParty.get(url,
|
response = HTTParty.get(url,
|
||||||
:body => {
|
:body => {
|
||||||
member_group_id:sObj.customer.membership_type,
|
member_group_id:sObj.customer.membership_type,
|
||||||
merchant_uid:merchant_uid,
|
merchant_uid:merchant_uid,
|
||||||
campaign_type_id: campaign_type_id,
|
campaign_type_id: campaign_type_id,
|
||||||
@@ -215,7 +223,7 @@ class Customer < ApplicationRecord
|
|||||||
response = { "status": false , "message": "Connect To" }
|
response = { "status": false , "message": "Connect To" }
|
||||||
rescue OpenURI::HTTPError
|
rescue OpenURI::HTTPError
|
||||||
response = { "status": false, "message": "Can't connect server"}
|
response = { "status": false, "message": "Can't connect server"}
|
||||||
|
|
||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = { "status": false, "message": "Can't connect server"}
|
response = { "status": false, "message": "Can't connect server"}
|
||||||
end
|
end
|
||||||
@@ -232,7 +240,7 @@ class Customer < ApplicationRecord
|
|||||||
response["membership_campaign_data"].each do |a|
|
response["membership_campaign_data"].each do |a|
|
||||||
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
|
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
|
||||||
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
|
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
|
||||||
|
|
||||||
type_arr.push(data)
|
type_arr.push(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -249,7 +257,7 @@ class Customer < ApplicationRecord
|
|||||||
actual = a[:amount] - amount
|
actual = a[:amount] - amount
|
||||||
data[:amount] = actual
|
data[:amount] = actual
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rebate_arr.push(data)
|
rebate_arr.push(data)
|
||||||
@@ -272,8 +280,8 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
# Control for Paypar Cloud
|
# Control for Paypar Cloud
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url,
|
response = HTTParty.post(url,
|
||||||
:body => {
|
:body => {
|
||||||
generic_customer_id:generic_customer_id ,
|
generic_customer_id:generic_customer_id ,
|
||||||
total_sale_transaction_amount: sObj.grand_total,
|
total_sale_transaction_amount: sObj.grand_total,
|
||||||
merchant_uid:merchant_uid,
|
merchant_uid:merchant_uid,
|
||||||
@@ -291,7 +299,7 @@ class Customer < ApplicationRecord
|
|||||||
response = { "status": false , "message": "Connect To" }
|
response = { "status": false , "message": "Connect To" }
|
||||||
rescue OpenURI::HTTPError
|
rescue OpenURI::HTTPError
|
||||||
response = { "status": false, "message": "Can't connect server"}
|
response = { "status": false, "message": "Can't connect server"}
|
||||||
|
|
||||||
rescue SocketError
|
rescue SocketError
|
||||||
response = { "status": false, "message": "Can't connect server"}
|
response = { "status": false, "message": "Can't connect server"}
|
||||||
end
|
end
|
||||||
@@ -302,7 +310,7 @@ class Customer < ApplicationRecord
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "no Response"
|
puts "no Response"
|
||||||
response = { "status": "no_member", "message": "Not membership"}
|
response = { "status": "no_member", "message": "Not membership"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -313,8 +321,8 @@ class Customer < ApplicationRecord
|
|||||||
auth_token = memberaction.auth_token.to_s
|
auth_token = memberaction.auth_token.to_s
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
begin
|
begin
|
||||||
response = HTTParty.get(url,
|
response = HTTParty.get(url,
|
||||||
:body => { paypar_account_no:account_no,
|
:body => { paypar_account_no:account_no,
|
||||||
merchant_uid:merchant_uid,
|
merchant_uid:merchant_uid,
|
||||||
auth_token:auth_token
|
auth_token:auth_token
|
||||||
}.to_json,
|
}.to_json,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class DiningCharge < ApplicationRecord
|
|||||||
|
|
||||||
def self.amount_calculate(dining_charges_obj, checkin , checkout)
|
def self.amount_calculate(dining_charges_obj, checkin , checkout)
|
||||||
# note :: the first Charge Block will cost all, the Time rounding block will included in 2nd Charge Block
|
# note :: the first Charge Block will cost all, the Time rounding block will included in 2nd Charge Block
|
||||||
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
|
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
|
||||||
block_count = 0
|
block_count = 0
|
||||||
price = 0
|
price = 0
|
||||||
minutes = DiningCharge.time_diff(checkout, checkin)
|
minutes = DiningCharge.time_diff(checkout, checkin)
|
||||||
@@ -13,18 +13,17 @@ class DiningCharge < ApplicationRecord
|
|||||||
if dining_minutes <= free_time
|
if dining_minutes <= free_time
|
||||||
price = 0
|
price = 0
|
||||||
else
|
else
|
||||||
charge_type = dining_charges_obj.charge_type
|
charge_type = dining_charges_obj.charge_type
|
||||||
if charge_type == 'hr'
|
if charge_type == 'hr'
|
||||||
block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
|
block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
|
||||||
elsif charge_type == 'day'
|
elsif charge_type == 'day'
|
||||||
block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'day')
|
block_count, price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'day')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return block_count, price
|
return block_count, price
|
||||||
else
|
else
|
||||||
puts "<<<<<<<< NO"
|
return 0, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# dining charges calculate
|
# dining charges calculate
|
||||||
@@ -37,7 +36,7 @@ class DiningCharge < ApplicationRecord
|
|||||||
rounding_time = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.strftime('%H:%M'))
|
rounding_time = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.utc.strftime('%H:%M'))
|
||||||
if result.to_i < 1
|
if result.to_i < 1
|
||||||
# for dining minute is under charge_block
|
# for dining minute is under charge_block
|
||||||
if dining_minutes > rounding_time
|
if dining_minutes > rounding_time
|
||||||
rounding_block = dining_minutes / rounding_time
|
rounding_block = dining_minutes / rounding_time
|
||||||
|
|
||||||
solid_price = rounding_block * chargesObj.time_rounding_block_price
|
solid_price = rounding_block * chargesObj.time_rounding_block_price
|
||||||
@@ -46,7 +45,7 @@ class DiningCharge < ApplicationRecord
|
|||||||
else
|
else
|
||||||
return 1, result.to_i,chargesObj.unit_price
|
return 1, result.to_i,chargesObj.unit_price
|
||||||
end
|
end
|
||||||
elsif result.to_i >= 1
|
elsif result.to_i >= 1
|
||||||
|
|
||||||
solid_price = result * chargesObj.unit_price
|
solid_price = result * chargesObj.unit_price
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ class DiningCharge < ApplicationRecord
|
|||||||
else
|
else
|
||||||
solid_price += (roundingblock * chargesObj.time_rounding_block_price)
|
solid_price += (roundingblock * chargesObj.time_rounding_block_price)
|
||||||
|
|
||||||
return result.to_i, DiningCharge.check_rounding(chargesObj, solid_price, extra_minutes)
|
return result.to_i, DiningCharge.check_rounding(chargesObj, solid_price, extra_minutes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -74,7 +73,7 @@ class DiningCharge < ApplicationRecord
|
|||||||
# rounding_block_remain = roundingblock / 1
|
# rounding_block_remain = roundingblock / 1
|
||||||
free_time = DiningCharge.convert_to_minutes(chargesObj.minimum_free_time.utc.strftime('%H:%M'))
|
free_time = DiningCharge.convert_to_minutes(chargesObj.minimum_free_time.utc.strftime('%H:%M'))
|
||||||
rounding_block_remain = extra_minutes - free_time
|
rounding_block_remain = extra_minutes - free_time
|
||||||
|
|
||||||
if chargesObj.time_rounding == "down"
|
if chargesObj.time_rounding == "down"
|
||||||
return solid_price
|
return solid_price
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
class DiningFacility < ApplicationRecord
|
class DiningFacility < ApplicationRecord
|
||||||
belongs_to :zone
|
belongs_to :zone
|
||||||
has_many :dining_charges
|
|
||||||
has_many :in_juties
|
has_many :in_juties
|
||||||
|
has_one :dining_charge
|
||||||
|
has_one :cashier_terminal_by_zone, foreign_key: "zone_id", primary_key: "zone_id"
|
||||||
|
has_one :cashier_terminal, through: :cashier_terminal_by_zone
|
||||||
|
has_one :current_shift, through: :cashier_terminal
|
||||||
|
has_many :order_queue_process_by_zones, foreign_key: "zone_id", primary_key: "zone_id"
|
||||||
|
has_many :order_queue_stations, -> { where(is_active: true) }, through: :order_queue_process_by_zones
|
||||||
|
|
||||||
has_many :bookings
|
has_many :bookings
|
||||||
has_many :current_bookings, -> { left_joins(:sale).assign.within_time_limit.merge(Booking.where(checkout_at: nil).or(Booking.merge(Sale.where(sale_status: ['new', nil])))) }, class_name: "Booking"
|
has_many :current_bookings, -> { left_joins(:sale).assign.within_time_limit.merge(Booking.where(checkout_at: nil).or(Booking.merge(Sale.where(sale_status: ['new', nil])))) }, class_name: "Booking"
|
||||||
has_one :current_checkin_booking, -> { assign.within_time_limit.where(checkout_at: nil) }, class_name: "Booking"
|
has_one :current_checkin_booking, -> { left_joins(:sale).assign.within_time_limit.merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
|
||||||
has_one :current_checkout_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(checkout_at: nil).merge(Sale.where(sale_status: ['new', nil])) }, class_name: "Booking"
|
has_one :current_checkout_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(checkout_at: nil).merge(Sale.where(sale_status: 'new')) }, class_name: "Booking"
|
||||||
has_one :current_reserved_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(reserved_at: nil).merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
|
has_one :current_reserved_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(reserved_at: nil).merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
|
||||||
|
|
||||||
|
has_many :current_sales, -> { where(sale_status: 'new').merge(Booking.assign.within_time_limit) }, through: :bookings, class_name: "Sale", source: "sale"
|
||||||
|
|
||||||
TABLE_TYPE = "Table"
|
TABLE_TYPE = "Table"
|
||||||
ROOM_TYPE = "Room"
|
ROOM_TYPE = "Room"
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ class Employee < ApplicationRecord
|
|||||||
has_secure_password
|
has_secure_password
|
||||||
has_many :commissioners
|
has_many :commissioners
|
||||||
has_many :shit_sales
|
has_many :shit_sales
|
||||||
|
has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) },class_name: "ShiftSale"
|
||||||
|
has_one :cashier_terminal, through: :current_shift
|
||||||
belongs_to :order_queue_station
|
belongs_to :order_queue_station
|
||||||
|
|
||||||
validates_presence_of :name, :role
|
validates_presence_of :name, :role
|
||||||
|
|||||||
@@ -31,17 +31,19 @@ class MenuItem < ApplicationRecord
|
|||||||
|
|
||||||
# Work with item_code = item_instance_code
|
# Work with item_code = item_instance_code
|
||||||
def self.search_by_item_code(item_code)
|
def self.search_by_item_code(item_code)
|
||||||
MenuItem.joins(:menu_item_instances)
|
MenuItem.left_joins(:menu_item_instances => :menu_instance_item_sets)
|
||||||
.where(menu_item_instances: {item_instance_code: item_code})
|
.where(menu_item_instances: {item_instance_code: item_code})
|
||||||
.pluck(:type, :account_id, :item_code, :item_instance_code, :name, :alt_name, "menu_item_instances.item_instance_name AS item_instance_name", :price, :promotion_price, :is_on_promotion, "menu_item_instances.is_available", :taxable)
|
.pluck(:type, :account_id, :item_code, :item_instance_code, :name, :alt_name, :item_instance_name, :price, :promotion_price, :is_on_promotion, "menu_item_instances.is_available", :taxable, :item_set_id)
|
||||||
.map { |type, account_id, item_code, item_instance_code, item_name, item_alt_name, item_instance_name, price, promotion_price, is_on_promotion, is_available, taxable|
|
.map { |type, account_id, item_code, item_instance_code, item_name, item_alt_name, item_instance_name, price, promotion_price, is_on_promotion, is_available, taxable, item_set_id|
|
||||||
|
name = item_instance_name if item_set_id
|
||||||
|
name ||= "#{item_name}#{' - ' + item_instance_name if item_instance_name.present?}"
|
||||||
{
|
{
|
||||||
type: type,
|
type: type,
|
||||||
account_id: account_id,
|
account_id: account_id,
|
||||||
item_code: item_code,
|
item_code: item_code,
|
||||||
item_instance_code: item_instance_code,
|
item_instance_code: item_instance_code,
|
||||||
name: item_name.to_s + (' - ' + item_instance_name.to_s) || '',
|
name: "#{name}",
|
||||||
alt_name: item_alt_name || '',
|
alt_name: "#{item_alt_name}",
|
||||||
price: price,
|
price: price,
|
||||||
promotion_price: promotion_price,
|
promotion_price: promotion_price,
|
||||||
is_on_promotion: is_on_promotion,
|
is_on_promotion: is_on_promotion,
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ class Order < ApplicationRecord
|
|||||||
menu_items = MenuItem.search_by_item_code(item_instance_codes)
|
menu_items = MenuItem.search_by_item_code(item_instance_codes)
|
||||||
menu_items += Product.search_by_product_code(item_instance_codes) if menu_items.length < item_instance_codes.length
|
menu_items += Product.search_by_product_code(item_instance_codes) if menu_items.length < item_instance_codes.length
|
||||||
|
|
||||||
new_order_items = []
|
|
||||||
items.each do |order_item|
|
items.each do |order_item|
|
||||||
menu_item = menu_items.find { |i| i[:item_instance_code].downcase == order_item[:item_instance_code].downcase }
|
menu_item = menu_items.find { |i| i[:item_instance_code].downcase == order_item[:item_instance_code].downcase }
|
||||||
sub_order_items = []
|
sub_order_items = []
|
||||||
@@ -144,8 +143,7 @@ class Order < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
sub_order_items = sub_order_items.to_json
|
sub_order_items = sub_order_items.to_json
|
||||||
new_order_items << OrderItem.new({
|
self.order_items.build({
|
||||||
order_id: id,
|
|
||||||
item_code: menu_item[:item_code],
|
item_code: menu_item[:item_code],
|
||||||
item_instance_code: order_item[:item_instance_code],
|
item_instance_code: order_item[:item_instance_code],
|
||||||
item_name: menu_item[:name],
|
item_name: menu_item[:name],
|
||||||
@@ -160,17 +158,6 @@ class Order < ApplicationRecord
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
ids = OrderItem.generate_ids(new_order_items.length)
|
|
||||||
new_order_items.each_with_index do |order_item, index|
|
|
||||||
order_item.order_items_id = ids[index]
|
|
||||||
end
|
|
||||||
|
|
||||||
OrderItem.import new_order_items, validate: false
|
|
||||||
|
|
||||||
new_order_items.each do |order_item|
|
|
||||||
order_item.run_callbacks(:save) { true }
|
|
||||||
end
|
|
||||||
|
|
||||||
self.item_count = self.order_items.count
|
self.item_count = self.order_items.count
|
||||||
self.save!
|
self.save!
|
||||||
|
|
||||||
@@ -199,7 +186,7 @@ class Order < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def default_values
|
def default_values
|
||||||
self.customer = Customer.find(1) if self.customer_id.nil?
|
self.customer = Customer.walkin if self.customer_id.nil?
|
||||||
self.source = "emenu" if self.source.nil?
|
self.source = "emenu" if self.source.nil?
|
||||||
self.order_type = "dine-in" if self.order_type.nil?
|
self.order_type = "dine-in" if self.order_type.nil?
|
||||||
end
|
end
|
||||||
@@ -419,62 +406,28 @@ class Order < ApplicationRecord
|
|||||||
print_status = nil
|
print_status = nil
|
||||||
cup_status = nil
|
cup_status = nil
|
||||||
|
|
||||||
#Send to background job for processing
|
#Send to background job for processing
|
||||||
order = Order.find(order_id)
|
order = Order.find(order_id)
|
||||||
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||||
|
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
if ENV["SERVER_MODE"] != 'cloud'
|
||||||
cup_status = `#{"sudo service cups status"}`
|
if Printer::PrinterWorker.printers.blank?
|
||||||
print_status = check_cup_status(cup_status)
|
msg = 'Print Error ! Please contact to service'
|
||||||
|
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: ''
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if print_status
|
if !sidekiq.nil?
|
||||||
if !sidekiq.nil?
|
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
else
|
||||||
else
|
if order
|
||||||
if order
|
oqs = OrderQueueStation.new
|
||||||
oqs = OrderQueueStation.new
|
oqs.process_order(order, table_id, order_source)
|
||||||
oqs.process_order(order, table_id, source)
|
|
||||||
end
|
|
||||||
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
|
||||||
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
|
||||||
cup_start = `#{"sudo service cups start"}`
|
|
||||||
cup_status = `#{"sudo service cups status"}`
|
|
||||||
print_status = check_cup_status(cup_status)
|
|
||||||
end
|
|
||||||
|
|
||||||
if print_status
|
|
||||||
if !sidekiq.nil?
|
|
||||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
|
||||||
else
|
|
||||||
if order
|
|
||||||
oqs = OrderQueueStation.new
|
|
||||||
oqs.process_order(order, table_id, source)
|
|
||||||
end
|
|
||||||
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
|
||||||
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
|
||||||
|
|
||||||
msg = ' Print Error ! Please contact to service'
|
|
||||||
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
|
|
||||||
end
|
|
||||||
if !sidekiq.nil?
|
|
||||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
|
||||||
else
|
|
||||||
if order
|
|
||||||
oqs = OrderQueueStation.new
|
|
||||||
oqs.process_order(order, table_id, source)
|
|
||||||
end
|
|
||||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
|
||||||
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
|
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||||
|
ActionCable.server.broadcast "order_queue_station_channel", order: assign_order, from: from
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.check_cup_status(status)
|
def self.check_cup_status(status)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ class OrderItem < ApplicationRecord
|
|||||||
|
|
||||||
#Associations
|
#Associations
|
||||||
belongs_to :order, autosave: true
|
belongs_to :order, autosave: true
|
||||||
|
has_one :menu_item, foreign_key: "item_code", primary_key: "item_code"
|
||||||
|
has_one :menu_category, through: :menu_item
|
||||||
# belongs_to :order, counter_cache: true
|
# belongs_to :order, counter_cache: true
|
||||||
|
|
||||||
#Validation
|
#Validation
|
||||||
|
|||||||
@@ -15,15 +15,14 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
validates_presence_of :station_name, :printer_name
|
validates_presence_of :station_name, :printer_name
|
||||||
|
|
||||||
def process_order(order, table_id, order_source = nil, pdf_status = nil ,change_to=nil, current_user=nil)
|
def process_order(order, table_id, order_source = nil, pdf_status = nil ,change_to=nil, current_user=nil)
|
||||||
|
|
||||||
oqs_stations = OrderQueueStation.active
|
|
||||||
order_items = order.order_items
|
order_items = order.order_items
|
||||||
|
|
||||||
if table_id.to_i > 0
|
if table_id.to_i > 0
|
||||||
# get dining
|
# get dining
|
||||||
dining = DiningFacility.find(table_id)
|
dining = DiningFacility.find(table_id)
|
||||||
oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}").pluck(:order_queue_station_id)
|
oqs_stations = dining.order_queue_stations
|
||||||
oqs_stations = oqs_stations.select { |s| oqs_by_zones.include? s.id }
|
else
|
||||||
|
oqs_stations = OrderQueueStation.active
|
||||||
end
|
end
|
||||||
|
|
||||||
assigned_order_items = []
|
assigned_order_items = []
|
||||||
@@ -31,12 +30,12 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
|
|
||||||
# ToDo per item per printer
|
# ToDo per item per printer
|
||||||
oqs_stations.each do |oqs|
|
oqs_stations.each do |oqs|
|
||||||
oqs_order_items = nil
|
|
||||||
oqs_order_items = order_items.select { |i| JSON.parse(oqs.processing_items).include? i.item_code }
|
oqs_order_items = order_items.select { |i| JSON.parse(oqs.processing_items).include? i.item_code }
|
||||||
assigned_order_items += oqs_order_items.map { |i| AssignedOrderItem.new({ order: order, item_code: i.item_code, instance_code: i.item_instance_code, order_queue_station: oqs, print_status: false, delivery_status: false }) }
|
|
||||||
oqs_order_items_by_zones << { oqs: oqs, oqs_order_items: oqs_order_items }
|
oqs_order_items_by_zones << { oqs: oqs, oqs_order_items: oqs_order_items }
|
||||||
|
|
||||||
|
print_status = false
|
||||||
if oqs.auto_print && order_source != "quick_service"
|
if oqs.auto_print && order_source != "quick_service"
|
||||||
|
print_status = true
|
||||||
if oqs_order_items.length > 0
|
if oqs_order_items.length > 0
|
||||||
if oqs.cut_per_item
|
if oqs.cut_per_item
|
||||||
print_slip_item(oqs, order, oqs_order_items, pdf_status, change_to, current_user, table_id)
|
print_slip_item(oqs, order, oqs_order_items, pdf_status, change_to, current_user, table_id)
|
||||||
@@ -45,15 +44,8 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if pdf_status.nil?
|
oqs_order_items.each { |i| AssignedOrderItem.create({ order: order, item_code: i.item_code, instance_code: i.item_instance_code, order_queue_station: oqs, print_status: print_status, delivery_status: false }) }
|
||||||
ids = AssignedOrderItem.generate_ids(assigned_order_items.length)
|
|
||||||
assigned_order_items.each_with_index do |assigned_order_item, index|
|
|
||||||
assigned_order_item.assigned_order_item_id = ids[index]
|
|
||||||
end
|
|
||||||
|
|
||||||
AssignedOrderItem.import assigned_order_items, validate: false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -163,13 +155,10 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
else
|
else
|
||||||
move_print_pdf(change_to,current_user,table_id,order_items,oqs)
|
move_print_pdf(change_to,current_user,table_id,order_items,oqs)
|
||||||
end
|
end
|
||||||
|
|
||||||
AssignedOrderItem.where("order_id = ?", order.order_id).update_all(print_status: true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#Print order_item in 1 slip per item
|
#Print order_item in 1 slip per item
|
||||||
def print_slip_item(oqs, order, assigned_items,pdf_status=nil,change_to=nil,current_user=nil,table_id=nil)
|
def print_slip_item(oqs, order, assigned_items,pdf_status=nil,change_to=nil,current_user=nil,table_id=nil)
|
||||||
|
|
||||||
if pdf_status.nil?
|
if pdf_status.nil?
|
||||||
# order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
|
# order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
|
||||||
# print when complete click
|
# print when complete click
|
||||||
@@ -184,8 +173,6 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
else
|
else
|
||||||
move_print_pdf(change_to,current_user,table_id,assigned_items,oqs)
|
move_print_pdf(change_to,current_user,table_id,assigned_items,oqs)
|
||||||
end
|
end
|
||||||
|
|
||||||
AssignedOrderItem.where("order_id = ?", order.order_id).update_all(print_status: true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_print_pdf(change_to,current_user,change_from,order_items,oqs)
|
def move_print_pdf(change_to,current_user,change_from,order_items,oqs)
|
||||||
|
|||||||
@@ -23,28 +23,18 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
if oqs.print_copy
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
#no print in cloud server
|
self.print(filename, oqs.printer_name)
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
#For print copy
|
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
|
||||||
else
|
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
#For print copy
|
||||||
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
|
|
||||||
return filename, order_id, oqs.printer_name
|
return filename, order_id, oqs.printer_name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Query for per order
|
# Query for per order
|
||||||
def print_order_summary(print_settings,oqs, order_id, order_items, print_status, before_updated_qty="", options="")
|
def print_order_summary(print_settings, oqs, order_id, order_items, print_status, before_updated_qty="", options="")
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
@@ -55,7 +45,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
shop = Shop.current_shop
|
shop = Shop.current_shop
|
||||||
directory_name = 'public/orders_'+shop.shop_code
|
directory_name = "public/orders_#{shop.shop_code}"
|
||||||
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
Dir.mkdir(directory_name) unless File.exists?(directory_name)
|
||||||
|
|
||||||
# For Print Per Item
|
# For Print Per Item
|
||||||
@@ -64,10 +54,10 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
order_items.each do |odi|
|
order_items.each do |odi|
|
||||||
odi_item = print_query('order_item', odi.order_items_id)
|
odi_item = print_query('order_item', odi.order_items_id)
|
||||||
|
|
||||||
filename = directory_name + "/order_item_#{order_id}" + ".pdf"
|
filename = directory_name + "/order_item_#{order_id}.pdf"
|
||||||
# filename = "tmp/order_item_#{order_id}" + ".pdf"
|
# filename = "tmp/order_item_#{order_id}" + ".pdf"
|
||||||
# For Item Options
|
# For Item Options
|
||||||
options = odi.options == "[]"? "" : odi.options
|
options = odi.options == "[]" ? "" : odi.options
|
||||||
|
|
||||||
# check for item not to show
|
# check for item not to show
|
||||||
#if odi.price != 0
|
#if odi.price != 0
|
||||||
@@ -75,19 +65,10 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
# pdf.render_file "tmp/order_item.pdf"
|
# pdf.render_file "tmp/order_item.pdf"
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
#no print in cloud server
|
||||||
#no print in cloud server
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
self.print(filename, oqs.printer_name)
|
||||||
self.print(filename, oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
@@ -95,33 +76,24 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
else
|
else
|
||||||
order = print_query('order_summary', order_id)
|
order = print_query('order_summary', order_id)
|
||||||
|
|
||||||
filename = directory_name + "/order_summary_#{order_id}" + ".pdf"
|
filename = directory_name + "/order_summary_#{order_id}.pdf"
|
||||||
# filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
# filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||||
pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, order_items, oqs.use_alternate_name, before_updated_qty)
|
pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, order_items, oqs.use_alternate_name, before_updated_qty)
|
||||||
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
if oqs.print_copy
|
#no print in cloud server
|
||||||
#no print in cloud server
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
self.print(filename, oqs.printer_name)
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
#For print copy
|
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
|
||||||
else
|
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
#For print copy
|
||||||
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
end
|
end
|
||||||
return filename, order_id, oqs.printer_name
|
return filename, order_id, oqs.printer_name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Print for orders in booking
|
# Print for orders in booking
|
||||||
def print_booking_summary(print_settings,oqs, booking_id, print_status,before_updated_qty="")
|
def print_booking_summary(print_settings, oqs, booking_id, print_status,before_updated_qty="")
|
||||||
# Must be one print
|
# Must be one print
|
||||||
if print_settings.print_copies == 0
|
if print_settings.print_copies == 0
|
||||||
print_settings.print_copies = 1
|
print_settings.print_copies = 1
|
||||||
@@ -146,36 +118,10 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
# check for item not to show
|
# check for item not to show
|
||||||
#if odi.price != 0
|
#if odi.price != 0
|
||||||
pdf = print_settings.unique_code.constantize.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
pdf = print_settings.unique_code.constantize.new(print_settings, odi, print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||||
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
if oqs.print_copy
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
#For print copy
|
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
|
||||||
else
|
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
#end
|
|
||||||
end
|
|
||||||
# For Print Order Summary
|
|
||||||
else
|
|
||||||
# filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
|
||||||
filename = directory_name + "/booking_summary_#{booking_id}" + ".pdf"
|
|
||||||
pdf = print_settings.unique_code.constantize.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
|
|
||||||
pdf.render_file filename
|
|
||||||
if oqs.print_copy
|
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
self.print(filename, oqs.printer_name)
|
self.print(filename, oqs.printer_name)
|
||||||
@@ -183,14 +129,22 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
#For print copy
|
#For print copy
|
||||||
# pdf.render_file filename.gsub(".","-copy.")
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
else
|
#end
|
||||||
print_settings.print_copies = 1
|
|
||||||
print_settings.save!
|
|
||||||
#no print in cloud server
|
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
|
||||||
self.print(filename, oqs.printer_name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
# For Print Order Summary
|
||||||
|
else
|
||||||
|
# filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
||||||
|
filename = directory_name + "/booking_summary_#{booking_id}" + ".pdf"
|
||||||
|
pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, oqs.use_alternate_name, before_updated_qty)
|
||||||
|
|
||||||
|
pdf.render_file filename
|
||||||
|
#no print in cloud server
|
||||||
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
|
self.print(filename, oqs.printer_name)
|
||||||
|
end
|
||||||
|
#For print copy
|
||||||
|
# pdf.render_file filename.gsub(".","-copy.")
|
||||||
|
# self.print(filename.gsub(".","-copy."), oqs.printer_name)
|
||||||
end
|
end
|
||||||
return filename, booking_id, oqs.printer_name
|
return filename, booking_id, oqs.printer_name
|
||||||
end
|
end
|
||||||
@@ -206,14 +160,14 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
.joins("left join menu_items as item ON item.item_code = order_items.item_code")
|
.joins("left join menu_items as item ON item.item_code = order_items.item_code")
|
||||||
|
|
||||||
if type == "order_item"
|
if type == "order_item"
|
||||||
query.where("order_items.order_items_id = '#{ id }'")
|
query.where("order_items.order_items_id = ?", id)
|
||||||
.group("order_items.item_code")
|
.group("order_items.item_code")
|
||||||
elsif type == "order_summary"
|
elsif type == "order_summary"
|
||||||
query.where("orders.order_id = '#{ id }'")
|
query.where("orders.order_id = ?", id)
|
||||||
.group("order_items.order_items_id")
|
.group("order_items.order_items_id")
|
||||||
else
|
else
|
||||||
# order summary for booking
|
# order summary for booking
|
||||||
query.where("b.booking_id = '#{ id }'")
|
query.where("b.booking_id = ?", id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -37,21 +37,22 @@ class Printer::PrinterWorker
|
|||||||
Cups.default_printer
|
Cups.default_printer
|
||||||
end
|
end
|
||||||
|
|
||||||
def print(file_path,printer_destination = nil )
|
def self.printer_exists?(printer)
|
||||||
# if printer_destination.nil?
|
Cups.show_destinations.include? printer
|
||||||
# printer_destination = self.printer_destination
|
end
|
||||||
# end
|
|
||||||
#
|
def print(file_path, printer_destination = nil )
|
||||||
# puts printer_destination
|
if printer_destination.nil?
|
||||||
# puts '........Printer Destination..........'
|
printer_destination = self.printer_destination
|
||||||
#
|
end
|
||||||
# copy = self.print_copies
|
|
||||||
# #Print only when printer information is not null
|
copy = self.print_copies
|
||||||
# if !self.printer_destination.nil?
|
#Print only when printer information is not null
|
||||||
# (1..copy).each do
|
if !self.printer_destination.nil?
|
||||||
# page = Cups::PrintJob.new(file_path, printer_destination)
|
(1..copy).each do
|
||||||
# page.print
|
page = Cups::PrintJob.new(file_path, printer_destination)
|
||||||
# end
|
page.print
|
||||||
# end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ class Product < ApplicationRecord
|
|||||||
account_id: account_id,
|
account_id: account_id,
|
||||||
item_code: item_code,
|
item_code: item_code,
|
||||||
item_instance_code: item_code,
|
item_instance_code: item_code,
|
||||||
name: item_name || '',
|
name: "#{item_name}",
|
||||||
alt_name: item_name || '',
|
alt_name: "#{item_name}",
|
||||||
price: price,
|
price: price,
|
||||||
promotion_price: 0,
|
promotion_price: 0,
|
||||||
is_on_promotion: 0,
|
is_on_promotion: 0,
|
||||||
|
|||||||
@@ -5,21 +5,25 @@ class Sale < ApplicationRecord
|
|||||||
#primary key - need to be unique generated for multiple shops
|
#primary key - need to be unique generated for multiple shops
|
||||||
before_create :generate_custom_id
|
before_create :generate_custom_id
|
||||||
before_create :generate_receipt_no
|
before_create :generate_receipt_no
|
||||||
|
|
||||||
belongs_to :cashier, foreign_key: "cashier_id", class_name: "Employee"
|
belongs_to :cashier, foreign_key: "cashier_id", class_name: "Employee"
|
||||||
belongs_to :customer, :optional => true
|
belongs_to :customer, :optional => true
|
||||||
belongs_to :shift_sale
|
belongs_to :shift_sale
|
||||||
has_one :survey, foreign_key: "receipt_no"
|
has_one :current_shift_by_cashier, through: :cashier, source: :current_shift
|
||||||
|
has_one :cashier_terminal_by_shift_sale, through: :shift_sale, source: :cashier_terminal
|
||||||
|
has_one :survey, foreign_key: "receipt_no"
|
||||||
has_many :sale_audits
|
has_many :sale_audits
|
||||||
has_many :sale_items
|
has_many :sale_items
|
||||||
has_many :sale_discount_items
|
has_many :sale_discount_items
|
||||||
has_many :sale_discounts
|
has_many :sale_discounts
|
||||||
has_many :sale_taxes
|
has_many :sale_taxes
|
||||||
has_many :sale_payments
|
has_many :sale_payments
|
||||||
|
has_many :payments_for_credits, through: :sale_audits
|
||||||
has_many :sale_orders
|
has_many :sale_orders
|
||||||
has_many :sale_payments_for_credits, through: :sale_audits
|
|
||||||
has_many :orders, through: :sale_orders
|
has_many :orders, through: :sale_orders
|
||||||
has_many :order_items, through: :sale_orders
|
has_many :order_items, through: :sale_orders
|
||||||
has_many :bookings
|
has_many :bookings
|
||||||
|
has_one :booking
|
||||||
has_many :product_commissions
|
has_many :product_commissions
|
||||||
|
|
||||||
before_validation :round_to_precision
|
before_validation :round_to_precision
|
||||||
@@ -30,7 +34,7 @@ class Sale < ApplicationRecord
|
|||||||
scope :paid, -> { where(payment_status: 'paid')}
|
scope :paid, -> { where(payment_status: 'paid')}
|
||||||
scope :completed, -> { where(sale_status: 'completed') }
|
scope :completed, -> { where(sale_status: 'completed') }
|
||||||
scope :receipt_date_between, -> (from, to) { where(receipt_date: from..to) }
|
scope :receipt_date_between, -> (from, to) { where(receipt_date: from..to) }
|
||||||
scope :along_with_sale_payments_except_void_between, -> (from, to) { joins(sanitize_sql_array(["LEFT JOIN sale_payments on sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND sale_payments.created_at BETWEEN ? and ?", from, to])) }
|
scope :along_with_sale_payments_except_void_between, -> (from, to) { joins(sanitize_sql_array(["LEFT JOIN sale_payments ON sales.sale_status != 'void' AND sale_payments.sale_id = sales.sale_id AND sale_payments.created_at BETWEEN ? and ?", from, to])) }
|
||||||
|
|
||||||
def qty_of(item_instance_code)
|
def qty_of(item_instance_code)
|
||||||
order_items.select(:order_items_id, :item_instance_code, 'SUM(qty) as qty').where(item_instance_code: item_instance_code).group(:item_instance_code).first
|
order_items.select(:order_items_id, :item_instance_code, 'SUM(qty) as qty').where(item_instance_code: item_instance_code).group(:item_instance_code).first
|
||||||
@@ -79,188 +83,114 @@ class Sale < ApplicationRecord
|
|||||||
Rails.logger.debug '........ Sale data sync completed .......'
|
Rails.logger.debug '........ Sale data sync completed .......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def self.generate_invoice_from_booking(booking, requested_by, cashier, order_source = nil, current_checkin_induties_count)
|
|
||||||
if booking
|
|
||||||
Rails.logger.debug "Booking -> " + booking.id.to_s
|
|
||||||
Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s
|
|
||||||
#get all order attached to this booking and combine into 1 invoice
|
|
||||||
|
|
||||||
unless sale = booking.sale
|
def self.generate_invoice_from_booking(booking, requested_by, cashier, order_source = nil, in_duties_count = 0)
|
||||||
sale = booking.build_sale(
|
Sale.transaction do
|
||||||
|
if booking
|
||||||
|
current = Time.now
|
||||||
|
#get all order attached to this booking and combine into 1 invoice
|
||||||
|
sale = booking.sale || booking.build_sale(
|
||||||
{
|
{
|
||||||
tax_type: "execulive" # Default Tax - Values
|
tax_type: "execulive" # Default Tax - Values
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
|
||||||
booking.booking_orders.each do |order|
|
|
||||||
sale.generate_invoice_from_order(order.order_id, booking, requested_by, cashier, order_source)
|
|
||||||
# saleObj = Sale.find(sale_id)
|
|
||||||
# order = booking.booking_orders.take.order
|
|
||||||
# link_order_sale(order.order_id)
|
|
||||||
end
|
|
||||||
# InventoryJob.perform_now(self.id)
|
|
||||||
# InventoryDefinition.calculate_product_count(saleObj)
|
|
||||||
|
|
||||||
|
if cashier.role == 'cashier'
|
||||||
# dining charges
|
sale.cashier = cashier
|
||||||
charges = DiningCharge.where('dining_facility_id=?', booking.dining_facility_id).take
|
sale.shift_sale = cashier.current_shift
|
||||||
if !charges.nil?
|
elsif booking.dining_facility
|
||||||
block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
|
if sale.shift_sale = booking.current_shift_by_dining_facility
|
||||||
if charges.charge_type =='hr'
|
sale.cashier = sale.shift_sale.employee
|
||||||
dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s
|
|
||||||
else
|
|
||||||
dining_time = booking.checkin_at.strftime('%B %d, %H:%M %p').to_s + " - " + booking.checkout_at.strftime('%B %d, %H:%M %p').to_s
|
|
||||||
end
|
|
||||||
later_time = booking.checkout_at
|
|
||||||
early_time = booking.checkin_at
|
|
||||||
distance_in_minutes = ((later_time - early_time)/60.0).round
|
|
||||||
basic_pay_amount = 0
|
|
||||||
name = ""
|
|
||||||
if current_checkin_induties_count != "0"
|
|
||||||
basic_pay = Commission.where('commission_type=?','Basic Pay')
|
|
||||||
basic_pay.each do |pay|
|
|
||||||
basic_pay_amount = pay.amount
|
|
||||||
name = pay.name
|
|
||||||
end
|
|
||||||
induties_pay_amount = (current_checkin_induties_count.to_i * (distance_in_minutes / 60.0).to_f * basic_pay_amount).to_i
|
|
||||||
sale.create_saleitem_indutycharges(charges, current_checkin_induties_count.to_i, induties_pay_amount, booking.dining_facility.name, dining_time, order_source, basic_pay_amount)
|
|
||||||
end
|
|
||||||
sale.create_saleitem_diningcharges(charges, block_count, diningprice, booking.dining_facility.name, dining_time, order_source)
|
|
||||||
end
|
|
||||||
|
|
||||||
return sale
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def generate_invoice_from_order(order_id, booking, requested_by, cashier = nil, order_source = nil)
|
|
||||||
taxable = true
|
|
||||||
|
|
||||||
order = Order.find(order_id)
|
|
||||||
|
|
||||||
# current cashier login
|
|
||||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
|
||||||
current_shift = ShiftSale.current_shift
|
|
||||||
# shift with terminal zone
|
|
||||||
|
|
||||||
# set cashier
|
|
||||||
if order_source.present? && order_source.downcase == "emenu"
|
|
||||||
if !booking.dining_facility_id.nil?
|
|
||||||
table = DiningFacility.find(booking.dining_facility_id)
|
|
||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
|
||||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{cashier_zone.cashier_terminal_id}").first
|
|
||||||
#for multiple zone with terminal
|
|
||||||
if shift.nil?
|
|
||||||
multiple_zone = CashierTerminalByZone.where("zone_id = #{table.zone_id}")
|
|
||||||
multiple_zone.each do |zone|
|
|
||||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and cashier_terminal_id = #{zone.cashier_terminal_id}").first
|
|
||||||
if !shift.nil? then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
else
|
if sale.shift_sale.nil?
|
||||||
shift = ShiftSale.current_open_shift(cashier.id)
|
if sale.cashier = Employee.where(role: 'cashier').where.not(token_session: [nil, '']).first
|
||||||
end
|
sale.shift_sale = sale.current_shift_by_cashier
|
||||||
# set cashier
|
|
||||||
if shift != nil #if current login employee open shift
|
|
||||||
self.cashier_id = cashier.id
|
|
||||||
self.cashier_name = cashier.name
|
|
||||||
self.shift_sale_id = shift.id
|
|
||||||
else
|
|
||||||
if open_cashier.count>0 # if we have two open cashier
|
|
||||||
# table and terminal in multiple shift
|
|
||||||
self.cashier_id = open_cashier[0].id
|
|
||||||
self.cashier_name = open_cashier[0].name
|
|
||||||
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
|
||||||
if shift_id
|
|
||||||
self.shift_sale_id = shift_id.id
|
|
||||||
else
|
else
|
||||||
self.shift_sale_id = current_shift.id
|
sale.shift_sale = ShiftSale.current_shift
|
||||||
|
sale.cashier = sale.shift_sale.employee
|
||||||
end
|
end
|
||||||
else
|
|
||||||
self.cashier_id = current_shift.employee_id
|
|
||||||
self.cashier_name = Employee.find(current_shift.employee_id).name
|
|
||||||
self.shift_sale_id = current_shift.id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# set waiter
|
|
||||||
self.requested_by = requested_by.name
|
|
||||||
|
|
||||||
self.requested_at = DateTime.now.utc.getlocal
|
|
||||||
|
|
||||||
Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}"
|
|
||||||
if order
|
|
||||||
self.customer_id = order.customer_id
|
|
||||||
Rails.logger.debug "Order -> #{order.id} | Items Count -> #{order.order_items.count}"
|
|
||||||
|
|
||||||
order.order_items.each do |item|
|
|
||||||
self.add_item(item)
|
|
||||||
if !item.set_menu_items.nil?
|
|
||||||
self.add_sub_item(item.set_menu_items)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sale.cashier_name = sale.cashier.name
|
||||||
|
sale.requested_by = requested_by.name
|
||||||
|
sale.requested_at = current
|
||||||
|
|
||||||
|
sale.sale_items << booking.order_items.to_sale_items
|
||||||
|
|
||||||
|
if booking.dining_facility.present? && dining_charge = booking.dining_facility.dining_charge
|
||||||
|
block_count, dining_price = DiningCharge.amount_calculate(dining_charge, booking.checkin_at, booking.checkout_at)
|
||||||
|
format = "%I:%M %p" if dining_charge.charge_type == "hr"
|
||||||
|
format ||= "%B %d, %I:%M %p"
|
||||||
|
dining_time = "#{booking.checkin_at.strftime(format)} - #{booking.checkout_at.strftime(format)}"
|
||||||
|
|
||||||
|
sale.sale_items.build({
|
||||||
|
menu_category_name: "Dining Charge",
|
||||||
|
menu_category_code: "DiningCharge",
|
||||||
|
product_name: "#{booking.dining_facility.name} ( #{dining_time} )",
|
||||||
|
product_code: dining_charge.item_code,
|
||||||
|
product_alt_name: '-',
|
||||||
|
account_id: 0,
|
||||||
|
is_taxable: dining_charge.taxable,
|
||||||
|
qty: block_count,
|
||||||
|
unit_price: dining_charge.unit_price,
|
||||||
|
price: dining_price,
|
||||||
|
taxable_price: dining_price,
|
||||||
|
})
|
||||||
|
|
||||||
|
if in_duties_count.to_i > 0
|
||||||
|
basic_pay = Commission.find_by(commission_type: 'Basic Pay')
|
||||||
|
in_duties_pay_amount = (in_duties_count.to_i * ((booking.checkout_at - booking.checkin_at) / 1.hours) * basic_pay_amount).to_i
|
||||||
|
|
||||||
|
sale.sale_items.build({
|
||||||
|
menu_category_name: "Induty Charge",
|
||||||
|
menu_category_code: "IndutyCharge",
|
||||||
|
product_name: "#{basic_pay.name} ( #{dining_time} )",
|
||||||
|
product_code: "",
|
||||||
|
product_alt_name: '-',
|
||||||
|
account_id: 0,
|
||||||
|
is_taxable: dining_charge.taxable,
|
||||||
|
qty: in_duties_count,
|
||||||
|
unit_price: basic_pay.amount,
|
||||||
|
price: in_duties_pay_amount,
|
||||||
|
taxable_price: in_duties_pay_amount,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
sale.orders << booking.orders
|
||||||
|
sale.customer_id = booking.orders[0].customer_id
|
||||||
|
|
||||||
|
sale.compute(booking.orders[0].source)
|
||||||
|
|
||||||
|
booking.orders.update_all(status: "billed")
|
||||||
|
booking.order_items.update_all(order_item_status: "billed")
|
||||||
|
|
||||||
|
booking.checkout_at = current unless booking.checkout_at && booking.checkout_at > current
|
||||||
|
booking.checkout_by = requested_by.name
|
||||||
|
|
||||||
|
booking.save
|
||||||
|
return sale
|
||||||
end
|
end
|
||||||
self.orders << order
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#compute sales summary
|
|
||||||
if order_source.nil?
|
|
||||||
order_source = order.source
|
|
||||||
end
|
|
||||||
self.compute(order_source)
|
|
||||||
|
|
||||||
#Update the order items that is billed
|
|
||||||
order.update_items_status_to_billed(nil)
|
|
||||||
order.status = "billed"
|
|
||||||
order.save
|
|
||||||
|
|
||||||
if !booking.checkout_at.nil?
|
|
||||||
if booking.checkout_at.utc < Time.now.utc
|
|
||||||
booking.checkout_at = Time.now.utc.getlocal
|
|
||||||
end
|
|
||||||
else
|
|
||||||
booking.checkout_at = Time.now.utc.getlocal
|
|
||||||
end
|
|
||||||
|
|
||||||
booking.checkout_by = requested_by.name
|
|
||||||
booking.save
|
|
||||||
|
|
||||||
# InventoryJob.perform_now(self.id)
|
|
||||||
# saleObj = Sale.find(self.id)
|
|
||||||
# InventoryDefinition.calculate_product_count(saleObj)
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#fOR Quick Service pay and create
|
#fOR Quick Service pay and create
|
||||||
def self.request_bill(order,current_user,current_login_employee)
|
def self.request_bill(order, current_user, current_login_employee)
|
||||||
if !ShiftSale.current_shift.nil?
|
if !ShiftSale.current_shift.nil?
|
||||||
order_id = order.order_id # order_id
|
order_id = order.order_id # order_id
|
||||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
booking = order.booking
|
||||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
|
||||||
|
|
||||||
if @sale_data = check_booking.sale
|
if booking.sale.nil?
|
||||||
# Create Sale if it doesn't exist
|
sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source)
|
||||||
# puts "current_login_employee"
|
# Promotion Activation
|
||||||
# puts current_login_employee.name
|
Promotion.promo_activate(sale_data)
|
||||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
|
||||||
elsif @sale_data = Sale.generate_invoice_from_booking(check_booking,current_login_employee,current_user,order.source)
|
|
||||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bind shift sale id to sale
|
return true, sale_data
|
||||||
# @sale_data.shift_sale_id = shift.id
|
|
||||||
# @sale_data.save
|
|
||||||
|
|
||||||
# Promotion Activation
|
|
||||||
Promotion.promo_activate(@sale_data)
|
|
||||||
@status = true
|
|
||||||
return @status, @sale_data
|
|
||||||
else
|
else
|
||||||
@status = false
|
return false, "No Current Open Shift for This Employee"
|
||||||
@message = "No Current Open Shift for This Employee"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#This is when spilt bill is request - then we cannot link order to invoice
|
#This is when spilt bill is request - then we cannot link order to invoice
|
||||||
@@ -858,11 +788,15 @@ def self.daily_sales_list(from,to)
|
|||||||
|
|
||||||
daily_total = connection.select_all("SELECT
|
daily_total = connection.select_all("SELECT
|
||||||
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
|
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
|
||||||
|
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) - (IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0)) as total_sale,
|
||||||
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
|
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
|
||||||
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
|
IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount,
|
||||||
IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
|
IFNULL(SUM(case when (sale_status='completed') then amount_changed else 0 end),0) as total_change_amount,
|
||||||
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
|
IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount,
|
||||||
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj,
|
IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj,
|
||||||
|
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21 as tax,
|
||||||
|
(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0))-(IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) / 21) as net_sale,
|
||||||
|
SUM(grand_total + total_discount) as gross_sale,
|
||||||
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
CAST((CONVERT_TZ(receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
||||||
SUM(kbzpay_amount) as kbzpay_amount,
|
SUM(kbzpay_amount) as kbzpay_amount,
|
||||||
SUM(mpu_amount) as mpu_amount,
|
SUM(mpu_amount) as mpu_amount,
|
||||||
@@ -1126,7 +1060,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
|||||||
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_type,customer_id)
|
def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account_type, customer_id)
|
||||||
# date_type_selection = get_sql_function_for_report_type(report_type)
|
# date_type_selection = get_sql_function_for_report_type(report_type)
|
||||||
if account_type.blank?
|
if account_type.blank?
|
||||||
account_type = ''
|
account_type = ''
|
||||||
@@ -1138,8 +1072,6 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status,account_
|
|||||||
customer_id = customer_id.to_s
|
customer_id = customer_id.to_s
|
||||||
customer_id[0] = ""
|
customer_id[0] = ""
|
||||||
customer_id = customer_id.chomp("]")
|
customer_id = customer_id.chomp("]")
|
||||||
else
|
|
||||||
customer_id = '"CUS-000000000000"'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
query = self.get_staff_meal_query()
|
query = self.get_staff_meal_query()
|
||||||
@@ -1296,7 +1228,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
|
|||||||
.includes(:bookings => :dining_facility)
|
.includes(:bookings => :dining_facility)
|
||||||
.select("sales.*, SUM(sale_payments.payment_amount) AS payments_for_credits_amount")
|
.select("sales.*, SUM(sale_payments.payment_amount) AS payments_for_credits_amount")
|
||||||
.joins(:bookings)
|
.joins(:bookings)
|
||||||
.left_joins(:sale_payments_for_credits)
|
.left_joins(:payments_for_credits)
|
||||||
.completed
|
.completed
|
||||||
.where.not(total_amount: 0)
|
.where.not(total_amount: 0)
|
||||||
.group(:sale_id)
|
.group(:sale_id)
|
||||||
|
|||||||
@@ -280,6 +280,11 @@ class SaleItem < ApplicationRecord
|
|||||||
|
|
||||||
# Loader Service SFTP End
|
# Loader Service SFTP End
|
||||||
|
|
||||||
|
protected
|
||||||
|
def self.generate_ids(count = 1)
|
||||||
|
SeedGenerator.generate_ids(self.name, "SLI", count)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
if self.sale_item_id.nil?
|
if self.sale_item_id.nil?
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class SalePayment < ApplicationRecord
|
|||||||
return self.save
|
return self.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil,payment_for=false)
|
def process_payment(invoice, action_by, cash_amount, payment_method, remark=nil, payment_for=false)
|
||||||
self.sale = invoice
|
self.sale = invoice
|
||||||
self.received_amount = cash_amount
|
self.received_amount = cash_amount
|
||||||
self.payment_reference = remark
|
self.payment_reference = remark
|
||||||
@@ -87,13 +87,14 @@ class SalePayment < ApplicationRecord
|
|||||||
amount_due = amount_due - payment.payment_amount
|
amount_due = amount_due - payment.payment_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (amount_due > 0)
|
if (amount_due > 0)
|
||||||
payment_status = false
|
payment_status = false
|
||||||
membership_data = nil
|
membership_data = nil
|
||||||
#route to payment type
|
#route to payment type
|
||||||
case payment_method
|
case payment_method
|
||||||
when "cash"
|
when "cash"
|
||||||
payment_status ,outstanding_amount ,balance_amount = cash_payment(payment_for)
|
payment_status, outstanding_amount, balance_amount = cash_payment(payment_for)
|
||||||
when "creditnote"
|
when "creditnote"
|
||||||
if !self.sale.customer_id.nil?
|
if !self.sale.customer_id.nil?
|
||||||
payment_status = creditnote_payment(self.customer_id)
|
payment_status = creditnote_payment(self.customer_id)
|
||||||
@@ -157,7 +158,7 @@ class SalePayment < ApplicationRecord
|
|||||||
# update complete order items in oqs
|
# update complete order items in oqs
|
||||||
booking = Booking.find_by_sale_id(sale_id)
|
booking = Booking.find_by_sale_id(sale_id)
|
||||||
booking.booking_orders.each do |sodr|
|
booking.booking_orders.each do |sodr|
|
||||||
assigned =AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").pluck(:assigned_order_item_id)
|
assigned = AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").pluck(:assigned_order_item_id)
|
||||||
AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(delivery_status: true)
|
AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(delivery_status: true)
|
||||||
# AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
# AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||||
# aoi.delivery_status = 1
|
# aoi.delivery_status = 1
|
||||||
@@ -165,7 +166,7 @@ class SalePayment < ApplicationRecord
|
|||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
return true, self.save,membership_data, outstanding_amount ,balance_amount
|
return true, self.save, membership_data, outstanding_amount, balance_amount
|
||||||
else
|
else
|
||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
remark = "Payment failed - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
remark = "Payment failed - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
||||||
@@ -173,6 +174,7 @@ class SalePayment < ApplicationRecord
|
|||||||
return false, "Payment failed"
|
return false, "Payment failed"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
sale_update_payment_status(0)
|
||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]"
|
||||||
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by.name)
|
sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by.name)
|
||||||
@@ -640,85 +642,62 @@ class SalePayment < ApplicationRecord
|
|||||||
return payment_status
|
return payment_status
|
||||||
end
|
end
|
||||||
|
|
||||||
def sale_update_payment_status(paid_amount,check_foc = false)
|
def sale_update_payment_status(paid_amount, check_foc = false)
|
||||||
#update amount_outstanding
|
#update amount_outstanding
|
||||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
sale = self.sale
|
||||||
self.sale.save!
|
sale.amount_received = sale.amount_received.to_f + paid_amount.to_f
|
||||||
self.sale.amount_changed = self.sale.amount_received.to_f - self.sale.grand_total.to_f
|
sale.amount_changed = sale.amount_received.to_f - sale.grand_total.to_f
|
||||||
all_received_amount = 0.0
|
|
||||||
sObj = Sale.find(self.sale_id)
|
all_received_amount = sale.sale_payments.reload.sum(&:payment_amount)
|
||||||
is_credit = 0
|
|
||||||
is_foc = 0
|
is_credit = sale.sale_payments.any? { |x| x.payment_method == "creditnote" }
|
||||||
is_kbz_pay = 0
|
is_foc = sale.sale_payments.any? { |x| x.payment_method == "foc" }
|
||||||
method_status = false
|
|
||||||
sObj.sale_payments.each do |spay|
|
if (sale.grand_total <= all_received_amount)
|
||||||
all_received_amount += spay.payment_amount.to_f
|
if is_credit
|
||||||
if spay.payment_method == "creditnote"
|
sale.payment_status = "outstanding"
|
||||||
is_credit = 1
|
elsif is_foc
|
||||||
end
|
sale.payment_status = "foc"
|
||||||
if spay.payment_method == "foc"
|
|
||||||
is_foc = 1
|
|
||||||
end
|
|
||||||
if spay.payment_method == KbzPay::KBZ_PAY
|
|
||||||
is_kbz_pay = 1
|
|
||||||
end
|
|
||||||
if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote" || spay.payment_method == KbzPay::KBZ_PAY
|
|
||||||
method_status = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (self.sale.grand_total <= all_received_amount) && method_status
|
|
||||||
if is_credit == 0
|
|
||||||
self.sale.payment_status = "paid"
|
|
||||||
else
|
else
|
||||||
self.sale.payment_status = "outstanding"
|
sale.payment_status = "paid"
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_foc == 0
|
sale.sale_status = "completed"
|
||||||
self.sale.payment_status = "paid"
|
|
||||||
else
|
|
||||||
self.sale.payment_status = "foc"
|
|
||||||
end
|
|
||||||
|
|
||||||
if is_kbz_pay == 1
|
|
||||||
self.sale.payment_status = 'paid'
|
|
||||||
end
|
|
||||||
|
|
||||||
self.sale.sale_status = "completed"
|
|
||||||
|
|
||||||
if MembershipSetting.find_by_rebate(1) && is_foc == 0 && is_credit == 0
|
if MembershipSetting.find_by_rebate(1) && is_foc == 0 && is_credit == 0
|
||||||
response = rebat(sObj)
|
response = rebat(sale)
|
||||||
|
|
||||||
#record an payment in sale-audit
|
#record an payment in sale-audit
|
||||||
remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
remark = "#{response} Rebate- for Customer #{sale.customer_id} | Sale Id [#{sale.sale_id}]| pay amount -> #{self.received_amount} "
|
||||||
sale_audit = SaleAudit.record_paymal(sObj.sale_id, remark, 1)
|
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
|
||||||
|
|
||||||
if !response.nil?
|
if !response.nil?
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
self.sale.rebate_status = 'true'
|
sale.rebate_status = 'true'
|
||||||
end
|
end
|
||||||
if response["status"] == false
|
if response["status"] == false
|
||||||
self.sale.rebate_status = 'false'
|
sale.rebate_status = 'false'
|
||||||
end
|
end
|
||||||
|
|
||||||
if response[:status] == false
|
if response[:status] == false
|
||||||
self.sale.rebate_status = 'false'
|
sale.rebate_status = 'false'
|
||||||
end
|
end
|
||||||
if response[:status] == "no_member"
|
if response[:status] == "no_member"
|
||||||
self.sale.rebate_status = nil
|
sale.rebate_status = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.sale.save!
|
sale.save!
|
||||||
|
|
||||||
if check_foc
|
if check_foc
|
||||||
table_update_status(sObj)
|
table_update_status(sale)
|
||||||
update_shift
|
update_shift
|
||||||
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
|
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
|
||||||
table_update_status(sObj)
|
table_update_status(sale)
|
||||||
update_shift
|
update_shift
|
||||||
elsif method_status && paid_amount.to_f == 0 && is_credit == 0
|
elsif paid_amount.to_f == 0 && !is_credit
|
||||||
table_update_status(sObj)
|
table_update_status(sale)
|
||||||
update_shift
|
update_shift
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -778,32 +757,16 @@ class SalePayment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def table_update_status(sale_obj)
|
def table_update_status(sale_obj)
|
||||||
status = true
|
puts "Update staus 1"
|
||||||
sale_count = 0
|
if booking = sale_obj.booking
|
||||||
if booking = sale_obj.bookings[0]
|
puts "Update staus 2"
|
||||||
if booking.dining_facility_id.to_i > 0
|
if booking.dining_facility
|
||||||
|
puts "Update staus 3"
|
||||||
table = booking.dining_facility
|
table = booking.dining_facility
|
||||||
if Booking.left_joins(:sale).where(dining_facility_id: booking.dining_facility_id).where.not(booking_status: 'moved').where("sales.sale_status NOT IN ('completed', 'void', 'spoile', 'waste') OR sales.sale_status IS NULL").exists?
|
if !table.current_bookings.exists?
|
||||||
status = false
|
puts "Update staus 3"
|
||||||
|
table.update_attributes(status: "available")
|
||||||
end
|
end
|
||||||
|
|
||||||
if status
|
|
||||||
table.update_attributes(status: "available")
|
|
||||||
# table.status = "available"
|
|
||||||
# table.save
|
|
||||||
end
|
|
||||||
|
|
||||||
# type = 'payment'
|
|
||||||
#Send to background job for processing
|
|
||||||
# OrderBroadcastJob.perform_later(table,type)
|
|
||||||
#if ENV["SERVER_MODE"] != 'cloud'
|
|
||||||
# if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
# from = request.subdomain + "." + request.domain
|
|
||||||
# else
|
|
||||||
# from = ""
|
|
||||||
# end
|
|
||||||
# ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
|
||||||
#end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,28 +3,44 @@ class SeedGenerator < ApplicationRecord
|
|||||||
def self.generate_id(model, prefix)
|
def self.generate_id(model, prefix)
|
||||||
model_name = self.get_model_name(model)
|
model_name = self.get_model_name(model)
|
||||||
|
|
||||||
|
prefix ||= ''
|
||||||
|
prefix << '-' if prefix.present?
|
||||||
|
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
prefix = "C#{prefix}"
|
prefix << 'C'
|
||||||
|
else
|
||||||
|
prefix << 'L'
|
||||||
end
|
end
|
||||||
|
|
||||||
cur_val, next_val = self.update_seed(model_name)
|
if shop = Shop.current_shop
|
||||||
|
prefix << shop.shop_code
|
||||||
|
end
|
||||||
|
|
||||||
padding_len = 15 - prefix.length
|
seed = self.update_seed(model_name)
|
||||||
saleOrderId = prefix +"-"+ cur_val.to_s.to_s.rjust(padding_len,'0')
|
length = 15 - prefix.length
|
||||||
return saleOrderId
|
prefix + seed.to_s.rjust(length, '0')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.generate_ids(model, prefix, count = 1)
|
def self.generate_ids(model, prefix, count = 1)
|
||||||
model_name = self.get_model_name(model)
|
model_name = self.get_model_name(model)
|
||||||
|
|
||||||
|
prefix ||= ''
|
||||||
|
prefix << '-' if prefix.present?
|
||||||
|
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
prefix = "C#{prefix}"
|
prefix << 'C'
|
||||||
|
else
|
||||||
|
prefix << 'L'
|
||||||
|
end
|
||||||
|
|
||||||
|
if shop = Shop.current_shop
|
||||||
|
prefix << shop.shop_code
|
||||||
end
|
end
|
||||||
|
|
||||||
start = self.update_seed(model_name, count)
|
start = self.update_seed(model_name, count)
|
||||||
stop = start + count - 1
|
stop = start + count - 1
|
||||||
length = 15 - prefix.length
|
length = 15 - prefix.length
|
||||||
(start..stop).map { |c| "#{prefix}-#{c.to_s.rjust(length, '0')}" }
|
(start..stop).map { |c| prefix + c.to_s.rjust(length, '0') }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.sync_seed_generator_records(seed_generators)
|
def self.sync_seed_generator_records(seed_generators)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ShiftSale < ApplicationRecord
|
|||||||
|
|
||||||
def self.current_shift
|
def self.current_shift
|
||||||
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||||
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null").first
|
shift = ShiftSale.where.not(shift_started_at: nil).where(shift_closed_at: nil).first
|
||||||
return shift
|
return shift
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class TaxProfile < ApplicationRecord
|
class TaxProfile < ApplicationRecord
|
||||||
|
has_one :lookup, -> { where(lookup_type: 'tax_profiles') }, foreign_key: "value", primary_key: "group_type"
|
||||||
|
|
||||||
default_scope { order('order_by asc') }
|
default_scope { order('order_by asc') }
|
||||||
# validations
|
# validations
|
||||||
validates_presence_of :name, :rate, :group_type
|
validates_presence_of :name, :rate, :group_type
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class OrderSummaryPdf < Prawn::Document
|
class OrderSummaryPdf < Prawn::Document
|
||||||
include NumberFormattable
|
include NumberFormattable
|
||||||
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
|
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, print_status, order_items = nil,alt_name,before_updated_qty)
|
def initialize(print_settings, order, print_status, order_items = nil, alt_name, before_updated_qty)
|
||||||
self.page_width = print_settings.page_width
|
self.page_width = print_settings.page_width
|
||||||
self.page_height = print_settings.page_height
|
self.page_height = print_settings.page_height
|
||||||
self.header_font_size = print_settings.header_font_size.to_i
|
self.header_font_size = print_settings.header_font_size.to_i
|
||||||
|
|||||||
@@ -6,21 +6,21 @@ if item.is_available
|
|||||||
attr_format = []
|
attr_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
if item.item_attributes.count > 0
|
if item.item_attributes.count > 0
|
||||||
item_attributes = @item_attributes.select{ |x| item.item_attributes.include?(x.id.to_s) }
|
item_attributes = item.item_attributes.map(&:to_s)
|
||||||
attr_format = item_attributes.group_by {|att| att.attribute_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
attr_format = @item_attributes.select { |x| item_attributes.include?(x.id.to_s) }.group_by {|att| att.attribute_type.strip }.map { |type, values| {type: type, values: values.map { |x| x.name.strip } } }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Format for option json
|
# Format for option json
|
||||||
opt_format = []
|
opt_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
if item.item_options.count > 0
|
if item.item_options.count > 0
|
||||||
item_options = @item_options.select{ |x| item.item_options.include?(x.id.to_s) }
|
item_options = item.item_options.map(&:to_s)
|
||||||
opt_format = item_options.group_by {|opt| opt.option_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
opt_format = @item_options.select { |x| item_options.include?(x.id.to_s) }.group_by {|opt| opt.option_type.strip }.map { |type, values| {type: type, values: values.map { |x| x.name.strip } } }
|
||||||
end
|
end
|
||||||
|
|
||||||
#Menu Item Information
|
#Menu Item Information
|
||||||
json.id item.id
|
json.id item.id
|
||||||
json.code item.item_code
|
json.code item.item_code
|
||||||
json.name item.name
|
json.name item.name
|
||||||
json.alt_name item.alt_name
|
json.alt_name item.alt_name
|
||||||
if !request_url.nil? && request_url != '' && !item.image_path.nil?
|
if !request_url.nil? && request_url != '' && !item.image_path.nil?
|
||||||
@@ -44,7 +44,7 @@ if item.is_available
|
|||||||
json.alt_name its.alt_name
|
json.alt_name its.alt_name
|
||||||
json.min_selectable_qty its.min_selectable_qty
|
json.min_selectable_qty its.min_selectable_qty
|
||||||
json.max_selectable_qty its.max_selectable_qty
|
json.max_selectable_qty its.max_selectable_qty
|
||||||
json.instances its.menu_item_instances.map { |i| {id: i.id} }
|
json.instances its.menu_item_instances.map { |i| {id: i.id} }
|
||||||
end
|
end
|
||||||
|
|
||||||
json.attributes attr_format
|
json.attributes attr_format
|
||||||
@@ -64,7 +64,8 @@ if item.is_available
|
|||||||
json.instances item.menu_item_instances do |is|
|
json.instances item.menu_item_instances do |is|
|
||||||
if is.is_available
|
if is.is_available
|
||||||
# Convert id to name for attributes
|
# Convert id to name for attributes
|
||||||
instance_attr = @item_attributes.select{ |x| item.item_attributes.include?(x.id) }.pluck(:name)
|
item_attributes = is.item_attributes.map(&:to_s)
|
||||||
|
instance_attr = @item_attributes.select{ |x| item_attributes.include?(x.id.to_s) }.pluck(:name)
|
||||||
|
|
||||||
json.id is.id
|
json.id is.id
|
||||||
json.code is.item_instance_code
|
json.code is.item_instance_code
|
||||||
|
|||||||
@@ -31,15 +31,13 @@ json.is_sub_item item.is_sub_item
|
|||||||
json.unit item.unit
|
json.unit item.unit
|
||||||
|
|
||||||
# Item Sets of Menu Item
|
# Item Sets of Menu Item
|
||||||
json.item_sets item.item_sets.includes(:menu_item_instances) do |its|
|
json.item_sets item.item_sets do |its|
|
||||||
json.id its.id
|
json.id its.id
|
||||||
json.name its.name
|
json.name its.name
|
||||||
json.alt_name its.alt_name
|
json.alt_name its.alt_name
|
||||||
json.min_selectable_qty its.min_selectable_qty
|
json.min_selectable_qty its.min_selectable_qty
|
||||||
json.max_selectable_qty its.max_selectable_qty
|
json.max_selectable_qty its.max_selectable_qty
|
||||||
json.instances its.menu_item_instances do |i|
|
json.instances its.menu_item_instances.map { |i| {id: i.id} }
|
||||||
json.id i.id
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
json.attributes attr_format
|
json.attributes attr_format
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="type" id="role" value="<%= current_user.role%>">
|
<input type="hidden" name="type" id="role" value="<%= current_user.role%>">
|
||||||
<input type="hidden" name="cashier_type" id="cashier_type" value="<%= type%>">
|
<input type="hidden" name="cashier_type" id="cashier_type" value="<%= type%>">
|
||||||
|
<input type="hidden" name="inclusive_tax" id="inclusive_tax" value="<%= @inclusive_tax%>">
|
||||||
|
<input type="hidden" name="exclusive_tax" id="exclusive_tax" value="<%= @exclusive_tax%>">
|
||||||
<input type="hidden" name="link_type" id="link_type" value="<%= @cashier_type %>">
|
<input type="hidden" name="link_type" id="link_type" value="<%= @cashier_type %>">
|
||||||
<input type="hidden" name="display_type" id="display_type" value="<%= @display_type%>">
|
<input type="hidden" name="display_type" id="display_type" value="<%= @display_type%>">
|
||||||
<div class="row m-t--20">
|
<div class="row m-t--20">
|
||||||
@@ -259,19 +261,28 @@
|
|||||||
<div class="card-footer custom-card-footer" style="padding: 0.35rem 0.15rem !important;">
|
<div class="card-footer custom-card-footer" style="padding: 0.35rem 0.15rem !important;">
|
||||||
|
|
||||||
<table class="table" id="order-charges-table" border="0">
|
<table class="table" id="order-charges-table" border="0">
|
||||||
<tr>
|
<%if @cashier_type=='quick_service' %>
|
||||||
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td>
|
<tr>
|
||||||
|
<td colspan="3" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Tax:</strong></td>
|
||||||
|
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="total_tax">0.00</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total + tax:</strong></td>
|
||||||
|
<% else %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td>
|
||||||
|
<% end %>
|
||||||
<td style="padding:2px;" width="15%"><strong id="total_qty">0</strong></td>
|
<td style="padding:2px;" width="15%"><strong id="total_qty">0</strong></td>
|
||||||
|
|
||||||
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total">0.00</strong></td>
|
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total">0.00</strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<% if type && modify_order%>
|
<% if type && modify_order%>
|
||||||
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
|
<input type="hidden" name="customer_id" id="customer_id" value="<%= walkin.customer_id %>">
|
||||||
|
|
||||||
<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>
|
<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%>
|
<%elsif !modify_order && type%>
|
||||||
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
|
<input type="hidden" name="customer_id" id="customer_id" value="<%= walkin.customer_id %>">
|
||||||
<% if current_user.role != "waiter"%>
|
<% if current_user.role != "waiter"%>
|
||||||
|
|
||||||
<% if @quick_service_only %>
|
<% if @quick_service_only %>
|
||||||
@@ -794,6 +805,8 @@
|
|||||||
$(document).on('click', '#clear_all', function(event){
|
$(document).on('click', '#clear_all', function(event){
|
||||||
$(".summary-items tbody").empty();
|
$(".summary-items tbody").empty();
|
||||||
$('#sub_total').text("0.00");
|
$('#sub_total').text("0.00");
|
||||||
|
$('#total_qty').text("0");
|
||||||
|
$('#total_tax').text("0");
|
||||||
$(".create").attr("disabled","disabled");
|
$(".create").attr("disabled","disabled");
|
||||||
customer_display_view(null,"reload");
|
customer_display_view(null,"reload");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<div class="input-append col-md-7 form-group pull-left">
|
<div class="input-append col-md-7 form-group pull-left">
|
||||||
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-9">
|
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-9">
|
||||||
<input type="hidden" name="type" id="type" value="">
|
<input type="hidden" name="type" id="type" value="">
|
||||||
<button type="submit" class="btn btn-primary btn-sm">Search</button>
|
<button type="submit" class="btn btn-primary btn-sm">Search</button>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<button id="member_acc_no" class="btn btn-success btn-sm"><span class="fa fa-credit-card"></span> Member Card</button> -->
|
<button id="member_acc_no" class="btn btn-success btn-sm"><span class="fa fa-credit-card"></span> Member Card</button> -->
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% if @crm_customers.count > 0 %>
|
<% if @crm_customers.count > 0 %>
|
||||||
<% @i = 0 %>
|
<% @i = 0 %>
|
||||||
<% @crm_customers.each do |crm_customer| %>
|
<% @crm_customers.each do |crm_customer| %>
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
|
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
|
||||||
<td>
|
<td>
|
||||||
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
|
<% if crm_customer.customer_id != "" && crm_customer.customer_id != "" %>
|
||||||
<%= @i += 1 %>
|
<%= @i += 1 %>
|
||||||
<%else%>
|
<%else%>
|
||||||
-
|
-
|
||||||
@@ -156,7 +156,7 @@
|
|||||||
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
||||||
<span class="patch_method"></span>
|
<span class="patch_method"></span>
|
||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane active" role="tabpanel" id="step1">
|
<div class="tab-pane active" role="tabpanel" id="step1">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -225,7 +225,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-12 col-md-12 col-lg-12" align="right">
|
<div class="col-sm-12 col-md-12 col-lg-12" align="right">
|
||||||
<button type="button" class="btn btn-md bg-blue btn-info-full next-step">Next</button>
|
<button type="button" class="btn btn-md bg-blue btn-info-full next-step">Next</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- .end-of-step1 -->
|
</div> <!-- .end-of-step1 -->
|
||||||
<div class="tab-pane" role="tabpanel" id="complete">
|
<div class="tab-pane" role="tabpanel" id="complete">
|
||||||
@@ -238,12 +238,12 @@
|
|||||||
<% if f.object.image_path? %>
|
<% if f.object.image_path? %>
|
||||||
<p><%= f.object.name %></p>
|
<p><%= f.object.name %></p>
|
||||||
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
|
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
|
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<%= f.file_field :image_path, :class => "img-thumbnail" %>
|
<%= f.file_field :image_path, :class => "img-thumbnail" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -291,7 +291,7 @@
|
|||||||
<option value="<%= ct.value %>">
|
<option value="<%= ct.value %>">
|
||||||
<%= ct.name %></option>
|
<%= ct.name %></option>
|
||||||
<%end %>
|
<%end %>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-12 col-md-12 col-lg-12">
|
<div class="col-sm-12 col-md-12 col-lg-12">
|
||||||
<label class="control-label"><%= t("views.right_panel.detail.paypar_account_no") %>:</label>
|
<label class="control-label"><%= t("views.right_panel.detail.paypar_account_no") %>:</label>
|
||||||
<div class="-group">
|
<div class="-group">
|
||||||
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
|
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
|
||||||
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
|
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -332,7 +332,7 @@
|
|||||||
<option value="<%= member.value %>">
|
<option value="<%= member.value %>">
|
||||||
<%= member.name %></option>
|
<%= member.name %></option>
|
||||||
<%end %>
|
<%end %>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -363,7 +363,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var cashier_type = "<%= @cashier_type %>";
|
var cashier_type = "<%= @cashier_type %>";
|
||||||
var page = "<%= @page %>";
|
var page = "<%= @page %>";
|
||||||
var paypar_account_no = [];
|
var paypar_account_no = [];
|
||||||
$(function() {
|
$(function() {
|
||||||
paypar_account_no = JSON.parse('<%= @paypar_accountno.to_json.html_safe %>', function (key, value) {
|
paypar_account_no = JSON.parse('<%= @paypar_accountno.to_json.html_safe %>', function (key, value) {
|
||||||
@@ -391,14 +391,14 @@
|
|||||||
$('.datepicker').css('cursor','pointer');*/
|
$('.datepicker').css('cursor','pointer');*/
|
||||||
|
|
||||||
// Read Card Reader
|
// Read Card Reader
|
||||||
$("#paypar_account_no").on('focus', function(e){
|
$("#paypar_account_no").on('focus', function(e){
|
||||||
if($(this).val() == ''){
|
if($(this).val() == ''){
|
||||||
$("#sxModal").show();
|
$("#sxModal").show();
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
getCardNo();
|
getCardNo();
|
||||||
$("#sxModal").hide();
|
$("#sxModal").hide();
|
||||||
},100);
|
},100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
@@ -406,20 +406,20 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
// Read Card Reader
|
// Read Card Reader
|
||||||
$("#member_acc_no").on('click', function(e){
|
$("#member_acc_no").on('click', function(e){
|
||||||
localStorage.setItem("member_card",true);
|
localStorage.setItem("member_card",true);
|
||||||
var cardNo = "";
|
var cardNo = "";
|
||||||
var customer_id = '';
|
var customer_id = '';
|
||||||
var customer_name = '';
|
var customer_name = '';
|
||||||
var sale_id = $("#sale_id").val() || 0;
|
var sale_id = $("#sale_id").val() || 0;
|
||||||
var customer_mamber_card_no = 0;
|
var customer_mamber_card_no = 0;
|
||||||
$("#sxModal").show();
|
$("#sxModal").show();
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
getCardNo();
|
getCardNo();
|
||||||
$("#sxModal").hide();
|
$("#sxModal").hide();
|
||||||
customer_mamber_card_no = $("#search").val();
|
customer_mamber_card_no = $("#search").val();
|
||||||
|
|
||||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/origami/"+sale_id+"/get_customer" ,
|
url: "/origami/"+sale_id+"/get_customer" ,
|
||||||
@@ -442,7 +442,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},100);
|
},100);
|
||||||
});
|
});
|
||||||
@@ -450,12 +450,12 @@
|
|||||||
/*new customer UI func:*/
|
/*new customer UI func:*/
|
||||||
//Initialize tooltips
|
//Initialize tooltips
|
||||||
$('.nav-tabs > li a[title]').tooltip();
|
$('.nav-tabs > li a[title]').tooltip();
|
||||||
|
|
||||||
//Wizard
|
//Wizard
|
||||||
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
|
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
|
||||||
|
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
|
|
||||||
if ($target.parent().hasClass('disabled')) {
|
if ($target.parent().hasClass('disabled')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -522,21 +522,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// QR Code Reader
|
// QR Code Reader
|
||||||
$("#qr_code").on('click', function(e){
|
$("#qr_code").on('click', function(e){
|
||||||
var code = "";
|
var code = "";
|
||||||
var customer_id = '';
|
var customer_id = '';
|
||||||
var customer_name = '';
|
var customer_name = '';
|
||||||
var sale_id = $("#sale_id").val() || 0;
|
var sale_id = $("#sale_id").val() || 0;
|
||||||
var customer_mamber_card_no = 0;
|
var customer_mamber_card_no = 0;
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
code=getQRCode();
|
code=getQRCode();
|
||||||
setQRCode(code);
|
setQRCode(code);
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
customer_mamber_card_no = $("#search").val();
|
customer_mamber_card_no = $("#search").val();
|
||||||
|
|
||||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/origami/"+sale_id+"/get_customer" ,
|
url: "/origami/"+sale_id+"/get_customer" ,
|
||||||
@@ -558,8 +558,8 @@
|
|||||||
update_sale(customer_id, customer_name,sale_id);
|
update_sale(customer_id, customer_name,sale_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Read qrcode from java
|
// Read qrcode from java
|
||||||
@@ -595,12 +595,12 @@
|
|||||||
data: {},
|
data: {},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var taxes = JSON.stringify(data.tax_profiles);
|
var taxes = JSON.stringify(data.tax_profiles);
|
||||||
var parse_taxes = JSON.parse(taxes);
|
var parse_taxes = JSON.parse(taxes);
|
||||||
$.each(parse_taxes, function(i, value){
|
$.each(parse_taxes, function(i, value){
|
||||||
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected");
|
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected");
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#customer_id').val(data.id);
|
$('#customer_id').val(data.id);
|
||||||
$('#customer_name').val(data.name);
|
$('#customer_name').val(data.name);
|
||||||
$('#customer_company').val(data.company);
|
$('#customer_company').val(data.company);
|
||||||
@@ -701,7 +701,7 @@
|
|||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,9 +724,9 @@
|
|||||||
window.location.href = '/origami/room/'+id;
|
window.location.href = '/origami/room/'+id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#sxModal .btn_cancel").on('click',function(){
|
$("#sxModal .btn_cancel").on('click',function(){
|
||||||
@@ -734,4 +734,3 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -41,21 +41,21 @@ if (menu.menu_categories)
|
|||||||
attr_format = []
|
attr_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
if item.item_attributes.count > 0
|
if item.item_attributes.count > 0
|
||||||
item_attributes = @item_attributes.select{ |x| item.item_attributes.include?(x.id.to_s) }
|
item_attributes = item.item_attributes.map(&:to_s)
|
||||||
attr_format = item_attributes.group_by {|att| att.attribute_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
attr_format = @item_attributes.select { |x| item_attributes.include?(x.id.to_s) }.group_by {|att| att.attribute_type.strip }.map { |type, values| {type: type, values: values.map { |x| x.name.strip } } }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Format for option json
|
# Format for option json
|
||||||
opt_format = []
|
opt_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
if item.item_options.count > 0
|
if item.item_options.count > 0
|
||||||
item_options = @item_options.select{ |x| item.item_options.include?(x.id.to_s) }
|
item_options = item.item_options.map(&:to_s)
|
||||||
opt_format = item_options.group_by {|opt| opt.option_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
opt_format = @item_options.select { |x| item_options.include?(x.id.to_s) }.group_by {|opt| opt.option_type.strip }.map { |type, values| {type: type, values: values.map { |x| x.name.strip } } }
|
||||||
end
|
end
|
||||||
|
|
||||||
#Menu Item Information
|
#Menu Item Information
|
||||||
json.id item.id
|
json.id item.id
|
||||||
json.code item.item_code
|
json.code item.item_code
|
||||||
json.name item.name
|
json.name item.name
|
||||||
json.alt_name item.alt_name
|
json.alt_name item.alt_name
|
||||||
json.image item.image_path.url
|
json.image item.image_path.url
|
||||||
@@ -69,15 +69,14 @@ if (menu.menu_categories)
|
|||||||
json.unit item.unit
|
json.unit item.unit
|
||||||
|
|
||||||
# Item Sets of Menu Item
|
# Item Sets of Menu Item
|
||||||
json.item_sets item.item_sets.map { |its|
|
json.item_sets item.item_sets do |its|
|
||||||
{ id: its.id,
|
json.id its.id
|
||||||
name: its.name,
|
json.name its.name
|
||||||
alt_name: its.alt_name,
|
json.alt_name its.alt_name
|
||||||
min_selectable_qty: its.min_selectable_qty,
|
json.min_selectable_qty its.min_selectable_qty
|
||||||
max_selectable_qty: its.max_selectable_qty,
|
json.max_selectable_qty its.max_selectable_qty
|
||||||
instances: its.menu_item_instances.map { |i| {id: i.id} }
|
json.instances its.menu_item_instances.map { |i| {id: i.id} }
|
||||||
}
|
end
|
||||||
}
|
|
||||||
|
|
||||||
json.attributes attr_format
|
json.attributes attr_format
|
||||||
json.options opt_format
|
json.options opt_format
|
||||||
@@ -85,7 +84,8 @@ if (menu.menu_categories)
|
|||||||
json.instances item.menu_item_instances do |is|
|
json.instances item.menu_item_instances do |is|
|
||||||
if is.is_available
|
if is.is_available
|
||||||
# Convert id to name for attributes
|
# Convert id to name for attributes
|
||||||
instance_attr = @item_attributes.select{ |x| item.item_attributes.include?(x.id) }.pluck(:name)
|
item_attributes = is.item_attributes.map(&:to_s)
|
||||||
|
instance_attr = @item_attributes.select{ |x| item_attributes.include?(x.id.to_s) }.pluck(:name)
|
||||||
|
|
||||||
json.id is.id
|
json.id is.id
|
||||||
json.code is.item_instance_code
|
json.code is.item_instance_code
|
||||||
|
|||||||
@@ -1686,9 +1686,8 @@ $(document).ready(function(){
|
|||||||
$("#customer_name").on("click",function(){
|
$("#customer_name").on("click",function(){
|
||||||
//start customer modal popup
|
//start customer modal popup
|
||||||
if((cashier_type=='quick_service' || cashier_type=='food_court') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){
|
if((cashier_type=='quick_service' || cashier_type=='food_court') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){
|
||||||
// if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
|
|
||||||
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
|
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<% alph = "A" %>
|
<% alph = "A" %>
|
||||||
|
|
||||||
<% slice.each do |payment_method| %>
|
<% slice.each do |payment_method| %>
|
||||||
<th style="text-align:center;">
|
<th style="text-align:center;">
|
||||||
<%= alph %>
|
<%= alph %>
|
||||||
@@ -122,7 +122,12 @@
|
|||||||
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
|
<th style='text-align:center;'>(<%= t("views.right_panel.detail.discount") %>)</th>
|
||||||
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
|
<!-- <th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %> + <br/> <%= t("views.right_panel.detail.rnd_adj_sh") %></th> -->
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.rnd_adj_sh") %></th>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.grand_total") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.gross_sales") %></th>
|
||||||
|
<th style='text-align:center;'><%= t("views.right_panel.detail.total_sales") %></th>
|
||||||
|
<% if @tax.blank? %>
|
||||||
|
<th style='text-align:center;'><%= t("views.right_panel.detail.tax") %></th>
|
||||||
|
<% end %>
|
||||||
|
<th style='text-align:center;'><%= t("views.right_panel.detail.net_sales") %></th>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -148,6 +153,10 @@
|
|||||||
<% total = 0 %>
|
<% total = 0 %>
|
||||||
<% grand_total = 0 %>
|
<% grand_total = 0 %>
|
||||||
<% old_grand_total = 0 %>
|
<% old_grand_total = 0 %>
|
||||||
|
<% gross_sale = 0 %>
|
||||||
|
<% total_sale = 0 %>
|
||||||
|
<% tax = 0 %>
|
||||||
|
<% net_sale = 0 %>
|
||||||
<% count = 1 %> <% rounding_adj = 0 %>
|
<% count = 1 %> <% rounding_adj = 0 %>
|
||||||
<% @sale_data.each do |sale| %>
|
<% @sale_data.each do |sale| %>
|
||||||
<% void += sale[:void_amount] %>
|
<% void += sale[:void_amount] %>
|
||||||
@@ -171,6 +180,10 @@
|
|||||||
<% grand_total += sale[:grand_total].to_f %>
|
<% grand_total += sale[:grand_total].to_f %>
|
||||||
<% old_grand_total += sale[:old_grand_total].to_f %>
|
<% old_grand_total += sale[:old_grand_total].to_f %>
|
||||||
<% rounding_adj += sale[:rounding_adj].to_f %>
|
<% rounding_adj += sale[:rounding_adj].to_f %>
|
||||||
|
<% gross_sale += sale[:gross_sale].to_f %>
|
||||||
|
<% total_sale += sale[:total_sale].to_f %>
|
||||||
|
<% tax += sale[:tax].to_f %>
|
||||||
|
<% net_sale += sale[:net_sale].to_f %>
|
||||||
<tr>
|
<tr>
|
||||||
<td style='text-align:right;'><%= count %></td>
|
<td style='text-align:right;'><%= count %></td>
|
||||||
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
|
||||||
@@ -218,7 +231,12 @@
|
|||||||
<td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
|
<td style='text-align:right;'>(<%= number_format(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)</td>
|
||||||
<!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
|
<!-- <td style='text-align:right;'><%= number_format(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td> -->
|
||||||
<td style='text-align:right;'><%= number_format(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_format(sale[:rounding_adj].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_format(sale[:grand_total], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_format(sale[:gross_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_format(sale[:total_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<% if @tax.blank? %>
|
||||||
|
<td style='text-align:right;'><%= number_format(sale[:tax], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<% end %>
|
||||||
|
<td style='text-align:right;'><%= number_format(sale[:net_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<% count = count + 1 %>
|
<% count = count + 1 %>
|
||||||
@@ -303,7 +321,10 @@
|
|||||||
|
|
||||||
<td style='text-align:right;'>(<%= number_format(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td>
|
<td style='text-align:right;'>(<%= number_format(discount, precision:precision.to_i,delimiter:delimiter) rescue '-'%>)</td>
|
||||||
<td style='text-align:right;'><%= number_format(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_format(rounding_adj, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_format(grand_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;'><%= number_format(gross_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_format(total_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_format(tax, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
@@ -319,15 +340,19 @@
|
|||||||
<td colspan="2" style='text-align:right;'><%= number_format(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td colspan="2" style='text-align:right;'><%= number_format(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% net = grand_total %>
|
||||||
|
<% net = net - rounding_adj%>
|
||||||
<% net = grand_total %>
|
<% net = net - total_tax %>
|
||||||
<% net = net - rounding_adj%>
|
<tr style="font-weight:600;">
|
||||||
<% net = net - total_tax %>
|
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||||
|
<td colspan="5" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<% else %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||||
<td colspan="2" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td colspan="5" style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<%= f.input :seater %>
|
<%= f.input :seater %>
|
||||||
<%= f.input :order_by %>
|
<%= f.input :order_by %>
|
||||||
<%= f.input :is_active %>
|
<%= f.input :is_active %>
|
||||||
<% if @settings_room.dining_charges.length == 0 %>
|
<% if @settings_room.dining_charge.nil? %>
|
||||||
<% if @settings_room.id != nil %>
|
<% if @settings_room.id != nil %>
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="">
|
<div class="">
|
||||||
@@ -20,33 +20,31 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% @settings_room.dining_charges.each do |dc| %>
|
<% dc = @settings_room.dining_charge %>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="col-md-">
|
<div class="col-md-">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr><td colspan="2">
|
<tr><td colspan="2">
|
||||||
<div class="col-md-10"><b><u>Dining Charge</u></b></div></td>
|
<div class="col-md-10"><b><u>Dining Charge</u></b></div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="align-right">Item code :</td>
|
<td class="align-right">Item code :</td>
|
||||||
<td class="align-left"><%= dc.item_code %></td>
|
<td class="align-left"><%= dc.item_code %></td>
|
||||||
<td class="align-right">Unit price : </td>
|
<td class="align-right">Unit price : </td>
|
||||||
<td class="align-left"><%= dc.unit_price %></td>
|
<td class="align-left"><%= dc.unit_price %></td>
|
||||||
<td class="align-right">Charge type : </td>
|
<td class="align-right">Charge type : </td>
|
||||||
<td class="align-left"><%= dc.charge_type %></td>
|
<td class="align-left"><%= dc.charge_type %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to 'Edit Charges', edit_settings_zone_room_dining_charge_path(@zone,@settings_room,dc),:class => 'btn bg-deep-purple' %>
|
<%= link_to 'Edit Charges', edit_settings_zone_room_dining_charge_path(@zone,@settings_room,dc),:class => 'btn bg-deep-purple' %>
|
||||||
<!-- <button class="btn btn-primary" src="<%= edit_settings_zone_room_dining_charge_path(@zone,@settings_room,dc) %>">Edit Charge</button> -->
|
<!-- <button class="btn btn-primary" src="<%= edit_settings_zone_room_dining_charge_path(@zone,@settings_room,dc) %>">Edit Charge</button> -->
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -62,7 +60,7 @@
|
|||||||
<div class="body">
|
<div class="body">
|
||||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
||||||
<p>
|
<p>
|
||||||
1) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.room_txt") %> <%= t("views.right_panel.detail.name_txt2") %> <br>
|
1) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.room_txt") %> <%= t("views.right_panel.detail.name_txt2") %> <br>
|
||||||
2) <%= t("views.right_panel.detail.status") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.status_txt") %> <br>
|
2) <%= t("views.right_panel.detail.status") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.status_txt") %> <br>
|
||||||
3) <%= t("views.right_panel.detail.seater") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.seat_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.room_txt") %> <br>
|
3) <%= t("views.right_panel.detail.seater") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.seat_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.room_txt") %> <br>
|
||||||
4) <%= t("views.right_panel.detail.order_by") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.order_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.room_txt") %> <br>
|
4) <%= t("views.right_panel.detail.order_by") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.order_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.room_txt") %> <br>
|
||||||
@@ -78,7 +76,6 @@
|
|||||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.zone_txt") %> <%= t("views.right_panel.detail.detail_txt") %> <br>
|
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.zone_txt") %> <%= t("views.right_panel.detail.detail_txt") %> <br>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -11,14 +11,14 @@
|
|||||||
<%= f.input :seater %>
|
<%= f.input :seater %>
|
||||||
<%= f.input :order_by %>
|
<%= f.input :order_by %>
|
||||||
<%= f.input :is_active %>
|
<%= f.input :is_active %>
|
||||||
<% if @settings_table.dining_charges.length == 0 %>
|
<% if @settings_table.dining_charge.nil? %>
|
||||||
<% if @settings_table.id != nil %>
|
<% if @settings_table.id != nil %>
|
||||||
<div class="col-md-">
|
<div class="col-md-">
|
||||||
<%= link_to 'Add For Extra Charges', new_settings_zone_table_dining_charge_path(@zone,@settings_table),:class => 'btn bg-deep-purple' %>
|
<%= link_to 'Add For Extra Charges', new_settings_zone_table_dining_charge_path(@zone,@settings_table),:class => 'btn bg-deep-purple' %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% @settings_table.dining_charges.each do |dc| %>
|
<% dc = @settings_table.dining_charge %>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<span class="card-title"><b><u>Dining Charge</u></b></span>
|
<span class="card-title"><b><u>Dining Charge</u></b></span>
|
||||||
@@ -48,7 +48,6 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@
|
|||||||
<div class="body">
|
<div class="body">
|
||||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
||||||
<p>
|
<p>
|
||||||
1) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.table_txt") %> <%= t("views.right_panel.detail.name_txt2") %> <br>
|
1) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.table_txt") %> <%= t("views.right_panel.detail.name_txt2") %> <br>
|
||||||
2) <%= t("views.right_panel.detail.status") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.status_txt") %> <br>
|
2) <%= t("views.right_panel.detail.status") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.status_txt") %> <br>
|
||||||
3) <%= t("views.right_panel.detail.seater") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.seat_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.table_txt") %> <br>
|
3) <%= t("views.right_panel.detail.seater") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.seat_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.table_txt") %> <br>
|
||||||
4) <%= t("views.right_panel.detail.order_by") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.order_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.table_txt") %> <br>
|
4) <%= t("views.right_panel.detail.order_by") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.order_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.table_txt") %> <br>
|
||||||
@@ -81,8 +80,6 @@
|
|||||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.zone_txt") %> <br>
|
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.zone_txt") %> <br>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,43 +53,42 @@
|
|||||||
|
|
||||||
<span class="hidden" id="delete_text">
|
<span class="hidden" id="delete_text">
|
||||||
<h6>Are you sure you want to delete this row ?</h6>
|
<h6>Are you sure you want to delete this row ?</h6>
|
||||||
<h6>This action can't be undo. </h6>
|
<h6>This action can't be undo. </h6>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<% @table.dining_charges.each do |dc| %>
|
<% dc = @table.dining_charge %>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<h4 class="card-title">Dining Charge</h4>
|
<h4 class="card-title">Dining Charge</h4>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<th>Item Code</th>
|
<th>Item Code</th>
|
||||||
<th>Unit Price</th>
|
<th>Unit Price</th>
|
||||||
<th>Charge Type</th>
|
<th>Charge Type</th>
|
||||||
<th>Free Time</th>
|
<th>Free Time</th>
|
||||||
<th>Charges Block</th>
|
<th>Charges Block</th>
|
||||||
<th>Time Rounding</th>
|
<th>Time Rounding</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= dc.item_code %></td>
|
<td><%= dc.item_code %></td>
|
||||||
<td><%= dc.unit_price %></td>
|
<td><%= dc.unit_price %></td>
|
||||||
<td><%= dc.charge_type %></td>
|
<td><%= dc.charge_type %></td>
|
||||||
<td><%= (dc.minimum_free_time).utc.strftime("%H:%M") %></td>
|
<td><%= (dc.minimum_free_time).utc.strftime("%H:%M") %></td>
|
||||||
<td><%= (dc.charge_block).utc.strftime("%H:%M") %></td>
|
<td><%= (dc.charge_block).utc.strftime("%H:%M") %></td>
|
||||||
<td><%= dc.time_rounding %></td>
|
<td><%= dc.time_rounding %></td>
|
||||||
<td><%= link_to 'Edit Charges', edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc),:class => 'btn bg-deep-purple' %>
|
<td><%= link_to 'Edit Charges', edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc),:class => 'btn bg-deep-purple' %>
|
||||||
<!-- <button class="btn btn-primary" src="<%= edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc) %>">Edit Charge</button> -->
|
<!-- <button class="btn btn-primary" src="<%= edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc) %>">Edit Charge</button> -->
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -98,7 +97,7 @@
|
|||||||
<div class="body">
|
<div class="body">
|
||||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
|
||||||
<p>
|
<p>
|
||||||
1) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.table_txt") %> <%= t("views.right_panel.detail.name_txt") %> <%= t("views.right_panel.detail.table_txt") %><br>
|
1) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.table_txt") %> <%= t("views.right_panel.detail.name_txt") %> <%= t("views.right_panel.detail.table_txt") %><br>
|
||||||
2) <%= t("views.right_panel.detail.status") %> - <%= t("views.right_panel.detail.table_txt") %> <%= t("views.right_panel.detail.status_txt") %> <br>
|
2) <%= t("views.right_panel.detail.status") %> - <%= t("views.right_panel.detail.table_txt") %> <%= t("views.right_panel.detail.status_txt") %> <br>
|
||||||
3) <%= t("views.right_panel.detail.seater") %> - <%= t("views.right_panel.detail.seat_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.table_txt") %> <br>
|
3) <%= t("views.right_panel.detail.seater") %> - <%= t("views.right_panel.detail.seat_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.table_txt") %> <br>
|
||||||
4) <%= t("views.right_panel.detail.order_by") %> - <%= t("views.right_panel.detail.order_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.table_txt") %> <br>
|
4) <%= t("views.right_panel.detail.order_by") %> - <%= t("views.right_panel.detail.order_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.table_txt") %> <br>
|
||||||
@@ -118,8 +117,6 @@
|
|||||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.zone_txt") %> <br>
|
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.zone_txt") %> <br>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,24 @@ set :linked_dirs, %w{log tmp/pids tmp/puma tmp/cache tmp/sockets vendor/bundle p
|
|||||||
set :tests, []
|
set :tests, []
|
||||||
set :pty, true
|
set :pty, true
|
||||||
|
|
||||||
set :puma_jungle_conf, '/etc/puma.conf'
|
#set :puma_state, "#{shared_path}/tmp/pids/puma.state"
|
||||||
set :puma_run_path, '/usr/local/bin/run-puma'
|
#set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
|
||||||
set :puma_bind, %w(tcp://0.0.0.0:9393)
|
set :puma_bind, %w(tcp://0.0.0.0:9393)
|
||||||
|
#set :puma_conf, "#{shared_path}/puma.rb"
|
||||||
|
#set :puma_access_log, "#{shared_path}/log/puma_access.log"
|
||||||
|
#set :puma_error_log, "#{shared_path}/log/puma_error.log"
|
||||||
|
#set :puma_role, :app
|
||||||
|
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
|
||||||
|
set :puma_threads, [0, 16]
|
||||||
|
set :puma_workers, 2
|
||||||
|
#set :puma_worker_timeout, nil
|
||||||
|
#set :puma_init_active_record, false
|
||||||
|
#set :puma_preload_app, false
|
||||||
|
#set :puma_daemonize, false
|
||||||
|
#set :puma_plugins, [] #accept array of plugins
|
||||||
|
#set :puma_tag, fetch(:application)
|
||||||
|
#set :puma_restart_command, 'bundle exec puma'
|
||||||
|
|
||||||
|
|
||||||
#set :enable_ssl, true
|
#set :enable_ssl, true
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
# set :rails_env, :production
|
# set :rails_env, :production
|
||||||
|
|
||||||
set :stage, :production
|
set :stage, :production
|
||||||
set :server_name, "a.c2l.shop"
|
set :server_name, "doemal.app"
|
||||||
set :branch, "r-1902001-01"
|
set :branch, "r-1902001-01"
|
||||||
|
|
||||||
set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
||||||
server '167.71.194.57', user: 'deploy', roles: %w{web app db}, primary: true
|
server '178.128.58.251', user: 'deploy', roles: %w{web app db}, primary: true
|
||||||
|
|
||||||
set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
|
set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
|
||||||
set :rbenv_ruby, '2.6.5'
|
set :rbenv_ruby, '2.6.5'
|
||||||
|
|||||||
1
config/deploy/shared/.rbenv-vars
Normal file
1
config/deploy/shared/.rbenv-vars
Normal file
@@ -0,0 +1 @@
|
|||||||
|
SECRET_KEY_BASE=33c956cc0e41623bf4e0aedbb16061fa7460a993452b58311d07009782dc242925a52dbb79b506c35308e65cda7cb07b014f78daea0a7ea883a535dc14b33a09
|
||||||
6
config/deploy/shared/database.yml.erb
Normal file
6
config/deploy/shared/database.yml.erb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
production:
|
||||||
|
adapter: postgresql
|
||||||
|
host: localhost
|
||||||
|
database: iticket
|
||||||
|
username: wathon
|
||||||
|
password: root
|
||||||
11
config/deploy/shared/log_rotation.erb
Normal file
11
config/deploy/shared/log_rotation.erb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<%= fetch(:deploy_to) %>/shared/log/*.log {
|
||||||
|
daily
|
||||||
|
missingok
|
||||||
|
rotate 52
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
notifempty
|
||||||
|
sharedscripts
|
||||||
|
endscript
|
||||||
|
copytruncate
|
||||||
|
}
|
||||||
2
config/deploy/shared/monit.conf.erb
Normal file
2
config/deploy/shared/monit.conf.erb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<% application = fetch(:application) %>
|
||||||
|
set mail-format { subject: <%= "#{fetch(:full_app_name)} - #{fetch(:rails_env)}" %> $SERVICE $EVENT at $DATE }
|
||||||
40
config/deploy/shared/nginx.conf.erb
Normal file
40
config/deploy/shared/nginx.conf.erb
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
server {
|
||||||
|
server_name <%= fetch(:server_name) %>;
|
||||||
|
listen 80;
|
||||||
|
passenger_enabled on;
|
||||||
|
rails_env production;
|
||||||
|
root <%= fetch(:deploy_to) %>/current/public;
|
||||||
|
|
||||||
|
location ^~ /assets/ {
|
||||||
|
gzip_static on;
|
||||||
|
expires max;
|
||||||
|
add_header Cache-Control public;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 500 502 503 504 /500.html;
|
||||||
|
client_max_body_size 4G;
|
||||||
|
keepalive_timeout 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
<% if fetch(:enable_ssl) %>
|
||||||
|
server {
|
||||||
|
server_name <%= fetch(:server_name) %>;
|
||||||
|
listen 443;
|
||||||
|
passenger_enabled on;
|
||||||
|
rails_env production;
|
||||||
|
root <%= fetch(:deploy_to) %>/current/public;
|
||||||
|
|
||||||
|
location ^~ /assets/ {
|
||||||
|
gzip_static on;
|
||||||
|
expires max;
|
||||||
|
add_header Cache-Control public;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 500 502 503 504 /500.html;
|
||||||
|
client_max_body_size 4G;
|
||||||
|
keepalive_timeout 10;
|
||||||
|
ssl on;
|
||||||
|
ssl_certificate <%= fetch(:deploy_to) %>/shared/ssl_cert.crt;
|
||||||
|
ssl_certificate_key <%= fetch(:deploy_to) %>/shared/ssl_private_key.key;
|
||||||
|
}
|
||||||
|
<% end %>
|
||||||
4
config/deploy/shared/redis.yml.erb
Normal file
4
config/deploy/shared/redis.yml.erb
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<%= fetch(:rails_env) %>:
|
||||||
|
host: data.myapp.com
|
||||||
|
port: 6379
|
||||||
|
db: 0
|
||||||
2
config/deploy/shared/sidekiq.yml.erb
Normal file
2
config/deploy/shared/sidekiq.yml.erb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<%= fetch(:rails_env) %>:
|
||||||
|
:concurrency: <%= fetch(:sidekiq_concurrency, 5) %>
|
||||||
48
config/deploy/shared/sidekiq_init.sh.erb
Normal file
48
config/deploy/shared/sidekiq_init.sh.erb
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
APP_ROOT=<%= current_path %>
|
||||||
|
PID=$APP_ROOT/tmp/pids/sidekiq.pid
|
||||||
|
CMD="cd $APP_ROOT; RAILS_ENV=<%= "#{fetch(:rails_env)}" %> nohup bundle exec sidekiq -e <%= "#{fetch(:rails_env)}" %> -C $APP_ROOT/config/sidekiq.yml -i 0 -P $PID >> $APP_ROOT/log/sidekiq.log 2>&1 &"
|
||||||
|
STOP_CMD="cd $APP_ROOT; RAILS_ENV=<%= "#{fetch(:rails_env)}" %> bundle exec sidekiqctl stop $APP_ROOT/tmp/pids/sidekiq.pid 10"
|
||||||
|
AS_USER=<%= fetch(:deploy_user) %>
|
||||||
|
|
||||||
|
run () {
|
||||||
|
if [ "$(id -un)" = "$AS_USER" ]; then
|
||||||
|
eval $1
|
||||||
|
else
|
||||||
|
su -c "$1" - $AS_USER
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
sig () {
|
||||||
|
test -s "$PID" && kill -$1 `cat $PID`
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
sig 0 && echo >&2 "Already Running" && exit 0
|
||||||
|
run "$CMD"
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
if test -s "$PID" && kill -0 `cat $PID`
|
||||||
|
then
|
||||||
|
echo "stopping...."
|
||||||
|
run "$STOP_CMD"
|
||||||
|
else
|
||||||
|
echo "not running"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
restart|reload)
|
||||||
|
if test -s "$PID" && kill -0 `cat $PID`
|
||||||
|
then
|
||||||
|
echo "stopping...."
|
||||||
|
run "$STOP_CMD"
|
||||||
|
fi
|
||||||
|
run "$CMD"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo >&2 "Usage: $0 <start|stop|restart>"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
24
nweni.crt
24
nweni.crt
@@ -1,24 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEBzCCAu+gAwIBAgIJAOMNKpr3UCfFMA0GCSqGSIb3DQEBCwUAMIGiMQswCQYD
|
|
||||||
VQQGEwJNTTEPMA0GA1UECAwGWWFuZ29uMQ8wDQYDVQQHDAZZYW5nb24xGTAXBgNV
|
|
||||||
BAoMEENvZGUyTEFCIFB0ZSBMdGQxFDASBgNVBAsMC0RldmVsb3BtZW50MR0wGwYD
|
|
||||||
VQQDDBRDb2RlMkxBQiBDZXJ0aWZpY2F0ZTEhMB8GCSqGSIb3DQEJARYSaGVsbG9A
|
|
||||||
Y29kZTJsYWIuY29tMB4XDTE5MTIwNDA1NTgwMFoXDTIxMDQxNzA1NTgwMFowgZQx
|
|
||||||
CzAJBgNVBAYTAk1NMQ8wDQYDVQQIDAZZYW5nb24xDzANBgNVBAcMBllhbmdvbjEZ
|
|
||||||
MBcGA1UECgwQQ29kZTJMQUIgUHRlIEx0ZDEUMBIGA1UECwwLRGV2ZWxvcG1lbnQx
|
|
||||||
ITAfBgkqhkiG9w0BCQEWEmhlbGxvQGNvZGUybGFiLmNvbTEPMA0GA1UEAwwGTndl
|
|
||||||
IE5pMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlzBofZOWVWCDRJ3Y
|
|
||||||
8NSR+FJg1/KMcVXhJbF5xuEz5K4+b8/VJG6CPE6O9qnqMhFd+Fp/f8GReCiP3Xb9
|
|
||||||
dp8E5k6p/sTU18rDgurWm/DAhOXjq85EiNHitsLrGmLxYxHq2nxXFYuhYcM6lP0L
|
|
||||||
SXfgUuwMNs3HpNFo7Fk21M7XKzdZdJPB35s3wZVWmHPon8i/oX8PHB8/IrhPGU7P
|
|
||||||
Q33WZburEXK78jFbTGfavGSd5of17wIeI4saOpcAt7yz3rxa3tMb+FEZdJ1gxMrJ
|
|
||||||
EX8A/qUJ7MYyc4JV+ssKcom8iQcLzdBlNkEWDZpAglmCe6jF7v7QrzPZDDFDLc3A
|
|
||||||
L4W/NwIDAQABo0wwSjAfBgNVHSMEGDAWgBQkFPQitKTJkB0Xw/L/CbmtGTFv5TAJ
|
|
||||||
BgNVHRMEAjAAMAsGA1UdDwQEAwIE8DAPBgNVHREECDAGhwTAqAHyMA0GCSqGSIb3
|
|
||||||
DQEBCwUAA4IBAQCIFcpDdcIFxBnrOYjuadtL4X+iUT2UK1UMox/X2kz+agdpOVET
|
|
||||||
VRTMcGOFta/iecEAmI2BPl+TP+qNO2xAfXKbU6vrD0lsshB6PlUxGSxnlFTDW5Df
|
|
||||||
SZuiMb3J6AT9vdp/U1CwLGthrvmWyjXvYYKbEb9LIqKOVm0WVj8drhnGxAq0Ie6k
|
|
||||||
OrT76+8gjzYkR8HJ8v3bXijkeSMMTQxD+9K/wikoyaXtKV7QPjwjnKnYfOHpgvql
|
|
||||||
+lIF5S16FIGTxedX8qsvrF/P7/Z657riqZGaW9Nfm7j0kDS9tEWKBk+fW0zw/sYw
|
|
||||||
BRC3M+delv19ae//Ia0sIL2vNEB43HaXxNbK
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
28
nweni.key
28
nweni.key
@@ -1,28 +0,0 @@
|
|||||||
-----BEGIN PRIVATE KEY-----
|
|
||||||
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCXMGh9k5ZVYINE
|
|
||||||
ndjw1JH4UmDX8oxxVeElsXnG4TPkrj5vz9UkboI8To72qeoyEV34Wn9/wZF4KI/d
|
|
||||||
dv12nwTmTqn+xNTXysOC6tab8MCE5eOrzkSI0eK2wusaYvFjEerafFcVi6FhwzqU
|
|
||||||
/QtJd+BS7Aw2zcek0WjsWTbUztcrN1l0k8HfmzfBlVaYc+ifyL+hfw8cHz8iuE8Z
|
|
||||||
Ts9DfdZlu6sRcrvyMVtMZ9q8ZJ3mh/XvAh4jixo6lwC3vLPevFre0xv4URl0nWDE
|
|
||||||
yskRfwD+pQnsxjJzglX6ywpyibyJBwvN0GU2QRYNmkCCWYJ7qMXu/tCvM9kMMUMt
|
|
||||||
zcAvhb83AgMBAAECggEAN3cn7mH1tg65ObQbAYdKoeo+4xp1kaKq/bQVc/PsoMmX
|
|
||||||
2FdL35i3KL69ThrZ81JRwioZOlpeLtHaranYpOsD1iYn0XKOjzgw79eNshnp1xer
|
|
||||||
pbz/gZ5WaSwrKjwASJMrMMqK/DmElCQWWtBWkrZq0qEMfhKSWpIExyiXqAzV/WE5
|
|
||||||
jc+CllMGWY4vmTscWyKKBvqjaLJ7A1z+cRZzrPwmQKcZ2DQ/DVzjcTmh+W0CGPE9
|
|
||||||
gVL+mZ5rWbCbL43RWHKt/ewwrNs+io8zPWaOBAobUfGYa/IhCSLktmDSyjK/tUY3
|
|
||||||
CqW2Lqc+07I/cb4kQkBfIAUg4mZCTBwh80puTPGY4QKBgQDINGD2Yn6CpY1viQiR
|
|
||||||
rEWKfyYBEchI+um68Vz3l7d7nEOeO+OmPivBL1UCewf/ux3YqKu4HTrYd5VUVbxN
|
|
||||||
141k5Hv9XCf6Fn/wcSptJLK9bSkWh08+LcLS2/K7rnF57T2v1YIsn1zr0E6rKIEE
|
|
||||||
XRuodMjQvkex/KVrbXjK83JpJwKBgQDBUwMUK8IOrnYiq/EkRB2roCyLNbrUEEaU
|
|
||||||
QvrlOztOI8ctf236i51q2708aqSGrnjbQ6uXOHwX5O4i6Psjw+llPSF1wpE9tyGw
|
|
||||||
dhsBFYYMxnetXIPLnfxE2bnKNsN5dDtI/JwcKA5TB+3BXkIYbkCbs0z0/WDtjJZE
|
|
||||||
IOw40lMjcQKBgGvhpbo+2vMlqLBIhGCTFyoJV/5NicKhyp8c/r7Ad3PZgapblVF4
|
|
||||||
wPUpv0JF78qDFxMv2NCul44b6lD2njDIDX4njRS6uyQNScXUBUuo8dQXZYOpSC82
|
|
||||||
U3xyXzt5Rdaw24PLpojLGzRLHIkom1UxovzEaY3qaxHjFXRtGiEqzCUTAoGAT4ip
|
|
||||||
UZkXAxc/PtBiKrtjQYJqEPOP40K25rQPqFMP+Pu7K7qrMlJR9u5kEgEFousQiZRz
|
|
||||||
eYkhdGsYlYAoIfSthpr5swrS2gMHdyN/xJhoR8U24zmWdySN7n1sdAbHsKXi5goW
|
|
||||||
53aLPhma9NykcIybQ/MmC/xZ7iDSiUDKLi5JSeECgYBf5aSPelr/ShEKlxz4BgcD
|
|
||||||
XcMNzTZXNJTNgMHvLorlUG0Ev6C95SlwzJd0aiTLpm2WtO9Uy/AtueVQc02En3+1
|
|
||||||
E2eX+cTuYD+eAFjxdvAaOKwkPbtk8xAlcQ34iRdcXvLM+f6UpXk+8ytVvPc5dmF7
|
|
||||||
kM3zuXJ66D8u1IV6G0asyA==
|
|
||||||
-----END PRIVATE KEY-----
|
|
||||||
Reference in New Issue
Block a user