merge with r-19
This commit is contained in:
3
Gemfile
3
Gemfile
@@ -1,7 +1,6 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
#ruby '2.4.1'
|
||||||
#ruby '2.5.0'
|
|
||||||
#ruby '2.5.7'
|
#ruby '2.5.7'
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -288,6 +288,10 @@ For Number Formats
|
|||||||
=> settings/lookups => { lookup_type: number_format, name: strip_insignificant_zeros,
|
=> settings/lookups => { lookup_type: number_format, name: strip_insignificant_zeros,
|
||||||
value: {true: => ['1', 't', 'true', 'on', 'y', 'yes'], false: => ['0', 'f', 'false', 'off', 'n', 'no', ...] }
|
value: {true: => ['1', 't', 'true', 'on', 'y', 'yes'], false: => ['0', 'f', 'false', 'off', 'n', 'no', ...] }
|
||||||
|
|
||||||
|
For Booking checkin time limit
|
||||||
|
settings/lookups =>
|
||||||
|
{ lookup_type: checkin_time_limit, name: CheckinTimeLimit, value: total hours before checkout (e.g., '48')) }
|
||||||
|
|
||||||
/* Customer Types in lookups */
|
/* Customer Types in lookups */
|
||||||
1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein }
|
1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein }
|
||||||
2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway }
|
2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway }
|
||||||
|
|||||||
@@ -629,7 +629,7 @@ $(function() {
|
|||||||
status = "selected-attribute";
|
status = "selected-attribute";
|
||||||
}
|
}
|
||||||
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
|
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
|
||||||
disabled = "disabled";
|
// disabled = "disabled";
|
||||||
}
|
}
|
||||||
row +="<button id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
|
row +="<button id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
|
||||||
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
||||||
@@ -1102,16 +1102,30 @@ $(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;
|
||||||
|
total_price = total_price;
|
||||||
|
}
|
||||||
|
if (exclusive_tax >0){
|
||||||
|
exclusive_total = total_price * exclusive_tax;
|
||||||
|
total_price = total_price + exclusive_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(parseInt(exclusive_total) + parseInt(inclusive_total));
|
||||||
|
|
||||||
$('#sub_total').empty();
|
$('#sub_total').empty();
|
||||||
$('#sub_total').append(fixed_total_price);
|
$('#sub_total').append(fixed_total_price);
|
||||||
|
|||||||
@@ -38,4 +38,3 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayChannel', {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -225,3 +225,14 @@ i.logout_icon{
|
|||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.report-table-header {
|
||||||
|
font-size: .95rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: rgba(0, 0, 0, 0.54);
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-group-addon {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
}
|
}
|
||||||
.bmd-form-group {
|
.bmd-form-group {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-top: 0 !important;
|
|
||||||
}
|
}
|
||||||
.btn_create_induty{
|
.btn_create_induty{
|
||||||
display: inline;
|
display: inline;
|
||||||
|
|||||||
@@ -1,10 +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 :core_allow
|
before_action :core_allow
|
||||||
helper_method :current_token, :current_login_employee, :get_cashier
|
helper_method :current_token, :current_login_employee, :get_cashier
|
||||||
|
|||||||
@@ -10,7 +10,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?
|
||||||
@@ -52,13 +52,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
|
||||||
@@ -148,7 +141,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
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
else
|
else
|
||||||
render :json => { :status => false, :error_message => "No current booking!" }
|
render :json => { :status => false, :error_message => "No current booking!" }
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
render :json => { :status => false }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -95,7 +97,7 @@ class Api::CheckInProcessController < Api::ApiController
|
|||||||
render :json => { :status => false, :error_message => "Operation failed!" }
|
render :json => { :status => false, :error_message => "Operation failed!" }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
booking = dining_facility.get_current_checkout_booking
|
booking = dining_facility.current_checkout_booking
|
||||||
if booking.nil?
|
if booking.nil?
|
||||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||||
|
|
||||||
|
|||||||
@@ -71,15 +71,10 @@ class Api::OrdersController < Api::ApiController
|
|||||||
current_user =Employee.find(current_shift.employee_id)
|
current_user =Employee.find(current_shift.employee_id)
|
||||||
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
|
||||||
@@ -102,14 +97,14 @@ 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
|
||||||
@order.new_booking = true
|
@order.new_booking = true
|
||||||
@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.shop_code = @shop.shop_code
|
|
||||||
@order.is_extra_time = is_extra_time
|
@order.is_extra_time = is_extra_time
|
||||||
@order.extra_time = extra_time
|
@order.extra_time = extra_time
|
||||||
|
|
||||||
@@ -122,8 +117,9 @@ class Api::OrdersController < Api::ApiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
@status, @booking = @order.generate
|
@status, @booking = @order.generate
|
||||||
if params[:order_source] != "app"
|
|
||||||
@order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
if @status && @booking
|
||||||
|
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||||
end
|
end
|
||||||
if @order.table_id.to_i > 0
|
if @order.table_id.to_i > 0
|
||||||
table = DiningFacility.find(@booking.dining_facility_id)
|
table = DiningFacility.find(@booking.dining_facility_id)
|
||||||
@@ -131,11 +127,12 @@ class Api::OrdersController < Api::ApiController
|
|||||||
from = getCloudDomain #get sub domain in cloud mode
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||||
end
|
end
|
||||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
# # for parallel order
|
||||||
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court') || (@order.source == 'app')
|
# remoteIP = ""
|
||||||
@status, @sale = Sale.request_bill(@order,current_user,current_user)
|
# begin
|
||||||
end
|
# @status, @booking = @order.generate
|
||||||
end
|
# remoteIP = request.remote_ip
|
||||||
|
# end while request.remote_ip != remoteIP
|
||||||
else
|
else
|
||||||
return return_json_status_with_code(406, "Checkout time is over!")
|
return return_json_status_with_code(406, "Checkout time is over!")
|
||||||
end
|
end
|
||||||
@@ -198,7 +195,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
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ class Api::Restaurant::MenuController < Api::ApiController
|
|||||||
param_checksum = params[:checksum]
|
param_checksum = params[:checksum]
|
||||||
# checksum = File.readlines("public/checksums/menu_json.txt").pop.chomp
|
# checksum = File.readlines("public/checksums/menu_json.txt").pop.chomp
|
||||||
|
|
||||||
shop_code = params[:shop_code]
|
all_menu = Menu.includes(:menu_categories => [:children, :menu_items => [:menu_item_instances => :menu_instance_item_sets, :item_sets => :menu_item_instances]]).active.all
|
||||||
all_menu = Menu.where('shop_code=?',shop_code).active.all
|
|
||||||
@request_url = ''
|
@request_url = ''
|
||||||
if ENV["SERVER_MODE"] == "cloud"
|
if ENV["SERVER_MODE"] == "cloud"
|
||||||
@request_url = request.base_url
|
@request_url = request.base_url
|
||||||
@@ -17,10 +17,7 @@ class Api::Restaurant::MenuController < Api::ApiController
|
|||||||
# to hash
|
# to hash
|
||||||
menu_array = []
|
menu_array = []
|
||||||
all_menu.each do |m|
|
all_menu.each do |m|
|
||||||
menu_array.push(m.to_json(:include => {:menu_categories =>
|
menu_array.push(m.to_json(:include => { :menu_categories => { :include => { :menu_items => { :include => [ :item_sets, :menu_item_instances => { :include => :menu_instance_item_sets } ] } } } } ))
|
||||||
{ :include => { :menu_items =>
|
|
||||||
{ :include => [:menu_item_sets, :menu_item_instances =>
|
|
||||||
{ :include => :menu_instance_item_sets}]} } }}))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#export Checksum file generate by md5
|
#export Checksum file generate by md5
|
||||||
@@ -29,6 +26,10 @@ class Api::Restaurant::MenuController < Api::ApiController
|
|||||||
if menu_checksum != param_checksum
|
if menu_checksum != param_checksum
|
||||||
response.headers['CHECKSUM'] = menu_checksum
|
response.headers['CHECKSUM'] = menu_checksum
|
||||||
@menus = all_menu
|
@menus = all_menu
|
||||||
|
@item_attributes = MenuItemAttribute.all.load
|
||||||
|
@item_options = MenuItemOption.all.load
|
||||||
|
else
|
||||||
|
render :json => nil
|
||||||
end
|
end
|
||||||
# @current_menu = Menu.current_menu
|
# @current_menu = Menu.current_menu
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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,6 +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,5 +1,4 @@
|
|||||||
class BaseOqsController < ActionController::Base
|
class BaseOqsController < ActionController::Base
|
||||||
|
|
||||||
include MultiTenancy
|
include MultiTenancy
|
||||||
include LoginVerification
|
include LoginVerification
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -34,6 +33,7 @@ class BaseReportController < ActionController::Base
|
|||||||
if params[:from].present? && params[:to].present?
|
if params[:from].present? && params[:to].present?
|
||||||
from = Time.parse(params[:from])
|
from = Time.parse(params[:from])
|
||||||
to = Time.parse(params[:to])
|
to = Time.parse(params[:to])
|
||||||
|
|
||||||
else
|
else
|
||||||
case period.to_i
|
case period.to_i
|
||||||
when PERIOD["today"]
|
when PERIOD["today"]
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -4,7 +4,6 @@ module MultiTenancy
|
|||||||
included do
|
included do
|
||||||
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
|
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
|
||||||
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
|
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
|
||||||
helper_method :current_shop if respond_to? :helper_method
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module NumberFormattable
|
|||||||
@precision = @number_formats.find? { |x| x.name.parameterize.underscore == 'precision'}.value.to_i rescue nil
|
@precision = @number_formats.find? { |x| x.name.parameterize.underscore == 'precision'}.value.to_i rescue nil
|
||||||
end
|
end
|
||||||
if @precision.nil?
|
if @precision.nil?
|
||||||
@print_settings = PrintSetting.get_precision_delimiter if !defined? @number_formats
|
@print_settings = PrintSetting.get_precision_delimiter if !defined? @print_settings
|
||||||
if @print_settings
|
if @print_settings
|
||||||
@precision = @print_settings.precision.to_i
|
@precision = @print_settings.precision.to_i
|
||||||
else
|
else
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ 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")
|
||||||
|
.joins(:lookup)
|
||||||
.order("group_type ASC, order_by ASC")
|
.order("group_type ASC, order_by ASC")
|
||||||
|
|
||||||
@filter = filter
|
@filter = filter
|
||||||
@@ -147,13 +148,13 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
def new
|
def new
|
||||||
@crm_customer = Customer.new
|
@crm_customer = Customer.new
|
||||||
@membership = Customer.get_member_group()
|
@membership = Customer.get_member_group()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /crm/customers/1/edit
|
# GET /crm/customers/1/edit
|
||||||
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|
|
||||||
@@ -165,15 +166,13 @@ 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,
|
||||||
@@ -189,7 +188,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,
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class Foodcourt::FoodCourtController < ApplicationController
|
|||||||
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||||
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
||||||
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
||||||
.where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length
|
.where("orders.source='app' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length
|
||||||
render "foodcourt/addorders/detail"
|
render "foodcourt/addorders/detail"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController
|
|||||||
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||||
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
|
||||||
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
|
||||||
.where("sales.sale_status !=? and orders.source='app' and bookings.shop_code=? and DATE(bookings.created_at)=?",'void',@shop.shop_code,Date.today).order("bookings.created_at desc").uniq
|
.where("sales.sale_status !=? and orders.source='app' and DATE(bookings.created_at)=?",'void',@shop.shop_code,Date.today).order("bookings.created_at desc").uniq
|
||||||
end
|
end
|
||||||
def completed
|
def completed
|
||||||
customer =Customer.find_by_customer_id(params[:customer_id])
|
customer =Customer.find_by_customer_id(params[:customer_id])
|
||||||
|
|||||||
@@ -86,10 +86,10 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
|||||||
def destroy
|
def destroy
|
||||||
inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||||
@inventory_definition.destroy
|
@inventory_definition.destroy
|
||||||
# respond_to do |format|
|
respond_to do |format|
|
||||||
# format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||||
# format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
# end
|
end
|
||||||
|
|
||||||
# inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
# inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||||
StockJournal.delete_stock_journal(inventory.item_code,@shop)
|
StockJournal.delete_stock_journal(inventory.item_code,@shop)
|
||||||
|
|||||||
@@ -57,14 +57,6 @@ class Oqs::HomeController < BaseOqsController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# booking_id = dining.get_new_booking
|
|
||||||
# BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
|
|
||||||
# order=Order.find(bo.order_id);
|
|
||||||
# order.order_items.each do |oi|
|
|
||||||
# items.push(oi)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
render :json => items.to_json
|
render :json => items.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
if check_mobile
|
if check_mobile
|
||||||
@webview = true
|
@webview = true
|
||||||
end
|
end
|
||||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
|
|
||||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
|
@tables = Table.active.order('zone_id asc').group("zone_id")
|
||||||
@all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
|
@rooms = Room.active.order('zone_id asc').group("zone_id")
|
||||||
@all_room = Room.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
|
@all_table = Table.active.order('status desc')
|
||||||
|
@all_room = Room.active.order('status desc')
|
||||||
end
|
end
|
||||||
|
|
||||||
def detail
|
def detail
|
||||||
@@ -33,12 +34,13 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
@booking = @table.get_booking
|
@booking = @table.get_booking
|
||||||
if @booking
|
if @booking
|
||||||
@booking_id = @booking.booking_id
|
@booking_id = @booking.booking_id
|
||||||
@obj_order = @booking.orders.first
|
if @obj_order = @booking.orders.first
|
||||||
@customer = @obj_order.customer
|
@customer = @obj_order.customer
|
||||||
@date = @obj_order.created_at
|
@date = @obj_order.created_at
|
||||||
@order_items = @booking.order_items
|
@order_items = @booking.order_items
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def get_menu_category ()
|
def get_menu_category ()
|
||||||
if (params[:id])
|
if (params[:id])
|
||||||
@@ -106,7 +108,7 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
extra_time = Time.at(time)
|
extra_time = Time.at(time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if i["parent_order_item_id"];
|
if i["parent_order_item_id"]
|
||||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])}
|
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])}
|
||||||
else
|
else
|
||||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])}
|
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])}
|
||||||
@@ -115,11 +117,12 @@ 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.transaction do
|
||||||
@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]
|
||||||
@@ -130,7 +133,7 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
@order.new_booking = true
|
@order.new_booking = true
|
||||||
@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.shop_code = @shop.shop_code
|
|
||||||
@order.is_extra_time = is_extra_time
|
@order.is_extra_time = is_extra_time
|
||||||
@order.extra_time = extra_time
|
@order.extra_time = extra_time
|
||||||
|
|
||||||
@@ -150,14 +153,11 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
type = 'order'
|
type = 'order'
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
ActionCable.server.broadcast "order_channel", table: table,type:type,from:from
|
ActionCable.server.broadcast "order_channel", table: table,type:type,from:from
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
|
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
|
||||||
process_order_queue(@order.order_id,@order.table_id,@order.source)
|
process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Order.send_customer_view(@booking)
|
# Order.send_customer_view(@booking)
|
||||||
|
|
||||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||||
@@ -178,7 +178,7 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
result = {:status=> @status, :data => 0 }
|
result = {:status=> @status, :data => 0 }
|
||||||
render :json => result.to_json
|
render :json => result.to_json
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# render json for http status code
|
# render json for http status code
|
||||||
@@ -221,51 +221,17 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def process_order_queue(order_id, table_id, order_source)
|
def process_order_queue(order_id, table_id, order_source)
|
||||||
print_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_and_shop_code("sidekiq",@shop.shop_code)
|
sidekiq = Lookup.find_by_lookup_type("sidekiq")
|
||||||
if ENV["SERVER_MODE"] != 'cloud'
|
|
||||||
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, order_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'
|
if ENV["SERVER_MODE"] != 'cloud'
|
||||||
cup_start = `#{"sudo service cups start"}`
|
if Printer::PrinterWorker.printers.blank?
|
||||||
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, order_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'
|
|
||||||
from = ""
|
|
||||||
msg = 'Print Error ! Please contact to service'
|
msg = 'Print Error ! Please contact to service'
|
||||||
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error',from:from
|
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: ''
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if !sidekiq.nil?
|
if !sidekiq.nil?
|
||||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||||
else
|
else
|
||||||
@@ -273,14 +239,11 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
oqs = OrderQueueStation.new
|
oqs = OrderQueueStation.new
|
||||||
oqs.process_order(order, table_id, order_source)
|
oqs.process_order(order, table_id, order_source)
|
||||||
end
|
end
|
||||||
|
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
|
||||||
ActionCable.server.broadcast "order_queue_station_channel", order: assign_order, from: from
|
ActionCable.server.broadcast "order_queue_station_channel", order: assign_order, from: from
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_cup_status(status)
|
def check_cup_status(status)
|
||||||
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
|
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -104,9 +104,7 @@ class Origami::DashboardController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_all_menu
|
def get_all_menu
|
||||||
|
@menus = Menu.includes(:menu_categories => [:children, :menu_items => [:menu_item_instances => :menu_instance_item_sets, :item_sets => :menu_item_instances]]).active.all
|
||||||
@menus = Menu.includes(:menu_categories => :children).includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).includes(:menu_categories => {:menu_items => {:item_sets => :menu_item_instances}}).active.shop
|
|
||||||
|
|
||||||
@item_attributes = MenuItemAttribute.all.load
|
@item_attributes = MenuItemAttribute.all.load
|
||||||
@item_options = MenuItemOption.all.load
|
@item_options = MenuItemOption.all.load
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class Origami::FoodCourtController < ApplicationController
|
|||||||
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||||
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
|
||||||
@cashier_type = "food_court"
|
@cashier_type = "food_court"
|
||||||
|
|
||||||
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
|
||||||
@@ -57,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])
|
||||||
@@ -114,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,10 +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).active.order('status desc')
|
||||||
|
@rooms = Room.unscope(:order).includes(:zone, :current_checkin_booking, :current_checkout_booking, :current_reserved_booking).active.order('status desc')
|
||||||
@tables = Table.unscope(:order).includes(:zone).shop.active.order('status desc')
|
|
||||||
@rooms = Room.unscope(:order).includes(:zone).shop.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')
|
||||||
|
|
||||||
@@ -23,9 +21,8 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
@print_settings = PrintSetting.get_precision_delimiter()
|
@print_settings = PrintSetting.get_precision_delimiter()
|
||||||
@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).shop.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).shop.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')
|
||||||
|
|
||||||
@@ -36,75 +33,42 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
@status_sale = ""
|
@status_sale = ""
|
||||||
@sale_array = Array.new
|
@sale_array = Array.new
|
||||||
|
|
||||||
@membership = MembershipSetting.find_by_shop_code(@shop.shop_code)
|
@shop = shop_detail
|
||||||
@payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'")
|
@membership = MembershipSetting::MembershipSetting
|
||||||
@dining_booking = @dining.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}' ")
|
@payment_methods = PaymentMethodSetting.all
|
||||||
#@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'")
|
@dining_booking = @dining.current_bookings
|
||||||
|
|
||||||
@order_items = Array.new
|
@order_items = Array.new
|
||||||
@dining_booking.each do |booking|
|
@dining_booking.each do |booking|
|
||||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
if @obj_sale || @booking.blank?
|
||||||
@order_items = Array.new
|
|
||||||
# @assigned_order_items = Array.new
|
|
||||||
if booking.booking_orders.empty?
|
|
||||||
@booking = booking
|
@booking = booking
|
||||||
else
|
|
||||||
booking.booking_orders.each do |booking_order|
|
|
||||||
order = Order.find(booking_order.order_id)
|
|
||||||
if (order.status == "new")
|
|
||||||
@obj_order = order
|
|
||||||
@customer = order.customer
|
|
||||||
@date = order.created_at
|
|
||||||
@booking= booking
|
|
||||||
order.order_items.each do |item|
|
|
||||||
@order_items.push(item)
|
|
||||||
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
|
|
||||||
# if !assigned_order_items.nil?
|
|
||||||
# @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
@account_arr = Array.new
|
|
||||||
if @customer.tax_profiles
|
if booking.sale_id
|
||||||
accounts = @customer.tax_profiles
|
@obj_sale = booking.sale
|
||||||
@account_arr =[]
|
@sale_array.push(@obj_sale)
|
||||||
accounts.each do |acc|
|
@sale_taxes = @obj_sale.sale_taxes
|
||||||
account = TaxProfile.find_by_id(acc)
|
|
||||||
if !account.nil?
|
|
||||||
@account_arr.push(account)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@status_order = 'order'
|
|
||||||
else
|
|
||||||
sale = Sale.find(booking.sale_id)
|
|
||||||
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
|
|
||||||
@sale_array.push(sale)
|
|
||||||
if @status_order == 'order'
|
|
||||||
@status_order = 'sale'
|
|
||||||
end
|
|
||||||
@booking= booking
|
|
||||||
@date = sale.created_at
|
|
||||||
@status_sale = 'sale'
|
@status_sale = 'sale'
|
||||||
@obj_sale = sale
|
else
|
||||||
@customer = sale.customer
|
@order_items += booking.order_items
|
||||||
accounts = @customer.tax_profiles
|
@obj_order = booking.orders.first
|
||||||
@account_arr =[]
|
end
|
||||||
accounts.each do |acc|
|
|
||||||
account = TaxProfile.find_by_id(acc)
|
if @obj_sale || @customer.blank?
|
||||||
if !account.nil?
|
if obj = @obj_sale || @obj_order
|
||||||
@account_arr.push(account)
|
@customer = obj.customer
|
||||||
|
@date = obj.created_at
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @obj_sale
|
||||||
|
@status_order = 'sale'
|
||||||
|
else
|
||||||
|
@status_order = 'order'
|
||||||
end
|
end
|
||||||
@sale_taxes = []
|
|
||||||
sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id)
|
if (@obj_sale || @account_arr.blank?) && @customer
|
||||||
if !sale_taxes.empty?
|
@account_arr = TaxProfile.find_by(id: @customer.tax_profiles)
|
||||||
sale_taxes.each do |sale_tax|
|
|
||||||
@sale_taxes.push(sale_tax)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -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,65 +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)
|
|
||||||
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
|
||||||
|
|
||||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
cashier_terminal ||= sale_data.cashier_terminal_by_shift_sale
|
||||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
|
||||||
# Print for First Bill to Customer
|
|
||||||
unique_code = "ReceiptBillPdf"
|
|
||||||
print_settings = PrintSetting.all
|
|
||||||
if !print_settings.nil?
|
|
||||||
print_settings.each do |setting|
|
|
||||||
if setting.unique_code == 'ReceiptBillPdf'
|
|
||||||
unique_code = "ReceiptBillPdf"
|
|
||||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
|
||||||
unique_code = "ReceiptBillStarPdf"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if !receipt_bill_a5_pdf.empty?
|
customer = sale_data.customer
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
|
||||||
if receipt_bilA5[1] == '1'
|
|
||||||
unique_code = "ReceiptBillA5Pdf"
|
|
||||||
else
|
|
||||||
unique_code = unique_code#{}"ReceiptBillPdf"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#shop detail
|
|
||||||
## shop_detail = @shop
|
|
||||||
# customer= Customer.where('customer_id=' +.customer_id)
|
|
||||||
customer = Customer.find(sale_data.customer_id)
|
|
||||||
# rounding adjustment
|
|
||||||
if @shop.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"
|
||||||
@@ -76,14 +29,12 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
|
remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}"
|
||||||
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type )
|
||||||
# get member information
|
# get member information
|
||||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
if customer.membership_id != nil && rebate
|
if customer.membership_id != nil && rebate
|
||||||
# member_info = Customer.get_member_account(customer)
|
# member_info = Customer.get_member_account(customer)
|
||||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||||
current_balance = 0
|
current_balance = 0
|
||||||
end
|
end
|
||||||
# get printer info
|
|
||||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
|
||||||
|
|
||||||
# find order id by sale id
|
# find order id by sale id
|
||||||
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||||
@@ -94,12 +45,13 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||||
|
|
||||||
|
print_settings = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
|
||||||
#TODO :: KBZPAY ( QR )
|
#TODO :: KBZPAY ( QR )
|
||||||
# On/Off setting ( show or not qr )
|
# On/Off setting ( show or not qr )
|
||||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||||
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => @shop.shop_code).last
|
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||||
|
|
||||||
status = false
|
status = false
|
||||||
qr = nil
|
qr = nil
|
||||||
@@ -113,7 +65,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil)
|
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil)
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
@@ -138,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
|
|
||||||
# rounding adjustment
|
|
||||||
if !path.include? ("credit_payment")
|
|
||||||
if @shop.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
|
||||||
@@ -166,67 +102,46 @@ 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)
|
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
|
|
||||||
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'
|
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
|
||||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
|
||||||
else
|
|
||||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
|
||||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cashier_terminal ||= saleObj.cashier_terminal_by_shift_sale
|
||||||
|
|
||||||
|
if booking.dining_facility
|
||||||
|
ActionCable.server.broadcast(
|
||||||
|
"order_channel",
|
||||||
|
table: booking.dining_facility,
|
||||||
|
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.where("shop_code='#{@shop.shop_code}'").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"
|
|
||||||
print_settings = PrintSetting.all
|
|
||||||
if !print_settings.nil?
|
|
||||||
print_settings.each do |setting|
|
|
||||||
if setting.unique_code == 'ReceiptBillPdf'
|
|
||||||
unique_code = "ReceiptBillPdf"
|
|
||||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
|
||||||
unique_code = "ReceiptBillStarPdf"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if !receipt_bill_a5_pdf.empty?
|
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
|
||||||
if receipt_bilA5[1] == '1'
|
|
||||||
unique_code = "ReceiptBillA5Pdf"
|
unique_code = "ReceiptBillA5Pdf"
|
||||||
# else
|
else
|
||||||
|
unique_code = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
customer= Customer.find(saleObj.customer_id)
|
customer = saleObj.customer
|
||||||
|
|
||||||
# get member information
|
# get member information
|
||||||
rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code)
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||||
|
|
||||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||||
@@ -240,8 +155,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
#orders print out
|
#orders print out
|
||||||
if type == "quick_service"
|
if type == "quick_service"
|
||||||
booking = Booking.find_by_sale_id(sale_id)
|
if booking.dining_facility_id.present?
|
||||||
if booking.dining_facility_id.to_i>0
|
|
||||||
table_id = booking.dining_facility_id
|
table_id = booking.dining_facility_id
|
||||||
else
|
else
|
||||||
table_id = 0
|
table_id = 0
|
||||||
@@ -278,22 +192,20 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
#card_balance amount for Paymal payment
|
#card_balance amount for Paymal payment
|
||||||
card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id)
|
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
|
||||||
|
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||||
# Calculate Food and Beverage Total
|
# Calculate Food and Beverage Total
|
||||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
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)
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
other_amount = SaleItem.calculate_other_charges(sale_items)
|
other_amount = SaleItem.calculate_other_charges(sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
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, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref)
|
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
|
||||||
logger.debug 'saleObj++++++++++++++++++++++++++'
|
|
||||||
logger.debug saleObj.to_json
|
|
||||||
if !saleObj.nil?
|
if !saleObj.nil?
|
||||||
# InventoryJob.perform_now(self.id)
|
# InventoryJob.perform_now(self.id)
|
||||||
# InventoryDefinition.calculate_product_count(saleObj)
|
# InventoryDefinition.calculate_product_count(saleObj)
|
||||||
@@ -330,7 +242,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
if path.include? ("credit_payment")
|
if path.include? ("credit_payment")
|
||||||
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
|
@sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount")
|
||||||
end
|
end
|
||||||
|
|
||||||
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code)
|
||||||
@@ -381,7 +293,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)
|
||||||
|
|
||||||
@@ -636,11 +548,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
current_balance = nil
|
current_balance = nil
|
||||||
order_source = params[:type]
|
order_source = params[:type]
|
||||||
|
|
||||||
if(Sale.exists?(sale_id))
|
if Sale.exists?(sale_id)
|
||||||
saleObj = Sale.find(sale_id)
|
saleObj = Sale.find(sale_id)
|
||||||
#calculate cash acmount
|
#calculate cash acmount
|
||||||
cash = saleObj.total_amount
|
cash = saleObj.total_amount
|
||||||
|
|
||||||
|
sale_payment = SalePayment.new
|
||||||
|
sale_payment.process_payment(saleObj, current_user, cash, "foc" ,remark)
|
||||||
|
|
||||||
if saleObj.discount_type == "member_discount"
|
if saleObj.discount_type == "member_discount"
|
||||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||||
saleObj.compute_by_sale_items(0, nil, order_source)
|
saleObj.compute_by_sale_items(0, nil, order_source)
|
||||||
@@ -648,9 +563,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||||
|
|
||||||
sale_payment = SalePayment.new
|
|
||||||
sale_payment.process_payment(saleObj, current_user, cash, "foc" ,remark)
|
|
||||||
|
|
||||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||||
if bookings[0].dining_facility_id.to_i > 0
|
if bookings[0].dining_facility_id.to_i > 0
|
||||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||||
@@ -659,8 +571,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# For Cashier by Zone
|
# For Cashier by Zone
|
||||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||||
|
|
||||||
@@ -795,7 +705,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# get printer info
|
# get printer info
|
||||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_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)
|
||||||
|
|
||||||
@@ -817,8 +727,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
order_source = params[:cashier_type]
|
order_source = params[:cashier_type]
|
||||||
tax_type = params[:tax_type]
|
tax_type = params[:tax_type]
|
||||||
|
remark = "Change tax to #{tax_type.upcase} for Sale ID #{sale_id} By #{current_login_employee.name}"
|
||||||
sale = Sale.find(sale_id)
|
sale = Sale.find(sale_id)
|
||||||
sale.compute_by_sale_items(sale.total_discount, nil, order_source, tax_type)
|
sale.compute_by_sale_items(sale.total_discount, nil, order_source, tax_type)
|
||||||
|
SaleAudit.record_audit_change_tax(sale_id,remark,current_login_employee.name)
|
||||||
|
|
||||||
render json: JSON.generate({:status => true})
|
render json: JSON.generate({:status => true})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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,13 +10,13 @@ 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 = []
|
||||||
@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
|
||||||
@@ -26,8 +26,11 @@ class Origami::QuickServiceController < ApplicationController
|
|||||||
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.where("shop_code='#{@shop.shop_code}'").collection_of('quickservice_add_order')
|
|
||||||
|
lookup_dine_in = Lookup.collection_of('quickservice_add_order')
|
||||||
|
# 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"
|
||||||
@@ -37,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
|
||||||
|
|
||||||
@@ -52,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])
|
||||||
@@ -109,7 +128,7 @@ 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
|
||||||
|
|||||||
@@ -18,10 +18,8 @@ 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])
|
|
||||||
@status = true
|
|
||||||
# in-duty update
|
# in-duty update
|
||||||
in_duties = InDuty.where("booking_id=?", booking.id)
|
in_duties = InDuty.where("booking_id=?", booking.id)
|
||||||
if !in_duties.empty?
|
if !in_duties.empty?
|
||||||
@@ -32,11 +30,6 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
induty.save
|
induty.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Bind shift sale id to sale
|
|
||||||
# @sale_data.shift_sale_id = shift.id
|
|
||||||
# @sale_data.save
|
|
||||||
|
|
||||||
action_by = current_user.name
|
action_by = current_user.name
|
||||||
type = "REQUEST_BILL"
|
type = "REQUEST_BILL"
|
||||||
@@ -54,22 +47,20 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
from = ""
|
from = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
if order.source == "cashier" || order.source == "quick_service"
|
if ["quick_service", "cashier"].include? order.source
|
||||||
ActionCable.server.broadcast "bill_channel", table: table, from: from
|
ActionCable.server.broadcast "bill_channel", table: table, from: from
|
||||||
end
|
end
|
||||||
if order.source == "quick_service" || order.source == "food_court"
|
|
||||||
result = {:status=> @status, :data => sale_data.sale_id }
|
unless ["quick_service", "food_court"].include? order.source
|
||||||
render :json => result.to_json
|
|
||||||
else
|
|
||||||
#check checkInOut pdf print
|
#check checkInOut pdf print
|
||||||
checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time')
|
checkout_time = Lookup.collection_of('checkout_time')
|
||||||
if !booking.dining_facility_id.nil?
|
if !booking.dining_facility_id.nil?
|
||||||
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
terminal = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||||
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id)
|
||||||
|
|
||||||
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server
|
||||||
unique_code = "CheckInOutPdf"
|
unique_code = "CheckInOutPdf"
|
||||||
printer = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code)
|
printer = PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
|
||||||
# print when complete click
|
# print when complete click
|
||||||
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
order_queue_printer = Printer::OrderQueuePrinter.new(printer)
|
||||||
@@ -80,34 +71,25 @@ class Origami::RequestBillsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
@status = true
|
@status = true
|
||||||
|
sale_id = sale_data.sale_id
|
||||||
|
else
|
||||||
|
@status = false
|
||||||
|
sale_id = nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@status = true
|
||||||
|
sale_id = booking.sale_id
|
||||||
|
end
|
||||||
|
end
|
||||||
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
|
|
||||||
# # 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
|
||||||
|
|||||||
@@ -27,52 +27,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 = []
|
|
||||||
|
Sale.transaction do
|
||||||
table = DiningFacility.find(dining)
|
table = DiningFacility.find(dining)
|
||||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
booking = table.current_checkin_booking
|
||||||
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 = Sale.find(sale_id)
|
||||||
order = Order.find(booking_order.order_id)
|
existing = sale.booking
|
||||||
order.status = 'billed'
|
|
||||||
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_items << booking.order_items.to_sale_items
|
||||||
saleobj.compute(order.source,tax_type)
|
sale.orders << booking.orders
|
||||||
saleobj.save
|
|
||||||
order.save
|
|
||||||
booking.save
|
|
||||||
|
|
||||||
order_array.push(order.order_id)
|
sale.compute(booking.orders[0].source, tax_type)
|
||||||
end
|
|
||||||
|
|
||||||
receipt_no = Sale.find(sale_id).receipt_no
|
|
||||||
action_by = current_user.name
|
|
||||||
type = "ADD_TO_EXISTING"
|
type = "ADD_TO_EXISTING"
|
||||||
|
receipt_no = sale.receipt_no
|
||||||
|
action_by = current_user.name
|
||||||
|
order_ids = booking.orders.map(&:order_id)
|
||||||
|
|
||||||
remark = "#{action_by} add to existing order #{order_array} to Receipt No=>#{receipt_no} in #{table.name}"
|
remark = "#{action_by} add to existing order #{order_ids.to_s} to Receipt No=>#{receipt_no} in #{table.name}"
|
||||||
sale_audit = SaleAudit.record_audit_sale(sale_id, remark, action_by, type)
|
sale_audit = SaleAudit.record_audit_sale(sale_id, remark, action_by, type)
|
||||||
|
|
||||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
booking.orders.update_all(status: "billed")
|
||||||
booking_order.each do |bo|
|
booking.order_items.update_all(order_item_status: "billed")
|
||||||
bo.booking_id = existing_booking.booking_id
|
BookingOrder.where(booking_id: booking.booking_id).update_all(booking_id: existing)
|
||||||
bo.save
|
|
||||||
end
|
booking.booking_status = "moved"
|
||||||
end
|
booking.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,68 +16,25 @@ 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
|
|
||||||
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
|
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
|
|
||||||
i = 1
|
|
||||||
while i <= item.qty.to_i do
|
|
||||||
arr_item = {'order_items_id' => item.order_items_id,
|
|
||||||
'order_id' => item.order_id,
|
|
||||||
'order_item_status' => item.order_item_status,
|
|
||||||
'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
|
end
|
||||||
|
|
||||||
|
@order_items << { 'all_order' => order_items }
|
||||||
else
|
else
|
||||||
@booking = nil
|
@booking = nil
|
||||||
end
|
end
|
||||||
@@ -85,310 +42,94 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
|
|
||||||
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.transaction do
|
||||||
|
if params[:booking_id].present?
|
||||||
booking = Booking.find(params[:booking_id])
|
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
|
else
|
||||||
table = nil
|
type = "TableBooking" if params[:type] == "Table"
|
||||||
cashier_zone = nil
|
type ||= "RoomBooking"
|
||||||
|
|
||||||
|
split_orders = []
|
||||||
|
new_order = nil
|
||||||
|
|
||||||
|
booking = Booking.create({:dining_facility_id => table.id, :type => type, :checkin_at => Time.now.utc, :checkin_by => current_user.name, :booking_status => "assign" })
|
||||||
|
|
||||||
|
if orders.present?
|
||||||
|
split_orders += orders.map { |x| x["id"] }
|
||||||
end
|
end
|
||||||
|
|
||||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
if order_items.present?
|
||||||
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
order_items = order_items.inject([]) do |arr, v|
|
||||||
|
v["qty"] = v["qty"].to_i
|
||||||
if sale_data = booking.sale
|
if i = arr.find { |x| x["id"] == v["id"] }
|
||||||
status = true
|
i["qty"] = i["qty"] + v["qty"]
|
||||||
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
|
arr << v
|
||||||
end
|
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
|
else
|
||||||
if params[:type] == "Table"
|
order_item.qty = order_item.qty - split_item["qty"]
|
||||||
type = "TableBooking"
|
order_item.save
|
||||||
else
|
order_item_dup = order_item.dup
|
||||||
type = "RoomBooking"
|
order_item_dup.qty = split_item["qty"]
|
||||||
end
|
new_order.order_items << order_item_dup
|
||||||
|
|
||||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
|
||||||
:checkin_at => Time.now.utc, :checkin_by => current_user.name,
|
|
||||||
:booking_status => "assign",
|
|
||||||
:shop_code =>@shop.shop_code})
|
|
||||||
|
|
||||||
if !orders.nil?
|
|
||||||
orders.each do |order|
|
|
||||||
BookingOrder.find_by_order_id(order["id"]).delete
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order["id"]})
|
|
||||||
end
|
|
||||||
elsif !order_items.nil?
|
|
||||||
order_item_count = 0
|
|
||||||
order_id_count = 0
|
|
||||||
order_id = nil
|
|
||||||
|
|
||||||
arr_order_ids.each do |order|
|
|
||||||
order.each do |odr|
|
|
||||||
data = Order.find(odr[0])
|
|
||||||
if data.order_items.count == odr[1]
|
|
||||||
order_id = odr[0]
|
|
||||||
order_id_count += 1
|
|
||||||
else
|
|
||||||
order_item_count += 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if !order_id.nil?
|
|
||||||
if 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
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
new_order_status = true
|
split_orders << order
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if new_order_status
|
if new_order.present?
|
||||||
BookingOrder.find_by_order_id(order_id).delete
|
booking.orders << new_order
|
||||||
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
|
end
|
||||||
else
|
|
||||||
customer = Customer.find(params[:customer_id])
|
if split_orders.present?
|
||||||
order_type = "dine_in"
|
BookingOrder.where(order_id: split_orders).update_all(booking_id: booking.booking_id)
|
||||||
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
|
|
||||||
|
|
||||||
if sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type ,params[:current_checkin_induties_count])
|
|
||||||
status = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if booking.sale.nil?
|
||||||
|
sale_data = Sale.generate_invoice_from_booking(booking, current_user, current_user, cashier_type, params[:current_checkin_induties_count])
|
||||||
Promotion.promo_activate(sale_data)
|
Promotion.promo_activate(sale_data)
|
||||||
|
end
|
||||||
|
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
from = request.subdomain + "." + request.domain
|
from = request.subdomain + "." + request.domain
|
||||||
else
|
else
|
||||||
from = ""
|
from = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
ActionCable.server.broadcast "bill_channel", table: table, from:from
|
ActionCable.server.broadcast "bill_channel", table: table, from:from
|
||||||
|
|
||||||
render :json => { status: status }
|
render :json => { status: true }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
render :json => { status: false, error_message: 'No Current Open Shift!'}
|
render :json => { status: false, error_message: 'No Current Open Shift!'}
|
||||||
end
|
end
|
||||||
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.shop_code = @shop.shop_code
|
|
||||||
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
|
|
||||||
|
|
||||||
same_order = OrderItem.find_by_order_id(order_id)
|
|
||||||
if same_order.nil?
|
|
||||||
OrderItem.processs_item(orderItem.item_code,
|
|
||||||
orderItem.item_instance_code,
|
|
||||||
orderItem.item_name,
|
|
||||||
orderItem.alt_name,
|
|
||||||
orderItem.account_id,
|
|
||||||
order_item['qty'],
|
|
||||||
orderItem.price,
|
|
||||||
orderItem.options,
|
|
||||||
set_menu_items_obj.to_json,
|
|
||||||
order_id,
|
|
||||||
orderItem.item_order_by,
|
|
||||||
orderItem.taxable)
|
|
||||||
else
|
|
||||||
same_order.qty = same_order.qty.to_f + order_item['qty'].to_f
|
|
||||||
same_order.set_menu_items = set_menu_items_obj.to_json
|
|
||||||
same_order.save
|
|
||||||
end
|
|
||||||
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
|
|
||||||
else
|
|
||||||
orderItem.order_id = order_id
|
|
||||||
end
|
|
||||||
orderItem.save!
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_sale
|
def update_sale
|
||||||
sale = Sale.find(params[:sale_id])
|
sale = Sale.find(params[:sale_id])
|
||||||
sale.equal_persons = params[:total_customer].to_i
|
sale.equal_persons = params[:total_customer].to_i
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
@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
|
||||||
@@ -33,7 +33,7 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
@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_and_shop_code(@dining_facility.name,nil,@shop.shop_code)
|
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +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
|
||||||
@sale_array = Array.new
|
@sale_array = Array.new
|
||||||
@table.bookings.each do |booking|
|
@table.bookings.each do |booking|
|
||||||
|
|
||||||
@@ -31,29 +32,7 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
|||||||
|
|
||||||
@membership = MembershipSetting::MembershipSetting
|
@membership = MembershipSetting::MembershipSetting
|
||||||
@payment_methods = PaymentMethodSetting.all
|
@payment_methods = PaymentMethodSetting.all
|
||||||
@sale_array = Array.new
|
@sale_array = @table.current_sales
|
||||||
@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
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ class Reports::HourlySaleitemController < BaseReportController
|
|||||||
@account = Account.where("shop_code='#{@shop.shop_code}'")
|
@account = Account.where("shop_code='#{@shop.shop_code}'")
|
||||||
from, to = get_date_range_from_params
|
from, to = get_date_range_from_params
|
||||||
|
|
||||||
|
@start_time = params[:start_time]
|
||||||
|
@end_time = params[:end_time]
|
||||||
|
|
||||||
shift_sale_range = ''
|
shift_sale_range = ''
|
||||||
|
|
||||||
shift = ''
|
shift = ''
|
||||||
@@ -23,9 +26,10 @@ class Reports::HourlySaleitemController < BaseReportController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
filter = params[:filter]
|
||||||
account_type = params[:account_type]
|
account_type = params[:account_type]
|
||||||
@type = params[:sale_type]
|
@type = params[:sale_type]
|
||||||
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code)
|
@sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,filter,@start_time,@end_time)
|
||||||
|
|
||||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'")
|
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'")
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ class AssignedOrderItem < ApplicationRecord
|
|||||||
return order_item
|
return order_item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
def self.generate_ids(count = 1)
|
||||||
|
SeedGenerator.generate_ids(self.name, "AOI", count)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
if self.assigned_order_item_id.nil?
|
if self.assigned_order_item_id.nil?
|
||||||
|
|||||||
@@ -6,13 +6,62 @@ 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}")}
|
||||||
scope :shop, -> { where("bookings.shop_code=?",Shop.current_shop.shop_code) }
|
scope :assign, -> { where(booking_status: 'assign')}
|
||||||
|
scope :within_time_limit, -> { where(checkin_at: Lookup.get_checkin_time_limit.hours.ago..DateTime::Infinity.new) }
|
||||||
|
|
||||||
def self.sync_booking_records(bookings)
|
def self.sync_booking_records(bookings)
|
||||||
if !bookings.nil?
|
if !bookings.nil?
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
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)}
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ class Customer < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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")
|
||||||
|
|||||||
@@ -22,9 +22,8 @@ class DiningCharge < ApplicationRecord
|
|||||||
end
|
end
|
||||||
return block_count, price
|
return block_count, price
|
||||||
else
|
else
|
||||||
Rails.logger.info "Params not enough"
|
return 0, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# dining charges calculate
|
# dining charges calculate
|
||||||
|
|||||||
@@ -1,7 +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 :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, -> { 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')) }, 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"
|
||||||
@@ -22,7 +35,7 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_booking
|
def get_booking
|
||||||
booking = self.get_current_booking
|
booking = self.current_checkin_booking
|
||||||
if booking
|
if booking
|
||||||
if booking.dining_facility_id.to_i == self.id
|
if booking.dining_facility_id.to_i == self.id
|
||||||
if booking.booking_status == 'assign'
|
if booking.booking_status == 'assign'
|
||||||
@@ -38,26 +51,8 @@ class DiningFacility < ApplicationRecord
|
|||||||
Booking.where(dining_facility_id: self.id, booking_status: 'assign', checkout_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first #and checkout_at is null
|
Booking.where(dining_facility_id: self.id, booking_status: 'assign', checkout_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first #and checkout_at is null
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_moved_booking
|
|
||||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
|
||||||
Booking.where(dining_facility_id: self.id, booking_status: 'moved', checkout_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_new_booking
|
|
||||||
# query for new
|
|
||||||
Booking.where(dining_facility_id: self.id, booking_status: 'assign', sale_id: nil, checkout_at: nil).first
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_current_checkout_booking
|
|
||||||
|
|
||||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
|
||||||
Booking.where(dining_facility_id: self.id, booking_status: 'assign', checkout_at: nil).where.not(reserved_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_checkout_booking
|
def get_checkout_booking
|
||||||
booking = self.get_current_checkout_booking
|
booking = self.current_reserved_booking
|
||||||
if booking
|
if booking
|
||||||
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time")
|
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time")
|
||||||
free_time_min = 0
|
free_time_min = 0
|
||||||
@@ -97,8 +92,7 @@ class DiningFacility < ApplicationRecord
|
|||||||
def self.get_checkin_booking
|
def self.get_checkin_booking
|
||||||
|
|
||||||
checkin_time_lookup = Lookup.get_checkin_time_limit
|
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||||
bookings = Booking.where(booking_status: 'assign', checkout_at: nil).where.not(reserved_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago)
|
bookings = self.current_checkin_booking
|
||||||
|
|
||||||
arr_booking = Array.new
|
arr_booking = Array.new
|
||||||
if bookings
|
if bookings
|
||||||
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time")
|
lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time")
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -83,21 +83,8 @@ class InventoryDefinition < ApplicationRecord
|
|||||||
.order("mi.menu_category_id desc")
|
.order("mi.menu_category_id desc")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_by_category(shop,filter)
|
def self.get_by_category(filter)
|
||||||
# THEN (SELECT min(balance) FROM stock_journals
|
least_stock = StockJournal.select(:balance).joins("JOIN inventory_definitions ON stock_journals.item_code = inventory_definitions.item_code").order(:id => :desc).limit(1).to_sql
|
||||||
# least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
|
|
||||||
# THEN (SELECT balance FROM stock_journals
|
|
||||||
# WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock'
|
|
||||||
# ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
|
|
||||||
# FROM stock_journals
|
|
||||||
# WHERE stock_journals.item_code = inventory_definitions.item_code
|
|
||||||
# ORDER BY stock_journals.created_at DESC LIMIT 1"
|
|
||||||
least_stock = "(SELECT
|
|
||||||
(SELECT balance FROM stock_journals WHERE item_code = inventory_definitions.item_code
|
|
||||||
ORDER BY id DESC LIMIT 1)
|
|
||||||
FROM stock_journals
|
|
||||||
WHERE stock_journals.item_code = inventory_definitions.item_code
|
|
||||||
ORDER BY stock_journals.created_at DESC LIMIT 1)"
|
|
||||||
|
|
||||||
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
||||||
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
|
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class Lookup < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.collection_of(type)
|
def self.collection_of(type)
|
||||||
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }
|
Lookup.where("lookup_type" => type ).pluck("name, value")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_shift_sale_lookup(shop_code)
|
def self.create_shift_sale_lookup(shop_code)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class MembershipSetting < ApplicationRecord
|
class MembershipSetting < ApplicationRecord
|
||||||
scope :active, -> { where(is_active: true) }
|
scope :active, -> { where(is_active: true) }
|
||||||
|
|
||||||
# MembershipSetting = MembershipSetting.find_by_id(1)
|
MembershipSetting = MembershipSetting.first
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,26 +31,26 @@ 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)
|
||||||
menu_item_hash = Hash.new
|
MenuItem.left_joins(:menu_item_instances => :menu_instance_item_sets)
|
||||||
mt_instance = MenuItemInstance.find_by_item_instance_code(item_code)
|
.where(menu_item_instances: {item_instance_code: item_code})
|
||||||
if (!mt_instance.nil?)
|
.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)
|
||||||
menu_item = MenuItem.find(mt_instance.menu_item_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, item_set_id|
|
||||||
menu_item_hash[:type] = menu_item.type
|
name = item_instance_name if item_set_id
|
||||||
menu_item_hash[:account_id] = menu_item.account_id
|
name ||= "#{item_name}#{' - ' + item_instance_name if item_instance_name.present?}"
|
||||||
menu_item_hash[:item_code] = menu_item.item_code
|
{
|
||||||
menu_item_hash[:item_instance_code] = mt_instance.item_instance_code
|
type: type,
|
||||||
menu_item_hash[:name] = menu_item.name.to_s + " - " + mt_instance.item_instance_name.to_s
|
account_id: account_id,
|
||||||
menu_item_hash[:alt_name] = menu_item.alt_name.to_s # + " - " + mt_instance.item_instance_name.to_s
|
item_code: item_code,
|
||||||
menu_item_hash[:price] = mt_instance.price
|
item_instance_code: item_instance_code,
|
||||||
menu_item_hash[:promotion_price] = mt_instance.promotion_price
|
name: "#{name}",
|
||||||
menu_item_hash[:is_on_promotion] = mt_instance.is_on_promotion
|
alt_name: "#{item_alt_name}",
|
||||||
menu_item_hash[:is_available] = mt_instance.is_available
|
price: price,
|
||||||
menu_item_hash[:taxable] = menu_item.taxable
|
promotion_price: promotion_price,
|
||||||
|
is_on_promotion: is_on_promotion,
|
||||||
return menu_item_hash
|
is_available: is_available,
|
||||||
end
|
taxable: taxable
|
||||||
|
}
|
||||||
return nil
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.deleteRecursive(menu_item)
|
def self.deleteRecursive(menu_item)
|
||||||
|
|||||||
@@ -26,25 +26,16 @@ class Order < ApplicationRecord
|
|||||||
def generate
|
def generate
|
||||||
booking = nil
|
booking = nil
|
||||||
if self.new_booking
|
if self.new_booking
|
||||||
if self.table_id.to_i > 0
|
|
||||||
table_id = self.table_id
|
|
||||||
else
|
|
||||||
table_id = nil
|
|
||||||
end
|
|
||||||
#add extra time
|
#add extra time
|
||||||
if self.is_extra_time && self.extra_time
|
if self.is_extra_time && self.extra_time
|
||||||
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
|
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
|
||||||
:checkin_at => Time.now.utc, :checkout_at => Time.now.utc + self.extra_time.to_i,
|
:checkin_at => Time.now.utc, :checkout_at => Time.now.utc + self.extra_time.to_i,
|
||||||
:checkin_by => self.employee_name,
|
:checkin_by => self.employee_name,
|
||||||
:booking_status => "assign",
|
:booking_status => "assign" })
|
||||||
:customer_id => self.customer_id,
|
|
||||||
:shop_code=>self.shop_code})
|
|
||||||
else
|
else
|
||||||
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
|
booking = Booking.create({:dining_facility_id => table_id,:type => "TableBooking",
|
||||||
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||||
:booking_status => "assign",
|
:booking_status => "assign" })
|
||||||
:customer_id => self.customer_id,
|
|
||||||
:shop_code=>self.shop_code })
|
|
||||||
end
|
end
|
||||||
#end extra time
|
#end extra time
|
||||||
|
|
||||||
@@ -54,7 +45,6 @@ class Order < ApplicationRecord
|
|||||||
# table.status = "occupied"
|
# table.status = "occupied"
|
||||||
# table.save
|
# table.save
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
booking = Booking.find(self.booking_id)
|
booking = Booking.find(self.booking_id)
|
||||||
#add extra time
|
#add extra time
|
||||||
@@ -74,7 +64,7 @@ class Order < ApplicationRecord
|
|||||||
|
|
||||||
self.adding_line_items
|
self.adding_line_items
|
||||||
#Add Order Table and Room relation afrer order creation
|
#Add Order Table and Room relation afrer order creation
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
|
booking.orders << self
|
||||||
|
|
||||||
#Send order to queue one it done!
|
#Send order to queue one it done!
|
||||||
# if self.source != "quick_service"
|
# if self.source != "quick_service"
|
||||||
@@ -111,7 +101,7 @@ class Order < ApplicationRecord
|
|||||||
|
|
||||||
self.adding_line_items
|
self.adding_line_items
|
||||||
#Add Order Table and Room relation afrer order creation
|
#Add Order Table and Room relation afrer order creation
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
|
booking.orders << self
|
||||||
|
|
||||||
#Send order to queue one it done!
|
#Send order to queue one it done!
|
||||||
# if self.source != "quick_service"
|
# if self.source != "quick_service"
|
||||||
@@ -122,7 +112,6 @@ class Order < ApplicationRecord
|
|||||||
send_order_broadcast(booking)
|
send_order_broadcast(booking)
|
||||||
|
|
||||||
return true, booking
|
return true, booking
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -137,49 +126,36 @@ class Order < ApplicationRecord
|
|||||||
def adding_line_items
|
def adding_line_items
|
||||||
if self.items
|
if self.items
|
||||||
#re-order to
|
#re-order to
|
||||||
ordered_list = re_order_items(self.items)
|
items = re_order_items(self.items)
|
||||||
|
|
||||||
#loop to add all items to order
|
#loop to add all items to order
|
||||||
ordered_list.each do |item|
|
item_instance_codes = items.map { |i| i[:item_instance_code] }
|
||||||
|
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_item = MenuItem.search_by_item_code(item[:item_instance_code])
|
items.each do |order_item|
|
||||||
|
menu_item = menu_items.find { |i| i[:item_instance_code].downcase == order_item[:item_instance_code].downcase }
|
||||||
# For Product while item code not in menu item
|
sub_order_items = []
|
||||||
if menu_item.nil?
|
if order_item[:sub_items].length > 0
|
||||||
menu_item = Product.search_by_product_code(item[:item_instance_code])
|
sub_menu_items = MenuItem.search_by_item_code(order_item[:sub_items].map { |i| i[:item_instance_code] })
|
||||||
end
|
order_item[:sub_items].each do |sub_order_item|
|
||||||
|
sub_menu_item = sub_menu_items.find { |i| i[:item_instance_code] == sub_order_item[:item_instance_code] }
|
||||||
#if (!menu_item.nil?)
|
sub_order_items << { item_instance_code: sub_order_item[:item_instance_code], item_instance_name: sub_menu_item[:name], quantity: sub_order_item[:quantity], price: sub_menu_item[:price], options: sub_order_item[:options] }
|
||||||
# Rails.logger.debug menu_item
|
|
||||||
set_order_items = Array.new
|
|
||||||
##If menu Item set item - must add child items to order as well, where price is only take from menu_item
|
|
||||||
if (menu_item[:type] == "SetMenuItem")
|
|
||||||
if (item.include? 'sub_items') || (item.include? :sub_items)
|
|
||||||
item[:sub_items].each do |si|
|
|
||||||
# Retrive instance's Price
|
|
||||||
set_item = MenuItem.search_by_item_code(si[:item_instance_code])
|
|
||||||
set_order_items.push({"item_instance_code"=>si[:item_instance_code], "item_instance_name"=>set_item[:name], "quantity"=>si[:quantity], "price"=>set_item[:price], "options"=>si[:options]})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set_order_items = set_order_items.to_json
|
sub_order_items = sub_order_items.to_json
|
||||||
else
|
self.order_items.build({
|
||||||
set_order_items = nil
|
item_code: menu_item[:item_code],
|
||||||
end
|
item_instance_code: order_item[:item_instance_code],
|
||||||
|
item_name: menu_item[:name],
|
||||||
# not insert with price 0
|
alt_name: menu_item[:alt_name],
|
||||||
# puts item[:price]
|
account_id: menu_item[:account_id],
|
||||||
# puts item
|
qty: order_item[:quantity],
|
||||||
# if(item[:price] != 0 )
|
price: menu_item[:price],
|
||||||
# OrderItem.processs_item(menu_item[:item_code], menu_item[:name], menu_item[:account_id],
|
options: order_item[:options],
|
||||||
# item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
|
set_menu_items: sub_order_items,
|
||||||
# self.employee_name)
|
item_order_by: employee_name,
|
||||||
# end
|
taxable: menu_item[:taxable]
|
||||||
|
})
|
||||||
OrderItem.processs_item(menu_item[:item_code], item[:item_instance_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
|
|
||||||
item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
|
|
||||||
self.employee_name, menu_item[:taxable])
|
|
||||||
|
|
||||||
#end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.item_count = self.order_items.count
|
self.item_count = self.order_items.count
|
||||||
@@ -190,7 +166,6 @@ class Order < ApplicationRecord
|
|||||||
self.errors.add(:order_items, :blank, message: "Order items cannot be blank")
|
self.errors.add(:order_items, :blank, message: "Order items cannot be blank")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_items_status_to_billed(items)
|
def update_items_status_to_billed(items)
|
||||||
@@ -211,72 +186,14 @@ 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
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def re_order_items(form_items) #reorder inputs items as parents and child
|
def re_order_items(items) #reorder inputs items as parents and child
|
||||||
parent_id = Array.new
|
new_items = items.select { |i| i[:parent_order_item_id].blank? }.map { |x| x[:sub_items] = items.select { |y| x[:order_item_id] == y[:parent_order_item_id] }; x }
|
||||||
parents = Array.new
|
|
||||||
parents_and_children_items = Array.new
|
|
||||||
|
|
||||||
new_items_list = Array.new
|
|
||||||
|
|
||||||
form_items.each do |parent|
|
|
||||||
if !parent[:parent_order_item_id].nil?
|
|
||||||
if (!parent_id.include?(parent[:parent_order_item_id]))
|
|
||||||
parent_id.push(parent[:parent_order_item_id])
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Rails.logger.debug "Parent Id count -> " + parent_id.count.to_s
|
|
||||||
|
|
||||||
|
|
||||||
parent_id.each do |pid|
|
|
||||||
form_items.each do |item|
|
|
||||||
Rails.logger.debug "Adding - Parents -> " + pid.to_s + " - " + item[:order_item_id].to_s
|
|
||||||
if (pid == item[:order_item_id])
|
|
||||||
parents.push(item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Rails.logger.debug "Parents count -> " + parents.count.to_s
|
|
||||||
|
|
||||||
parents.each do |parent|
|
|
||||||
children = Array.new
|
|
||||||
form_items.each do |item|
|
|
||||||
if (parent[:order_item_id] == item[:parent_order_item_id] )
|
|
||||||
children.push(item)
|
|
||||||
#Items to remove for new list
|
|
||||||
parents_and_children_items.push(item)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
parent[:sub_items] = children
|
|
||||||
end
|
|
||||||
Rails.logger.debug "Parent/children Items to remove -> " + parents_and_children_items.count.to_s
|
|
||||||
|
|
||||||
#Remove process items
|
|
||||||
#c = a.reject{ |e| b.include? e }
|
|
||||||
|
|
||||||
new_items_list = form_items - parents_and_children_items
|
|
||||||
|
|
||||||
|
|
||||||
Rails.logger.debug "New list count -> " + new_items_list.count.to_s
|
|
||||||
|
|
||||||
#Add parent to the list
|
|
||||||
#new_items_list = new_items_list + parents
|
|
||||||
|
|
||||||
Rails.logger.debug "Re-Order List (Parent)-"
|
|
||||||
|
|
||||||
Rails.logger.debug parents
|
|
||||||
|
|
||||||
Rails.logger.debug "Re-Order List -"
|
|
||||||
Rails.logger.debug new_items_list
|
|
||||||
|
|
||||||
return new_items_list
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -494,45 +411,12 @@ class Order < ApplicationRecord
|
|||||||
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)
|
|
||||||
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'
|
|
||||||
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'
|
msg = 'Print Error ! Please contact to service'
|
||||||
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
|
ActionCable.server.broadcast "call_waiter_channel", table: msg, time:'print_error', from: ''
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if !sidekiq.nil?
|
if !sidekiq.nil?
|
||||||
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
OrderQueueProcessorJob.perform_later(order_id, table_id)
|
||||||
else
|
else
|
||||||
@@ -544,8 +428,6 @@ class Order < ApplicationRecord
|
|||||||
ActionCable.server.broadcast "order_queue_station_channel", order: assign_order
|
ActionCable.server.broadcast "order_queue_station_channel", order: assign_order
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.check_cup_status(status)
|
def self.check_cup_status(status)
|
||||||
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
|
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -102,7 +104,13 @@ class OrderItem < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
def self.generate_ids(count = 1)
|
||||||
|
SeedGenerator.generate_ids(self.name, "ODI", count)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
if self.order_items_id.nil?
|
if self.order_items_id.nil?
|
||||||
self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI")
|
self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI")
|
||||||
|
|||||||
@@ -15,104 +15,39 @@ 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.where("shop_code='#{order.shop_code}'")
|
|
||||||
|
|
||||||
|
|
||||||
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}")
|
oqs_stations = dining.order_queue_stations
|
||||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
else
|
||||||
|
oqs_stations = OrderQueueStation.active
|
||||||
|
end
|
||||||
|
|
||||||
|
assigned_order_items = []
|
||||||
|
oqs_order_items_by_zones = []
|
||||||
|
|
||||||
# ToDo per item per printer
|
# ToDo per item per printer
|
||||||
|
|
||||||
oqs_by_zones.each do |oqpbz|
|
|
||||||
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
|
|
||||||
is_auto_printed = false
|
|
||||||
oqs_order_items = []
|
|
||||||
|
|
||||||
if oqs.is_active
|
|
||||||
#Get List of items -
|
|
||||||
pq_items = JSON.parse(oqs.processing_items)
|
|
||||||
#Loop through the processing items
|
|
||||||
pq_items.each do |pq_item|
|
|
||||||
#Processing through the looping items
|
|
||||||
order_items.each do |order_item|
|
|
||||||
if (pq_item == order_item.item_code)
|
|
||||||
# if oqs.id == oqpbz.order_queue_station_id
|
|
||||||
# #Same Order_items can appear in two location.
|
|
||||||
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
|
||||||
# else
|
|
||||||
|
|
||||||
if (order_item.qty > 0)
|
|
||||||
if pdf_status.nil?
|
|
||||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
|
|
||||||
end
|
|
||||||
oqs_order_items.push(order_item)
|
|
||||||
end
|
|
||||||
# end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if oqs.auto_print && order_source != "quick_service"
|
|
||||||
if oqs_order_items.length > 0
|
|
||||||
if oqs.cut_per_item
|
|
||||||
print_slip_item(oqs, order, oqs_order_items,pdf_status,change_to,current_user,table_id)
|
|
||||||
else
|
|
||||||
print_slip(oqs, order, oqs_order_items,pdf_status,change_to,current_user,table_id)
|
|
||||||
end
|
|
||||||
is_auto_printed = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
oqs_stations.each do |oqs|
|
oqs_stations.each do |oqs|
|
||||||
is_auto_printed = false
|
oqs_order_items = order_items.select { |i| JSON.parse(oqs.processing_items).include? i.item_code }
|
||||||
oqs_order_items = []
|
oqs_order_items_by_zones << { oqs: oqs, oqs_order_items: oqs_order_items }
|
||||||
|
|
||||||
if oqs.is_active
|
|
||||||
#Get List of items -
|
|
||||||
pq_items = JSON.parse(oqs.processing_items)
|
|
||||||
#Loop through the processing items
|
|
||||||
pq_items.each do |pq_item|
|
|
||||||
#Processing through the looping items
|
|
||||||
order_items.each do |order_item|
|
|
||||||
if (pq_item == order_item.item_code)
|
|
||||||
# if oqs.id == oqpbz.order_queue_station_id
|
|
||||||
# #Same Order_items can appear in two location.
|
|
||||||
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
|
||||||
# else
|
|
||||||
|
|
||||||
if (order_item.qty > 0)
|
|
||||||
if pdf_status.nil?
|
|
||||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
|
|
||||||
end
|
|
||||||
oqs_order_items.push(order_item)
|
|
||||||
end
|
|
||||||
# end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
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)
|
||||||
else
|
else
|
||||||
print_slip(oqs, order, oqs_order_items, pdf_status, change_to, current_user, table_id)
|
print_slip(oqs, order, oqs_order_items, pdf_status, change_to, current_user, table_id)
|
||||||
end
|
end
|
||||||
is_auto_printed = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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 }) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end #end else
|
|
||||||
end
|
|
||||||
|
|
||||||
def pay_process_order_queue (order_id, table_id)
|
def pay_process_order_queue (order_id, table_id)
|
||||||
|
|
||||||
@@ -213,80 +148,31 @@ class OrderQueueStation < ApplicationRecord
|
|||||||
#Print order_items in 1 slip
|
#Print order_items in 1 slip
|
||||||
def print_slip(oqs, order, order_items ,pdf_status=nil,change_to=nil,current_user=nil,table_id=nil)
|
def print_slip(oqs, order, order_items ,pdf_status=nil,change_to=nil,current_user=nil,table_id=nil)
|
||||||
if pdf_status.nil?
|
if pdf_status.nil?
|
||||||
printer = PrintSetting.where("shop_code='#{oqs.shop_code}'").order("id ASC")
|
if print_settings = PrintSetting.where("unique_code REGEXP ?", "order.*summary.*pdf").first
|
||||||
unique_code="OrderSummaryPdf"
|
|
||||||
|
|
||||||
if !printer.empty?
|
|
||||||
printer.each do |printer_setting|
|
|
||||||
if printer_setting.unique_code == 'OrderSummaryPdf'
|
|
||||||
unique_code="OrderSummaryPdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimPdf'
|
|
||||||
unique_code="OrderSummarySlimPdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetPdf'
|
|
||||||
unique_code="OrderSummarySetPdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf'
|
|
||||||
unique_code="OrderSummaryCustomisePdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf'
|
|
||||||
unique_code="OrderSummarySetCustomisePdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf'
|
|
||||||
unique_code="OrderSummarySlimCustomisePdf"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,oqs.shop_code)
|
|
||||||
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
||||||
order_queue_printer.print_order_summary(print_settings, oqs, order.order_id, order_items, print_status="")
|
order_queue_printer.print_order_summary(print_settings, oqs, order.order_id, order_items, print_status="")
|
||||||
|
end
|
||||||
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
|
||||||
|
|
||||||
assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
|
|
||||||
AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).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?
|
||||||
printer = PrintSetting.where("shop_code='#{oqs.shop_code}'").order("id ASC")
|
|
||||||
unique_code="OrderItemPdf"
|
|
||||||
|
|
||||||
if !printer.empty?
|
|
||||||
printer.each do |printer_setting|
|
|
||||||
if printer_setting.unique_code == 'OrderItemPdf'
|
|
||||||
unique_code="OrderItemPdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderItemStarPdf'
|
|
||||||
unique_code="OrderItemStarPdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
|
|
||||||
unique_code="OrderItemSlimPdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderSetItemPdf'
|
|
||||||
unique_code="OrderSetItemPdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderItemCustomisePdf'
|
|
||||||
unique_code="OrderItemCustomisePdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderSetItemCustomisePdf'
|
|
||||||
unique_code="OrderSetItemCustomisePdf"
|
|
||||||
elsif printer_setting.unique_code == 'OrderItemSlimCustomisePdf'
|
|
||||||
unique_code="OrderItemSlimCustomisePdf"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# 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
|
||||||
print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,oqs.shop_code)
|
if print_settings = PrintSetting.where("unique_code REGEXP ?", "order.*item.*pdf").first
|
||||||
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
||||||
if !assigned_items.nil?
|
if !assigned_items.nil?
|
||||||
assigned_items.each do |order_item|
|
assigned_items.each do |order_item|
|
||||||
order_queue_printer.print_order_item(print_settings, oqs,order_item.order_id, order_item.order_items_id, print_status="" )
|
order_queue_printer.print_order_item(print_settings, oqs,order_item.order_id, order_item.order_items_id, print_status="" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
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
|
||||||
|
|
||||||
assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
|
|
||||||
AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).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)
|
||||||
|
|||||||
@@ -9,33 +9,10 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code)
|
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code)
|
||||||
options = order_item[0].options
|
options = order_item[0].options
|
||||||
# filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
|
||||||
|
|
||||||
# pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
|
||||||
print_setting = PrintSetting.all
|
|
||||||
|
|
||||||
# check for item not to show
|
# check for item not to show
|
||||||
pdf = ''
|
|
||||||
# if order_item[0].price != 0
|
# if order_item[0].price != 0
|
||||||
if !print_setting.empty?
|
pdf = print_settings.unique_code.constantize.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||||
print_setting.each do |print_settings|
|
|
||||||
if print_settings.unique_code == 'OrderItemPdf'
|
|
||||||
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemStarPdf'
|
|
||||||
pdf = OrderItemStarPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
|
||||||
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
|
||||||
pdf = OrderSetItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemCustomisePdf'
|
|
||||||
pdf = OrderItemCustomisePdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSetItemCustomisePdf'
|
|
||||||
pdf = OrderSetItemCustomisePdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemSlimCustomisePdf'
|
|
||||||
pdf = OrderItemSlimCustomisePdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
|
||||||
@@ -47,22 +24,12 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
|
|
||||||
if oqs.print_copy
|
|
||||||
#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
|
end
|
||||||
#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
|
|
||||||
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
|
|
||||||
|
|
||||||
return filename, order_id, oqs.printer_name
|
return filename, order_id, oqs.printer_name
|
||||||
end
|
end
|
||||||
@@ -78,13 +45,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
|||||||
print_settings.save!
|
print_settings.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
print_setting = PrintSetting.all.order("id ASC")
|
shop = Shop.current_shop
|
||||||
order=print_query('order_summary', order_id)
|
directory_name = "public/orders_#{shop.shop_code}"
|
||||||
|
|
||||||
|
|
||||||
# shop = Shop.current_shop
|
|
||||||
directory_name = 'public/orders_'+ oqs.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
|
||||||
@@ -93,77 +55,33 @@ 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
|
||||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
pdf = print_settings.unique_code.constantize.new(print_settings, odi_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
||||||
if !print_setting.empty?
|
|
||||||
print_setting.each do |print_settings|
|
|
||||||
if print_settings.unique_code == 'OrderItemPdf'
|
|
||||||
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemStarPdf'
|
|
||||||
pdf = OrderItemStarPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
|
||||||
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
|
||||||
pdf = OrderSetItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemCustomisePdf'
|
|
||||||
pdf = OrderItemCustomisePdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSetItemCustomisePdf'
|
|
||||||
pdf = OrderSetItemCustomisePdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemSlimCustomisePdf'
|
|
||||||
pdf = OrderItemSlimCustomisePdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# 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
|
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
|
||||||
# For Print Order Summary
|
# For Print Order Summary
|
||||||
else
|
else
|
||||||
filename = directory_name + "/order_summary_#{order_id}" + ".pdf"
|
order = print_query('order_summary', order_id)
|
||||||
|
|
||||||
|
filename = directory_name + "/order_summary_#{order_id}.pdf"
|
||||||
# filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
# filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.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)
|
||||||
if !print_setting.empty?
|
|
||||||
print_setting.each do |print_settings|
|
|
||||||
if print_settings.unique_code == 'OrderSummaryPdf'
|
|
||||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummarySlimPdf'
|
|
||||||
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummarySetPdf'
|
|
||||||
pdf = OrderSummarySetPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummaryCustomisePdf'
|
|
||||||
pdf = OrderSummaryCustomisePdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummarySetCustomisePdf'
|
|
||||||
pdf = OrderSummarySetCustomisePdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummarySlimCustomisePdf'
|
|
||||||
pdf = OrderSummarySlimCustomisePdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -171,14 +89,6 @@ 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
|
|
||||||
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
|
||||||
return filename, order_id, oqs.printer_name
|
return filename, order_id, oqs.printer_name
|
||||||
end
|
end
|
||||||
@@ -210,29 +120,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 = OrderItemPdf.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)
|
||||||
if !print_setting.empty?
|
|
||||||
print_setting.each do |print_settings|
|
|
||||||
if print_settings.unique_code == 'OrderItemPdf'
|
|
||||||
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemStarPdf'
|
|
||||||
pdf = OrderItemStarPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemSlimPdf'
|
|
||||||
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSetItemPdf'
|
|
||||||
pdf = OrderSetItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemCustomisePdf'
|
|
||||||
pdf = OrderItemCustomisePdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSetItemCustomisePdf'
|
|
||||||
pdf = OrderSetItemCustomisePdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderItemSlimCustomisePdf'
|
|
||||||
pdf = OrderItemSlimCustomisePdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
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)
|
||||||
@@ -240,42 +131,15 @@ 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
|
|
||||||
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
|
||||||
# For Print Order Summary
|
# For Print Order Summary
|
||||||
else
|
else
|
||||||
# filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
# filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
||||||
filename = directory_name + "/booking_summary_#{booking_id}" + ".pdf"
|
filename = directory_name + "/booking_summary_#{booking_id}" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
pdf = print_settings.unique_code.constantize.new(print_settings, order, print_status, oqs.use_alternate_name, before_updated_qty)
|
||||||
|
|
||||||
if !print_setting.empty?
|
|
||||||
print_setting.each do |print_settings|
|
|
||||||
if print_settings.unique_code == 'OrderSummaryPdf'
|
|
||||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummarySlimPdf'
|
|
||||||
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummarySetPdf'
|
|
||||||
pdf = OrderSummarySetPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummaryCustomisePdf'
|
|
||||||
pdf = OrderSummaryCustomisePdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummarySetCustomisePdf'
|
|
||||||
pdf = OrderSummarySetCustomisePdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
elsif print_settings.unique_code == 'OrderSummarySlimCustomisePdf'
|
|
||||||
pdf = OrderSummarySlimCustomisePdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -283,50 +147,29 @@ 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
|
|
||||||
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
|
||||||
return filename, booking_id, oqs.printer_name
|
return filename, booking_id, oqs.printer_name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Query for OQS with status
|
# Query for OQS with status
|
||||||
def print_query(type, id)
|
def print_query(type, id)
|
||||||
|
query = OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
||||||
|
.joins("left join orders ON orders.order_id = order_items.order_id")
|
||||||
|
.joins("left join booking_orders AS bo ON bo.order_id=order_items.order_id")
|
||||||
|
.joins("left join bookings AS b ON b.booking_id = bo.booking_id")
|
||||||
|
.joins("left join dining_facilities AS df ON df.id = b.dining_facility_id")
|
||||||
|
.joins("left join customers as cus ON cus.customer_id = orders.customer_id")
|
||||||
|
.joins("left join menu_items as item ON item.item_code = order_items.item_code")
|
||||||
|
|
||||||
if type == "order_item"
|
if type == "order_item"
|
||||||
OrderItem.select("orders.source,cus.contact_no,rder_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
query.where("order_items.order_items_id = ?", id)
|
||||||
.joins("left join orders ON orders.order_id = order_items.order_id
|
|
||||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
|
||||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
|
||||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
|
||||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
|
||||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
|
||||||
.where("order_items.order_items_id = '#{ id }'")
|
|
||||||
.group("order_items.item_code")
|
.group("order_items.item_code")
|
||||||
elsif type == "order_summary"
|
elsif type == "order_summary"
|
||||||
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
query.where("orders.order_id = ?", id)
|
||||||
.joins("left join orders ON orders.order_id = order_items.order_id
|
|
||||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
|
||||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
|
||||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
|
||||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
|
||||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
|
||||||
.where("orders.order_id = '#{ id }'")
|
|
||||||
.group("order_items.order_items_id")
|
.group("order_items.order_items_id")
|
||||||
else
|
else
|
||||||
# order summary for booking
|
# order summary for booking
|
||||||
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name")
|
query.where("b.booking_id = ?", id)
|
||||||
.joins("left join orders ON orders.order_id = order_items.order_id
|
|
||||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
|
||||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
|
||||||
left join dining_facilities AS df ON df.id = b.dining_facility_id
|
|
||||||
left join customers as cus ON cus.customer_id = orders.customer_id
|
|
||||||
left join menu_items as item ON item.item_code = order_items.item_code")
|
|
||||||
.where("b.booking_id = '#{ id }'")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -37,21 +37,22 @@ class Printer::PrinterWorker
|
|||||||
Cups.default_printer
|
Cups.default_printer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.printer_exists?(printer)
|
||||||
|
Cups.show_destinations.include? printer
|
||||||
|
end
|
||||||
|
|
||||||
def print(file_path, printer_destination = nil )
|
def print(file_path, printer_destination = nil )
|
||||||
# if printer_destination.nil?
|
if printer_destination.nil?
|
||||||
# printer_destination = self.printer_destination
|
printer_destination = self.printer_destination
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# puts printer_destination
|
copy = self.print_copies
|
||||||
# puts '........Printer Destination..........'
|
#Print only when printer information is not null
|
||||||
#
|
if !self.printer_destination.nil?
|
||||||
# copy = self.print_copies
|
(1..copy).each do
|
||||||
# #Print only when printer information is not null
|
page = Cups::PrintJob.new(file_path, printer_destination)
|
||||||
# if !self.printer_destination.nil?
|
page.print
|
||||||
# (1..copy).each do
|
end
|
||||||
# page = Cups::PrintJob.new(file_path, printer_destination)
|
end
|
||||||
# page.print
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,26 +4,9 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
printer = PrintSetting.all
|
printer = PrintSetting.where("unique_code REGEXP ?", "order.*item.*pdf").first
|
||||||
pdf = OrderItemPdf.new
|
pdf = printer.unique_code.constantize.new
|
||||||
|
|
||||||
if !printer.empty?
|
|
||||||
printer.each do |printer_setting|
|
|
||||||
if printer_setting.unique_code == 'OrderItemPdf'
|
|
||||||
pdf = OrderItemPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
|
|
||||||
pdf = OrderItemSlimPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSetItemPdf'
|
|
||||||
pdf = OrderSetItemPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderItemCustomisePdf'
|
|
||||||
pdf = OrderItemCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSetItemCustomisePdf'
|
|
||||||
pdf = OrderSetItemCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderItemSlimCustomisePdf'
|
|
||||||
pdf = OrderItemSlimCustomisePdf.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf"
|
pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf"
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
@@ -36,26 +19,9 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
printer = PrintSetting.all
|
printer = PrintSetting.where("unique_code REGEXP ?", "order.*summary.*pdf").first
|
||||||
pdf = OrderSummaryPdf.new
|
pdf = printer.unique_code.constantize.new
|
||||||
|
|
||||||
if !printer.empty?
|
|
||||||
printer.each do |printer_setting|
|
|
||||||
if printer_setting.unique_code == 'OrderSummaryPdf'
|
|
||||||
pdf = OrderSummaryPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimPdf'
|
|
||||||
pdf = OrderSummarySlimPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetPdf'
|
|
||||||
pdf = OrderSummarySetPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf'
|
|
||||||
pdf = OrderSummaryCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf'
|
|
||||||
pdf = OrderSummarySetCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf'
|
|
||||||
pdf = OrderSummarySlimCustomisePdf.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
@@ -67,26 +33,10 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
printer = PrintSetting.all
|
printer = PrintSetting.where("unique_code REGEXP ?", "order.*summary.*pdf").first
|
||||||
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.new
|
pdf = printer.unique_code.constantize.new
|
||||||
if !printer.empty?
|
|
||||||
printer.each do |printer_setting|
|
|
||||||
if printer_setting.unique_code == 'OrderSummaryPdf'
|
|
||||||
pdf = OrderSummaryPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimPdf'
|
|
||||||
pdf = OrderSummarySlimPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetPdf'
|
|
||||||
pdf = OrderSummarySetPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf'
|
|
||||||
pdf = OrderSummaryCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf'
|
|
||||||
pdf = OrderSummarySetCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf'
|
|
||||||
pdf = OrderSummarySlimCustomisePdf.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
@@ -98,26 +48,10 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
printer = PrintSetting.all
|
printer = PrintSetting.where("unique_code REGEXP ?", "order.*summary.*pdf").first
|
||||||
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.new
|
pdf = printer.unique_code.constantize.new
|
||||||
if !printer.empty?
|
|
||||||
printer.each do |printer_setting|
|
|
||||||
if printer_setting.unique_code == 'OrderSummaryPdf'
|
|
||||||
pdf = OrderSummaryPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimPdf'
|
|
||||||
pdf = OrderSummarySlimPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetPdf'
|
|
||||||
pdf = OrderSummarySetPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf'
|
|
||||||
pdf = OrderSummaryCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf'
|
|
||||||
pdf = OrderSummarySetCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf'
|
|
||||||
pdf = OrderSummarySlimCustomisePdf.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
@@ -129,26 +63,10 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
printer = PrintSetting.all
|
printer = PrintSetting.where("unique_code REGEXP ?", "order.*summary.*pdf").first
|
||||||
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.new
|
pdf = printer.unique_code.constantize.new
|
||||||
if !printer.empty?
|
|
||||||
printer.each do |printer_setting|
|
|
||||||
if printer_setting.unique_code == 'OrderSummaryPdf'
|
|
||||||
pdf = OrderSummaryPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimPdf'
|
|
||||||
pdf = OrderSummarySlimPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetPdf'
|
|
||||||
pdf = OrderSummarySetPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf'
|
|
||||||
pdf = OrderSummaryCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf'
|
|
||||||
pdf = OrderSummarySetCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf'
|
|
||||||
pdf = OrderSummarySlimCustomisePdf.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
@@ -160,26 +78,10 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
printer = PrintSetting.all
|
printer = PrintSetting.where("unique_code REGEXP ?", "order.*summary.*pdf").first
|
||||||
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
||||||
pdf = OrderSummaryPdf.new
|
pdf = printer.unique_code.constantize.new
|
||||||
if !printer.empty?
|
|
||||||
printer.each do |printer_setting|
|
|
||||||
if printer_setting.unique_code == 'OrderSummaryPdf'
|
|
||||||
pdf = OrderSummaryPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimPdf'
|
|
||||||
pdf = OrderSummarySlimPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetPdf'
|
|
||||||
pdf = OrderSummarySetPdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummaryCustomisePdf'
|
|
||||||
pdf = OrderSummaryCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySetCustomisePdf'
|
|
||||||
pdf = OrderSummarySetCustomisePdf.new
|
|
||||||
elsif printer_setting.unique_code == 'OrderSummarySlimCustomisePdf'
|
|
||||||
pdf = OrderSummarySlimCustomisePdf.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
pdf.render_file filename
|
pdf.render_file filename
|
||||||
#no print in cloud server
|
#no print in cloud server
|
||||||
if ENV["SERVER_MODE"] != "cloud"
|
if ENV["SERVER_MODE"] != "cloud"
|
||||||
@@ -192,32 +94,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
puts printer_settings.to_json
|
if printer_settings
|
||||||
if !printer_settings.nil?
|
if !printer_settings.unique_code.match?(/receiptbillorder/i)
|
||||||
if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder")
|
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
|
||||||
pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref)
|
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||||
settings = PrintSetting.where("shop_code='#{shop_details.shop_code}'")
|
else
|
||||||
if !settings.nil?
|
pdf = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code.constantize.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
||||||
settings.each do |setting|
|
|
||||||
if setting.unique_code == 'ReceiptBillPdf'
|
|
||||||
pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref)
|
|
||||||
elsif setting.unique_code == 'ReceiptBillStarPdf'
|
|
||||||
pdf = ReceiptBillStarPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
receipt_bill_a5_pdf = Lookup.where("shop_code='#{shop_details.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
|
||||||
if !receipt_bill_a5_pdf.empty?
|
|
||||||
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
|
||||||
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
|
||||||
if receipt_bilA5[1] == '1'
|
|
||||||
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref)
|
|
||||||
# else
|
|
||||||
# pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
#doemal online order pdf template
|
#doemal online order pdf template
|
||||||
|
|||||||
@@ -5,29 +5,23 @@ class Product < ApplicationRecord
|
|||||||
mount_uploader :image_path, ProductImageUploader
|
mount_uploader :image_path, ProductImageUploader
|
||||||
|
|
||||||
def self.search_by_product_code(item_code)
|
def self.search_by_product_code(item_code)
|
||||||
account = Account.find_by_title('Product')
|
Product.joins("JOIN accounts ON accounts.title = 'Product'")
|
||||||
if !account.nil?
|
.where(item_code: item_code)
|
||||||
account_id = account.id
|
.pluck("accounts.id AS account_id", :item_code, :name, :alt_name, :unit_price, :taxable)
|
||||||
else
|
.map { |account_id, item_code, item_name, item_alt_name, price, taxable|
|
||||||
account_id = 1
|
{
|
||||||
end
|
type: 'Product',
|
||||||
|
account_id: account_id,
|
||||||
menu_item_hash = Hash.new
|
item_code: item_code,
|
||||||
mt_instance = Product.find_by_item_code(item_code)
|
item_instance_code: item_code,
|
||||||
if (!mt_instance.nil?)
|
name: "#{item_name}",
|
||||||
menu_item_hash[:type] = 'Product'
|
alt_name: "#{item_name}",
|
||||||
menu_item_hash[:account_id] = account_id
|
price: price,
|
||||||
menu_item_hash[:item_code] = mt_instance.item_code
|
promotion_price: 0,
|
||||||
menu_item_hash[:item_instance_code] = mt_instance.item_code
|
is_on_promotion: 0,
|
||||||
menu_item_hash[:name] = mt_instance.name.to_s
|
is_available: 0,
|
||||||
menu_item_hash[:alt_name] = mt_instance.alt_name.to_s
|
taxable: taxable
|
||||||
menu_item_hash[:price] = mt_instance.unit_price
|
}
|
||||||
menu_item_hash[:promotion_price] = 0
|
}
|
||||||
menu_item_hash[:is_on_promotion] = 0
|
|
||||||
menu_item_hash[:is_available] = 0
|
|
||||||
menu_item_hash[:taxable] = mt_instance.taxable
|
|
||||||
|
|
||||||
return menu_item_hash
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ 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 :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_one :survey, foreign_key: "receipt_no"
|
||||||
has_many :sale_audits
|
has_many :sale_audits
|
||||||
has_many :sale_items
|
has_many :sale_items
|
||||||
@@ -15,11 +18,12 @@ class Sale < ApplicationRecord
|
|||||||
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
|
||||||
@@ -31,9 +35,7 @@ class Sale < ApplicationRecord
|
|||||||
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])) }
|
||||||
scope :shop, -> { where("sales.shop_code=?",Shop.current_shop.shop_code) }
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
@@ -82,186 +84,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'
|
||||||
|
sale.cashier = cashier
|
||||||
|
sale.shift_sale = cashier.current_shift
|
||||||
|
elsif booking.dining_facility
|
||||||
|
if sale.shift_sale = booking.current_shift_by_dining_facility
|
||||||
|
sale.cashier = sale.shift_sale.employee
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# dining charges
|
if sale.shift_sale.nil?
|
||||||
charges = DiningCharge.where('dining_facility_id=?', booking.dining_facility_id).take
|
if sale.cashier = Employee.where(role: 'cashier').where.not(token_session: [nil, '']).first
|
||||||
if !charges.nil?
|
sale.shift_sale = sale.current_shift_by_cashier
|
||||||
block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
|
|
||||||
if charges.charge_type =='hr'
|
|
||||||
dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s
|
|
||||||
else
|
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
|
sale.shift_sale = ShiftSale.current_shift
|
||||||
|
sale.cashier = sale.shift_sale.employee
|
||||||
end
|
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
|
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
|
return sale
|
||||||
end
|
end
|
||||||
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
|
|
||||||
else
|
|
||||||
shift = ShiftSale.current_open_shift(cashier)
|
|
||||||
end
|
|
||||||
# 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])
|
|
||||||
if shift_id
|
|
||||||
self.shift_sale_id = shift_id.id
|
|
||||||
else
|
|
||||||
self.shift_sale_id = current_shift.id
|
|
||||||
end
|
|
||||||
else
|
|
||||||
self.cashier_id = current_shift.employee_id
|
|
||||||
self.cashier_name = Employee.find(current_shift.employee_id).name
|
|
||||||
self.shift_sale_id = current_shift.id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# set waiter
|
|
||||||
self.requested_by = requested_by.name
|
|
||||||
|
|
||||||
self.requested_at = DateTime.now.utc.getlocal
|
|
||||||
self.shop_code = Shop.current_shop.shop_code
|
|
||||||
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
|
|
||||||
self.orders << order
|
|
||||||
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)
|
||||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
# Promotion Activation
|
||||||
elsif @sale_data = Sale.generate_invoice_from_booking(check_booking,current_login_employee,current_user,order.source)
|
Promotion.promo_activate(sale_data)
|
||||||
@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
|
||||||
@@ -532,6 +462,19 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
|
tax_profiles = unique_tax_profiles(order_source, self.customer_id)
|
||||||
|
if tax_type.nil?
|
||||||
|
if tax_profiles.count == 2
|
||||||
|
tax_type = "all"
|
||||||
|
elsif tax_profiles.count == 1
|
||||||
|
if tax_profiles.name.downcase == "service charges"
|
||||||
|
tax_type = "Service Charges"
|
||||||
|
else
|
||||||
|
tax_type = "Commercial Tax"
|
||||||
|
end
|
||||||
|
elsif tax_profiles.count < 1
|
||||||
|
tax_type = "no_tax"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# #Creat new tax records
|
# #Creat new tax records
|
||||||
if self.payment_status != 'foc' && tax_type.to_s == "all"
|
if self.payment_status != 'foc' && tax_type.to_s == "all"
|
||||||
@@ -690,14 +633,6 @@ class Sale < ApplicationRecord
|
|||||||
self.total_tax = total_tax_amount
|
self.total_tax = total_tax_amount
|
||||||
end
|
end
|
||||||
|
|
||||||
def product_get_unit_price(item_code)
|
|
||||||
menu_item_hash =MenuItem.search_by_item_code(item_code)
|
|
||||||
if (menu_instance_code)
|
|
||||||
return menu_ item_hash[:item_instance_code], menu_item_hash[:price]
|
|
||||||
end
|
|
||||||
return nil,nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def link_order_sale(order_id)
|
def link_order_sale(order_id)
|
||||||
#create if it doesn't exist
|
#create if it doesn't exist
|
||||||
saleOrder = SaleOrder.where("sale_id=? and order_id=?", self.id, order_id).take
|
saleOrder = SaleOrder.where("sale_id=? and order_id=?", self.id, order_id).take
|
||||||
@@ -861,11 +796,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) 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,
|
||||||
|
(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 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,
|
||||||
@@ -1129,7 +1068,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,shop_code)
|
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 = ''
|
||||||
@@ -1141,8 +1080,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()
|
||||||
@@ -1299,7 +1236,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)
|
||||||
@@ -1352,16 +1289,16 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,
|
|||||||
|
|
||||||
if order_source.present?
|
if order_source.present?
|
||||||
if order_source == "cashier"
|
if order_source == "cashier"
|
||||||
credits = credits.where("order_sources.source IN (?)", ['cashier', 'emenu'])
|
credits = credits.where("orders.source IN (?)", ['cashier', 'emenu'])
|
||||||
else
|
else
|
||||||
credits = credits.where("order_sources.source = ?", order_source)
|
credits = credits.where("orders.source = ?", order_source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if filter == 'paid'
|
if filter == 'paid'
|
||||||
credits = credits.where("payments_for_credits IS NOT NULL")
|
credits = credits.where("payments_for_credits.sale_id IS NOT NULL")
|
||||||
elsif filter == 'unpaid'
|
elsif filter == 'unpaid'
|
||||||
credits = credits.where("payments_for_credits IS NULL")
|
credits = credits.where("payments_for_credits.sale_id IS NULL")
|
||||||
end
|
end
|
||||||
|
|
||||||
if shift.present?
|
if shift.present?
|
||||||
@@ -1428,42 +1365,9 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type,shop_code)
|
def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type)
|
||||||
sub_query = "SELECT (CASE WHEN SUM(sale_payments.payment_amount) > 0 THEN SUM(sale_payments.payment_amount) ELSE 0 END)
|
payments_total = SalePayment.select("
|
||||||
FROM sale_payments
|
sales.receipt_date as sale_date,
|
||||||
INNER JOIN sale_audits sa
|
|
||||||
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id
|
|
||||||
INNER JOIN sales ON sa.sale_id = sales.sale_id
|
|
||||||
WHERE sales.sale_status='completed' and sales.shop_code='#{shop_code}'"
|
|
||||||
|
|
||||||
if shift.present?
|
|
||||||
shift_ids = shift.map(&:id).join(",")
|
|
||||||
sub_query += " AND sales.shift_sale_id in (#{shift_ids})"
|
|
||||||
elsif shift_sale_range.present?
|
|
||||||
shift_ids = shift_sale_range.map(&:id).join(",")
|
|
||||||
sub_query += " AND sales.shift_sale_id in (#{shift_ids})"
|
|
||||||
else
|
|
||||||
sub_query += " AND sales.receipt_date between '#{from}' and '#{to}'"
|
|
||||||
end
|
|
||||||
|
|
||||||
sub_query1 = "CASE WHEN (SELECT SUM(sale_payments.payment_amount)
|
|
||||||
FROM sale_payments
|
|
||||||
WHERE sale_payments.payment_method = 'creditnote'
|
|
||||||
AND sale_payments.sale_id = s.sale_id
|
|
||||||
) - (SELECT SUM(sale_payments.payment_amount)
|
|
||||||
FROM sale_payments
|
|
||||||
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
|
||||||
WHERE sale_payments.sale_id = s.sale_id) = 0
|
|
||||||
THEN sale_payments.sale_id = s.sale_id
|
|
||||||
AND sale_payments.payment_method!='creditnote' ELSE 1 END"
|
|
||||||
|
|
||||||
sale_payment = SalePayment.select("s.amount_changed as change_amount,s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
|
|
||||||
s.cashier_name as cashier_name")
|
|
||||||
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
|
|
||||||
.where("(#{sub_query1}) and s.shop_code='#{shop_code}'")
|
|
||||||
.order('s.receipt_no DESC')
|
|
||||||
|
|
||||||
payments_total = SalePayment.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
|
|
||||||
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
|
||||||
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
|
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
|
||||||
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
|
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
|
||||||
@@ -1476,48 +1380,42 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
|||||||
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
|
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
|
||||||
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
|
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
|
||||||
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
|
||||||
SUM(case when (sale_payments.payment_method='cash') then sales.amount_changed else 0 end) as total_change_amount,
|
SUM(case when (sale_payments.payment_method='cash') then
|
||||||
(CASE WHEN (SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end)) > 0 THEN (SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) - (#{sub_query})) ELSE 0 END) as credit_amount,
|
sales.amount_changed else 0 end) as total_change_amount,
|
||||||
|
SUM(case when (sale_payments.payment_method='creditnote') then
|
||||||
|
sale_payments.payment_amount else 0 end) -
|
||||||
|
SUM(case when (sale_audits.sale_audit_id IS NOT NULL) then
|
||||||
|
sale_payments.payment_amount else 0 end) as credit_amount,
|
||||||
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
|
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
|
||||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||||
.joins("join sales on sales.sale_id = sale_payments.sale_id")
|
.joins(:sale).left_joins(:sale_audit)
|
||||||
.where("sales.shop_code='#{shop_code}'")
|
.merge(Sale.completed.receipt_date_between(from, to))
|
||||||
|
|
||||||
|
sales = Sale.select(Sale.column_names)
|
||||||
|
.select("SUM(sale_payments.payment_amount) as payment_for_credits_amount")
|
||||||
|
.left_joins(:payments_for_credits)
|
||||||
|
.group(:sale_id)
|
||||||
|
|
||||||
|
sale_payment = SalePayment.select("sales.amount_changed as change_amount,sales.receipt_no, sale_payments.*, sales.receipt_date as sale_date,
|
||||||
|
sales.cashier_name as cashier_name")
|
||||||
|
.joins("JOIN (#{sales.to_sql}) as sales ON sales.sale_id = sale_payments.sale_id")
|
||||||
|
.where("sale_payments.payment_method != 'creditnote' OR payment_for_credits_amount - sale_payments.payment_amount <= 0")
|
||||||
|
.where.not(payment_amount: 0)
|
||||||
|
.merge(Sale.completed.receipt_date_between(from, to))
|
||||||
|
|
||||||
if shift.present?
|
if shift.present?
|
||||||
|
payments_total = payments_total.where(sales: {shift_sale_id: shift.to_a})
|
||||||
all_total = payments_total.where("sales.shift_sale_id in (?) and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
|
sale_payment = sale_payment.merge(Sale.where(sales: {shift_sale_id: shift.to_a}))
|
||||||
# .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
|
|
||||||
if payment_type.blank?
|
|
||||||
sale_type = sale_payment.where(" s.sale_status = 'completed' and payment_amount != 0 and s.shift_sale_id in (?)",shift.to_a)
|
|
||||||
.order("payment_method")
|
|
||||||
else
|
|
||||||
sale_type = sale_payment.where(" payment_method= '#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift.to_a)
|
|
||||||
end
|
|
||||||
|
|
||||||
elsif shift_sale_range.present?
|
elsif shift_sale_range.present?
|
||||||
|
payments_total = payments_total.where(sales: {shift_sale_id: shift_sale_range.to_a})
|
||||||
all_total = payments_total.where("sales.shift_sale_id in (?) and sale_status= 'completed' and sale_payments.payment_amount != 0", shift_sale_range.to_a)
|
sale_payment = sale_payment.merge(Sale.where(sales: {shift_sale_id: shift_sale_range.to_a}))
|
||||||
# .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
|
|
||||||
if payment_type.blank?
|
|
||||||
sale_type = sale_payment.where(" s.sale_status = 'completed' and payment_amount != 0 and s.shift_sale_id in (?)",shift_sale_range.to_a)
|
|
||||||
.order("payment_method")
|
|
||||||
else
|
|
||||||
sale_type = sale_payment.where(" payment_method='#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift_sale_range.to_a)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
if payment_type.present?
|
||||||
|
sale_payment = sale_payment.where(payment_method: payment_type)
|
||||||
all_total = payments_total.where("sales.receipt_date between ? and ? and sales.sale_status= 'completed' and sale_payments.payment_amount != 0", from,to)
|
|
||||||
# .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
|
|
||||||
if payment_type.blank?
|
|
||||||
sale_type = sale_payment.where(" s.sale_status = 'completed' and payment_amount != 0 and s.receipt_date between ? and ? ",from,to)
|
|
||||||
.order("payment_method")
|
|
||||||
else
|
|
||||||
sale_type = sale_payment.where(" payment_method='#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return all_total,sale_type
|
return payments_total, sale_payment
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_wastes_and_spoilages(from,to,status)
|
def self.get_wastes_and_spoilages(from,to,status)
|
||||||
@@ -1550,10 +1448,10 @@ end
|
|||||||
cash = 0.0
|
cash = 0.0
|
||||||
self.sale_payments.each do |pay|
|
self.sale_payments.each do |pay|
|
||||||
if pay.payment_method == 'cash'
|
if pay.payment_method == 'cash'
|
||||||
cash = pay.payment_amount-self.amount_changed
|
cash += pay.payment_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return cash
|
return cash - self.amount_changed
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_credit_amount
|
def get_credit_amount
|
||||||
@@ -2130,6 +2028,7 @@ end
|
|||||||
|
|
||||||
def unique_tax_profiles(order_source, customer_id)
|
def unique_tax_profiles(order_source, customer_id)
|
||||||
tax_data = TaxProfile.where(group_type: order_source)
|
tax_data = TaxProfile.where(group_type: order_source)
|
||||||
|
|
||||||
customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first
|
customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first
|
||||||
if customer_tax_profiles.present?
|
if customer_tax_profiles.present?
|
||||||
tax_data = tax_data.where(id: customer_tax_profiles.tax_profiles)
|
tax_data = tax_data.where(id: customer_tax_profiles.tax_profiles)
|
||||||
@@ -2159,7 +2058,7 @@ def self.employee_sale(shift=nil,from=nil,to=nil,from_time=nil,to_time=nil, curr
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Start hourly sale item report
|
# Start hourly sale item report
|
||||||
def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,account_type,shop_code)
|
def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,account_type,filter,start_time,end_time)
|
||||||
# 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 = ''
|
||||||
@@ -2167,7 +2066,26 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
|||||||
account_type = " and acc.title = '#{account_type}'"
|
account_type = " and acc.title = '#{account_type}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
query = self.get_hourly_item_query(type)
|
if start_time.blank? || end_time.blank?
|
||||||
|
receipt_date = "sales.receipt_date between '#{from}' and '#{to}'"
|
||||||
|
query = self.get_hourly_item_query(type,filter,true)
|
||||||
|
else
|
||||||
|
start_time = Time.parse(start_time).utc
|
||||||
|
end_time = Time.parse(end_time).utc
|
||||||
|
receipt_date = "sales.receipt_date between '#{start_time}' and '#{end_time}'"
|
||||||
|
query = self.get_hourly_item_query(type,filter,false)
|
||||||
|
end
|
||||||
|
|
||||||
|
unless start_time.blank? && end_time.blank?
|
||||||
|
from_date = from.to_date
|
||||||
|
to_date = to.to_date
|
||||||
|
from_date_time = DateTime.new(from_date.year, from_date.month, from_date.day, start_time.hour, start_time.min, start_time.sec, start_time.zone)
|
||||||
|
to_date_time = DateTime.new(to_date.year, to_date.month, to_date.day, end_time.hour, end_time.min, end_time.sec, end_time.zone)
|
||||||
|
receipt_date = "sales.receipt_date between '#{from_date_time}' and '#{to_date_time}'"
|
||||||
|
query = self.get_hourly_item_query(type,filter,false)
|
||||||
|
end
|
||||||
|
|
||||||
|
# query = self.get_hourly_item_query(type,filter)
|
||||||
|
|
||||||
discount_query = 0
|
discount_query = 0
|
||||||
total_card_amount = 0
|
total_card_amount = 0
|
||||||
@@ -2228,7 +2146,7 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
|||||||
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
|
||||||
|
|
||||||
else
|
else
|
||||||
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
query = query.where("#{receipt_date} #{account_type} and sale_status='completed'")
|
||||||
if type.nil? || type == 'all' || type == "other"
|
if type.nil? || type == 'all' || type == "other"
|
||||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||||
end
|
end
|
||||||
@@ -2255,11 +2173,16 @@ def self.get_by_hourly_items(shift_sale_range, shift, from, to, status,type,acco
|
|||||||
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_hourly_item_query(type)
|
def self.get_hourly_item_query(type,filter,status)
|
||||||
|
if status
|
||||||
|
group_by = "acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price,hour"
|
||||||
|
else
|
||||||
|
group_by = "acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price"
|
||||||
|
end
|
||||||
check_product = "i.menu_category_name != 'product'"
|
check_product = "i.menu_category_name != 'product'"
|
||||||
if type == "revenue"
|
if type == "revenue"
|
||||||
sale_type = "i.qty > 0 and status IS NULL"
|
sale_type = "i.qty > 0 and status IS NULL"
|
||||||
elsif type == "all" || type.nil?
|
elsif type == "all" || type.nil? || type.empty?
|
||||||
sale_type = "#{check_product}"
|
sale_type = "#{check_product}"
|
||||||
elsif type == "discount"
|
elsif type == "discount"
|
||||||
sale_type = "#{check_product} and i.status = 'Discount'"
|
sale_type = "#{check_product} and i.status = 'Discount'"
|
||||||
@@ -2287,8 +2210,8 @@ def self.get_hourly_item_query(type)
|
|||||||
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
|
||||||
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
||||||
query = query.joins(" JOIN accounts acc ON acc.id = i.account_id")
|
query = query.joins(" JOIN accounts acc ON acc.id = i.account_id")
|
||||||
query = query.where("#{sale_type}")
|
query = query.where("#{sale_type} and i.product_name LIKE '%#{filter}%'" )
|
||||||
query = query.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price,hour")
|
query = query.group("#{group_by}")
|
||||||
.order("hour asc")
|
.order("hour asc")
|
||||||
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
|
# query = query.order("i.menu_category_name asc, SUM(i.qty) desc")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class SaleAudit < ApplicationRecord
|
|||||||
|
|
||||||
belongs_to :sale
|
belongs_to :sale
|
||||||
|
|
||||||
belongs_to :sale_payments_for_credit, -> { where "SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id" }, foreign_key: "sale_id", primary_key: "sale_id", class_name: "SalePayment"
|
belongs_to :payments_for_credit, -> { where "SUBSTRING_INDEX(sale_audits.remark,'||',1) = sale_payments.sale_payment_id" }, foreign_key: "sale_id", primary_key: "sale_id", class_name: "SalePayment"
|
||||||
|
|
||||||
def self.sync_sale_audit_records(sale_audits)
|
def self.sync_sale_audit_records(sale_audits)
|
||||||
if !sale_audits.nil?
|
if !sale_audits.nil?
|
||||||
@@ -124,6 +124,17 @@ class SaleAudit < ApplicationRecord
|
|||||||
sale_audit.save!
|
sale_audit.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.record_audit_change_tax(sale_id, remark, action_by)
|
||||||
|
sale_audit = SaleAudit.new()
|
||||||
|
sale_audit.sale_id = sale_id
|
||||||
|
sale_audit.action = "CHANGE_TAX"
|
||||||
|
sale_audit.action_at = DateTime.now.utc
|
||||||
|
sale_audit.action_by = action_by
|
||||||
|
sale_audit.remark = remark
|
||||||
|
sale_audit.approved_by = action_by
|
||||||
|
sale_audit.save!
|
||||||
|
end
|
||||||
|
|
||||||
def self.paymal_search(sale_id)
|
def self.paymal_search(sale_id)
|
||||||
amount = nil
|
amount = nil
|
||||||
paymal = SaleAudit.where("sale_id =? and action = 'PAYMAL'",sale_id)
|
paymal = SaleAudit.where("sale_id =? and action = 'PAYMAL'",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?
|
||||||
|
|||||||
@@ -73,19 +73,13 @@ class SalePayment < ApplicationRecord
|
|||||||
self.action_by = action_by
|
self.action_by = action_by
|
||||||
#get all payment for this invoices
|
#get all payment for this invoices
|
||||||
if payment_for
|
if payment_for
|
||||||
invoice_sale_payments = SalePayment.get_sale_payment_for_credit(invoice)
|
amount_due = SalePayment.get_credit_amount_due_left(self.sale_id).first.payment_amount
|
||||||
amount_due = SalePayment.get_credit_amount_due_left(self.sale_id)[0] ? SalePayment.get_credit_amount_due_left(self.sale_id)[0].payment_amount.to_f : 0
|
|
||||||
else
|
else
|
||||||
invoice_sale_payments = invoice.sale_payments
|
amount_due = invoice.sale_payments
|
||||||
amount_due = invoice.grand_total
|
.map(&:payment_amount).reduce(invoice.grand_total, :-)
|
||||||
end
|
end
|
||||||
|
|
||||||
invoice_sale_payments.each do |payment|
|
if amount_due > 0
|
||||||
if (payment.payment_status == "paid" )
|
|
||||||
amount_due = amount_due - payment.payment_amount
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if (amount_due > 0)
|
|
||||||
payment_status = false
|
payment_status = false
|
||||||
membership_data = nil
|
membership_data = nil
|
||||||
#route to payment type
|
#route to payment type
|
||||||
@@ -173,6 +167,7 @@ class SalePayment < ApplicationRecord
|
|||||||
return false, self.save,membership_data
|
return false, self.save,membership_data
|
||||||
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)
|
||||||
@@ -412,19 +407,19 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
def foc_payment
|
def foc_payment
|
||||||
payment_status = false
|
payment_status = false
|
||||||
|
sale = self.sale
|
||||||
# add to sale item with foc
|
# add to sale item with foc
|
||||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
|
sale_items = sale.sale_items
|
||||||
|
|
||||||
sale_items.each do|item|
|
sale_items.each do|item|
|
||||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
SaleItem.update_existing_item(item.qty, item, sale.sale_id, "foc", item.unit_price, item.price)
|
||||||
end
|
end
|
||||||
sale = Sale.find(self.sale.sale_id)
|
|
||||||
sale.compute_by_sale_items(sale.total_discount,'','','',"foc")
|
sale.compute_by_sale_items(sale.total_discount,'','','',"foc")
|
||||||
|
|
||||||
self.payment_method = "foc"
|
self.payment_method = "foc"
|
||||||
self.payment_amount = self.received_amount
|
self.payment_amount = self.received_amount
|
||||||
# self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
|
||||||
self.outstanding_amount = 0.00
|
self.outstanding_amount = 0.00
|
||||||
self.payment_status = "paid"
|
self.payment_status = "paid"
|
||||||
payment_status = self.save!
|
payment_status = self.save!
|
||||||
@@ -635,83 +630,59 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
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!
|
total_payment_amount = sale.sale_payments.reload.sum(&:payment_amount)
|
||||||
self.sale.amount_changed = self.sale.amount_received.to_f - self.sale.grand_total.to_f
|
sale.amount_received = sale.amount_received.to_f + paid_amount.to_f
|
||||||
all_received_amount = 0.0
|
sale.amount_changed = total_payment_amount - sale.grand_total.to_f
|
||||||
sObj = Sale.find(self.sale_id)
|
|
||||||
is_credit = 0
|
is_credit = sale.sale_payments.any? { |x| x.payment_method == "creditnote" }
|
||||||
is_foc = 0
|
is_foc = sale.sale_payments.any? { |x| x.payment_method == "foc" }
|
||||||
is_kbz_pay = 0
|
|
||||||
method_status = false
|
if sale.grand_total <= total_payment_amount && sale.sale_status == "new"
|
||||||
sObj.sale_payments.each do |spay|
|
sale.payment_status = "paid"
|
||||||
all_received_amount += spay.payment_amount.to_f
|
if is_credit
|
||||||
if spay.payment_method == "creditnote"
|
sale.payment_status = "outstanding"
|
||||||
is_credit = 1
|
|
||||||
end
|
end
|
||||||
if spay.payment_method == "foc"
|
if is_foc
|
||||||
is_foc = 1
|
sale.payment_status = "foc"
|
||||||
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 || spay.payment_method =="paymal"
|
|
||||||
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
|
|
||||||
self.sale.payment_status = "outstanding"
|
|
||||||
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
|
if MembershipSetting.find_by_rebate(1) && is_foc == 0 && is_credit == 0
|
||||||
self.sale.payment_status = 'paid'
|
response = rebat(sale)
|
||||||
end
|
|
||||||
|
|
||||||
self.sale.sale_status = "completed"
|
|
||||||
|
|
||||||
if MembershipSetting.find_by_rebate_and_shop_code(1,self.sale.shop_code) && is_foc == 0 && is_credit == 0
|
|
||||||
response = rebat(sObj)
|
|
||||||
|
|
||||||
#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
|
||||||
@@ -745,7 +716,8 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
# update for shift with credit payment
|
# update for shift with credit payment
|
||||||
def update_shift_for_credit_payment
|
def update_shift_for_credit_payment
|
||||||
shift = ShiftSale.find_by_id(self.sale.shift_sale_id)
|
shift_credit = ShiftSale.find_by_id(self.sale.shift_sale_id)
|
||||||
|
shift = ShiftSale.find_by_id(ShiftSale.current_shift)
|
||||||
if !shift.nil?
|
if !shift.nil?
|
||||||
credit_payment_left = get_credit_payment_left[0].payment_amount.to_f
|
credit_payment_left = get_credit_payment_left[0].payment_amount.to_f
|
||||||
if self.payment_method == "cash"
|
if self.payment_method == "cash"
|
||||||
@@ -763,41 +735,28 @@ class SalePayment < ApplicationRecord
|
|||||||
shift.other_sales = shift.other_sales.to_f + self.received_amount.to_f
|
shift.other_sales = shift.other_sales.to_f + self.received_amount.to_f
|
||||||
end
|
end
|
||||||
if credit_payment_left == 0 || credit_payment_left >= self.received_amount.to_f
|
if credit_payment_left == 0 || credit_payment_left >= self.received_amount.to_f
|
||||||
shift.credit_sales = shift.credit_sales.to_f - self.received_amount.to_f
|
if shift.id == shift_credit.id
|
||||||
|
shift.credit_sales = shift_credit.credit_sales.to_f - self.received_amount.to_f
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
shift.credit_sales = shift.credit_sales.to_f - (self.received_amount.to_f + credit_payment_left)
|
shift.credit_sales = shift_credit.credit_sales.to_f - (self.received_amount.to_f + credit_payment_left)
|
||||||
end
|
end
|
||||||
shift.save
|
shift.save
|
||||||
end
|
end
|
||||||
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"
|
||||||
end
|
|
||||||
|
|
||||||
if status
|
|
||||||
table.update_attributes(status: "available")
|
table.update_attributes(status: "available")
|
||||||
# table.status = "available"
|
|
||||||
# table.save
|
|
||||||
end
|
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
|
||||||
@@ -955,13 +914,16 @@ class SalePayment < ApplicationRecord
|
|||||||
#credit payment query
|
#credit payment query
|
||||||
|
|
||||||
def self.get_credit_sales(params)
|
def self.get_credit_sales(params)
|
||||||
|
total_payment_amounts = SalePayment.select("sale_payments.sale_id, SUM(sale_payments.payment_amount) as total_payment_amount").group(:sale_id)
|
||||||
|
|
||||||
payments = SalePayment.select("sale_payments.sale_id, sale_payments.sale_payment_id, sale_payments.payment_method, sale_payments.payment_amount")
|
payments = SalePayment.select("sale_payments.sale_id, sale_payments.sale_payment_id, sale_payments.payment_method, sale_payments.payment_amount")
|
||||||
.select("SUM(sale_payments.payment_amount) OVER (PARTITION BY sale_payments.sale_id) total_payment_amount")
|
.select("total_payment_amount")
|
||||||
|
.joins("JOIN (#{total_payment_amounts.to_sql}) AS total_payment_amounts ON total_payment_amounts.sale_id = sale_payments.sale_id")
|
||||||
|
|
||||||
credit_sales = Sale.select("sales.sale_id, sales.receipt_no, sales.receipt_date as sale_date, sales.cashier_name")
|
credit_sales = Sale.select("sales.sale_id, sales.receipt_no, sales.receipt_date as sale_date, sales.cashier_name")
|
||||||
.select("sale_payments.sale_payment_id, sale_payments.payment_amount").select("customers.name as customer_name")
|
.select("sale_payments.sale_payment_id, sale_payments.payment_amount").select("customers.name as customer_name")
|
||||||
.joins("JOIN (#{payments.to_sql}) AS sale_payments ON sale_payments.sale_id = sales.sale_id").joins(:customer).joins(:orders)
|
.joins("JOIN (#{payments.to_sql}) AS sale_payments ON sale_payments.sale_id = sales.sale_id").joins(:customer).joins(:orders)
|
||||||
.completed.paid.where("sale_payments.payment_method = 'creditnote' AND sales.grand_total > sale_payments.total_payment_amount - sale_payments.payment_amount").shop
|
.completed.where("sale_payments.payment_method = 'creditnote' AND sales.grand_total > sale_payments.total_payment_amount - sale_payments.payment_amount")
|
||||||
.group(:receipt_no)
|
.group(:receipt_no)
|
||||||
.order(:receipt_date).order(:receipt_no)
|
.order(:receipt_date).order(:receipt_no)
|
||||||
|
|
||||||
@@ -984,64 +946,29 @@ class SalePayment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.get_credit_amount_due_left(sale_id)
|
def self.get_credit_amount_due_left(sale_id)
|
||||||
query = SalePayment.select("(SUM(sale_payments.payment_amount) -
|
SalePayment.left_joins(:sale_audit).where(sale_id: sale_id)
|
||||||
(CASE WHEN SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id
|
.select("SUM(CASE WHEN sale_payments.payment_method = 'creditnote' THEN sale_payments.payment_amount ELSE 0 END) - SUM(CASE WHEN sale_audits.sale_audit_id IS NOT NULL THEN sale_payments.payment_amount ELSE 0 END) AS payment_amount")
|
||||||
THEN SUM(sale_payments.payment_amount) ELSE 0 END)) as payment_amount")
|
|
||||||
.joins(" LEFT JOIN sale_audits sa on SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id")
|
|
||||||
.where("sale_payments.payment_method = 'creditnote' AND sale_payments.sale_id = '#{sale_id}'")
|
|
||||||
return query
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_credit_total_left(sale_id)
|
def self.get_credit_total_left(sale_id)
|
||||||
query = SalePayment.select("(SUM(sale_payments.payment_amount) -
|
SalePayment.left_joins(:sale_audit).where(sale_id: sale_id)
|
||||||
(SELECT (CASE WHEN SUM(sale_payments.payment_amount) > 0 THEN SUM(sale_payments.payment_amount) ELSE 0 END) AS payment_amount
|
.select("SUM(CASE WHEN sale_payments.payment_method = 'creditnote' THEN sale_payments.payment_amount ELSE 0 END) - SUM(CASE WHEN sale_audits.sale_audit_id IS NOT NULL THEN sale_payments.payment_amount ELSE 0 END) AS payment_amount")
|
||||||
FROM sale_payments
|
|
||||||
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
|
||||||
WHERE sale_payments.sale_id = '#{sale_id}')) as payment_amount")
|
|
||||||
.where("sale_payments.payment_method = 'creditnote' AND sale_payments.sale_id = '#{sale_id}'")
|
|
||||||
return query
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_sale_payment_for_credit(sale_data)
|
def self.get_sale_payment_for_credit(sale_data)
|
||||||
query = sale_data.sale_payments
|
sale_data.sale_payments
|
||||||
.joins(" JOIN sale_audits sa on SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id")
|
.joins(:sale_audit)
|
||||||
.where("sa.action='SALEPAYMENT' AND sa.remark IS NOT NULL
|
|
||||||
AND DATE_FORMAT(sale_payments.created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(sale_payments.created_at,'%Y-%m-%d') = '#{Date.today.prev_day}'
|
|
||||||
") #AND sale_payments.payment_method!='cash'
|
|
||||||
.group("sale_payments.sale_payment_id")
|
|
||||||
return query
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_credit_payment_left
|
def get_credit_payment_left
|
||||||
sql = "SELECT SUM(payment_amount)
|
SalePayment.left_joins(:sale_audit).where(sale_id: sale_id)
|
||||||
from sale_payments
|
.select("SUM(CASE WHEN sale_payments.payment_method = 'creditnote' THEN sale_payments.payment_amount ELSE 0 END) - SUM(CASE WHEN sale_audits.sale_audit_id IS NOT NULL THEN sale_payments.payment_amount ELSE 0 END) AS payment_amount")
|
||||||
join sale_audits on SUBSTRING_INDEX(remark,'||',1)=sale_payment_id
|
|
||||||
where sale_payments.sale_id = '#{self.sale_id}'"
|
|
||||||
|
|
||||||
query = SalePayment.select("(SUM(payment_amount) - (#{sql})) as payment_amount")
|
|
||||||
.where("sale_payments.payment_method = 'creditnote' AND sale_payments.sale_id = '#{self.sale_id}'")
|
|
||||||
return query
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_sale_payments(sale_data)
|
def self.get_sale_payments(sale_data)
|
||||||
sql = "SELECT SUM(payment_amount)
|
sale_data.sale_payments
|
||||||
FROM sale_payments where payment_method='creditnote'
|
.merge(SalePayment.where.not(payment_method: 'creditnote')
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
.or(SalePayment.where.not(SalePayment.arel_table[:payment_amount].lteq(sale_data.sale_payments.joins(:sale_audit).sum(:payment_amount)))))
|
||||||
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
|
||||||
FROM sale_payments where payment_method='creditnote'
|
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
|
||||||
|
|
||||||
query = sale_data.sale_payments
|
|
||||||
.where("CASE WHEN ((#{sql}) - (#{sql1})
|
|
||||||
ELSE SUM(payment_amount) END
|
|
||||||
FROM sale_payments
|
|
||||||
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
|
||||||
JOIN sale_audits sa
|
|
||||||
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
|
|
||||||
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
|
||||||
THEN payment_method!='creditnote' ELSE 1 END")
|
|
||||||
.group("sale_payments.sale_payment_id")
|
|
||||||
return query
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -3,19 +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
|
||||||
if (cur_val == 0)
|
|
||||||
cur_val, next_val = self.execute_query(model_name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
padding_len = 15 - prefix.length
|
seed = self.update_seed(model_name)
|
||||||
saleOrderId = prefix +"-"+ cur_val.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
length = 16 - prefix.length
|
||||||
return saleOrderId
|
prefix + seed.to_s.rjust(length, '0')
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.generate_ids(model, prefix, count = 1)
|
||||||
|
model_name = self.get_model_name(model)
|
||||||
|
|
||||||
|
prefix ||= ''
|
||||||
|
prefix << '-' if prefix.present?
|
||||||
|
|
||||||
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
|
prefix << 'C'
|
||||||
|
else
|
||||||
|
prefix << 'L'
|
||||||
|
end
|
||||||
|
|
||||||
|
if shop = Shop.current_shop
|
||||||
|
prefix << shop.shop_code
|
||||||
|
end
|
||||||
|
|
||||||
|
start = self.update_seed(model_name, count)
|
||||||
|
stop = start + count - 1
|
||||||
|
length = 16 - prefix.length
|
||||||
|
(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)
|
||||||
@@ -100,41 +125,13 @@ class SeedGenerator < ApplicationRecord
|
|||||||
return model_name
|
return model_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.execute_query(model)
|
def self.update_seed(model, count = 1)
|
||||||
current = 0
|
SeedGenerator.transaction do
|
||||||
nex = 0
|
seed = SeedGenerator.lock.find_by_model(model)
|
||||||
|
seed.next = seed.next + (count * seed.increase_by)
|
||||||
sql = "INSERT INTO seed_generators (model, created_at, updated_at)
|
seed.current = seed.next - seed.increase_by
|
||||||
VALUES('#{ model }', NOW(), NOW())
|
seed.save!
|
||||||
ON DUPLICATE KEY UPDATE current = current + 1, next = next + 1;"
|
seed.next_before_last_save
|
||||||
|
end
|
||||||
select_sql = "select * from seed_generators where model='#{model}';"
|
|
||||||
ActiveRecord::Base.connection.execute(sql);
|
|
||||||
select_result = ActiveRecord::Base.connection.execute(select_sql);
|
|
||||||
|
|
||||||
select_result.each do |row|
|
|
||||||
current = row [3]
|
|
||||||
nex = row[4]
|
|
||||||
end
|
|
||||||
|
|
||||||
return current, nex
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.update_seed(model)
|
|
||||||
current = 0
|
|
||||||
nex = 0
|
|
||||||
|
|
||||||
update_sql = "UPDATE seed_generators set current = next, next = next + 1 WHERE model='#{model}';"
|
|
||||||
select_sql = "select * from seed_generators where model='#{model}';"
|
|
||||||
update_result = ActiveRecord::Base.connection.execute(update_sql);
|
|
||||||
|
|
||||||
select_result = ActiveRecord::Base.connection.execute(select_sql);
|
|
||||||
|
|
||||||
select_result.each do |row|
|
|
||||||
current = row [3]
|
|
||||||
nex = row[4]
|
|
||||||
end
|
|
||||||
|
|
||||||
return current, nex
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -388,25 +388,12 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
|
|
||||||
def sale_payment(sale_data,precision,delimiter)
|
def sale_payment(sale_data,precision,delimiter)
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
# move_down 10
|
|
||||||
sql = "SELECT SUM(payment_amount)
|
|
||||||
FROM sale_payments where payment_method='creditnote'
|
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
|
||||||
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
|
||||||
FROM sale_payments where payment_method='creditnote'
|
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
|
||||||
|
|
||||||
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
query = sale_data.sale_payments
|
||||||
.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
.merge(SalePayment.where.not(payment_method: 'creditnote')
|
||||||
ELSE SUM(payment_amount) END
|
.or(SalePayment.where.not(SalePayment.arel_table[:payment_amount].lteq(sale_data.sale_payments.joins(:sale_audit).sum(:payment_amount)))))
|
||||||
FROM sale_payments
|
|
||||||
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
query.each do |payment|
|
||||||
JOIN sale_audits sa
|
|
||||||
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
|
|
||||||
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
|
||||||
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id)
|
|
||||||
.group("payment_method")
|
|
||||||
sale_payments.each do |payment|
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
if payment.payment_method == "paypar"
|
if payment.payment_method == "paypar"
|
||||||
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do
|
||||||
@@ -614,12 +601,16 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sign(sale_data)
|
def sign(sale_data)
|
||||||
sql = "SELECT SUM(payment_amount)
|
# sql = "SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
# FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
# and sale_id='#{sale_data.sale_id}'"
|
||||||
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
# sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
# FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
# and sale_id='#{sale_data.sale_id}'"
|
||||||
|
sql = SalePayment.select("(SUM(payment_amount))").where("payment_method='creditnote'
|
||||||
|
and sale_id='#{sale_data.sale_id}'").to_sql
|
||||||
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ("
|
||||||
|
sql1 += sql
|
||||||
|
|
||||||
SalePayment.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
SalePayment.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
ELSE SUM(payment_amount) END
|
ELSE SUM(payment_amount) END
|
||||||
|
|||||||
@@ -453,12 +453,15 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
def sale_payment(sale_data,precision,delimiter)
|
def sale_payment(sale_data,precision,delimiter)
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
#move_down line_move
|
#move_down line_move
|
||||||
sql = "SELECT SUM(payment_amount)
|
# sql = "SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
# FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
# and sale_id='#{sale_data.sale_id}'"
|
||||||
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
sql = SalePayment.select("(SUM(payment_amount))").where("payment_method='creditnote' and sale_id='#{sale_data.sale_id}'").to_sql
|
||||||
FROM sale_payments where payment_method='creditnote'
|
# sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
# FROM sale_payments where payment_method='creditnote'
|
||||||
|
# and sale_id='#{sale_data.sale_id}'"
|
||||||
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ("
|
||||||
|
sql1 += sql
|
||||||
|
|
||||||
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
||||||
.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
@@ -685,21 +688,11 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sign(sale_data)
|
def sign(sale_data)
|
||||||
sql = "SELECT SUM(payment_amount)
|
query = sale_data.sale_payments
|
||||||
FROM sale_payments where payment_method='creditnote'
|
.merge(SalePayment.where.not(payment_method: 'creditnote')
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
.or(SalePayment.where.not(SalePayment.arel_table[:payment_amount].lteq(sale_data.sale_payments.joins(:sale_audit).sum(:payment_amount)))))
|
||||||
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
|
||||||
FROM sale_payments where payment_method='creditnote'
|
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
|
||||||
|
|
||||||
SalePayment.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
query.each do |payment|
|
||||||
ELSE SUM(payment_amount) END
|
|
||||||
FROM sale_payments
|
|
||||||
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
|
||||||
JOIN sale_audits sa
|
|
||||||
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
|
|
||||||
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
|
||||||
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
|
|
||||||
if payment.payment_method == "creditnote"
|
if payment.payment_method == "creditnote"
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|||||||
@@ -383,12 +383,16 @@ class ReceiptBillStarPdf < Prawn::Document
|
|||||||
def sale_payment(sale_data,precision,delimiter)
|
def sale_payment(sale_data,precision,delimiter)
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
#move_down line_move
|
#move_down line_move
|
||||||
sql = "SELECT SUM(payment_amount)
|
# sql = "SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
# FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
# and sale_id='#{sale_data.sale_id}'"
|
||||||
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
# sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
||||||
FROM sale_payments where payment_method='creditnote'
|
# FROM sale_payments where payment_method='creditnote'
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
# and sale_id='#{sale_data.sale_id}'"
|
||||||
|
sql = SalePayment.select("(SUM(payment_amount))").where("payment_method='creditnote'
|
||||||
|
and sale_id='#{sale_data.sale_id}'").to_sql
|
||||||
|
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ("
|
||||||
|
sql1 += sql
|
||||||
|
|
||||||
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
|
||||||
.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
||||||
@@ -609,21 +613,11 @@ class ReceiptBillStarPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
|
|
||||||
def sign(sale_data)
|
def sign(sale_data)
|
||||||
sql = "SELECT SUM(payment_amount)
|
query = sale_data.sale_payments
|
||||||
FROM sale_payments where payment_method='creditnote'
|
.merge(SalePayment.where.not(payment_method: 'creditnote')
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
.or(SalePayment.where.not(SalePayment.arel_table[:payment_amount].lteq(sale_data.sale_payments.joins(:sale_audit).sum(:payment_amount)))))
|
||||||
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
|
|
||||||
FROM sale_payments where payment_method='creditnote'
|
|
||||||
and sale_id='#{sale_data.sale_id}'"
|
|
||||||
|
|
||||||
SalePayment.where("(CASE WHEN ((#{sql}) - (#{sql1})
|
query.each do |payment|
|
||||||
ELSE SUM(payment_amount) END
|
|
||||||
FROM sale_payments
|
|
||||||
JOIN sales s ON s.sale_id=sale_payments.sale_id
|
|
||||||
JOIN sale_audits sa
|
|
||||||
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
|
|
||||||
where sa.sale_id='#{sale_data.sale_id}')) = 0
|
|
||||||
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
|
|
||||||
if payment.payment_method == "creditnote"
|
if payment.payment_method == "creditnote"
|
||||||
|
|
||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|||||||
@@ -2,51 +2,20 @@
|
|||||||
attr_format = []
|
attr_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
if item.is_available
|
if item.is_available
|
||||||
|
# Format for attributes json
|
||||||
|
attr_format = []
|
||||||
|
# Format for attributes json
|
||||||
if item.item_attributes.count > 0
|
if item.item_attributes.count > 0
|
||||||
item.item_attributes.each do|attr_id|
|
item_attributes = item.item_attributes.map(&:to_s)
|
||||||
menu_attr = MenuItemAttribute.find(attr_id)
|
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 } } }
|
||||||
if attr_format.count == 0
|
|
||||||
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
attr_format.each do |af|
|
|
||||||
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
|
|
||||||
if menu_attr.attribute_type == af[:type]
|
|
||||||
af[:values].push(menu_attr.name)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
|
||||||
attr_format.push(new_attr)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
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.item_options.each do|opt|
|
item_options = item.item_options.map(&:to_s)
|
||||||
menu_opt = MenuItemOption.find(opt)
|
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 } } }
|
||||||
if opt_format.count == 0
|
|
||||||
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
opt_format.each do |of|
|
|
||||||
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
|
||||||
if menu_opt.option_type == of[:type]
|
|
||||||
of[:values].push(menu_opt.name)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
|
||||||
opt_format.push(new_opt)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#Menu Item Information
|
#Menu Item Information
|
||||||
@@ -75,9 +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 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
|
||||||
@@ -97,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 = is.item_attributes.map(&:to_s)
|
||||||
|
instance_attr = @item_attributes.select{ |x| item_attributes.include?(x.id.to_s) }.pluck(:name)
|
||||||
|
|
||||||
is.item_attributes.each do |ia|
|
is.item_attributes.each do |ia|
|
||||||
# mItemAttr = MenuItemAttribute.find(is)
|
# mItemAttr = MenuItemAttribute.find(is)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
<% end%>
|
<% end%>
|
||||||
<!-- else quick_service or cashier for table -->
|
<!-- else quick_service or cashier for table -->
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if @table.get_current_checkout_booking.nil? %>
|
<% if @table.current_checkout_booking.nil? %>
|
||||||
<% if !menu.code.include? "SPL" %>
|
<% if !menu.code.include? "SPL" %>
|
||||||
<li class="nav-item ">
|
<li class="nav-item ">
|
||||||
<p class="hidden menu-id"><%= menu.id %></p>
|
<p class="hidden menu-id"><%= menu.id %></p>
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
<% end%>
|
<% end%>
|
||||||
<!-- else quick_service or cashier for table -->
|
<!-- else quick_service or cashier for table -->
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if @table.get_current_checkout_booking.nil? %>
|
<% if @table.current_checkout_booking.nil? %>
|
||||||
<% if !menu.code.include? "SPL" %>
|
<% if !menu.code.include? "SPL" %>
|
||||||
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
|
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
|
||||||
<div class='card-block custom-card-block'>
|
<div class='card-block custom-card-block'>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
<div class="row ">
|
<div class="row ">
|
||||||
<div class="col-lg-4 col-md-4 col-sm-4" style="padding-left: 17px;">
|
<div class="col-lg-4 col-md-4 col-sm-4" style="padding-left: 17px;">
|
||||||
<%= form_tag inventory_path, :id => "filter_form", :method => :get do %>
|
<%= form_tag inventory_path, :id => "filter_form", :method => :get do %>
|
||||||
|
|
||||||
<!-- col-lg-4 col-md-4 col-sm-4 -->
|
<!-- col-lg-4 col-md-4 col-sm-4 -->
|
||||||
<!-- <label class="font-14"><%= t("views.right_panel.detail.product") %></label> -->
|
<!-- <label class="font-14"><%= t("views.right_panel.detail.product") %></label> -->
|
||||||
<input type="text" class="form-control" name="filter" id="Product" type="text" placeholder="Product" style="height: 32px;">
|
<input type="text" class="form-control" name="filter" id="Product" type="text" placeholder="Product" style="height: 32px;">
|
||||||
|
|||||||
@@ -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">
|
||||||
@@ -52,7 +54,7 @@
|
|||||||
<% end%>
|
<% end%>
|
||||||
<!-- else quick_service or cashier for table -->
|
<!-- else quick_service or cashier for table -->
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if @table.get_current_checkout_booking.nil? %>
|
<% if @table.current_checkout_booking.nil? %>
|
||||||
<% if !menu.code.include? "SPL" %>
|
<% if !menu.code.include? "SPL" %>
|
||||||
<li class="nav-item ">
|
<li class="nav-item ">
|
||||||
<p class="hidden menu-id"><%= menu.id %></p>
|
<p class="hidden menu-id"><%= menu.id %></p>
|
||||||
@@ -120,7 +122,7 @@
|
|||||||
<% end%>
|
<% end%>
|
||||||
<!-- else quick_service or cashier for table -->
|
<!-- else quick_service or cashier for table -->
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if @table.get_current_checkout_booking.nil? %>
|
<% if @table.current_checkout_booking.nil? %>
|
||||||
<% if !menu.code.include? "SPL" %>
|
<% if !menu.code.include? "SPL" %>
|
||||||
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
|
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
|
||||||
<div class='card-block custom-card-block'>
|
<div class='card-block custom-card-block'>
|
||||||
@@ -199,7 +201,7 @@
|
|||||||
<div class="col-md-3 col-lg-3 col-sm-3">Table : <%=@table.name%></div>
|
<div class="col-md-3 col-lg-3 col-sm-3">Table : <%=@table.name%></div>
|
||||||
<p class="hidden" id="table_id"><%=@table_id%></p>
|
<p class="hidden" id="table_id"><%=@table_id%></p>
|
||||||
<p class="hidden" id="table_type"><%=@table.type%></p>
|
<p class="hidden" id="table_type"><%=@table.type%></p>
|
||||||
<p class="hidden" id="table_get_current"><%=@table.get_current_checkout_booking%></p>
|
<p class="hidden" id="table_get_current"><%=@table.current_checkout_booking%></p>
|
||||||
<% end%>
|
<% end%>
|
||||||
|
|
||||||
<p class="hidden" id="booking_id"><%=@booking_id%></p>
|
<p class="hidden" id="booking_id"><%=@booking_id%></p>
|
||||||
@@ -231,7 +233,7 @@
|
|||||||
<p class="hidden" id="table_type"><%=@table.type%></p>
|
<p class="hidden" id="table_type"><%=@table.type%></p>
|
||||||
<p class="hidden" id="booking_id"><%=@booking_id%></p>
|
<p class="hidden" id="booking_id"><%=@booking_id%></p>
|
||||||
<p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : ''%></p>
|
<p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : ''%></p>
|
||||||
<p class="hidden" id="table_get_current"><%=@table.get_current_checkout_booking%></p>
|
<p class="hidden" id="table_get_current"><%=@table.current_checkout_booking%></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-lg-3 col-sm-3">
|
<div class="col-md-3 col-lg-3 col-sm-3">
|
||||||
<button type="button" class="btn btn-xs btn-danger waves-effect" id='clear_all'>Clear
|
<button type="button" class="btn btn-xs btn-danger waves-effect" id='clear_all'>Clear
|
||||||
@@ -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">
|
||||||
|
<%if @cashier_type=='quick_service' %>
|
||||||
|
<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>
|
<tr>
|
||||||
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td>
|
<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");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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%>
|
||||||
-
|
-
|
||||||
@@ -734,4 +734,3 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -41,16 +41,16 @@ 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
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -813,8 +813,10 @@
|
|||||||
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
|
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
|
||||||
if (discount) {
|
if (discount) {
|
||||||
if(checkReceiptNoInFirstBillData(receipt_no,"")){
|
if(checkReceiptNoInFirstBillData(receipt_no,"")){
|
||||||
|
$("button.change_tax").hide();
|
||||||
$("#pay").show();
|
$("#pay").show();
|
||||||
}else{
|
}else{
|
||||||
|
$("button.change_tax").show();
|
||||||
$("#pay").hide();
|
$("#pay").hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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});
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,11 @@
|
|||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="<%= column_count = @payment_methods.length + 8 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
<th colspan="<%= column_count = @payment_methods.length + 12 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% @count = 1 %>
|
<% @count = 1 %>
|
||||||
<% @payment_methods.each_slice(10) do |slice| %>
|
<% @payment_methods.each_slice(10) do |slice| %>
|
||||||
<tr>
|
<!-- <tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<% alph = "A" %>
|
<% alph = "A" %>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||||
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
<th style="text-align:center;"><%= alph = alph.ord.next.chr %></th>
|
||||||
</tr>
|
</tr> -->
|
||||||
<!-- <tr>
|
<!-- <tr>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
|
||||||
@@ -73,6 +73,12 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
<th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th>
|
<th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th>
|
||||||
<th colspan=4 style='text-align:center;'>Outgoing</th>
|
<th colspan=4 style='text-align:center;'>Outgoing</th>
|
||||||
|
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Gross Sales = (Income+Discount) - (FOC+Void)"><i class="material-icons md-18">live_help</i></th>
|
||||||
|
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Total Sales = Gross Sales - Discount"><i class="material-icons md-18">live_help</i></th>
|
||||||
|
<% if @tax.blank? %>
|
||||||
|
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Tax = Total Sales / 21"><i class="material-icons md-18">live_help</i></th>
|
||||||
|
<th style='text-align:center;' data-toggle="tooltip" data-placement="top" title="Net Sales = Total Sales - Tax"><i class="material-icons md-18">live_help</i></th>
|
||||||
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
||||||
@@ -122,7 +128,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>
|
||||||
|
<th style='text-align:center;'><%= t("views.right_panel.detail.net_sales") %></th>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -148,6 +159,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 +186,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 +237,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>
|
||||||
|
<td style='text-align:right;'><%= number_format(sale[:net_sale], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<% count = count + 1 %>
|
<% count = count + 1 %>
|
||||||
@@ -303,7 +327,12 @@
|
|||||||
|
|
||||||
<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>
|
||||||
|
<% if @tax.blank? %>
|
||||||
|
<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>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
@@ -315,19 +344,23 @@
|
|||||||
<% @tax.each do |tax|
|
<% @tax.each do |tax|
|
||||||
total_tax += tax.tax_amount.to_f %>
|
total_tax += tax.tax_amount.to_f %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="<%= colspan %>" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
<td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
||||||
<td colspan="2" style='text-align:right;'><%= number_format(tax.tax_amount, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td colspan="5" 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 = grand_total %>
|
||||||
<% net = net - rounding_adj%>
|
<% net = net - rounding_adj%>
|
||||||
<% net = net - total_tax %>
|
<% net = net - total_tax %>
|
||||||
<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 + 2 %>" 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, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% else %>
|
||||||
|
<tr style="font-weight:600;">
|
||||||
|
<td colspan="<%= colspan + 2 %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||||
|
<td colspan="5" style='text-align:right;'><%= number_format(net_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -7,65 +7,79 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-lg-12">
|
<div class="col-md-12 col-lg-12">
|
||||||
<div class="card" style="width:129%;">
|
<div class="card mbl_card">
|
||||||
<div class="body table-responsive">
|
<div class="body table-responsive">
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="<%= column_count = @payment_methods.length + 8 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
<th colspan="<%= column_count = @payment_methods.length + 12 %>"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%></th>
|
||||||
|
</tr>
|
||||||
|
<% @count = 1 %>
|
||||||
|
<% @payment_methods.each_slice(10) do |slice| %>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th colspan="<%= @count + 1 %>" style='text-align:center;'>Income</th>
|
||||||
|
<th colspan=4 style='text-align:center;'>Outgoing</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
|
||||||
|
|
||||||
<% if @payment_methods.include? ("MPU") %>
|
<% if @payment_methods.include? ("MPU") %>
|
||||||
<th style='text-align:center;' class='mobile'><%= t("views.right_panel.detail.mpu_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.mpu_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("Master") %>
|
<% if @payment_methods.include? ("Master") %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.master_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.master_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("VISA") %>
|
<% if @payment_methods.include? ("VISA") %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.visa_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.visa_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("JCB") %>
|
<% if @payment_methods.include? ("JCB") %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.jcb_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.jcb_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.unionpay_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.unionpay_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("KBZPay") %>
|
<% if @payment_methods.include? ("KBZPay") %>
|
||||||
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.kbzpay_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.kbzpay_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("Alipay") %>
|
<% if @payment_methods.include? ("Alipay") %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.alipay_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.alipay_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("PAYMAL") %>
|
<% if @payment_methods.include? ("PAYMAL") %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.paymal_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.paymal_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("DINGA") %>
|
<% if @payment_methods.include? ("DINGA") %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.dinga_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.dinga_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("JunctionPay") %>
|
<% if @payment_methods.include? ("JunctionPay") %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.junctionpay_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.junctionpay_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("Redeem") %>
|
<% if @payment_methods.include? ("Redeem") %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.redeem_sales") %></th>
|
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.redeem_sales") %></th>
|
||||||
|
<% end %>
|
||||||
|
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||||
|
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.foc_sales") %></th>
|
<th style='text-align:center;'><%= t("views.right_panel.detail.foc_sales") %></th>
|
||||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
|
||||||
<th style='text-align:center;'><%= t("views.right_panel.detail.giftvoucher_sales") %></th>
|
|
||||||
<% end %>
|
|
||||||
<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>
|
||||||
<% unless @sale_data.blank? %>
|
<% unless @sale_data.blank? %>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% void = 0 %>
|
<% void = 0 %>
|
||||||
<% mpu = 0 %>
|
<% mpu = 0 %>
|
||||||
@@ -87,6 +101,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] %>
|
||||||
@@ -110,118 +128,154 @@
|
|||||||
<% 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>
|
||||||
<% if @payment_methods.include? ("MPU") %>
|
<% if @payment_methods.include? ("MPU") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:mpu_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("Master") %>
|
<% if @payment_methods.include? ("Master") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:master_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("VISA") %>
|
<% if @payment_methods.include? ("VISA") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:visa_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("JCB") %>
|
<% if @payment_methods.include? ("JCB") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:jcb_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:unionpay_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:unionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("Alipay") %>
|
<% if @payment_methods.include? ("Alipay") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:alipay_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("KBZPay") %>
|
<% if @payment_methods.include? ("KBZPay") %>
|
||||||
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("PAYMAL") %>
|
<% if @payment_methods.include? ("PAYMAL") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paymal_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("DINGA") %>
|
<% if @payment_methods.include? ("DINGA") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:dinga_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:dinga_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("JunctionPay") %>
|
<% if @payment_methods.include? ("JunctionPay") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:junctionpay_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:junctionpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("Redeem") %>
|
<% if @payment_methods.include? ("Redeem") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(sale[:paypar_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), delimiter: delimiter) rescue '-'%></td>
|
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]),delimiter => ',') rescue '-'%></td>
|
|
||||||
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), delimiter => ',') rescue '-'%></td>
|
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]),delimiter => ',') rescue '-'%></td>
|
|
||||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:giftvoucher_amount]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_format(sale[:giftvoucher_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), delimiter => ',') rescue '-'%>)</td>
|
<td style='text-align:right;'><%= number_format(sale[:cash_amount]-sale[:total_change_amount], precision:precision.to_i, delimiter: delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_format(sale[:credit_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<!-- <td style='text-align:right;'><%= number_with_delimiter(sale[:grand_total].to_f + sale[:rounding_adj].to_f ,delimiter => ',') rescue '-'%></td> -->
|
<td style='color:red;text-align:right;'><%= number_format(sale[:void_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]),delimiter => ',') rescue '-'%></td>
|
<td style='text-align:right;'><%= number_format(sale[:foc_amount], precision:precision.to_i,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[:rounding_adj].to_f, 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 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% colspan = 7 %>
|
<% colspan = 7 %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="2" style='text-align:center;'><b>Total</b></td>
|
<td colspan="2" style='text-align:center;'>Total</td>
|
||||||
<% if @payment_methods.include? ("MPU") %>
|
<% if @payment_methods.include? ("MPU") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",mpu),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(mpu , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end%>
|
<% end%>
|
||||||
<% if @payment_methods.include? ("Master") %>
|
<% if @payment_methods.include? ("Master") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",master),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(master, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end%>
|
<% end%>
|
||||||
<% if @payment_methods.include? ("VISA") %>
|
<% if @payment_methods.include? ("VISA") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",visa), delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(visa, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end%>
|
<% end%>
|
||||||
<% if @payment_methods.include? ("JCB") %>
|
<% if @payment_methods.include? ("JCB") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",jcb),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(jcb, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end%>
|
<% end%>
|
||||||
<% if @payment_methods.include? ("UNIONPAY") %>
|
<% if @payment_methods.include? ("UNIONPAY") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",unionpay),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(unionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("Alipay") %>
|
<% if @payment_methods.include? ("Alipay") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",alipay),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("KBZPay") %>
|
<% if @payment_methods.include? ("KBZPay") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",kbzpay),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("PAYMAL") %>
|
<% if @payment_methods.include? ("PAYMAL") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",paymal),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paymal, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("DINGA") %>
|
<% if @payment_methods.include? ("DINGA") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",dinga),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(dinga, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("JunctionPay") %>
|
<% if @payment_methods.include? ("JunctionPay") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",junctionpay),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(junctionpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @payment_methods.include? ("Redeem") %>
|
<% if @payment_methods.include? ("Redeem") %>
|
||||||
|
<% if !request.user_agent.include? "Mobile" %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",paypar),delimiter => ',') rescue '-'%></b></td>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",cash),delimiter => ',') rescue '-'%></b></td>
|
<td style='text-align:right;' class="d-none d-sm-table-cell"><%= number_format(paypar, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",credit),delimiter => ',') rescue '-'%></b></td>
|
<% end %>
|
||||||
<td style='color:red;text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",void),delimiter => ',') rescue '-'%></b></td>
|
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",foc), delimiter => ',') rescue '-'%></b></td>
|
|
||||||
<% if @payment_methods.include? ("GiftVoucher") %>
|
<% if @payment_methods.include? ("GiftVoucher") %>
|
||||||
<% colspan += 1 %>
|
<% colspan += 1 %>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",giftvoucher), delimiter => ',') rescue '-'%></b></td>
|
<td style='text-align:right;'><%= number_format(giftvoucher, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td style='text-align:right;'><b>(<%= number_with_delimiter(discount,delimiter => ',') rescue '-'%>)</b></td>
|
<td style='text-align:right;'><%= number_format(cash, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",rounding_adj),delimiter => ',') rescue '-'%></b></td>
|
<td style='text-align:right;'><%= number_format(credit, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
<td style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",grand_total),delimiter => ',') rescue '-'%></b></td>
|
<td style='color:red;text-align:right;'><%= number_format(void, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td style='text-align:right;'><%= number_format(foc, 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(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>
|
<tr style="font-weight:600;">
|
||||||
<td colspan="<%= column_count %>"> </td>
|
<td colspan="<%= column_count %>"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<% total_tax = 0 %>
|
<% total_tax = 0 %>
|
||||||
@@ -230,19 +284,23 @@
|
|||||||
<% @tax.each do |tax|
|
<% @tax.each do |tax|
|
||||||
total_tax += tax.tax_amount.to_f %>
|
total_tax += tax.tax_amount.to_f %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="<%= colspan %>" style='text-align:right;'><b><%= tax.tax_name rescue '-'%></b></td>
|
<td colspan="<%= colspan %>" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
|
||||||
<td colspan="2" style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount),delimiter => ',') rescue '-'%></b></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 = grand_total %>
|
||||||
<% net = net - rounding_adj%>
|
<% net = net - rounding_adj%>
|
||||||
<% net = net - total_tax %>
|
<% net = net - total_tax %>
|
||||||
<tr style="font-weight:600;">
|
<tr style="font-weight:600;">
|
||||||
<td colspan="<%= colspan %>" style='text-align:right;'><b><%= t("views.right_panel.detail.net_amount") %></b></td>
|
<td colspan="<%= colspan %>" style='text-align:right;'><%= t("views.right_panel.detail.net_amount") %></td>
|
||||||
<td colspan="2" style='text-align:right;'><b><%= number_with_delimiter(sprintf("%.2f",net),delimiter => ',') rescue '-'%></b></td>
|
<td colspan="5" style='text-align:right;'><%= number_format(net, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% else %>
|
||||||
|
<tr style="font-weight:600;">
|
||||||
|
<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_sale, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -2,6 +2,57 @@
|
|||||||
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
|
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
|
||||||
<% if period_type != false %>
|
<% if period_type != false %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-lg-4 col-md-4 col-sm-4" style="padding-left: 17px;">
|
||||||
|
<%= form_tag reports_hourly_saleitem_index_path, :id => "filter_form", :method => :get do %>
|
||||||
|
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.product") %></label>
|
||||||
|
<input type="text" class="form-control" name="filter" id="Product" type="text" placeholder="Product" style="height: 32px;">
|
||||||
|
</div>
|
||||||
|
<!-- <div class="col-lg-2 col-md-2 col-sm-2 text-">
|
||||||
|
<input type="submit" value="Filter" class='btn btn-primary'>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
||||||
|
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.from_time") %></label>
|
||||||
|
<input data-behaviour='timepicker' class="form-control m-t-3 timepicker" value="<%= @start_time %>" name="start_time" id="start_time" type="text" placeholder="From Time" style="height: 32px;">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
||||||
|
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.to_time") %></label>
|
||||||
|
<input data-behaviour='timepicker' class="form-control m-t-3 timepicker" value="<%= @end_time %>" name="end_time" id="end_time" type="text" placeholder="To Time" style="height: 32px;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
||||||
|
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.from") %></label>
|
||||||
|
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
||||||
|
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.to") %></label>
|
||||||
|
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
|
||||||
|
</div>
|
||||||
|
<!-- <input type="hidden" name="report_type" value="sale_item" id="sel_sale_type"> -->
|
||||||
|
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
||||||
|
<label class="font-14 mbl_lbl">Select Type</label>
|
||||||
|
<select name="sale_type" id="sel_sale_type" class="form-control">
|
||||||
|
<option value="">Select Type</option>
|
||||||
|
<option value="revenue" selected>Revenue Only</option>
|
||||||
|
<option value="all">All Type</option>
|
||||||
|
<option value="discount">Discount Only</option>
|
||||||
|
<option value="void">Void Only</option>
|
||||||
|
<option value="foc">Foc Only</option>
|
||||||
|
<option value="promotion">Promotion Only</option>
|
||||||
|
<option value="other">Other Amount Only</option>
|
||||||
|
</select>
|
||||||
|
</div> -->
|
||||||
|
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
||||||
|
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_account") %></label>
|
||||||
|
|
||||||
|
<select name="account_type" id="account_type" class="form-control">
|
||||||
|
<option value = "">Select Account</option>
|
||||||
|
<% @account.each do |acc| %>
|
||||||
|
<option value="<%=acc.title%>" class="<%=acc.title%>" > <%=acc.title%></option>
|
||||||
|
<%end %>
|
||||||
|
</select>
|
||||||
|
</div> -->
|
||||||
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
|
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
|
||||||
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_period") %></label>
|
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_period") %></label>
|
||||||
<select name="period" id="sel_period" class="form-control">
|
<select name="period" id="sel_period" class="form-control">
|
||||||
@@ -18,39 +69,6 @@
|
|||||||
<option value="9">Last year</option>
|
<option value="9">Last year</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<!-- <input type="hidden" name="report_type" value="sale_item" id="sel_sale_type"> -->
|
|
||||||
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
|
||||||
<label class="font-14 mbl_lbl">Select Type</label>
|
|
||||||
<select name="sale_type" id="sel_sale_type" class="form-control">
|
|
||||||
<option value="">Select Type</option>
|
|
||||||
<option value="revenue" selected>Revenue Only</option>
|
|
||||||
<option value="all">All Type</option>
|
|
||||||
<option value="discount">Discount Only</option>
|
|
||||||
<option value="void">Void Only</option>
|
|
||||||
<option value="foc">Foc Only</option>
|
|
||||||
<option value="promotion">Promotion Only</option>
|
|
||||||
<option value="other">Other Amount Only</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
|
||||||
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.select_account") %></label>
|
|
||||||
|
|
||||||
<select name="account_type" id="account_type" class="form-control">
|
|
||||||
<option value = "">Select Account</option>
|
|
||||||
<% @account.each do |acc| %>
|
|
||||||
<option value="<%=acc.title%>" class="<%=acc.title%>" > <%=acc.title%></option>
|
|
||||||
<%end %>
|
|
||||||
</select>
|
|
||||||
</div> -->
|
|
||||||
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
|
||||||
<!-- <label class="">Select Shift Period</label> -->
|
|
||||||
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.from") %></label>
|
|
||||||
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-2 col-md-2 col-sm-2 col-mbl-view mbl-style">
|
|
||||||
<label class="font-14 mbl_lbl"><%= t("views.right_panel.detail.to") %></label>
|
|
||||||
<input data-behaviour='datepicker' class="form-control m-t-3 datepicker" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
|
<div class="col-lg-2 col-md-2 col-sm-2 mbl-style">
|
||||||
<label class="font-14 mbl_lbl">All Shift</label>
|
<label class="font-14 mbl_lbl">All Shift</label>
|
||||||
<select class="form-control select" name="shift_name" id="shift_name" >
|
<select class="form-control select" name="shift_name" id="shift_name" >
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="margin-top-20">
|
<div class="margin-top-20">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
<div colspan="7" class="report-table-header">
|
||||||
|
<%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
|
||||||
|
</div>
|
||||||
|
<% if @start_time.blank? || @end_time.blank? %>
|
||||||
<table class="table table-striped" border="0">
|
<table class="table table-striped" border="0">
|
||||||
<% time_arr = Array.new %>
|
<% time_arr = Array.new %>
|
||||||
<% acc_arr = Array.new %>
|
<% acc_arr = Array.new %>
|
||||||
@@ -35,10 +38,14 @@
|
|||||||
<% sale_item_count =1 %>
|
<% sale_item_count =1 %>
|
||||||
<% time_count = time_count + 1 %>
|
<% time_count = time_count + 1 %>
|
||||||
<thead>
|
<thead>
|
||||||
<td> </td>
|
<!-- <td> </td> -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
<% if @start_time.blank? || @end_time.blank? %>
|
||||||
<strong>Time :<%= sale.date_format %></strong>
|
<strong>Time :<%= sale.date_format %></strong>
|
||||||
|
<% else %>
|
||||||
|
<strong>Time : <%= "#{@start_time} - #{@end_time}" %></strong>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
@@ -88,7 +95,6 @@
|
|||||||
end %>
|
end %>
|
||||||
|
|
||||||
<% grand_total += sale.grand_total %>
|
<% grand_total += sale.grand_total %>
|
||||||
|
|
||||||
<% if !sale.item_code.nil?%>
|
<% if !sale.item_code.nil?%>
|
||||||
<% waste_and_spoil_item_count += sale.qty.to_i %>
|
<% waste_and_spoil_item_count += sale.qty.to_i %>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -106,6 +112,7 @@
|
|||||||
<!-- <td><%= sale.date_format %></td> -->
|
<!-- <td><%= sale.date_format %></td> -->
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<!-- new tr -->
|
<!-- new tr -->
|
||||||
<% count = count + 1 %>
|
<% count = count + 1 %>
|
||||||
<% @hourly_total_qty.each do |hr| %>
|
<% @hourly_total_qty.each do |hr| %>
|
||||||
@@ -134,6 +141,272 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
<% else %>
|
||||||
|
<table class="table table-striped" id="items_table" border="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="7"> <%= t("views.right_panel.detail.from_time") %> : <%= @start_time rescue '-' %> - <%= t("views.right_panel.detail.to_time") %> : <%= @end_time rescue '-'%></th>
|
||||||
|
</tr>
|
||||||
|
<% if @shift_from %>
|
||||||
|
<tr>
|
||||||
|
<% if @shift_data.employee %>
|
||||||
|
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||||
|
<% end %>
|
||||||
|
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.code") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.product") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.revenue") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% acc_arr = Array.new %>
|
||||||
|
<% cate_arr = Array.new %>
|
||||||
|
<% p_qty = 0 %>
|
||||||
|
<% sub_qty = 0 %>
|
||||||
|
<% sub_total = 0 %>
|
||||||
|
<% other_sub_total = 0 %>
|
||||||
|
<% product_sub_total = 0 %>
|
||||||
|
<% count = 0 %>
|
||||||
|
<% row_count = 0 %>
|
||||||
|
<% total_price = 0 %>
|
||||||
|
<% cate_count = 0 %>
|
||||||
|
<% acc_count = 0 %>
|
||||||
|
<% grand_total = 0 %>
|
||||||
|
<% total_qty = 0 %>
|
||||||
|
<% total_amount = 0 %>
|
||||||
|
<% discount = 0 %>
|
||||||
|
<% total_item_foc = 0 %>
|
||||||
|
<% total_item_dis = 0.0 %>
|
||||||
|
<% total_tax = 0 %>
|
||||||
|
<% unless @sale_data.blank? %>
|
||||||
|
<% @sale_data.each do |sale| %>
|
||||||
|
<% row_count += 1 %>
|
||||||
|
<!-- all total qty sum -->
|
||||||
|
|
||||||
|
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
|
||||||
|
total_qty += sale.total_item
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type == "foc" && sale.price > 0
|
||||||
|
total_qty += sale.total_item
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type == "Discount"
|
||||||
|
total_qty += sale.total_item*(-1)
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type =="promotion" && @type == "promotion"
|
||||||
|
total_qty += sale.total_item*(-1)
|
||||||
|
end %>
|
||||||
|
<!-- end all total qty -->
|
||||||
|
<% if sale.status_type == "foc" && sale.grand_total < 0
|
||||||
|
total_item_foc += sale.grand_total*(-1)
|
||||||
|
end %>
|
||||||
|
|
||||||
|
<% if sale.status_type == "Discount" && sale.grand_total < 0
|
||||||
|
total_item_dis += sale.grand_total*(-1)
|
||||||
|
end %>
|
||||||
|
|
||||||
|
<% if !acc_arr.include?(sale.account_id) %>
|
||||||
|
<tr>
|
||||||
|
<td><b><%= sale.account_name %></b></td>
|
||||||
|
<td colspan="4"> </td>
|
||||||
|
<td><%= t("views.right_panel.detail.total_price_by") %> <%= sale.account_name %></td>
|
||||||
|
<td>
|
||||||
|
<% @totalByAccount.each do |account, total| %>
|
||||||
|
<% if sale.account_id == account %>
|
||||||
|
<b><%= number_format(total, precision:precision.to_i,delimiter:delimiter) %></b>
|
||||||
|
<% grand_total += total %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% acc_arr.push(sale.account_id) %>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||||
|
<td><%= sale.menu_category_name %></td>
|
||||||
|
<% cate_arr.push(sale.menu_category_id) %>
|
||||||
|
<% else %>
|
||||||
|
<td> </td>
|
||||||
|
<% end %>
|
||||||
|
<td><%= sale.item_code rescue '-' %></td>
|
||||||
|
<td><%= sale.product_name rescue '-' %></td>
|
||||||
|
<% if sale.status_type != "Discount" %>
|
||||||
|
<td><%= sale.total_item rescue '-' %></td>
|
||||||
|
<%else%>
|
||||||
|
<td><%= sale.total_item*(-1) rescue '-' %></td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<td><%= number_format(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td><%= number_format(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
|
||||||
|
<% @menu_cate_count.each do |key,value| %>
|
||||||
|
<% if sale.account_id == key %>
|
||||||
|
<% count = count + 1 %>
|
||||||
|
<% sub_total += sale.grand_total %>
|
||||||
|
<% #sub_qty += sale.total_item %>
|
||||||
|
<% if sale.status_type !="Discount" && (!sale.product_name.include? "FOC") && sale.status_type != "promotion"
|
||||||
|
sub_qty += sale.total_item
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type =="Discount"
|
||||||
|
sub_qty += sale.total_item*(-1)
|
||||||
|
end %>
|
||||||
|
|
||||||
|
<% if sale.status_type == "promotion" && @type == "promotion"
|
||||||
|
sub_qty += sale.total_item*(-1)
|
||||||
|
end %>
|
||||||
|
<% if count == value %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3"> </td>
|
||||||
|
<td><b>Total <%= sale.account_name %> Qty </b> </td>
|
||||||
|
<td><b><%= sub_qty %></b></td>
|
||||||
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
|
<td ><span class="underline"><%= number_format(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
|
||||||
|
</tr>
|
||||||
|
<% sub_total = 0.0%>
|
||||||
|
<% sub_qty = 0 %>
|
||||||
|
<% count = 0%>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<!--Product Sale -->
|
||||||
|
<% if @product.present?%>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><b>Product</b></td>
|
||||||
|
<td colspan="4"> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<% @product.each do |product| %>
|
||||||
|
<% if product.total_item > 0
|
||||||
|
total_qty += product.total_item
|
||||||
|
end %>
|
||||||
|
<% grand_total +=product.grand_total
|
||||||
|
p_qty += product.total_item%>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td>Product</td>
|
||||||
|
<td><%= product.product_code rescue '-' %></td>
|
||||||
|
<td><%= product.product_name rescue '-' %></td>
|
||||||
|
<td><%= product.total_item rescue '-' %></td>
|
||||||
|
<td> <%= number_format(product.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td> <%= number_format(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
|
||||||
|
<% product_sub_total += product.grand_total %>
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3"> </td>
|
||||||
|
<td><b>Total Product Qty </b> </td>
|
||||||
|
<td><b><%= p_qty %></b></td>
|
||||||
|
|
||||||
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
|
<td ><span><%= number_format(product_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<%end%>
|
||||||
|
<!-- End Product Sale -->
|
||||||
|
|
||||||
|
<!--Other Charges -->
|
||||||
|
<% if @type == "other" || @other_charges.present?%>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><b>Other Charges</b></td>
|
||||||
|
<td colspan="4"> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<% @other_charges.each do |other| %>
|
||||||
|
<% if other.total_item > 0
|
||||||
|
total_qty += other.total_item
|
||||||
|
end %>
|
||||||
|
<% grand_total +=other.grand_total%>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td>Other Charges</td>
|
||||||
|
<td><%= other.item_code rescue '-' %></td>
|
||||||
|
<td><%= other.product_name rescue '-' %></td>
|
||||||
|
<td><%= other.total_item rescue '-' %></td>
|
||||||
|
<td> <%= number_format(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td> <%= number_format(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
|
||||||
|
<% other_sub_total += other.grand_total %>
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5"> </td>
|
||||||
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
|
<td ><span><%= number_format(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<%end%>
|
||||||
|
<!-- End Other Charges -->
|
||||||
|
<tr style="border-top:2px solid grey;">
|
||||||
|
<td colspan="3"> </td>
|
||||||
|
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
|
||||||
|
<td><span><%= total_qty%></span></td>
|
||||||
|
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||||
|
<td><span><%= number_format(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<% if @type =="" || @type =="all" || @type.nil? %>
|
||||||
|
<tr class="foc_payment">
|
||||||
|
<td colspan="5"> </td>
|
||||||
|
<td>Total FOC Amount</td>
|
||||||
|
<td><span><%= number_format(@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="foc_payment" style="border-top:2px solid grey;border-bottom:2px solid grey;">
|
||||||
|
<td colspan="5"> </td>
|
||||||
|
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.net_amount") %></td>
|
||||||
|
<td style="border-bottom:2px solid grey;"><span><%= number_format(grand_total -@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% if @type == "other"%>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><b>Other Charges</b></td>
|
||||||
|
<td colspan="4"> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<% @other_charges.each do |other| %>
|
||||||
|
<% if other.total_item > 0
|
||||||
|
total_qty += other.total_item
|
||||||
|
end %>
|
||||||
|
<% grand_total +=other.grand_total%>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td>Other Charges</td>
|
||||||
|
<td><%= other.item_code rescue '-' %></td>
|
||||||
|
<td><%= other.product_name rescue '-' %></td>
|
||||||
|
<td><%= other.total_item rescue '-' %></td>
|
||||||
|
<td> <%= number_format(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td> <%= number_format(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
|
||||||
|
<% other_sub_total += other.grand_total %>
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5"> </td>
|
||||||
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
|
<td ><span><%= number_format(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<%end%>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="margin-top-20">
|
<div class="margin-top-20">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
<div colspan="7" class="report-table-header">
|
||||||
|
<%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
|
||||||
|
</div>
|
||||||
|
<% if @start_time.blank? || @end_time.blank? %>
|
||||||
<table class="table table-striped" border="0">
|
<table class="table table-striped" border="0">
|
||||||
<% time_arr = Array.new %>
|
<% time_arr = Array.new %>
|
||||||
<% acc_arr = Array.new %>
|
<% acc_arr = Array.new %>
|
||||||
@@ -25,10 +29,14 @@
|
|||||||
<% sale_item_count =1 %>
|
<% sale_item_count =1 %>
|
||||||
<% time_count = time_count + 1 %>
|
<% time_count = time_count + 1 %>
|
||||||
<thead>
|
<thead>
|
||||||
<td> </td>
|
<!-- <td> </td> -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
<% if @start_time.blank? || @end_time.blank? %>
|
||||||
<strong>Time :<%= sale.date_format %></strong>
|
<strong>Time :<%= sale.date_format %></strong>
|
||||||
|
<% else %>
|
||||||
|
<strong>Time : <%= "#{@start_time} - #{@end_time}" %></strong>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
@@ -78,7 +86,6 @@
|
|||||||
end %>
|
end %>
|
||||||
|
|
||||||
<% grand_total += sale.grand_total %>
|
<% grand_total += sale.grand_total %>
|
||||||
|
|
||||||
<% if !sale.item_code.nil?%>
|
<% if !sale.item_code.nil?%>
|
||||||
<% waste_and_spoil_item_count += sale.qty.to_i %>
|
<% waste_and_spoil_item_count += sale.qty.to_i %>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -96,6 +103,7 @@
|
|||||||
<!-- <td><%= sale.date_format %></td> -->
|
<!-- <td><%= sale.date_format %></td> -->
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<!-- new tr -->
|
<!-- new tr -->
|
||||||
<% count = count + 1 %>
|
<% count = count + 1 %>
|
||||||
<% @hourly_total_qty.each do |hr| %>
|
<% @hourly_total_qty.each do |hr| %>
|
||||||
@@ -118,11 +126,278 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% footer_arr.push(sale.sale_id) %>
|
<% footer_arr.push(sale.sale_id) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
<% else %>
|
||||||
|
<table class="table table-striped" id="items_table" border="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="7"> <%= t("views.right_panel.detail.from_time") %> : <%= @start_time rescue '-' %> - <%= t("views.right_panel.detail.to_time") %> : <%= @end_time rescue '-'%></th>
|
||||||
|
</tr>
|
||||||
|
<% if @shift_from %>
|
||||||
|
<tr>
|
||||||
|
<% if @shift_data.employee %>
|
||||||
|
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||||
|
<% end %>
|
||||||
|
<th colspan="7"> <%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<th> </th>
|
||||||
|
<th><%= t("views.right_panel.header.menu_category") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.code") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.product") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.unit_price") %></th>
|
||||||
|
<th><%= t("views.right_panel.detail.revenue") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% acc_arr = Array.new %>
|
||||||
|
<% cate_arr = Array.new %>
|
||||||
|
<% p_qty = 0 %>
|
||||||
|
<% sub_qty = 0 %>
|
||||||
|
<% sub_total = 0 %>
|
||||||
|
<% other_sub_total = 0 %>
|
||||||
|
<% product_sub_total = 0 %>
|
||||||
|
<% count = 0 %>
|
||||||
|
<% row_count = 0 %>
|
||||||
|
<% total_price = 0 %>
|
||||||
|
<% cate_count = 0 %>
|
||||||
|
<% acc_count = 0 %>
|
||||||
|
<% grand_total = 0 %>
|
||||||
|
<% total_qty = 0 %>
|
||||||
|
<% total_amount = 0 %>
|
||||||
|
<% discount = 0 %>
|
||||||
|
<% total_item_foc = 0 %>
|
||||||
|
<% total_item_dis = 0.0 %>
|
||||||
|
<% total_tax = 0 %>
|
||||||
|
<% unless @sale_data.blank? %>
|
||||||
|
<% @sale_data.each do |sale| %>
|
||||||
|
<% row_count += 1 %>
|
||||||
|
<!-- all total qty sum -->
|
||||||
|
|
||||||
|
<% if sale.status_type != "Discount" && sale.status_type != "foc" && sale.status_type != "promotion"
|
||||||
|
total_qty += sale.total_item
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type == "foc" && sale.price > 0
|
||||||
|
total_qty += sale.total_item
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type == "Discount"
|
||||||
|
total_qty += sale.total_item*(-1)
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type =="promotion" && @type == "promotion"
|
||||||
|
total_qty += sale.total_item*(-1)
|
||||||
|
end %>
|
||||||
|
<!-- end all total qty -->
|
||||||
|
<% if sale.status_type == "foc" && sale.grand_total < 0
|
||||||
|
total_item_foc += sale.grand_total*(-1)
|
||||||
|
end %>
|
||||||
|
|
||||||
|
<% if sale.status_type == "Discount" && sale.grand_total < 0
|
||||||
|
total_item_dis += sale.grand_total*(-1)
|
||||||
|
end %>
|
||||||
|
|
||||||
|
<% if !acc_arr.include?(sale.account_id) %>
|
||||||
|
<tr>
|
||||||
|
<td><b><%= sale.account_name %></b></td>
|
||||||
|
<td colspan="4"> </td>
|
||||||
|
<td><%= t("views.right_panel.detail.total_price_by") %> <%= sale.account_name %></td>
|
||||||
|
<td>
|
||||||
|
<% @totalByAccount.each do |account, total| %>
|
||||||
|
<% if sale.account_id == account %>
|
||||||
|
<b><%= number_format(total, precision:precision.to_i,delimiter:delimiter) %></b>
|
||||||
|
<% grand_total += total %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% acc_arr.push(sale.account_id) %>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<% if !cate_arr.include?(sale.menu_category_id) %>
|
||||||
|
<td><%= sale.menu_category_name %></td>
|
||||||
|
<% cate_arr.push(sale.menu_category_id) %>
|
||||||
|
<% else %>
|
||||||
|
<td> </td>
|
||||||
|
<% end %>
|
||||||
|
<td><%= sale.item_code rescue '-' %></td>
|
||||||
|
<td><%= sale.product_name rescue '-' %></td>
|
||||||
|
<% if sale.status_type != "Discount" %>
|
||||||
|
<td><%= sale.total_item rescue '-' %></td>
|
||||||
|
<%else%>
|
||||||
|
<td><%= sale.total_item*(-1) rescue '-' %></td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<td><%= number_format(sale.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td><%= number_format(sale.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
|
||||||
|
<% @menu_cate_count.each do |key,value| %>
|
||||||
|
<% if sale.account_id == key %>
|
||||||
|
<% count = count + 1 %>
|
||||||
|
<% sub_total += sale.grand_total %>
|
||||||
|
<% #sub_qty += sale.total_item %>
|
||||||
|
<% if sale.status_type !="Discount" && (!sale.product_name.include? "FOC") && sale.status_type != "promotion"
|
||||||
|
sub_qty += sale.total_item
|
||||||
|
end %>
|
||||||
|
<% if sale.status_type =="Discount"
|
||||||
|
sub_qty += sale.total_item*(-1)
|
||||||
|
end %>
|
||||||
|
|
||||||
|
<% if sale.status_type == "promotion" && @type == "promotion"
|
||||||
|
sub_qty += sale.total_item*(-1)
|
||||||
|
end %>
|
||||||
|
<% if count == value %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3"> </td>
|
||||||
|
<td><b>Total <%= sale.account_name %> Qty </b> </td>
|
||||||
|
<td><b><%= sub_qty %></b></td>
|
||||||
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
|
<td ><span class="underline"><%= number_format(sub_total , precision:precision.to_i,delimiter:delimiter)%> </span></td>
|
||||||
|
</tr>
|
||||||
|
<% sub_total = 0.0%>
|
||||||
|
<% sub_qty = 0 %>
|
||||||
|
<% count = 0%>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<!--Product Sale -->
|
||||||
|
<% if @product.present?%>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><b>Product</b></td>
|
||||||
|
<td colspan="4"> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<% @product.each do |product| %>
|
||||||
|
<% if product.total_item > 0
|
||||||
|
total_qty += product.total_item
|
||||||
|
end %>
|
||||||
|
<% grand_total +=product.grand_total
|
||||||
|
p_qty += product.total_item%>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td>Product</td>
|
||||||
|
<td><%= product.product_code rescue '-' %></td>
|
||||||
|
<td><%= product.product_name rescue '-' %></td>
|
||||||
|
<td><%= product.total_item rescue '-' %></td>
|
||||||
|
<td> <%= number_format(product.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td> <%= number_format(product.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
|
||||||
|
<% product_sub_total += product.grand_total %>
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3"> </td>
|
||||||
|
<td><b>Total Product Qty </b> </td>
|
||||||
|
<td><b><%= p_qty %></b></td>
|
||||||
|
|
||||||
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
|
<td ><span><%= number_format(product_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<%end%>
|
||||||
|
<!-- End Product Sale -->
|
||||||
|
|
||||||
|
<!--Other Charges -->
|
||||||
|
<% if @type == "other" || @other_charges.present?%>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><b>Other Charges</b></td>
|
||||||
|
<td colspan="4"> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<% @other_charges.each do |other| %>
|
||||||
|
<% if other.total_item > 0
|
||||||
|
total_qty += other.total_item
|
||||||
|
end %>
|
||||||
|
<% grand_total +=other.grand_total%>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td>Other Charges</td>
|
||||||
|
<td><%= other.item_code rescue '-' %></td>
|
||||||
|
<td><%= other.product_name rescue '-' %></td>
|
||||||
|
<td><%= other.total_item rescue '-' %></td>
|
||||||
|
<td> <%= number_format(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td> <%= number_format(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
|
||||||
|
<% other_sub_total += other.grand_total %>
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5"> </td>
|
||||||
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
|
<td ><span><%= number_format(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<%end%>
|
||||||
|
<!-- End Other Charges -->
|
||||||
|
<tr style="border-top:2px solid grey;">
|
||||||
|
<td colspan="3"> </td>
|
||||||
|
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %></td>
|
||||||
|
<td><span><%= total_qty%></span></td>
|
||||||
|
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
|
||||||
|
<td><span><%= number_format(grand_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<% if @type =="" || @type =="all" || @type.nil? %>
|
||||||
|
<tr class="foc_payment">
|
||||||
|
<td colspan="5"> </td>
|
||||||
|
<td>Total FOC Amount</td>
|
||||||
|
<td><span><%= number_format(@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="foc_payment" style="border-top:2px solid grey;border-bottom:2px solid grey;">
|
||||||
|
<td colspan="5"> </td>
|
||||||
|
<td style="border-bottom:2px solid grey;"><%= t("views.right_panel.detail.net_amount") %></td>
|
||||||
|
<td style="border-bottom:2px solid grey;"><span><%= number_format(grand_total -@foc_data , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% if @type == "other"%>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><b>Other Charges</b></td>
|
||||||
|
<td colspan="4"> </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<% @other_charges.each do |other| %>
|
||||||
|
<% if other.total_item > 0
|
||||||
|
total_qty += other.total_item
|
||||||
|
end %>
|
||||||
|
<% grand_total +=other.grand_total%>
|
||||||
|
<tr>
|
||||||
|
<td> </td>
|
||||||
|
<td>Other Charges</td>
|
||||||
|
<td><%= other.item_code rescue '-' %></td>
|
||||||
|
<td><%= other.product_name rescue '-' %></td>
|
||||||
|
<td><%= other.total_item rescue '-' %></td>
|
||||||
|
<td> <%= number_format(other.unit_price , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
<td> <%= number_format(other.grand_total , precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||||
|
</tr>
|
||||||
|
<!-- sub total -->
|
||||||
|
|
||||||
|
<% other_sub_total += other.grand_total %>
|
||||||
|
<!-- end sub total -->
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5"> </td>
|
||||||
|
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||||
|
<td ><span><%= number_format(other_sub_total , precision:precision.to_i,delimiter:delimiter)%></span></td>
|
||||||
|
</tr>
|
||||||
|
<%end%>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -136,7 +136,7 @@
|
|||||||
<% sale_payments = result.sale_payments %>
|
<% sale_payments = result.sale_payments %>
|
||||||
<% if sale_payments.length > 0%>
|
<% if sale_payments.length > 0%>
|
||||||
<% sale_payments.each do |rec| %>
|
<% sale_payments.each do |rec| %>
|
||||||
<% next if rec.payment_method == 'credit_note' && result.payments_for_credits_amount < rec.payment_amount %>
|
<% if rec.payment_amount > 0 %>
|
||||||
<tr>
|
<tr>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
@@ -155,6 +155,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
<% if result.amount_changed != 0 %>
|
<% if result.amount_changed != 0 %>
|
||||||
<tr>
|
<tr>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
|
|||||||
@@ -39,8 +39,7 @@
|
|||||||
<% grand_total = grand_total.to_f + result.grand_total.to_f%>
|
<% grand_total = grand_total.to_f + result.grand_total.to_f%>
|
||||||
<% table_name=nil
|
<% table_name=nil
|
||||||
table_type =nil
|
table_type =nil
|
||||||
if result.table_id.to_i>0
|
if table = result.bookings[0].dining_facility
|
||||||
table = DiningFacility.find(result.table_id)
|
|
||||||
table_type = table.type
|
table_type = table.type
|
||||||
table_name = table.name
|
table_name = table.name
|
||||||
end %>
|
end %>
|
||||||
@@ -126,7 +125,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% sale_payments = SalePayment.get_sale_payments(result) %>
|
<% sale_payments = result.sale_payments %>
|
||||||
<% if sale_payments.length > 0%>
|
<% if sale_payments.length > 0%>
|
||||||
<% sale_payments.each do |rec| %>
|
<% sale_payments.each do |rec| %>
|
||||||
<%if rec.payment_amount.to_f > 0 %>
|
<%if rec.payment_amount.to_f > 0 %>
|
||||||
@@ -134,7 +133,7 @@
|
|||||||
<td> </td>
|
<td> </td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<td>Payment <%= rec.payment_method.upcase %></td>
|
<td>Payment <%= rec.payment_method.upcase %></td>
|
||||||
<td><%= rec.payment_amount %> ( <%= result.payment_status %> )</td>
|
<td><%= rec.payment_amount %> ( <%= rec.payment_status %> )</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|||||||
@@ -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,8 +20,7 @@
|
|||||||
</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">
|
||||||
@@ -47,7 +46,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions p-l-15">
|
<div class="form-actions p-l-15">
|
||||||
@@ -81,4 +79,3 @@
|
|||||||
</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>
|
||||||
@@ -49,7 +49,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions p-l-15">
|
<div class="form-actions p-l-15">
|
||||||
@@ -84,5 +83,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
</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>
|
||||||
@@ -89,7 +89,6 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -121,5 +120,3 @@
|
|||||||
</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) %>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user