fixed conflict
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
include TokenVerification
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
# before_action :lookup_domain
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
|
||||
private
|
||||
#this is base api base controller to need to inherit.
|
||||
@@ -21,4 +22,46 @@ class Api::ApiController < ActionController::API
|
||||
def current_login_employee
|
||||
@employee = Employee.find_by_token_session(current_token)
|
||||
end
|
||||
|
||||
# def lookup_domain
|
||||
# if request.subdomain.present? && request.subdomain != "www"
|
||||
# from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
# if (!@license.nil?)
|
||||
# logger.info "Location - " + @license.dbhost
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # authenticate_session_token
|
||||
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
# else
|
||||
# # reconnect_default_db
|
||||
# logger.info 'License is nil'
|
||||
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# def website_connection(license)
|
||||
# default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
# :username => license.dbusername, :password => license.dbpassword)
|
||||
# end
|
||||
|
||||
# def reconnect_default_db
|
||||
# ActiveRecord::Base.establish_connection(Rails.env)
|
||||
# end
|
||||
|
||||
# # Regular database.yml configuration hash
|
||||
# def default_connection
|
||||
# @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
||||
# end
|
||||
|
||||
# def cache_license(url, lookup)
|
||||
# @license = License.new(url, lookup)
|
||||
|
||||
# if (@license.detail_with_local_cache(lookup) == true)
|
||||
# return @license
|
||||
# else
|
||||
# return nil
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -7,8 +7,7 @@ class Api::AuthenticateController < Api::ApiController
|
||||
|
||||
if emp_id && password
|
||||
@employee = Employee.login(emp_id, password)
|
||||
|
||||
if @employee
|
||||
if @employee && @employee.role == "waiter"
|
||||
render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Bad Emp_ID or Password."})
|
||||
|
||||
@@ -5,8 +5,8 @@ class Api::BillController < Api::ApiController
|
||||
def create
|
||||
@status = false
|
||||
@error_message = "Order ID or Booking ID is require to request for a bill."
|
||||
|
||||
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
|
||||
# if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
|
||||
if !ShiftSale.current_shift.nil?
|
||||
#create Bill by Booking ID
|
||||
table = 0
|
||||
if (params[:booking_id])
|
||||
@@ -41,12 +41,15 @@ class Api::BillController < Api::ApiController
|
||||
end
|
||||
|
||||
# Bind shift sale id to sale
|
||||
@sale_data.shift_sale_id = shift_by_terminal.id
|
||||
@sale_data.save
|
||||
# @sale_data.shift_sale_id = shift_by_terminal.id
|
||||
# @sale_data.save
|
||||
|
||||
Promotion.promo_activate(@sale)
|
||||
|
||||
BillBroadcastJob.perform_later(table)
|
||||
#BillBroadcastJob.perform_later(table)
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
ActionCable.server.broadcast "bill_channel",table: table
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Api::BookingsController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
# skip_before_action :authenticate
|
||||
#Show customer by ID
|
||||
def index
|
||||
@customer = Customer.find_by(params[:id])
|
||||
|
||||
@@ -5,15 +5,16 @@ class Api::CallWaitersController < ActionController::API
|
||||
@table_id = params[:dining_id]
|
||||
@time = params[:time]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
CallWaiterJob.perform_later(@table,@time)
|
||||
|
||||
# CallWaiterJob.perform_later(@table,@time)
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time
|
||||
end
|
||||
# get printer info
|
||||
# @shop = Shop::ShopDetail
|
||||
# unique_code = "CallWaiterPdf"
|
||||
# print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
# printer.print_call_waiter(print_settings,@table,@time,@shop)
|
||||
|
||||
@shop = Shop.first
|
||||
unique_code = "CallWaiterPdf"
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_call_waiter(print_settings,@table,@time,@shop)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Api::CheckInProcessController < Api::ApiController
|
||||
|
||||
# before_action :authenticate
|
||||
def check_in_time
|
||||
if params[:dining_id]
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
@@ -11,17 +11,24 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
||||
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
|
||||
|
||||
extra_minutes = (booking.checkout_at - booking.reserved_at) / 1.minutes
|
||||
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||
alert_time_min = 0
|
||||
if !lookup_checkout_time.nil?
|
||||
if lookup_checkout_time[0][0] == 'min'
|
||||
alert_time_min = (lookup_checkout_time[0][1]).to_i
|
||||
else
|
||||
alert_time_min = 15
|
||||
end
|
||||
if !lookup_checkout_time.empty?
|
||||
now = Time.now.utc
|
||||
lookup_checkout_time.each do |checkout_time|
|
||||
arr_time = checkout_time[0].split("-")
|
||||
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
|
||||
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
|
||||
if start_time <= now && now <= end_time
|
||||
alert_time_min = checkout_time[1].to_i
|
||||
end
|
||||
end
|
||||
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes }
|
||||
else
|
||||
render :json => { :status => true }
|
||||
end
|
||||
|
||||
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min }
|
||||
else
|
||||
render :json => { :status => false, :error_message => "No current booking!" }
|
||||
end
|
||||
@@ -33,31 +40,41 @@ class Api::CheckInProcessController < Api::ApiController
|
||||
dining_facility = DiningFacility.find(params[:dining_id])
|
||||
if dining_facility.status == "available"
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||
|
||||
checkout_at = Time.now.utc
|
||||
|
||||
if !lookup_checkout_time.nil?
|
||||
if lookup_checkout_time[0][0] == 'hr'
|
||||
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
|
||||
else
|
||||
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
|
||||
end
|
||||
end
|
||||
|
||||
dining_facility.status = "occupied"
|
||||
dining_facility.save!
|
||||
|
||||
if dining_facility.type == "Table"
|
||||
type = "TableBooking"
|
||||
else
|
||||
type = "RoomBooking"
|
||||
end
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
||||
booking.save!
|
||||
if !lookup_checkout_time.empty?
|
||||
today = Time.now.utc.getlocal
|
||||
checkout_at = Time.now.utc.getlocal
|
||||
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||
lookup_checkout_time.each do |checkout_time|
|
||||
arr_time = checkout_time[0].split("-")
|
||||
start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p")
|
||||
end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p")
|
||||
if start_time <= today.strftime("%H:%M%p") && today.strftime("%H:%M%p") <= end_time
|
||||
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
|
||||
end
|
||||
end
|
||||
|
||||
if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
|
||||
dining_facility.status = "occupied"
|
||||
dining_facility.save!
|
||||
|
||||
if dining_facility.type == "Table"
|
||||
type = "TableBooking"
|
||||
else
|
||||
type = "RoomBooking"
|
||||
end
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
||||
booking.save!
|
||||
|
||||
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
|
||||
else
|
||||
render :json => { :status => true }
|
||||
end
|
||||
else
|
||||
render :json => { :status => true }
|
||||
end
|
||||
else
|
||||
error_message = "#{dining_facility.type} is not available!"
|
||||
render :json => { :status => false, :error_message => error_message }
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
class Api::OrderReserve::OrderReservationController < Api::ApiController
|
||||
# skip_before_action :authenticate
|
||||
ORDER = "order"
|
||||
RESERVATION = "reservation"
|
||||
ORDER_RESERVATION = "order_and_reservation"
|
||||
|
||||
def check_customer
|
||||
customer_id = 0
|
||||
if !params[:name]
|
||||
render :json => { :status => false, :message => "name is required!" }
|
||||
elsif !params[:email]
|
||||
render :json => { :status => false, :message => "email is required!" }
|
||||
elsif !params[:membership_id]
|
||||
render :json => { :status => false, :message => "membership_id is required!" }
|
||||
end
|
||||
|
||||
check_customer = Customer.find_by_email_and_membership_id(params[:email],params[:membership_id])
|
||||
if !check_customer.nil?
|
||||
customer_id = check_customer.customer_id
|
||||
else
|
||||
customer = Customer.addCustomer(params)
|
||||
customer_id = customer.id
|
||||
end
|
||||
|
||||
render :json => { :status => true, :data => { :customer_id => customer_id} }
|
||||
end
|
||||
|
||||
def create
|
||||
status = false
|
||||
if !params[:cus_info]
|
||||
render :json => { :status => false, :message => "cus_info is required!" }
|
||||
elsif !params[:requested_time]
|
||||
render :json => { :status => false, :message => "requested_time is required!" }
|
||||
elsif !params[:callback_url]
|
||||
render :json => { :status => false, :message => "callback_url is required!" }
|
||||
elsif !params[:reference]
|
||||
render :json => { :status => false, :message => "reference is required!" }
|
||||
elsif !params[:order_type]
|
||||
render :json => { :status => false, :message => "order_type is required!" }
|
||||
elsif params[:order_type] == ORDER || params[:order_type] == ORDER_RESERVATION
|
||||
if !params[:order_info]
|
||||
render :json => { :status => false, :message => "order_info is required!" }
|
||||
else
|
||||
status = true
|
||||
end
|
||||
elsif params[:order_type] == RESERVATION || params[:order_type] == ORDER_RESERVATION
|
||||
if !params[:reservation_info]
|
||||
render :json => { :status => false, :message => "reservation_info is required!" }
|
||||
else
|
||||
status = true
|
||||
end
|
||||
elsif !params[:payment_info]
|
||||
render :json => { :status => false, :message => "payment_info is required!" }
|
||||
elsif !params[:delivery_info]
|
||||
render :json => { :status => false, :message => "delivery_info is required!" }
|
||||
end
|
||||
|
||||
if status == true
|
||||
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(params)
|
||||
|
||||
order_reservation = OrderReservation.find(order_reservation_id)
|
||||
# if ENV["SERVER_MODE"] != 'cloud'
|
||||
# ActionCable.server.broadcast "order_reservation_channel",data: order_reservation
|
||||
# end
|
||||
if flag
|
||||
render :json => { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
|
||||
else
|
||||
render :json => { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
class Api::OrdersController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
# skip_before_action :authenticate
|
||||
#Description
|
||||
# This API show current order details
|
||||
# Input Params - order_id
|
||||
@@ -50,64 +50,89 @@ class Api::OrdersController < Api::ApiController
|
||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
@order.items = params[:order_items]
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if checkin_checkout_time(params[:booking_id])
|
||||
#for extratime
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
params[:order_items].each { |i|
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
arr_exts = i["item_instance_code"].split("_")
|
||||
if arr_exts[1].match(/^(\d)+$/)
|
||||
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
||||
extra_time = Time.at(time)
|
||||
end
|
||||
end
|
||||
}
|
||||
#end extra time
|
||||
puts params[:order_items]
|
||||
puts "ORDER ITEMS"
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
@order.items = params[:order_items]
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
end #booking exists
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
# # for parallel order
|
||||
# remoteIP = ""
|
||||
# begin
|
||||
# @status, @booking = @order.generate
|
||||
# remoteIP = request.remote_ip
|
||||
# end while request.remote_ip != remoteIP
|
||||
@status, @booking = @order.generate
|
||||
# # for parallel order
|
||||
# remoteIP = ""
|
||||
# begin
|
||||
# @status, @booking = @order.generate
|
||||
# remoteIP = request.remote_ip
|
||||
# end while request.remote_ip != remoteIP
|
||||
else
|
||||
return return_json_status_with_code(406, "Checkout time is over!")
|
||||
end
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
def return_json_status_with_code(code, msg)
|
||||
render status: code, json: {
|
||||
message: msg,
|
||||
booking_id: booking_id
|
||||
message: msg
|
||||
# booking_id: booking_id
|
||||
}.to_json
|
||||
end
|
||||
|
||||
@@ -147,13 +172,86 @@ class Api::OrdersController < Api::ApiController
|
||||
# Update customer info, Guest Info
|
||||
# Input Params
|
||||
# order_id , order_items {[item_code, item_instance_code , qty, option, variants]}
|
||||
def update
|
||||
# def update
|
||||
|
||||
end
|
||||
# end
|
||||
|
||||
def order_params
|
||||
params.permits(:order_source, :booking_id,:order_type,
|
||||
:customer_id,:guest_info, :table_id, :room_id,
|
||||
order_items: [:item_code, :qty, :option, :remark])
|
||||
end
|
||||
|
||||
#checked checkin and checkout time
|
||||
def checkin_checkout_time(booking_id)
|
||||
status = true
|
||||
if !booking_id.nil?
|
||||
today = Time.now.utc
|
||||
booking = Booking.find(booking_id)
|
||||
if !booking.nil?
|
||||
if !booking.checkout_at.nil?
|
||||
checkout_time = booking.checkout_at.utc
|
||||
if checkout_time <= today
|
||||
status = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return status
|
||||
end
|
||||
|
||||
def update
|
||||
Rails.logger.debug "Booking ID - " + params[:booking_id].to_s
|
||||
if checkin_checkout_time(params[:booking_id])
|
||||
Rails.logger.debug "Order Item ID - " + params[:order_item_id].to_s
|
||||
|
||||
order_items_id = params[:order_item_id]
|
||||
qty_weight = params[:quantity].to_f
|
||||
remarks = params[:remark]
|
||||
|
||||
order_item = OrderItem.find(order_items_id)
|
||||
before_updated_qty = order_item.qty
|
||||
|
||||
order_item.item_order_by = current_login_employee.name
|
||||
order_item.qty = qty_weight
|
||||
order_item.remark = remarks
|
||||
order_item.save
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# print
|
||||
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
|
||||
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
||||
|
||||
unique_code="OrderItemPdf"
|
||||
if !order_slim_pdf.empty?
|
||||
order_slim_pdf.each do |order_item_slim|
|
||||
if order_item_slim[0] == 'OrderSlimPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
unique_code="OrderItemSlimPdf"
|
||||
else
|
||||
unique_code="OrderItemPdf"
|
||||
end
|
||||
elsif order_item_slim[0] == 'OrderSetPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
unique_code="OrderSetItemPdf"
|
||||
else
|
||||
unique_code="OrderItemPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
|
||||
end
|
||||
|
||||
return return_json_status_with_code(200, "updated successfully!")
|
||||
else
|
||||
return return_json_status_with_code(406, "Checkout time is over!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -84,6 +84,17 @@ class Api::PaymentsController < ActionController::API
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
#TODO: implement paypar implementation
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
when "JunctionPay"
|
||||
sale_payment.payment_method = "JunctionPay"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.customer_id = params[:customer_id]
|
||||
sale_payment.payment_reference = params[:vochure_no]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
when "alipay"
|
||||
sale_payment.payment_method = "alipay"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class Api::Restaurant::ItemSetsController < Api::ApiController
|
||||
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class Api::Restaurant::MenuCategoriesController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
class Api::Restaurant::MenuCategoriesController < Api::ApiController
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class Api::Restaurant::MenuController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class Api::Restaurant::MenuItemAttributesController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
class Api::Restaurant::MenuItemAttributesController < Api::ApiController
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class Api::Restaurant::MenuItemInstancesController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
class Api::Restaurant::MenuItemInstancesController < Api::ApiController
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
|
||||
48
app/controllers/api/survey_controller.rb
Normal file
48
app/controllers/api/survey_controller.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
class Api::SurveyController < Api::ApiController
|
||||
|
||||
# before_action :authenticate
|
||||
|
||||
def index
|
||||
dining_facility = DiningFacility.find(params[:id])
|
||||
survey_data = Survey.find_by_dining_name(dining_facility.name)
|
||||
countries = Lookup.collection_of("country")
|
||||
if !countries.nil? || !survey_data.nil?
|
||||
render :json => { :status => true, :data => { :countries => countries, :survey_data => survey_data} }
|
||||
else
|
||||
render :json => { :status => true, :error_message => "There is no data" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
dining_facility = DiningFacility.find(params[:id])
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
|
||||
if params[:survey_id]
|
||||
survey = Survey.find(params[:survey_id])
|
||||
else
|
||||
survey = Survey.new
|
||||
end
|
||||
survey.dining_name = dining_facility.name
|
||||
survey.shift_id = shift_by_terminal.id
|
||||
survey.child = params[:child]
|
||||
survey.adult = params[:adult]
|
||||
survey.male = params[:male]
|
||||
survey.female = params[:female]
|
||||
survey.local = params[:local]
|
||||
survey.created_by = current_login_employee.name
|
||||
survey.total_customer = params[:total_customer]
|
||||
survey.total_amount = params[:total_amount]
|
||||
survey.foreigner = params[:foreigner].to_json
|
||||
survey.save!
|
||||
|
||||
render :json => { :status => true }
|
||||
end
|
||||
|
||||
# private
|
||||
# def survey_params
|
||||
# params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner,
|
||||
# :dining_name,:created_by,:total_customer,:total_amount)
|
||||
# end
|
||||
|
||||
end
|
||||
@@ -1,118 +1,25 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
include LoginVerification
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
# lookup domain for db from provision
|
||||
before_action :lookup_domain, :set_locale
|
||||
|
||||
helper_method :current_company,:current_login_employee,:current_user
|
||||
# before_action :set_locale
|
||||
# helper_method :current_company,:current_login_employee,:current_user
|
||||
# alias_method :current_user, :current_login_employee,:current_user
|
||||
#this is base api base controller to need to inherit.
|
||||
#all token authentication must be done here
|
||||
#response format must be set to JSON
|
||||
|
||||
#change locallization
|
||||
def set_locale
|
||||
I18n.locale = params[:locale] || I18n.default_locale
|
||||
end
|
||||
|
||||
# RESTful url for localize
|
||||
def default_url_options
|
||||
{ locale: I18n.locale }
|
||||
end
|
||||
|
||||
def lookup_domain
|
||||
if request.subdomain.present? && request.subdomain != "www"
|
||||
from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
if (!@license.nil?)
|
||||
# logger.info "Location - " + @license.name
|
||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
else
|
||||
# reconnect_default_db
|
||||
logger.info 'License is nil'
|
||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
||||
render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
end
|
||||
else
|
||||
# check for license file
|
||||
# if check_license
|
||||
# current_license(ENV["SX_PROVISION_URL"])
|
||||
# else
|
||||
# redirect_to activate_path
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
def current_license(url)
|
||||
@license = License.new(url)
|
||||
flag = @license.detail_with_local_file()
|
||||
if (flag == 0)
|
||||
flash[:notice] = 'Expired or No License!'
|
||||
elsif (flag == 2)
|
||||
flash[:notice] = 'Expiring! Please, License extend...'
|
||||
else
|
||||
puts "RUN SAY BYAR"
|
||||
end
|
||||
end
|
||||
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
|
||||
if (@license.detail_with_local_cache(lookup) == true)
|
||||
return @license
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def website_connection(license)
|
||||
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
:username => license.dbusername, :password => license.dbpassword)
|
||||
|
||||
end
|
||||
|
||||
def reconnect_default_db
|
||||
ActiveRecord::Base.establish_connection(Rails.env)
|
||||
end
|
||||
|
||||
# Regular database.yml configuration hash
|
||||
def default_connection
|
||||
@default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
||||
end
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
def current_company
|
||||
begin
|
||||
return Company.first
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
if (!session[:session_token].nil?)
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_license
|
||||
if License.check_license_file
|
||||
return true
|
||||
end
|
||||
return false
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
class BaseController < ActionController::Base
|
||||
layout "installation"
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
class BaseCrmController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification
|
||||
layout "CRM"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
@@ -20,8 +24,14 @@ class BaseCrmController < ActionController::Base
|
||||
{ locale: I18n.locale }
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
class BaseInventoryController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification
|
||||
layout "inventory"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,12 @@ class BaseOqsController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "OQS"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
@@ -19,9 +23,15 @@ class BaseOqsController < ActionController::Base
|
||||
def default_url_options
|
||||
{ locale: I18n.locale }
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,20 +2,61 @@ class BaseOrigamiController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "origami"
|
||||
|
||||
# before_action :checkin_process
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail, :current_token
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to origami_root_path
|
||||
# redirect_to origami_root_path
|
||||
redirect_to origami_dashboard_path
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
def check_user
|
||||
if check_mobile
|
||||
if current_user.nil?
|
||||
return render status: 401, json: {
|
||||
message: "User using other device!"
|
||||
}.to_json
|
||||
end
|
||||
else
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# def checkin_process
|
||||
# CheckinJob.set(wait: 1.minute).perform_later()
|
||||
# end
|
||||
|
||||
# Get current Cashier
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
#check webview
|
||||
def check_mobile
|
||||
status = false
|
||||
authenticate_with_http_token do |token, options|
|
||||
if token
|
||||
session[:webview] = true
|
||||
session[:session_token] = token
|
||||
end
|
||||
end
|
||||
|
||||
if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i
|
||||
status = true
|
||||
end
|
||||
|
||||
return status
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
class BaseReportController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "application"
|
||||
include LoginVerification
|
||||
layout "application"
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
PERIOD = {
|
||||
"today" => 0,
|
||||
"yesterday" => 1,
|
||||
@@ -83,8 +83,16 @@ class BaseReportController < ActionController::Base
|
||||
end
|
||||
|
||||
return from, to
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
class BaseWaiterController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LoginVerification
|
||||
layout "waiter"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
88
app/controllers/concerns/license_verification.rb
Normal file
88
app/controllers/concerns/license_verification.rb
Normal file
@@ -0,0 +1,88 @@
|
||||
module LicenseVerification
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :lookup_domain
|
||||
end
|
||||
|
||||
protected
|
||||
def lookup_domain
|
||||
if request.subdomain.present? && request.subdomain != "www"
|
||||
from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
if (!@license.nil?)
|
||||
# logger.info "Location - " + @license.name
|
||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# authenticate_session_token
|
||||
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
else
|
||||
# reconnect_default_db
|
||||
logger.info 'License is nil'
|
||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
||||
render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
end
|
||||
else
|
||||
# check for license file
|
||||
# if check_license
|
||||
# current_license(ENV["SX_PROVISION_URL"])
|
||||
# else
|
||||
# redirect_to activate_path
|
||||
# end
|
||||
end
|
||||
authenticate_session_token
|
||||
end
|
||||
|
||||
def authenticate_session_token
|
||||
token = session[:session_token]
|
||||
if (token)
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
#Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
else
|
||||
flash[:notice] = 'Invalid Access!'
|
||||
# return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def current_license(url)
|
||||
@license = License.new(url)
|
||||
flag = @license.detail_with_local_file()
|
||||
if (flag == 0)
|
||||
flash[:notice] = 'Expired or No License!'
|
||||
elsif (flag == 2)
|
||||
flash[:notice] = 'Expiring! Please, License extend...'
|
||||
else
|
||||
puts "RUN SAY BYAR"
|
||||
end
|
||||
end
|
||||
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
|
||||
if (@license.detail_with_local_cache(lookup) == true)
|
||||
return @license
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def website_connection(license)
|
||||
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
:username => license.dbusername, :password => license.dbpassword)
|
||||
|
||||
end
|
||||
|
||||
def reconnect_default_db
|
||||
ActiveRecord::Base.establish_connection(Rails.env)
|
||||
end
|
||||
|
||||
# Regular database.yml configuration hash
|
||||
def default_connection
|
||||
@default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
||||
end
|
||||
end
|
||||
@@ -2,37 +2,10 @@ module LoginVerification
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :authenticate
|
||||
helper_method :current_company,:current_login_employee
|
||||
|
||||
before_action :authenticate_session_token
|
||||
helper_method :current_company, :current_login_employee, :current_user, :get_cashier
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
authenticate_session_token || render_unauthorized
|
||||
end
|
||||
|
||||
def authenticate_session_token
|
||||
token = session[:session_token]
|
||||
if (token)
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def render_unauthorized()
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
#all token authentication must be done here
|
||||
#response format must be set to JSON
|
||||
@@ -42,18 +15,42 @@ module LoginVerification
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
|
||||
private
|
||||
def check_installation
|
||||
if current_company.nil?
|
||||
redirect_to install_path
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
# Get current Cashiers
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
authenticate_session_token || render_unauthorized
|
||||
end
|
||||
|
||||
def authenticate_session_token
|
||||
token = session[:session_token]
|
||||
if (token)
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
#Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def render_unauthorized
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,15 +9,23 @@ module TokenVerification
|
||||
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
def authenticate
|
||||
authenticate_token || render_unauthorized
|
||||
end
|
||||
|
||||
def authenticate_token
|
||||
authenticate_with_http_token do |token, options|
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
Rails.logger.debug "token - " + token.to_s
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
def authenticate_token
|
||||
authenticate_with_http_token do |token, options|
|
||||
# Rails.logger.debug "token - " + token.to_s
|
||||
if(options.length !=0 && options["from"] == "DOEMAL")
|
||||
if(ENV["SERVER_MODE"] === "cloud")
|
||||
from = "local" #request.subdomain.downcase + "." + request.domain.downcase
|
||||
aes = MyAesCrypt.new
|
||||
return aes.checkKeyForAuth(from, token)
|
||||
end
|
||||
end
|
||||
|
||||
@user = Employee.
|
||||
(token)
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
|
||||
@@ -14,5 +14,5 @@ class Crm::BookingsController < BaseCrmController
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -37,6 +37,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
@crm_customer = Customer.new
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
@membership_types = Lookup.collection_of("member_group_type")
|
||||
|
||||
@taxes = TaxProfile.all.order("order_by asc")
|
||||
|
||||
@filter = filter
|
||||
@@ -141,7 +143,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -165,7 +167,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' }
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' }
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
|
||||
end
|
||||
@@ -184,21 +186,21 @@ class Crm::CustomersController < BaseCrmController
|
||||
if response["message"] == "Account has not exist."
|
||||
customer.destroy
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer cannot created.' + response["message"]}
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer cannot created.' + response["message"]}
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] }
|
||||
end
|
||||
end
|
||||
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' + response["message"]}
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' + response["message"]}
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' + response["message"] }
|
||||
end
|
||||
end
|
||||
else
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. noted'}
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created. noted'}
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' }
|
||||
end
|
||||
@@ -207,7 +209,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
if params[:sale_id]
|
||||
flash[:errors] = @crm_customers.errors
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page]}
|
||||
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
|
||||
else
|
||||
flash[:errors] = @crm_customers.errors
|
||||
@@ -267,7 +269,7 @@ end
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -326,7 +328,7 @@ end
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -394,6 +396,7 @@ end
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :image_path)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -45,13 +45,13 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
respond_to do |format|
|
||||
if @dining_queue.save
|
||||
|
||||
unique_code = "QueueNoPdf"
|
||||
# unique_code = "QueueNoPdf"
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
# # get printer info
|
||||
# print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_queue_no(print_settings,@dining_queue)
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
# printer.print_queue_no(print_settings,@dining_queue)
|
||||
|
||||
format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @dining_queue }
|
||||
@@ -142,4 +142,5 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
def dining_queue_params
|
||||
params.require(:dining_queue).permit(:customer_id, :name, :contact_no, :queue_no,:status,:seater,:remark)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -33,13 +33,13 @@ class Crm::HomeController < BaseCrmController
|
||||
|
||||
end
|
||||
|
||||
unique_code="CrmOrderPdf"
|
||||
# unique_code="CrmOrderPdf"
|
||||
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
# print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_crm_order(@booking,order_items,print_settings)
|
||||
# printer.print_crm_order(@booking,order_items,print_settings)
|
||||
|
||||
end
|
||||
|
||||
@@ -55,6 +55,6 @@ class Crm::HomeController < BaseCrmController
|
||||
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
class HomeController < ApplicationController
|
||||
class HomeController < ApplicationController
|
||||
# layout "application", except: [:index, :show]
|
||||
skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
|
||||
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
|
||||
|
||||
before_action :check_user, only: :dashboard
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
# Special check for only dashboard
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
def index
|
||||
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
||||
@employees = Employee.all.order("name asc")
|
||||
@login_form = LoginForm.new()
|
||||
@login_form = LoginForm.new()
|
||||
render "layouts/login_dashboard", layout: false
|
||||
end
|
||||
|
||||
@@ -46,73 +61,103 @@ class HomeController < ApplicationController
|
||||
elsif @employee.role == "manager"
|
||||
session[:session_token] = @employee.token_session
|
||||
redirect_to dashboard_path
|
||||
elsif @employee.role == "supervisor" || @employee.role == "waiter"
|
||||
elsif @employee.role == "supervisor"
|
||||
session[:session_token] = @employee.token_session
|
||||
redirect_to origami_root_path
|
||||
elsif @employee.role == "waiter"
|
||||
session[:session_token] = @employee.token_session
|
||||
redirect_to origami_dashboard_path
|
||||
elsif @employee.role == "account"
|
||||
session[:session_token] = @employee.token_session
|
||||
redirect_to reports_dailysale_index_path
|
||||
elsif @employee.role == "kitchen"
|
||||
session[:session_token] = @employee.token_session
|
||||
redirect_to oqs_root_path
|
||||
else
|
||||
render :index
|
||||
end
|
||||
else
|
||||
redirect_to origami_root_path, :notice => "Username and Password doesn't match!"
|
||||
redirect_to root_path, :notice => "Username and Password doesn't match!"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def dashboard
|
||||
@from, @to, @from_time, @to_time = get_date_range_from_params
|
||||
|
||||
@shop = Shop.first
|
||||
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
|
||||
@top_products = Sale.top_products(today).sum('i.qty')
|
||||
@bottom_products = Sale.bottom_products(today).sum('i.qty')
|
||||
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
|
||||
if !@from.nil? && !@to.nil?
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
else
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
end
|
||||
else
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
if !@from.nil? && !@to.nil?
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
else
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
end
|
||||
else
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
@top_products = Sale.top_products(today,current_user,@from,@to,@from_time,@to_time).sum('i.qty')
|
||||
@bottom_products = Sale.bottom_products(today,current_user,@from,@to,@from_time,@to_time).sum('i.qty')
|
||||
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total)
|
||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||
# .sum(:grand_total)
|
||||
@employee_sales = Sale.employee_sales(today)
|
||||
@employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time)
|
||||
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||
@inventories = StockJournal.inventory_balances(today).sum(:balance)
|
||||
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time).sum(:balance)
|
||||
|
||||
@total_sale = Sale.total_sale(today)
|
||||
@total_count = Sale.total_count(today)
|
||||
@total_card = Sale.total_card_sale(today)
|
||||
@total_credit = Sale.credit_payment(today)
|
||||
@total_sale = Sale.total_sale(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_count = Sale.total_count(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today)
|
||||
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||
pay = Sale.payment_sale('card', today)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(payment.payment_method, today)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay" || payment.payment_method == "paymal" || payment.payment_method == "dinga" || payment.payment_method == "JunctionPay"
|
||||
pay = Sale.payment_sale('card', today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today)
|
||||
@total_customer = Sale.total_customer(today)
|
||||
@total_dinein = Sale.total_dinein(today)
|
||||
@total_takeaway = Sale.total_takeaway(today)
|
||||
@total_other_customer = Sale.total_other_customer(today)
|
||||
@total_membership = Sale.total_membership(today)
|
||||
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_customer = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_dinein = Sale.total_dinein(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_takeaway = Sale.total_takeaway(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_other_customer = Sale.total_other_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_membership = Sale.total_membership(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@total_order = Sale.total_order(today)
|
||||
@total_accounts = Sale.total_account(today)
|
||||
@total_order = Sale.total_order(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_accounts = Sale.total_account(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@account_data = Array.new
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, today)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, today,current_user,@from,@to,@from_time,@to_time)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(today)
|
||||
@total_foc_items = Sale.total_foc_items(today)
|
||||
@top_items = Sale.top_items(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -143,14 +188,15 @@ class HomeController < ApplicationController
|
||||
#check if cashier has existing open cashier
|
||||
shift = ShiftSale.current_open_shift(employee.id)
|
||||
if !shift.nil?
|
||||
redirect_to origami_root_path
|
||||
redirect_to origami_dashboard_path
|
||||
# redirect_to origami_root_path
|
||||
else
|
||||
redirect_to new_origami_shift_path
|
||||
end
|
||||
elsif employee.role == "manager"
|
||||
redirect_to dashboard_path
|
||||
elsif employee.role == "waiter"
|
||||
redirect_to oqs_root_path
|
||||
redirect_to origami_dashboard_path
|
||||
elsif employee.role == "crm"
|
||||
redirect_to crm_root_path
|
||||
elsif @employee.role == "supervisor"
|
||||
@@ -159,4 +205,30 @@ class HomeController < ApplicationController
|
||||
redirect_to reports_dailysale_index_path
|
||||
end
|
||||
end
|
||||
|
||||
def get_date_range_from_params
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
from_time = params[:from_time]
|
||||
to_time = params[:to_time]
|
||||
|
||||
if from.present? && to.present?
|
||||
# f_date = DateTime.parse(from)
|
||||
# t_date = DateTime.parse(to)
|
||||
# f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||
# t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||
# from = f_time.beginning_of_day.utc.getlocal
|
||||
# to = t_time.end_of_day.utc.getlocal
|
||||
|
||||
from = DateTime.parse(from).utc.getlocal.strftime('%Y-%m-%d')
|
||||
to = DateTime.parse(to).utc.getlocal.strftime('%Y-%m-%d')
|
||||
end
|
||||
|
||||
return from, to, from_time, to_time
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
class InstallController < BaseController
|
||||
skip_before_action :lookup_domain
|
||||
skip_before_action :verify_authenticity_token
|
||||
# before_action :check_license
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
@@ -30,7 +33,7 @@ class InstallController < BaseController
|
||||
# end
|
||||
|
||||
@license = License.new(ENV["SX_PROVISION_URL"])
|
||||
response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password)
|
||||
response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password)
|
||||
if response[:status]
|
||||
redirect_to root_url, notice: response["message"]
|
||||
else
|
||||
@@ -74,4 +77,9 @@ class InstallController < BaseController
|
||||
# return nil
|
||||
# end
|
||||
# end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,4 +3,10 @@ class Inventory::InventoryController < BaseInventoryController
|
||||
def index
|
||||
@products = InventoryDefinition.all.active.order('created_at desc')
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,6 +61,12 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_inventory_definition
|
||||
|
||||
@@ -61,6 +61,12 @@ class Inventory::StockCheckItemsController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_stock_check_item
|
||||
|
||||
@@ -38,6 +38,12 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /stock_checks
|
||||
|
||||
@@ -61,6 +61,12 @@ class StockJournalsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_stock_journal
|
||||
|
||||
75
app/controllers/oqs/edit_controller.rb
Executable file → Normal file
75
app/controllers/oqs/edit_controller.rb
Executable file → Normal file
@@ -1,8 +1,24 @@
|
||||
class Oqs::EditController < BaseOqsController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
assigned_item_id = params[:id]
|
||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'");
|
||||
@link_type = params[:type]
|
||||
@dining_type = nil
|
||||
@booking = nil
|
||||
if params[:type] == 'oqs'
|
||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'")
|
||||
elsif params[:type] == "pending"
|
||||
assigned_item = OrderItem.find(assigned_item_id)
|
||||
@booking = Booking.joins(" JOIN booking_orders as bko on bko.booking_id = bookings.booking_id")
|
||||
.where("bko.order_id = '#{assigned_item.order_id}'").first()
|
||||
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'")
|
||||
else
|
||||
assigned_item = OrderItem.find(assigned_item_id)
|
||||
dining = DiningFacility.find_by_id(params[:type])
|
||||
@dining_type = dining.type
|
||||
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'")
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -10,21 +26,56 @@ class Oqs::EditController < BaseOqsController
|
||||
qty_weight = params[:qty_weight]
|
||||
remarks = params[:remarks]
|
||||
|
||||
order_item = OrderItem.find(order_items_id);
|
||||
order_item = OrderItem.find(order_items_id)
|
||||
before_updated_qty = order_item.qty
|
||||
|
||||
order_item.item_order_by = current_user.name
|
||||
order_item.qty = qty_weight
|
||||
order_item.remark = remarks
|
||||
order_item.save
|
||||
|
||||
# print
|
||||
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
|
||||
unique_code="OrderItemPdf"
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# print
|
||||
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
|
||||
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'")
|
||||
|
||||
if !assigned_items.nil?
|
||||
assigned_items.each do |assign_item|
|
||||
# order queue stations
|
||||
oqs = assign_item.order_queue_station
|
||||
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Updated)" )
|
||||
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
||||
|
||||
unique_code="OrderItemPdf"
|
||||
if !order_slim_pdf.empty?
|
||||
order_slim_pdf.each do |order_item_slim|
|
||||
if order_item_slim[0] == 'OrderSlimPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
unique_code="OrderItemSlimPdf"
|
||||
else
|
||||
unique_code="OrderItemPdf"
|
||||
end
|
||||
elsif order_item_slim[0] == 'OrderSetPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
unique_code="OrderSetItemPdf"
|
||||
else
|
||||
unique_code="OrderItemPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,22 +1,37 @@
|
||||
class Oqs::HomeController < BaseOqsController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
|
||||
@queue_stations = OrderQueueStation.all
|
||||
|
||||
# Query for OQS with delivery status false
|
||||
# @queue_items_details = queue_items_query(false)
|
||||
|
||||
# Query for OQS with delivery status true
|
||||
|
||||
@tables = DiningFacility.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
|
||||
@filter = params[:filter]
|
||||
|
||||
@queue_stations = OrderQueueStation.all
|
||||
|
||||
@queue_completed_item = completed_order(@filter)
|
||||
if !@queue_completed_item.empty?
|
||||
@queue_completed_item.each do |queue_item|
|
||||
if !queue_item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
end
|
||||
queue_item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if !@filter.nil?
|
||||
@count = queue_items_count_query(false,@filter)
|
||||
@count.each do |count|
|
||||
#@count.each do |count|
|
||||
|
||||
end
|
||||
#end
|
||||
end
|
||||
|
||||
# @queue_stations_items=Array.new
|
||||
@@ -44,6 +59,7 @@ class Oqs::HomeController < BaseOqsController
|
||||
# Get Order items
|
||||
def get_order_items
|
||||
items = []
|
||||
assigned_items = []
|
||||
order_no = params[:order_no]
|
||||
status = params[:status]
|
||||
# dining = DiningFacility.find_by_name(table_name);
|
||||
@@ -72,13 +88,48 @@ class Oqs::HomeController < BaseOqsController
|
||||
items.push(oi)
|
||||
end
|
||||
|
||||
render :json => items.to_json
|
||||
if !items.empty?
|
||||
items.each do |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_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
|
||||
end
|
||||
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
end
|
||||
item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
end
|
||||
end
|
||||
render :json => {'items' => items, 'assigned_order_items' => assigned_items }
|
||||
end
|
||||
|
||||
def get_items_by_oqs
|
||||
oqs_id = params[:id]
|
||||
filter = params[:filter]
|
||||
items = queue_items_query(false,oqs_id,filter)
|
||||
table_id = params[:table_id]
|
||||
puts params
|
||||
puts table_id
|
||||
puts "sssssssssssss"
|
||||
items = queue_items_query(false,oqs_id,filter,table_id)
|
||||
if !items.empty?
|
||||
items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(JSON.parse(item.set_menu_items))
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
end
|
||||
item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
end
|
||||
end
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
@@ -103,19 +154,26 @@ class Oqs::HomeController < BaseOqsController
|
||||
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status,oqs_id=nil,filter)
|
||||
def queue_items_query(status,oqs_id=nil,filter,table_id)
|
||||
if oqs_id == nil
|
||||
oqs = ''
|
||||
else
|
||||
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
|
||||
end
|
||||
|
||||
if table_id.to_i>0
|
||||
table = "and df.id = '#{table_id}' "
|
||||
|
||||
else
|
||||
table = ''
|
||||
end
|
||||
|
||||
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
|
||||
oqs.id as station_id, oqs.station_name,
|
||||
oqs.is_active, oqpz.zone_id,
|
||||
df.name as zone, df.type as table_type,
|
||||
odt.order_id, odt.item_code, odt.item_name,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items,
|
||||
cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
@@ -125,7 +183,7 @@ class Oqs::HomeController < BaseOqsController
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table}")
|
||||
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
.order("assigned_order_items.assigned_order_item_id desc")
|
||||
.group("odt.order_items_id")
|
||||
@@ -134,7 +192,7 @@ class Oqs::HomeController < BaseOqsController
|
||||
|
||||
# Completed Order
|
||||
def completed_order(filter)
|
||||
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
@@ -153,19 +211,35 @@ class Oqs::HomeController < BaseOqsController
|
||||
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
|
||||
end
|
||||
|
||||
# def queue_items_count_query(status,filter)
|
||||
# query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
|
||||
# .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
# left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
# left join order_items as odt ON odt.item_instance_code = assigned_order_items.instance_code AND odt.order_id = assigned_order_items.order_id
|
||||
# left join customers as cus ON cus.customer_id = od.customer_id
|
||||
# left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
# left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
# left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
# .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
|
||||
# query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
# .group("oqs.id")
|
||||
|
||||
# end
|
||||
|
||||
def queue_items_count_query(status,filter)
|
||||
query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
left join order_items as odt ON odt.item_instance_code = assigned_order_items.instance_code AND odt.order_id = assigned_order_items.order_id
|
||||
# query = OrderQueueStation.all
|
||||
query = OrderQueueStation.select("order_queue_stations.id as station_id,
|
||||
(case when (count(odt.item_code)>0) then count(odt.item_code) else 0 end) as total")
|
||||
.joins(" left join assigned_order_items as aoi on aoi.order_queue_station_id= order_queue_stations.id
|
||||
left join orders as od ON od.order_id = aoi.order_id
|
||||
left join order_items as odt ON odt.item_instance_code = aoi.instance_code AND odt.order_id = aoi.order_id
|
||||
left join customers as cus ON cus.customer_id = od.customer_id
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join booking_orders as bo on bo.order_id = aoi.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
|
||||
.where("aoi.delivery_status = #{status} AND aoi.created_at >= '#{Time.now.beginning_of_day.utc}' ")
|
||||
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
.group("oqs.id")
|
||||
|
||||
.group("order_queue_stations.id")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,61 +1,106 @@
|
||||
class Oqs::PrintController < ApplicationController
|
||||
authorize_resource :class => false
|
||||
# Print Order Item
|
||||
def print
|
||||
unique_code="OrderItemPdf"
|
||||
assigned_item_id = params[:id]
|
||||
options = params[:options]
|
||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
||||
unique_code="OrderItemPdf"
|
||||
|
||||
if !order_slim_pdf.empty?
|
||||
order_slim_pdf.each do |order_item_slim|
|
||||
if order_item_slim[0] == 'OrderSlimPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
unique_code="OrderItemSlimPdf"
|
||||
else
|
||||
unique_code="OrderItemPdf"
|
||||
end
|
||||
elsif order_item_slim[0] == 'OrderSetPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
unique_code="OrderSetItemPdf"
|
||||
else
|
||||
unique_code="OrderItemPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assigned_item_id = params[:id]
|
||||
options = params[:options]
|
||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'")
|
||||
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
|
||||
|
||||
# Check Printed
|
||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||
# Check Printed
|
||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||
|
||||
# print when complete click
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, options )
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.print_status=true
|
||||
ai.save
|
||||
end
|
||||
# print when complete click
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options )
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.print_status=true
|
||||
ai.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Print Order Details with booking id
|
||||
def print_order_summary
|
||||
unique_code="OrderSummaryPdf"
|
||||
assigned_item_id = params[:id]
|
||||
table_name = params[:table_name]
|
||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
||||
unique_code="OrderSummaryPdf"
|
||||
if !order_slim_pdf.empty?
|
||||
order_slim_pdf.each do |order_summary_slim|
|
||||
if order_summary_slim[0] == 'OrderSlimPdf'
|
||||
if order_summary_slim[1] == '1'
|
||||
unique_code="OrderSummarySlimPdf"
|
||||
else
|
||||
unique_code="OrderSummaryPdf"
|
||||
end
|
||||
elsif order_summary_slim[0] == 'OrderSetPdf'
|
||||
if order_summary_slim[1] == '1'
|
||||
unique_code="OrderSummarySetPdf"
|
||||
else
|
||||
unique_code="OrderSummaryPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assigned_item_id = params[:id]
|
||||
table_name = params[:table_name]
|
||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
|
||||
# Check Printed
|
||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||
# Check Printed
|
||||
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
|
||||
|
||||
# get dining
|
||||
# dining = DiningFacility.find_by_name(table_name);
|
||||
# booking = Booking.find_by_dining_facility_id(dining.id)
|
||||
# get dining
|
||||
# dining = DiningFacility.find_by_name(table_name);
|
||||
# booking = Booking.find_by_dining_facility_id(dining.id)
|
||||
|
||||
# Get Booking ID
|
||||
booking_id = BookingOrder.where("order_id='#{assigned_item.order_id}'").pluck(:booking_id)[0]
|
||||
|
||||
# print when complete click
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status)
|
||||
# Get Booking ID
|
||||
booking_id = BookingOrder.where("order_id='#{assigned_item.order_id}'").pluck(:booking_id)[0]
|
||||
|
||||
# print when complete click
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status)
|
||||
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.print_status = true
|
||||
ai.save
|
||||
# update print status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.print_status = true
|
||||
ai.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,15 +1,28 @@
|
||||
class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
class Origami::AddordersController < BaseOrigamiController
|
||||
# before_action :set_dining, only: [:detail]
|
||||
|
||||
|
||||
def index
|
||||
@tables = Table.all.active.order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
|
||||
@all_table = Table.all.active.order('status desc')
|
||||
@all_room = Room.all.active.order('status desc')
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.all.active.order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
|
||||
@all_table = Table.all.active.order('status desc')
|
||||
@all_room = Room.all.active.order('status desc')
|
||||
end
|
||||
|
||||
def detail
|
||||
@menu = MenuCategory.all.active
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
@menus = Menu.all
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
@table_id = params[:id]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
@booking = @table.get_booking
|
||||
@@ -34,9 +47,10 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
puts params[:id]
|
||||
|
||||
#Pull this menu
|
||||
@menu = MenuCategory.find_by_id(params[:id])
|
||||
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
@@ -44,12 +58,30 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def get_item_instance
|
||||
@id = MenuItemInstance.find(params[:id])
|
||||
end
|
||||
|
||||
def get_menu()
|
||||
if (params[:id])
|
||||
#Pull this menu
|
||||
@menu = Menu.find_by_id(params[:id])
|
||||
@menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc")
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
Menu.current_menu
|
||||
end
|
||||
end
|
||||
|
||||
def get_menu_sub_category ()
|
||||
|
||||
id = params[:id]
|
||||
|
||||
if (id)
|
||||
#Pull this menu
|
||||
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
|
||||
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @sub_menu
|
||||
end
|
||||
@@ -62,62 +94,109 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
def create
|
||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
puts params[:order_items]
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
arr_exts = i["item_instance_code"].split("_")
|
||||
if arr_exts[1].match(/^(\d)+$/)
|
||||
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
||||
extra_time = Time.at(time)
|
||||
end
|
||||
end
|
||||
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"])}
|
||||
else
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])}
|
||||
end
|
||||
items_arr.push(items)
|
||||
}
|
||||
|
||||
puts items_arr.to_json
|
||||
puts "sssssssssssssssssssssss"
|
||||
# begin
|
||||
# if params[:order_source] == "quick_service"
|
||||
# customer_id = "CUS-000000000002" # for no customer id from mobile
|
||||
# else
|
||||
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
# end
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@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 = customer_id
|
||||
@order.items = items_arr
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if booking
|
||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
# puts "WWwwWWWWWWww"
|
||||
# puts sale_status
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if params[:table_id].to_i > 0
|
||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
# puts "OOOOOOOOO"
|
||||
# puts sale_status
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
table_status = true
|
||||
end
|
||||
end #booking exists
|
||||
if booking
|
||||
if table_status && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
# puts "MMMMMMMM"
|
||||
# puts sale_status
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
|
||||
# Order.send_customer_view(@booking)
|
||||
|
||||
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||
if @status && @booking && @order.source == 'quick_service'
|
||||
|
||||
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
||||
# for second display
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
|
||||
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale"
|
||||
|
||||
end
|
||||
result = {:status=> @status, :data => @sale }
|
||||
render :json => result.to_json
|
||||
end
|
||||
else
|
||||
result = {:status=> @status, :data => 0 }
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
|
||||
77
app/controllers/origami/alipay_controller.rb
Normal file
77
app/controllers/origami/alipay_controller.rb
Normal file
@@ -0,0 +1,77 @@
|
||||
class Origami::AlipayController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
# limit alipay_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = 0
|
||||
@alipaycount = 0
|
||||
@shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_alipay = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "alipay"
|
||||
@alipaycount = @alipaycount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_alipay = total - @alipaycount - others
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.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)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
99
app/controllers/origami/bank_integration_controller.rb
Normal file
99
app/controllers/origami/bank_integration_controller.rb
Normal file
@@ -0,0 +1,99 @@
|
||||
class Origami::BankIntegrationController < ApplicationController #BaseOrigamiController
|
||||
|
||||
def settle_trans
|
||||
if(params[:type] == 'request')
|
||||
card_settle_trans = CardSettleTran.new()
|
||||
card_settle_trans.req_date = Time.now.strftime("%Y-%m-%d")
|
||||
card_settle_trans.req_time = Time.now.utc
|
||||
card_settle_trans.req_cmd = params[:data][:cmd_type]
|
||||
card_settle_trans.req_type = params[:data][:payment_type]
|
||||
card_settle_trans.save()
|
||||
|
||||
card_settle_trans_id = card_settle_trans.id
|
||||
response = {status: 'success', card_settle_trans_id: card_settle_trans_id}
|
||||
else
|
||||
card_settle_trans = CardSettleTran.find(params[:card_settle_trans_id])
|
||||
card_settle_trans.res_date = Time.now.strftime("%Y-%m-%d")
|
||||
card_settle_trans.res_time = Time.now.utc
|
||||
card_settle_trans.res_cmd = params[:data][:CMD]
|
||||
card_settle_trans.res_type = params[:data][:TYPE]
|
||||
card_settle_trans.status = params[:data][:STATUS]
|
||||
card_settle_trans.sale_cnt = params[:data][:SALECNT]
|
||||
card_settle_trans.sale_amt = params[:data][:SALEAMT].to_f
|
||||
card_settle_trans.void_cnt = params[:data][:VOIDCNT]
|
||||
card_settle_trans.void_amt = params[:data][:VOIDAMT].to_f
|
||||
card_settle_trans.refund_cnt = params[:data][:REFUNDCNT]
|
||||
card_settle_trans.refund_amt = params[:data][:REFUNDAMT].to_f
|
||||
card_settle_trans.print_text_part1_type = params[:data][:PRINTTEXTPART1TYPE]
|
||||
card_settle_trans.print_text_part1_value = params[:data][:PRINTTEXTPART1VALUE]
|
||||
card_settle_trans.print_text_part2_type = params[:data][:PRINTTEXTPART2TYPE]
|
||||
card_settle_trans.print_text_part2_value = params[:data][:PRINTTEXTPART2VALUE]
|
||||
card_settle_trans.print_text_part3_type = params[:data][:PRINTTEXTPART3TYPE]
|
||||
card_settle_trans.print_text_part3_value = params[:data][:PRINTTEXTPART3VALUE]
|
||||
card_settle_trans.print_text_part4_type = params[:data][:PRINTTEXTPART4TYPE]
|
||||
card_settle_trans.print_text_part4_value = params[:data][:PRINTTEXTPART4VALUE]
|
||||
card_settle_trans.save()
|
||||
response = {status: 'success'}
|
||||
end
|
||||
render json: response
|
||||
end
|
||||
|
||||
def sale_trans
|
||||
if(params[:type] == 'request')
|
||||
card_sale_trans = CardSaleTran.new()
|
||||
card_sale_trans.sale_id = params[:data][:sale_id]
|
||||
card_sale_trans.req_date = Time.now.strftime("%Y-%m-%d")
|
||||
card_sale_trans.req_time = Time.now.utc
|
||||
card_sale_trans.req_amt = params[:data][:amt]
|
||||
card_sale_trans.req_inv_no = params[:data][:inv_no]
|
||||
card_sale_trans.req_cmd = params[:data][:cmd_type]
|
||||
card_sale_trans.req_type = params[:data][:payment_type]
|
||||
card_sale_trans.save()
|
||||
|
||||
card_sale_trans_id = card_sale_trans.id
|
||||
response = {status: 'success', card_sale_trans_id: card_sale_trans_id}
|
||||
else
|
||||
card_sale_trans = CardSaleTran.find(params[:card_sale_trans_id])
|
||||
card_sale_trans.res_date = params[:data][:DATE]
|
||||
card_sale_trans.res_time = params[:data][:TIME]
|
||||
card_sale_trans.res_amt = params[:data][:AMT].to_f / 100
|
||||
card_sale_trans.res_inv_no = params[:data][:ECRREF]
|
||||
card_sale_trans.res_cmd = params[:data][:CMD]
|
||||
card_sale_trans.res_type = params[:data][:TYPE]
|
||||
card_sale_trans.status = params[:data][:STATUS]
|
||||
card_sale_trans.resp = params[:data][:RESP]
|
||||
card_sale_trans.trace = params[:data][:TRACE]
|
||||
card_sale_trans.app_code = params[:data][:APPCODE]
|
||||
card_sale_trans.pan = params[:data][:PAN]
|
||||
card_sale_trans.exp_date = params[:data][:EXPDATE]
|
||||
card_sale_trans.tips = params[:data][:TIPS]
|
||||
card_sale_trans.entry_mode = params[:data][:ENTRYMODE]
|
||||
card_sale_trans.terminal_id = params[:data][:TERMINALID]
|
||||
card_sale_trans.merchant_id = params[:data][:MERCHANTID]
|
||||
card_sale_trans.card_holder = params[:data][:CARDHOLDERNAME]
|
||||
card_sale_trans.batch_no = params[:data][:BATCHNO]
|
||||
card_sale_trans.ref_no = params[:data][:REFNUM]
|
||||
card_sale_trans.app = params[:data][:APP]
|
||||
card_sale_trans.emv_app_id = params[:data][:AID]
|
||||
card_sale_trans.emv_cyptrogram = params[:data][:TC]
|
||||
card_sale_trans.curr_code = params[:data][:CURRCODE]
|
||||
card_sale_trans.fx_rate = params[:data][:FXRATE]
|
||||
card_sale_trans.foreign_amt = params[:data][:FOREIGNAMT]
|
||||
card_sale_trans.dcc_msg = params[:data][:DCCMSG]
|
||||
card_sale_trans.tender = params[:data][:TENDER]
|
||||
card_sale_trans.print_text_part1_type = params[:data][:PRINTTEXTPART1TYPE]
|
||||
card_sale_trans.print_text_part1_value = params[:data][:PRINTTEXTPART1VALUE]
|
||||
card_sale_trans.print_text_part2_type = params[:data][:PRINTTEXTPART2TYPE]
|
||||
card_sale_trans.print_text_part2_value = params[:data][:PRINTTEXTPART2VALUE]
|
||||
card_sale_trans.print_text_part3_type = params[:data][:PRINTTEXTPART3TYPE]
|
||||
card_sale_trans.print_text_part3_value = params[:data][:PRINTTEXTPART3VALUE]
|
||||
card_sale_trans.print_text_part4_type = params[:data][:PRINTTEXTPART4TYPE]
|
||||
card_sale_trans.print_text_part4_value = params[:data][:PRINTTEXTPART4VALUE]
|
||||
card_sale_trans.save()
|
||||
|
||||
response = {status: 'success'}
|
||||
end
|
||||
render json: response
|
||||
end
|
||||
|
||||
end
|
||||
@@ -14,4 +14,5 @@ class Origami::CashInsController < BaseOrigamiController
|
||||
shift.cash_in = shift.cash_in + amount.to_i
|
||||
shift.save
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,4 +7,5 @@ class Origami::CashMgmtController < ApplicationController
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -12,4 +12,5 @@ class Origami::CashOutsController < BaseOrigamiController
|
||||
shift.cash_out = shift.cash_out + amount.to_i
|
||||
shift.save
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,32 +2,38 @@ class Origami::CheckInProcessController < BaseOrigamiController
|
||||
|
||||
def check_in_process
|
||||
lookup_checkout_time = Lookup.collection_of("checkout_time")
|
||||
checkout_at = Time.now.utc
|
||||
today = Time.now.utc.getlocal
|
||||
checkout_at = Time.now.utc.getlocal
|
||||
if !lookup_checkout_time.empty?
|
||||
lookup_checkout_time.each do |checkout_time|
|
||||
arr_time = checkout_time[0].split("-")
|
||||
start_time = Time.parse(arr_time[0].strip).utc.getlocal.strftime("%H:%M%p")
|
||||
end_time = Time.parse(arr_time[1].strip).utc.getlocal.strftime("%H:%M%p")
|
||||
if start_time <= checkout_at.strftime("%H:%M%p") && checkout_at.strftime("%H:%M%p") <= end_time
|
||||
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
|
||||
end
|
||||
end
|
||||
|
||||
if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
|
||||
@dining_facility = DiningFacility.find(params[:dining_id])
|
||||
@dining_facility.status = "occupied"
|
||||
@dining_facility.save!
|
||||
|
||||
if !lookup_checkout_time.nil?
|
||||
if lookup_checkout_time[0][0] == 'hr'
|
||||
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
|
||||
else
|
||||
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
|
||||
if @dining_facility.type == "Table"
|
||||
type = "TableBooking"
|
||||
else
|
||||
type = "RoomBooking"
|
||||
end
|
||||
|
||||
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
||||
@booking.save!
|
||||
end
|
||||
end
|
||||
@dining_facility = DiningFacility.find(params[:dining_id])
|
||||
@dining_facility.status = "occupied"
|
||||
@dining_facility.save!
|
||||
|
||||
if @dining_facility.type == "Table"
|
||||
type = "TableBooking"
|
||||
else
|
||||
type = "RoomBooking"
|
||||
end
|
||||
|
||||
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
|
||||
@booking.save!
|
||||
|
||||
respond = {:status => 'ok'}
|
||||
respond_to do |format|
|
||||
format.json { render json: respond }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
# limit visa_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@@ -8,7 +9,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
@creditcount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
@shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
@@ -31,7 +32,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
sale_id = params[:sale_id]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
|
||||
@@ -9,7 +9,6 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def get_customer
|
||||
|
||||
filter = params[:filter]
|
||||
type = params[:type]
|
||||
|
||||
@@ -47,15 +46,31 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def add_customer
|
||||
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
@page = params[:page]
|
||||
|
||||
if(@sale_id[0,3] == "SAL")
|
||||
@booking = Booking.find_by_sale_id(@sale_id)
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
if @booking.dining_facility_id.to_i > 0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
else
|
||||
@dining_facility = nil
|
||||
end
|
||||
|
||||
else
|
||||
@booking_order = BookingOrder.find_by_order_id(@sale_id)
|
||||
@booking = Booking.find(@booking_order.booking_id)
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
if @booking.dining_facility_id.to_i > 0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
else
|
||||
@dining_facility = nil
|
||||
end
|
||||
end
|
||||
|
||||
filter = params[:filter]
|
||||
@@ -75,7 +90,8 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
|
||||
@membership_types = Lookup.collection_of("member_group_type")
|
||||
|
||||
respond_to do |format|
|
||||
# format.html { render :template => "crm/customers/index" }
|
||||
format.html { render action: "index"}
|
||||
@@ -85,10 +101,10 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
customer_id = params[:customer_id]
|
||||
customer = Customer.find(customer_id)
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
customer_id = params[:customer_id]
|
||||
customer = Customer.find(customer_id)
|
||||
order_source = params[:type]
|
||||
# Check and find with card no
|
||||
# if(!customer_id.include? "CUS")
|
||||
# customer = Customer.find_by_paypar_account_no(customer_id)
|
||||
@@ -122,12 +138,40 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
if(id == "SAL")
|
||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
|
||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
||||
end
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
end
|
||||
|
||||
def send_account
|
||||
amount = params[:amount]
|
||||
account_no = params[:account_no]
|
||||
receipt_no = params[:receipt_no]
|
||||
sale = Sale.find_by_receipt_no(receipt_no)
|
||||
@out = []
|
||||
action_by = current_user.id
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
merchant_uid= member_actions.merchant_account_id
|
||||
auth_token = member_actions.auth_token.to_s
|
||||
membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no)
|
||||
if membership_data["status"]==true
|
||||
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
|
||||
else
|
||||
remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Remark : #{membership_data[:message]}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
|
||||
end
|
||||
@out = membership_data
|
||||
|
||||
|
||||
render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"]})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
61
app/controllers/origami/dashboard_controller.rb
Normal file
61
app/controllers/origami/dashboard_controller.rb
Normal file
@@ -0,0 +1,61 @@
|
||||
class Origami::DashboardController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@shop = Shop.first
|
||||
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
# @orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
# @sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
|
||||
# @top_products = Sale.top_products(today).sum('i.qty')
|
||||
# @bottom_products = Sale.bottom_products(today).sum('i.qty')
|
||||
# @hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
|
||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||
# .sum(:grand_total)
|
||||
# @employee_sales = Sale.employee_sales(today)
|
||||
# .sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||
# @inventories = StockJournal.inventory_balances(today).sum(:balance)
|
||||
|
||||
@total_sale = Sale.total_sale(today)
|
||||
@total_count = Sale.total_count(today)
|
||||
@total_card = Sale.total_card_sale(today)
|
||||
@total_credit = Sale.credit_payment(today)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today)
|
||||
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||
pay = Sale.payment_sale('card', today)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(payment.payment_method, today)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today)
|
||||
@total_customer = Sale.total_customer(today)
|
||||
@total_dinein = Sale.total_dinein(today)
|
||||
@total_takeaway = Sale.total_takeaway(today)
|
||||
@total_other_customer = Sale.total_other_customer(today)
|
||||
@total_membership = Sale.total_membership(today)
|
||||
|
||||
@total_order = Sale.total_order(today)
|
||||
@total_accounts = Sale.total_account(today)
|
||||
@account_data = Array.new
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, today)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(today)
|
||||
@total_foc_items = Sale.total_foc_items(today)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@current_user = current_user
|
||||
end
|
||||
|
||||
end
|
||||
98
app/controllers/origami/dinga_controller.rb
Normal file
98
app/controllers/origami/dinga_controller.rb
Normal file
@@ -0,0 +1,98 @@
|
||||
class Origami::DingaController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
payment_method = params[:payment_method]
|
||||
@cashier_type = params[:type]
|
||||
@membership_rebate_balance=0
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@receipt_no = @sale_data.receipt_no
|
||||
@shop = Shop.first
|
||||
# if @shop.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
|
||||
# else
|
||||
# new_total = @sale_data.grand_total
|
||||
# end
|
||||
# @rounding_adj = new_total-@sale_data.grand_total
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
@sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "dinga"
|
||||
@payparcount = @payparcount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@payment_prices = @sale_data.grand_total - @payparcount -others
|
||||
|
||||
|
||||
if @sale_data
|
||||
if @sale_data.customer_id
|
||||
customer_data= Customer.find_by_customer_id(@sale_data.customer_id)
|
||||
if customer_data
|
||||
@membership_id = customer_data.membership_id
|
||||
if !@membership_id.nil?
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
merchant_uid= member_actions.merchant_account_id
|
||||
auth_token = member_actions.auth_token.to_s
|
||||
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
||||
if membership_data["status"]==true
|
||||
@membership_rebate_balance=membership_data["balance"]
|
||||
@out = true, @membership_rebate_balance,@membership_id
|
||||
end
|
||||
else
|
||||
@out =false,0
|
||||
end
|
||||
else
|
||||
@out = false,0
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
@out = false, 0
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:payment_amount]
|
||||
sale_id = params[:sale_id]
|
||||
transaction_ref = params[:transaction_ref]
|
||||
account_no = params[:account_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
# rounding adjustment
|
||||
# if shop_details.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)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "dinga",account_no)
|
||||
if status == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
@out =false, "Please try again payment!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,10 +3,20 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
def index
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
sale_id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
if @sale_data.bookings[0].dining_facility_id.to_i > 0
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
else
|
||||
@table = nil
|
||||
end
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@@ -15,15 +25,24 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
def create
|
||||
order_source = params[:cashier_type]
|
||||
sale_id = params[:sale_id]
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
overall_discount = params[:overall_discount]
|
||||
sub_total = params[:sub_total]
|
||||
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
else
|
||||
table = nil
|
||||
table_id = nil
|
||||
end
|
||||
|
||||
|
||||
# sale.total_discount = overall_discount.to_f
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
|
||||
@@ -33,7 +52,6 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
#save sale item for discount
|
||||
discount_items.each do |di|
|
||||
origin_sale_item = SaleItem.find(di["id"])
|
||||
puts origin_sale_item.to_json
|
||||
sale_item = SaleItem.new
|
||||
|
||||
sale_item.sale_id = sale_id
|
||||
@@ -41,7 +59,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale_item.product_name = di["name"]
|
||||
sale_item.item_instance_code = origin_sale_item.item_instance_code
|
||||
sale_item.product_alt_name = ""
|
||||
sale_item.remark = "Discount"
|
||||
sale_item.status = "Discount"
|
||||
|
||||
sale_item.qty = -1
|
||||
sale_item.unit_price = di["price"].to_f * (-1)
|
||||
@@ -54,6 +72,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_id, action_by,remark,"ITEMDISCOUNT" )
|
||||
|
||||
end
|
||||
@@ -62,13 +81,26 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# Re-calc All Amount in Sale
|
||||
if overall_discount.to_f > 0
|
||||
action_by = current_user.id
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
if table.nil?
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- no Table "
|
||||
else
|
||||
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
|
||||
end
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
|
||||
if !table.nil?
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Success" }
|
||||
end
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
if !table.nil?
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
result = {:status=> "Please, Check Again!" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -77,12 +109,19 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
# Remove selected discount Items
|
||||
def remove_discount_items
|
||||
order_source = params[:cashier_type]
|
||||
sale_id = params[:sale_id]
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
sale = Sale.find(sale_id)
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
end
|
||||
|
||||
|
||||
if discount_items.length > 0
|
||||
#destroy sale item for discount
|
||||
@@ -91,7 +130,11 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale.total_amount = (sale.total_amount + sale_item.price.abs)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
if table.nil?
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- No Table "
|
||||
else
|
||||
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEITEMDISCOUNT" )
|
||||
|
||||
sale_item.destroy
|
||||
@@ -101,10 +144,20 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
# sale.save
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
if table.nil?
|
||||
result = {:status=> "Please, Check Again!"}
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
@@ -113,17 +166,25 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# Remove all discount Items
|
||||
def remove_all_discount
|
||||
sale_id = params[:id]
|
||||
order_source = params[:type]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
dining = DiningFacility.find(table_id)
|
||||
table_type = dining.type
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
table_type = table.type
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
table_type = nil
|
||||
end
|
||||
|
||||
discount_items = []
|
||||
#destroy all discount sale item
|
||||
sale.sale_items.each do |si|
|
||||
if si.remark == "Discount" && si.price < 0
|
||||
if si.status == "Discount" && si.price < 0
|
||||
sale.total_amount = (sale.total_amount + si.price.abs)
|
||||
discount_items.push(si)
|
||||
end
|
||||
@@ -137,14 +198,28 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale.sale_items.destroy(discount_items)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{dining.name} "
|
||||
if table.nil?
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- No Table"
|
||||
else
|
||||
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
|
||||
end
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
|
||||
result = {:status=> "Success", :table_id => table_id, :dining => dining.name, :table_type => table_type }
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, 0, nil, order_source)
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
end
|
||||
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => dining.name, :table_type => table_type }
|
||||
if table.nil?
|
||||
result = {:status=> "Please, Check Again!"}
|
||||
else
|
||||
result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
render :json => result.to_json
|
||||
@@ -152,7 +227,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
# Member Discount
|
||||
def member_discount
|
||||
|
||||
order_source = params[:cashier_type]
|
||||
sale_id = params[:sale_id]
|
||||
is_card = params[:is_card]
|
||||
sub_total = params[:sub_total]
|
||||
@@ -207,13 +282,13 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
response = {"status": false, "message": "Can't open membership server " }
|
||||
response = {"status": false, "message": "Http party error" }
|
||||
|
||||
rescue Net::OpenTimeout
|
||||
response = {"status": false, "message": "Can't open membership server " }
|
||||
response = {"status": false, "message": "Connection TIme out " }
|
||||
rescue OpenURI::HTTPError
|
||||
response = {"status": false, "message": "Can't open membership server " }
|
||||
|
||||
@@ -231,7 +306,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
if response["discount_bonus_earned"]
|
||||
discount_amount = discount_amount + response["discount_bonus_earned"]
|
||||
end
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount', order_source)
|
||||
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
||||
elsif response["status"] == "500"
|
||||
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||
@@ -277,7 +352,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# sale_item.sale_id = sale_id
|
||||
# sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||
# sale_item.product_name = product_name
|
||||
# sale_item.remark = remark
|
||||
# sale_item.status = remark
|
||||
|
||||
# sale_item.qty = 1
|
||||
# sale_item.unit_price = (0-discount_amount.to_f)
|
||||
@@ -289,5 +364,5 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
# redirect_to origami_path(sale_id)
|
||||
# end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,34 +1,71 @@
|
||||
class Origami::HomeController < BaseOrigamiController
|
||||
before_action :set_dining, only: [:show]
|
||||
authorize_resource :class => false
|
||||
before_action :set_dining, only: [:show]
|
||||
|
||||
def index
|
||||
@webview = check_mobile
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@orders = Order.all.order('date desc')
|
||||
@shop = Shop::ShopDetail
|
||||
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@shop = Shop.first
|
||||
|
||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
# origami table detail
|
||||
def show
|
||||
@webview = check_mobile
|
||||
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@orders = Order.all.order('date desc')
|
||||
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
|
||||
@status_order = ""
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
@shop = Shop.first
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
|
||||
bookings = Booking.all
|
||||
if !bookings.today.nil?
|
||||
@order_items_count = Hash.new
|
||||
# bookings.each do |booking|
|
||||
# if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
# if !booking.booking_orders.empty?
|
||||
# booking.booking_orders.each do |booking_order|
|
||||
# order = Order.find(booking_order.order_id)
|
||||
# if !order.order_items.empty?
|
||||
# if !@order_items_count.key?(booking.dining_facility_id)
|
||||
# @order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
# else
|
||||
# @order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else
|
||||
# if !booking.sale_id.nil?
|
||||
# sale = Sale.find(booking.sale_id)
|
||||
# if sale.sale_status !='completed'
|
||||
# if !@order_items_count.key?(booking.dining_facility_id)
|
||||
# @order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
# else
|
||||
# @order_items_count[booking.dining_facility_id] = sale.sale_items.count
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
@dining.bookings.active.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
@order_items = Array.new
|
||||
# @assigned_order_items = Array.new
|
||||
if booking.booking_orders.empty?
|
||||
@booking = booking
|
||||
else
|
||||
@@ -41,12 +78,19 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@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
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
@account_arr.push(account)
|
||||
@account_arr = Array.new
|
||||
if @customer.tax_profiles
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -54,8 +98,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
|
||||
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'
|
||||
@@ -75,6 +118,15 @@ class Origami::HomeController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#for bank integration
|
||||
@checkout_time = Lookup.collection_of('checkout_time')
|
||||
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
|
||||
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -168,4 +168,5 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
def in_duty_params
|
||||
params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
85
app/controllers/origami/jcb_controller.rb
Executable file → Normal file
85
app/controllers/origami/jcb_controller.rb
Executable file → Normal file
@@ -2,53 +2,78 @@ class Origami::JcbController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@cashier_type = params[:type]
|
||||
# limit jcb_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
total = 0
|
||||
@jcbcount = 0
|
||||
others = 0
|
||||
@shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_jcb = 0
|
||||
@member_discount= 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "jcb"
|
||||
@jcbcount = @jcbcount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_jcb = total - @jcbcount - others
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "jcb"
|
||||
@jcbcount = @jcbcount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_jcb = total - @jcbcount - others
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
if shop_details.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)
|
||||
end
|
||||
# if shop_details.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)
|
||||
# end
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
70
app/controllers/origami/junction_pay_controller.rb
Normal file
70
app/controllers/origami/junction_pay_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
class Origami::JunctionPayController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
# limit jcb_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
@junction_pay_count = 0
|
||||
others = 0
|
||||
@cashier_id = current_user.emp_id
|
||||
|
||||
@payment_method_setting_nav = PaymentMethodSetting.all
|
||||
@shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "JunctionPay"
|
||||
@junction_pay_count = @junction_pay_count + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_junction_pay = total - @junction_pay_count - others
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
|
||||
def create
|
||||
gift_amount = params[:gift_amount]
|
||||
voucher_amount = params[:voucher_amount]
|
||||
voucher_no = params[:voucher_no]
|
||||
sale_id = params[:sale_id]
|
||||
|
||||
# Gift card or Voucher classified and add for payment_reference
|
||||
remarks = ''
|
||||
cash = (gift_amount.to_f + voucher_amount.to_f)
|
||||
if gift_amount.to_f > 0
|
||||
remarks = "Junciton Gift Card Payment. RefNo-" + voucher_no
|
||||
else
|
||||
remarks = "Junciton Voucher Payment. RefNo-" + voucher_no
|
||||
end
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.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)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "JunctionPay", remarks)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
81
app/controllers/origami/master_controller.rb
Executable file → Normal file
81
app/controllers/origami/master_controller.rb
Executable file → Normal file
@@ -2,52 +2,75 @@ class Origami::MasterController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@cashier_type = params[:type]
|
||||
# limit master_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
total = 0
|
||||
@mastercount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
@shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_master = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "master"
|
||||
@mastercount = @mastercount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "master"
|
||||
@mastercount = @mastercount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_master = total - @mastercount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
@can_master = total - @mastercount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
if shop_details.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)
|
||||
end
|
||||
# if shop_details.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)
|
||||
# end
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,5 +35,5 @@ class Origami::MoveroomController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -19,10 +19,18 @@ class Origami::MovetableController < BaseOrigamiController
|
||||
|
||||
order = Order.find(booking_order.order_id)
|
||||
@obj_order = order
|
||||
@customer = order.customer
|
||||
@date = order.created_at
|
||||
@booking= booking
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
@status_order = 'order'
|
||||
else
|
||||
@@ -32,26 +40,69 @@ class Origami::MovetableController < BaseOrigamiController
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
end
|
||||
@booking= booking
|
||||
@date = sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@obj_sale = sale
|
||||
@customer = sale.customer
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def moving
|
||||
change_to = params[:change_to] #new
|
||||
change_from = params[:change_from] #original
|
||||
bookings = Booking.where('dining_facility_id=?',change_from)
|
||||
def moving
|
||||
change_to = params[:change_to] #new
|
||||
change_from = params[:change_from] #original
|
||||
bookings = Booking.where('dining_facility_id=?',change_from)
|
||||
|
||||
booking_array = Array.new
|
||||
bookings.each do | booking |
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
booking_array.push(booking)
|
||||
end
|
||||
end
|
||||
booking_array = Array.new
|
||||
order_items = Array.new
|
||||
if !bookings.nil?
|
||||
bookings.each do | booking |
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
booking_array.push(booking)
|
||||
end
|
||||
|
||||
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
|
||||
end
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if order.status == 'new'
|
||||
order.order_items.each do |order_item|
|
||||
order_items.push(order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# get printer info
|
||||
@from = (DiningFacility.find(change_from)).name
|
||||
@to = (DiningFacility.find(change_to)).name
|
||||
@type = (DiningFacility.find(change_to)).type
|
||||
@moved_by = @current_user.name
|
||||
@date = DateTime.now
|
||||
@shop = Shop.first
|
||||
unique_code = "MoveTablePdf"
|
||||
pdf_no = PrintSetting.where(:unique_code => unique_code).count
|
||||
#print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
printer_array = []
|
||||
printer_array = PrintSetting.where(:unique_code => unique_code)
|
||||
|
||||
for i in 0..pdf_no
|
||||
if i != pdf_no
|
||||
print_settings = printer_array[i]
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
82
app/controllers/origami/mpu_controller.rb
Executable file → Normal file
82
app/controllers/origami/mpu_controller.rb
Executable file → Normal file
@@ -1,53 +1,77 @@
|
||||
class Origami::MpuController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@cashier_type = params[:type]
|
||||
# limit mpu_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
total = 0
|
||||
@mpucount = 0
|
||||
others = 0
|
||||
@shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_mpu = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "mpu"
|
||||
@mpucount = @mpucount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_mpu = total - @mpucount - others
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "mpu"
|
||||
@mpucount = @mpucount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_mpu = total - @mpucount - others
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
if shop_details.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)
|
||||
end
|
||||
# if shop_details.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)
|
||||
# end
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
58
app/controllers/origami/order_reservation_controller.rb
Normal file
58
app/controllers/origami/order_reservation_controller.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
class Origami::OrderReservationController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@order = OrderReservation.all
|
||||
end
|
||||
|
||||
def update
|
||||
@id = params[:order_id]
|
||||
@status = params[:status]
|
||||
@order_reservation = OrderReservation.find(@id)
|
||||
|
||||
status = true
|
||||
|
||||
if status
|
||||
if @status == "processed"
|
||||
result = OrderReservation.create_doemal_order(@order_reservation,current_user)
|
||||
elsif @status == "delivery"
|
||||
OrderReservation.update_order_reservation(@id, nil, "ready_to_delivery")
|
||||
response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"ready_to_delivery")
|
||||
result = {:status=> true, :message => "ready for delivery" }
|
||||
elsif @status == "completed"
|
||||
result = OrderReservation.update_doemal_payment(@order_reservation,current_user)
|
||||
else
|
||||
if @status == "cancel"
|
||||
OrderReservation.update_order_reservation(@id, nil, "cancelled")
|
||||
result = {:status=> true, :message => "rejected" }
|
||||
else
|
||||
OrderReservation.update_order_reservation(@id, nil, "accepted")
|
||||
result = {:status=> true, :message => "accepted" }
|
||||
end
|
||||
end
|
||||
render :json => result.to_json
|
||||
else
|
||||
result = {:status=> false, :message => "Order not accepted !" }
|
||||
render :json => result.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def get_order
|
||||
if (params[:id])
|
||||
@order = OrderReservation.find(params[:id])
|
||||
return @order
|
||||
end
|
||||
end
|
||||
|
||||
def send_status
|
||||
if params[:status] == "cancel"
|
||||
status = "rejected"
|
||||
else
|
||||
status = params[:status]
|
||||
end
|
||||
|
||||
response = OrderReservation.send_status_to_ordering(params[:url],params[:ref_no],status)
|
||||
|
||||
render :json => response
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,10 +1,37 @@
|
||||
class Origami::OrdersController < BaseOrigamiController
|
||||
def show
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@orders = Order.all.order('status desc')
|
||||
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@order = Order.find(params[:order_id])
|
||||
booking = Booking.select('bookings.booking_id, bookings.dining_facility_id')
|
||||
.joins(" JOIN booking_orders as bo on bo.booking_id = bookings.booking_id")
|
||||
.where("bo.order_id='#{params[:order_id]}'").first()
|
||||
|
||||
@booking = Array.new
|
||||
if !booking.nil?
|
||||
if booking.dining_facility_id.to_i > 0
|
||||
dining_facilities = DiningFacility.find_by_id(booking.dining_facility_id)
|
||||
@booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => dining_facilities.type})
|
||||
else
|
||||
@booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => nil})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#for split bill
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
|
||||
sale_order = SaleOrder.find_by_order_id(@order.order_id)
|
||||
if sale_order
|
||||
unless sale_order.sale_id.nil?
|
||||
@@ -12,5 +39,51 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
@sale_status = sale.sale_status
|
||||
end
|
||||
end
|
||||
|
||||
@order.order_items.each_with_index do |item, order_item_index|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
end
|
||||
@order.order_items[order_item_index].set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
end
|
||||
|
||||
bookings = Booking.all
|
||||
if !bookings.today.nil?
|
||||
@order_items_count = Hash.new
|
||||
bookings.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
if !booking.booking_orders.empty?
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
if !order.order_items.empty?
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if !booking.sale_id.nil?
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status !='completed'
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] = sale.sale_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,10 +2,21 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
authorize_resource :class => false
|
||||
|
||||
def index
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
if @sale_data.bookings[0].dining_facility_id.to_i > 0
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
else
|
||||
@table = nil
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,11 +24,18 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
sale_id = params[:sale_id]
|
||||
other_charges_items = JSON.parse(params[:other_charges_items])
|
||||
sub_total = params[:sub_total]
|
||||
cashier_type = params[:cashier_type]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_id = sale.bookings[0].dining_facility_id
|
||||
table = DiningFacility.find(table_id)
|
||||
else
|
||||
table_id = nil
|
||||
table = nil
|
||||
end
|
||||
|
||||
|
||||
# sale.total_amount = sub_total.to_f
|
||||
# sale.grand_total = sub_total.to_f + sale.total_tax;
|
||||
@@ -32,7 +50,7 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
sale_item.product_code = "Other Charges"
|
||||
sale_item.product_name = "*" + di["name"]
|
||||
sale_item.product_alt_name = ""
|
||||
sale_item.remark = "Other Charges"
|
||||
sale_item.status = "Other Charges"
|
||||
|
||||
sale_item.qty = 1
|
||||
sale_item.unit_price = di["price"]
|
||||
@@ -44,17 +62,25 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
sale_item.save
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
|
||||
if table.nil?
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->"
|
||||
else
|
||||
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
|
||||
end
|
||||
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ADDOTHERCHARGES" )
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, cashier_type)
|
||||
end
|
||||
|
||||
dining = {:table_id => table_id, :table_type => table.type }
|
||||
if !table.nil?
|
||||
dining = {:table_id => table_id, :table_type => table.type }
|
||||
render :json => dining.to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,10 +2,11 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
def index
|
||||
@membership_rebate_balance = 0
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
@payment_method_setting = PaymentMethodSetting.all
|
||||
|
||||
@rebate = MembershipSetting.find_by_rebate(1)
|
||||
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
# @sale_id = params[:sale_id]
|
||||
# sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
|
||||
99
app/controllers/origami/paymal_controller.rb
Normal file
99
app/controllers/origami/paymal_controller.rb
Normal file
@@ -0,0 +1,99 @@
|
||||
class Origami::PaymalController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
payment_method = params[:payment_method]
|
||||
@cashier_type = params[:type]
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@receipt_no = sale_data.receipt_no
|
||||
@shop = Shop.first
|
||||
# if @shop.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
# else
|
||||
# new_total = sale_data.grand_total
|
||||
# end
|
||||
# @rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "paypar"
|
||||
@payparcount = @payparcount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@payment_prices = sale_data.grand_total - @payparcount -others
|
||||
|
||||
|
||||
if sale_data
|
||||
if sale_data.customer_id
|
||||
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||
if customer_data
|
||||
@membership_id = customer_data.membership_id
|
||||
if !@membership_id.nil?
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
if membership_setting.gateway_url
|
||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
||||
if member_actions.gateway_url
|
||||
@campaign_type_id = nil
|
||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||
merchant_uid= member_actions.merchant_account_id
|
||||
auth_token = member_actions.auth_token.to_s
|
||||
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
||||
if membership_data["status"]==true
|
||||
@membership_rebate_balance=membership_data["balance"]
|
||||
@out = true, @membership_rebate_balance,@membership_id
|
||||
end
|
||||
else
|
||||
@out =false,0
|
||||
end
|
||||
else
|
||||
@out = false,0
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
else
|
||||
@out = false, 0
|
||||
end
|
||||
@out = false, 0
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:payment_amount]
|
||||
sale_id = params[:sale_id]
|
||||
transaction_ref = params[:transaction_ref]
|
||||
account_no = params[:account_no]
|
||||
puts params.to_json
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.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)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
status, @sale = sale_payment.process_payment(saleObj, @user, cash, "paymal",account_no)
|
||||
if status == true
|
||||
@out = true, "Success!"
|
||||
else
|
||||
@out =false, "Please try again payment!"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -8,71 +8,98 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
sale_items = SaleItem.where("sale_id=?",sale_id)
|
||||
member_info = nil
|
||||
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].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(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
# Print for First Bill to Customer
|
||||
unique_code = "ReceiptBillPdf"
|
||||
#shop detail
|
||||
shop_details = Shop::ShopDetail
|
||||
# customer= Customer.where('customer_id=' +.customer_id)
|
||||
customer = Customer.find(sale_data.customer_id)
|
||||
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = sale_data.grand_total % 25 # Modulus
|
||||
b = sale_data.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_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 ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
# Print for First Bill to Customer
|
||||
unique_code = "ReceiptBillPdf"
|
||||
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"
|
||||
else
|
||||
unique_code = "ReceiptBillPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
#shop detail
|
||||
shop_details = Shop.first
|
||||
# customer= Customer.where('customer_id=' +.customer_id)
|
||||
customer = Customer.find(sale_data.customer_id)
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = sale_data.grand_total % 25 # Modulus
|
||||
b = sale_data.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_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)
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
# 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)
|
||||
# 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)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
|
||||
# Calculate price_by_accounts
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
|
||||
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
member_info = nil
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
|
||||
shop_details = Shop.first
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
@@ -86,52 +113,108 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
|
||||
|
||||
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
|
||||
rebate_amount = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].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(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
# For Print
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||
|
||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
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"
|
||||
else
|
||||
unique_code = "ReceiptBillPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance)
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
|
||||
|
||||
if customer.membership_id != nil && rebate && credit_data.nil?
|
||||
member_info = Customer.get_member_account(customer)
|
||||
if member_info["status"] == true
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
end
|
||||
|
||||
#orders print out
|
||||
if params[:type] == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
end
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
# Order.pay_process_order_queue(order.order_id, table_id)
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.pay_process_order_queue(order.order_id, table_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#for card sale data
|
||||
card_data = Array.new
|
||||
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
||||
if !card_sale_trans_ref_no.nil?
|
||||
card_sale_trans_ref_no.each do |cash_sale_trans|
|
||||
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
||||
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
||||
card_no = cash_sale_trans.pan.last(4)
|
||||
card_no = card_no.rjust(19,"**** **** **** ")
|
||||
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
||||
end
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
|
||||
|
||||
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
|
||||
|
||||
#end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
|
||||
@@ -142,26 +225,77 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@visacount= 0.0
|
||||
@jcbcount= 0.0
|
||||
@mastercount = 0.0
|
||||
@unionpaycount = 0.0
|
||||
@alipaycount = 0.0
|
||||
@junctionpaycount = 0.0
|
||||
@credit = 0.0
|
||||
@paymalcount = 0.0
|
||||
@dingacount = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@balance = 0.00
|
||||
@balance = 0
|
||||
@accountable_type = ''
|
||||
@table_no = ''
|
||||
@dining = ''
|
||||
@other_payment = 0.0
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
|
||||
else
|
||||
new_total = @sale_data.grand_total
|
||||
@shop = Shop.first #show shop info
|
||||
|
||||
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
#total customer with individual total amount
|
||||
@individual_total = Array.new
|
||||
if !saleObj.equal_persons.nil?
|
||||
per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
|
||||
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
|
||||
end
|
||||
@rounding_adj = new_total-@sale_data.grand_total
|
||||
|
||||
# rounding adjustment
|
||||
# if @shop.is_rounding_adj
|
||||
# a = saleObj.grand_total % 25 # Modulus
|
||||
# b = saleObj.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(saleObj.grand_total)
|
||||
# @rounding_adj = new_total-saleObj.grand_total
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
# else
|
||||
# @rounding_adj = @sale_data.rounding_adjustment
|
||||
# end
|
||||
#end rounding adjustment
|
||||
|
||||
# rounding adjustment
|
||||
if @shop.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
b = saleObj.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(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)
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
else
|
||||
@rounding_adj = @sale_data.rounding_adjustment
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
accounts = @customer.tax_profiles
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
account = TaxProfile.find(acc.id)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
|
||||
@@ -172,7 +306,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
@balance += res["balance"]
|
||||
@balance = @balance.to_f + res["balance"].to_f
|
||||
# @accountable_type = res["accountable_type"]
|
||||
@accountable_type = "Rebate Balance"
|
||||
end
|
||||
@@ -183,28 +317,46 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#end customer amount
|
||||
|
||||
@sale_data.bookings.each do |sbk|
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
@checkin_time = sbk.checkin_at
|
||||
break
|
||||
if sbk.dining_facility_id.to_i >0
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
@checkin_time = sbk.checkin_at
|
||||
@dining = df
|
||||
break
|
||||
else
|
||||
@table_no = nil
|
||||
@checkin_time = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
|
||||
@sale_data.sale_payments.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash = spay.payment_amount
|
||||
end
|
||||
if spay.payment_method == "mpu"
|
||||
@other += spay.payment_amount
|
||||
elsif spay.payment_method == "paypar"
|
||||
@ppamount += spay.payment_amount
|
||||
elsif spay.payment_method == "visa"
|
||||
@visacount += spay.payment_amount
|
||||
elsif spay.payment_method == "jcb"
|
||||
@jcbcount += spay.payment_amount
|
||||
elsif spay.payment_method == "master"
|
||||
@mastercount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
@other_payment += spay.payment_amount
|
||||
if spay.payment_method == "mpu"
|
||||
@other += spay.payment_amount
|
||||
elsif spay.payment_method == "paypar"
|
||||
@ppamount += spay.payment_amount
|
||||
elsif spay.payment_method == "visa"
|
||||
@visacount += spay.payment_amount
|
||||
elsif spay.payment_method == "jcb"
|
||||
@jcbcount += spay.payment_amount
|
||||
elsif spay.payment_method == "master"
|
||||
@mastercount += spay.payment_amount
|
||||
elsif spay.payment_method == "unionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "JunctionPay"
|
||||
@junctionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
elsif spay.payment_method == "paymal"
|
||||
@paymalcount += spay.payment_amount
|
||||
elsif spay.payment_method == "alipay"
|
||||
@alipaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "dinga"
|
||||
@dingacount += spay.payment_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -215,84 +367,148 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
member_info = nil
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
#shop detail
|
||||
shop_details = Shop.first
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop::ShopDetail
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
#for card sale data
|
||||
card_data = Array.new
|
||||
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
||||
if !card_sale_trans_ref_no.nil?
|
||||
card_sale_trans_ref_no.each do |cash_sale_trans|
|
||||
card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
|
||||
card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
|
||||
card_no = cash_sale_trans.pan.last(4)
|
||||
card_no = card_no.rjust(19,"**** **** **** ")
|
||||
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
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)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data)
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
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)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance)
|
||||
end
|
||||
|
||||
def foc
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
sub_total = params[:sub_total]
|
||||
remark = params[:remark]
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
order_source = params[:type]
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, @user, cash, "foc")
|
||||
#calculate cash acmount
|
||||
cash = saleObj.total_amount
|
||||
|
||||
if saleObj.discount_type == "member_discount"
|
||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0,order_source)
|
||||
end
|
||||
|
||||
saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0)
|
||||
puts "FOC"
|
||||
puts saleObj.to_json
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
# if bookings.count > 1
|
||||
# # for Multiple Booking
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# else
|
||||
# table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
# end
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
shift = ShiftSale.find(saleObj.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
|
||||
|
||||
# Re-call Sale Data
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop::ShopDetail
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.first
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
|
||||
if params[:type] == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
end
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
Order.pay_process_order_queue(order.order_id,table_id)
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -313,4 +529,40 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#print function for receipt
|
||||
def print
|
||||
filename = params[:filename]
|
||||
receipt_no = params[:receipt_no]
|
||||
printer_name = params[:printer_name]
|
||||
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
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"
|
||||
else
|
||||
unique_code = "ReceiptBillPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# render :json => {status: true}
|
||||
end
|
||||
end
|
||||
@@ -1,12 +1,13 @@
|
||||
class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
def create
|
||||
sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
redeem_amount = params[:redeem_amount]
|
||||
membership_id = params[:membership_id]
|
||||
payment_method = "paypar"
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
@@ -27,4 +28,5 @@ class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
44
app/controllers/origami/pending_order_controller.rb
Normal file
44
app/controllers/origami/pending_order_controller.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
class Origami::PendingOrderController < BaseOrigamiController
|
||||
def index
|
||||
# @dining= DiningFacility.where("status = 'occupied'")
|
||||
# @order = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@sale = Sale.pending_sale
|
||||
@order = Sale.pending_order
|
||||
|
||||
end
|
||||
def show
|
||||
@sales = Sale.pending_sale
|
||||
@orders = Sale.pending_order
|
||||
@id = params[:sale_id]
|
||||
if(@id[0,3] == "SAL")
|
||||
@sale = Sale.find(@id)
|
||||
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||
@bookings = Booking.find(@booking)
|
||||
@status = "sale"
|
||||
else
|
||||
# @booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||
@bookings = Booking.find(@id)
|
||||
@status = "order"
|
||||
|
||||
@order_items = Array.new
|
||||
@bookings.booking_orders.each do |booking_order|
|
||||
@order = Order.find(booking_order.order_id)
|
||||
if (@order.status == "new")
|
||||
@order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
puts @status
|
||||
if @bookings.dining_facility_id.to_i > 0
|
||||
@table_id = Booking.find(@bookings.booking_id).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
else
|
||||
@table_id = nil
|
||||
@dining = nil
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -136,4 +136,5 @@ class Origami::ProductCommissionsController < BaseOrigamiController
|
||||
def product_commission_params
|
||||
params.fetch(:product_commission, {})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
240
app/controllers/origami/quick_service_controller.rb
Normal file
240
app/controllers/origami/quick_service_controller.rb
Normal file
@@ -0,0 +1,240 @@
|
||||
class Origami::QuickServiceController < ApplicationController
|
||||
# before_action :set_dining, only: [:detail]
|
||||
before_action :check_user
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
@menus = Menu.all
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
@zone = Zone.all
|
||||
@customer = Customer.all
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
# @tables = Table.all.active.order('zone_id asc').group("zone_id")
|
||||
# @rooms = Room.all.active.order('zone_id asc').group("zone_id")
|
||||
# @all_table = Table.all.active.order('status desc')
|
||||
# @all_room = Room.all.active.order('status desc')
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
|
||||
def modify_order
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
@menus = Menu.all
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
if(params[:id][0,3] == "BKI")
|
||||
@table_id = nil
|
||||
@table = nil
|
||||
@booking = Booking.find(params[:id])
|
||||
else
|
||||
@table_id = params[:id]
|
||||
@table = DiningFacility.find(@table_id)
|
||||
@booking = @table.get_booking
|
||||
end
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
if @booking
|
||||
@booking_id = @booking.booking_id
|
||||
@order_items = Array.new
|
||||
@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
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@booking = nil
|
||||
end
|
||||
render "origami/addorders/detail"
|
||||
end
|
||||
|
||||
def update_modify_order
|
||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
|
||||
items_arr = []
|
||||
JSON.parse(params[:order_items]).each { |i|
|
||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||
if i["item_instance_code"].include? "ext"
|
||||
is_extra_time = true
|
||||
arr_exts = i["item_instance_code"].split("_")
|
||||
if arr_exts[1].match(/^(\d)+$/)
|
||||
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
||||
extra_time = Time.at(time)
|
||||
end
|
||||
end
|
||||
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": i["options"]}
|
||||
else
|
||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
|
||||
end
|
||||
items_arr.push(items)
|
||||
}
|
||||
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
@order.items = items_arr
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
booking = Booking.find(params[:booking_id])
|
||||
if params[:table_id].to_i > 0
|
||||
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
|
||||
else
|
||||
table_status = true
|
||||
end
|
||||
if booking
|
||||
if table_status && booking.booking_status != 'moved'
|
||||
if !booking.sale_id.nil?
|
||||
sale_status = check_order_with_booking(booking)
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
end #booking exists
|
||||
else
|
||||
if params[:table_id].to_i > 0
|
||||
sale_status = check_order_with_table(params[:table_id])
|
||||
if sale_status
|
||||
# return false , @message = "bill requested"
|
||||
return return_json_status_with_code(400, "bill requested")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@status, @booking = @order.generate
|
||||
if(params[:sale_id][0,3] == "SAL")
|
||||
if @status && @booking && @order.source == 'quick_service'
|
||||
if params[:sale_id]
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
if @order.table_id.to_i > 0
|
||||
@table_id = @order.table_id
|
||||
else
|
||||
@table_id = nil
|
||||
end
|
||||
update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking)
|
||||
end
|
||||
|
||||
result = {:status=> true, :data => @sale }
|
||||
render :json => result.to_json
|
||||
end
|
||||
elsif (params[:sale_id][0,3] == "BKI")
|
||||
result = {:status=> true, :data => 'OK' }
|
||||
render :json => result.to_json
|
||||
else
|
||||
result = {:status=> true, :data => nil }
|
||||
render :json => result.to_json
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
puts params[:id]
|
||||
#Pull this menu
|
||||
@menu = MenuCategory.find_by_id(params[:id])
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu
|
||||
else
|
||||
MenuCategory.current_menu
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_menu_sub_category ()
|
||||
id = params[:id]
|
||||
if (id)
|
||||
#Pull this menu
|
||||
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @sub_menu
|
||||
end
|
||||
end
|
||||
|
||||
def get_all_product()
|
||||
@product = Product.all
|
||||
end
|
||||
|
||||
# render json for http status code
|
||||
def return_json_status_with_code(code, msg)
|
||||
render status: code, json: {
|
||||
message: msg,
|
||||
booking_id: booking_id
|
||||
}.to_json
|
||||
end
|
||||
|
||||
def check_order_with_table(table_id)
|
||||
table = DiningFacility.find(table_id)
|
||||
if table
|
||||
booking = table.get_current_booking
|
||||
# puts booking
|
||||
if booking
|
||||
if !booking.sale_id.nil?
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
end
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = booking.booking_id
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
# this can always true
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
@order.new_booking = true
|
||||
return false
|
||||
else
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,16 +2,18 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
payment_method = params[:payment_method]
|
||||
@cashier_type = params[:type]
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
@shop = Shop.first
|
||||
# if @shop.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
# else
|
||||
# new_total = sale_data.grand_total
|
||||
# end
|
||||
# @rounding_adj = new_total-sale_data.grand_total
|
||||
@rounding_adj = sale_data.rounding_adjustment
|
||||
|
||||
@payparcount = 0
|
||||
others = 0
|
||||
@@ -66,4 +68,5 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
end
|
||||
@out = false, 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,20 +1,30 @@
|
||||
class Origami::RequestBillsController < ApplicationController
|
||||
|
||||
before_action :check_user
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
# Print Request Bill and add to sale tables
|
||||
def print
|
||||
@sale = Sale.new
|
||||
sale_order=SaleOrder.new
|
||||
|
||||
if shift = ShiftSale.current_open_shift(current_user.id)
|
||||
if !ShiftSale.current_shift.nil?
|
||||
order_id = params[:id] # order_id
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
order = Order.find(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
if check_booking.dining_facility_id.to_i > 0
|
||||
table = DiningFacility.find(check_booking.dining_facility_id)
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
if check_booking.sale_id.nil?
|
||||
# Create Sale if it doesn't exist
|
||||
# puts "current_login_employee"
|
||||
# puts current_login_employee.name
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
else
|
||||
@@ -23,11 +33,19 @@ class Origami::RequestBillsController < ApplicationController
|
||||
end
|
||||
|
||||
# Bind shift sale id to sale
|
||||
@sale_data.shift_sale_id = shift.id
|
||||
@sale_data.save
|
||||
# @sale_data.shift_sale_id = shift.id
|
||||
# @sale_data.save
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(@sale)
|
||||
#bill channel
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
ActionCable.server.broadcast "bill_channel",table: table
|
||||
end
|
||||
if order.source == "quick_service"
|
||||
result = {:status=> @status, :data => @sale.sale_id }
|
||||
render :json => result.to_json
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift for This Employee"
|
||||
@@ -55,4 +73,5 @@ class Origami::RequestBillsController < ApplicationController
|
||||
|
||||
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,15 +3,24 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@orders = Order.all.order('date desc')
|
||||
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@orders = Order.all.order('date desc')
|
||||
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
|
||||
@room = DiningFacility.find(params[:room_id])
|
||||
|
||||
@@ -19,13 +28,46 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@status_sale = ""
|
||||
@sale_array = Array.new
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
@shop = Shop.first
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
|
||||
bookings = Booking.all
|
||||
if !bookings.today.nil?
|
||||
@order_items_count = Hash.new
|
||||
# bookings.each do |booking|
|
||||
# if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
# if !booking.booking_orders.empty?
|
||||
# booking.booking_orders.each do |booking_order|
|
||||
# order = Order.find(booking_order.order_id)
|
||||
# if !order.order_items.empty?
|
||||
# if !@order_items_count.key?(booking.dining_facility_id)
|
||||
# @order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
# else
|
||||
# @order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# else
|
||||
# if !booking.sale_id.nil?
|
||||
# sale = Sale.find(booking.sale_id)
|
||||
# if sale.sale_status !='completed'
|
||||
# if !@order_items_count.key?(booking.dining_facility_id)
|
||||
# @order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
# else
|
||||
# @order_items_count[booking.dining_facility_id] = sale.sale_items.count
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
@room.bookings.active.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
@order_items = Array.new
|
||||
# @assigned_order_items = Array.new
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
@customer = order.customer
|
||||
@@ -36,14 +78,17 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@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
|
||||
end
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
puts "enter"
|
||||
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'
|
||||
@@ -81,7 +126,12 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -2,16 +2,24 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
authorize_resource class: false
|
||||
# Index for sale item void OR edit
|
||||
def edit
|
||||
sale_id = params[:sale_id]
|
||||
@table_id = params[:table_id]
|
||||
@saleobj = Sale.find(sale_id)
|
||||
sale_id = params[:sale_id]
|
||||
if params[:table_id]
|
||||
@table_id = params[:table_id]
|
||||
else
|
||||
@table_id = nil
|
||||
end
|
||||
|
||||
@cashier_type = params[:type]
|
||||
@saleobj = Sale.find(sale_id)
|
||||
end
|
||||
|
||||
# create item void. make duplicate old record and update qty and price
|
||||
def item_void
|
||||
saleitemId = params[:sale_item_id]
|
||||
remark = params[:remark]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj.remark = 'void'
|
||||
saleitemObj.status = 'void'
|
||||
saleitemObj.remark = remark
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@@ -21,11 +29,24 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
@newsaleitem.is_taxable = 1
|
||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
|
||||
@newsaleitem.remark = remark
|
||||
@newsaleitem.save
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
|
||||
booking = Booking.find_by_sale_id(saleitemObj.sale_id)
|
||||
booking.booking_orders.each do |bo|
|
||||
order = Order.find(bo.order_id)
|
||||
order.order_items.each do |o|
|
||||
if saleitemObj.product_code == o.item_code
|
||||
o.qty = saleitemObj.qty * -1
|
||||
o.price = saleitemObj.price * -1
|
||||
o.save
|
||||
end
|
||||
end
|
||||
end
|
||||
action_by = current_user.id
|
||||
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMVOID" )
|
||||
@@ -36,8 +57,10 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
|
||||
def item_foc
|
||||
saleitemId = params[:sale_item_id]
|
||||
remark = params[:remark]
|
||||
saleitemObj = SaleItem.find(saleitemId)
|
||||
saleitemObj.remark = 'foc'
|
||||
saleitemObj.status = 'foc'
|
||||
saleitemObj.remark = remark
|
||||
saleitemObj.save
|
||||
@newsaleitem = SaleItem.new
|
||||
@newsaleitem = saleitemObj.dup
|
||||
@@ -47,16 +70,20 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
|
||||
@newsaleitem.price = saleitemObj.price * -1
|
||||
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
|
||||
@newsaleitem.remark = remark
|
||||
@newsaleitem.save
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMFOC" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order.source)
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
|
||||
@@ -65,7 +92,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# update_qty = params[:update_qty]
|
||||
# update_price = params[:update_price]
|
||||
# saleitemObj = SaleItem.find(saleitemId)
|
||||
# saleitemObj.remark = 'void'
|
||||
# saleitemObj.status = 'void'
|
||||
# saleitemObj.save
|
||||
# @newsaleitem = SaleItem.new
|
||||
# @newsaleitem = saleitemObj.dup
|
||||
@@ -105,7 +132,19 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
order.order_items.each do |o|
|
||||
if saleitemObj.product_code == o.item_code
|
||||
o.qty = update_qty
|
||||
o.price = update_price
|
||||
o.save
|
||||
end
|
||||
end
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order.source)
|
||||
|
||||
ProductCommission.edit_product_commission(saleitemObj)
|
||||
end
|
||||
@@ -117,7 +156,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
both = SaleItem.where('product_code=?', saleitemObj.product_code)
|
||||
both.each do |item|
|
||||
if item.qty.to_i > 0
|
||||
item.remark = nil
|
||||
item.status = nil
|
||||
item.save
|
||||
end
|
||||
end
|
||||
@@ -126,38 +165,44 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"ITEMCANCELVOID" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount, order.source)
|
||||
ProductCommission.remove_product_commission(saleitemObj)
|
||||
end
|
||||
|
||||
# remove all void items
|
||||
def cancel_all_void
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:type]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.sale_items.each do |item|
|
||||
if item.qty.to_i < 0
|
||||
item.destroy
|
||||
else
|
||||
item.remark = nil
|
||||
item.status = nil
|
||||
end
|
||||
item.save
|
||||
ProductCommission.remove_product_commission(item)
|
||||
end
|
||||
|
||||
# re-calc tax
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
||||
end
|
||||
|
||||
def apply_void
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:type]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.compute_without_void
|
||||
saleObj.compute_without_void(order_source)
|
||||
saleObj.sale_items.each do |item|
|
||||
ProductCommission.remove_product_commission(item)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,21 +3,31 @@ class Origami::SalesController < BaseOrigamiController
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
|
||||
@orders = Order.all.order('date desc')
|
||||
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||
@sale = Sale.find(params[:sale_id])
|
||||
@order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id
|
||||
@booking = BookingOrder.find_by_order_id(@order).booking_id
|
||||
@table_id = Booking.find(@booking).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
if Booking.find(@booking).dining_facility_id.to_i>0
|
||||
@table_id = Booking.find(@booking).dining_facility_id
|
||||
@dining = DiningFacility.find(@table_id)
|
||||
else
|
||||
@table_id = nil
|
||||
@dining = nil
|
||||
end
|
||||
end
|
||||
|
||||
def add_to_existing_invoice
|
||||
dining = params[:dining_id]
|
||||
sale_id = params[:sale_id]
|
||||
table = DiningFacility.find(dining)
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
table.bookings.each do |booking|
|
||||
# if !booking.checkout_at.nil?
|
||||
# existing_booking.update_attributes(checkout_at: checkout_at)
|
||||
# end
|
||||
if booking.sale_id.nil?
|
||||
booking.booking_orders.each do |booking_order|
|
||||
|
||||
booking.booking_status = 'moved'
|
||||
order = Order.find(booking_order.order_id)
|
||||
order.status = 'billed'
|
||||
@@ -36,7 +46,7 @@ class Origami::SalesController < BaseOrigamiController
|
||||
order.save
|
||||
booking.save
|
||||
end
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
|
||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||
booking_order.each do |bo|
|
||||
bo.booking_id = existing_booking.booking_id
|
||||
@@ -46,5 +56,4 @@ class Origami::SalesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
27
app/controllers/origami/second_display_controller.rb
Normal file
27
app/controllers/origami/second_display_controller.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
class Origami::SecondDisplayController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@display_images = DisplayImage.all
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def customer_view
|
||||
if params[:status]!= "billed"
|
||||
tax_profiles = TaxProfile.all.order("order_by asc")
|
||||
else
|
||||
tax_profiles = nil
|
||||
end
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status]
|
||||
end
|
||||
end
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -3,7 +3,14 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def show
|
||||
@cashier_type = params[:type]
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
#for bank integration
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -45,27 +52,53 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
cashier_terminal.is_currently_login = 0
|
||||
cashier_terminal.save
|
||||
|
||||
|
||||
unique_code = "CloseCashierPdf"
|
||||
shop_details = Shop.find(1)
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
|
||||
|
||||
#add shift_sale_id to card_settle_trans
|
||||
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
|
||||
|
||||
card_settle_trans.each do |data|
|
||||
card_sett_trans = CardSettleTran.find(data.id)
|
||||
card_sett_trans.shift_sale_id = @shift.id
|
||||
card_sett_trans.save()
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
close_cashier_pdf.each do |close_cashier|
|
||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||
if close_cashier[1] == '1'
|
||||
unique_code="CloseCashierCustomisePdf"
|
||||
else
|
||||
unique_code="CloseCashierPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
shop_details = Shop.find(1)
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
|
||||
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
|
||||
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
#byebug
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
|
||||
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges)
|
||||
end
|
||||
end
|
||||
Employee.logout(session[:session_token])
|
||||
session[:session_token] = nil
|
||||
@@ -88,8 +121,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
410
app/controllers/origami/split_bill_controller.rb
Executable file
410
app/controllers/origami/split_bill_controller.rb
Executable file
@@ -0,0 +1,410 @@
|
||||
class Origami::SplitBillController < BaseOrigamiController
|
||||
authorize_resource :class => false
|
||||
|
||||
def index
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
dining_id = params[:dining_id]
|
||||
@cashier_type = params[:type]
|
||||
@table = DiningFacility.find(dining_id)
|
||||
@booking = @table.get_booking
|
||||
@orders = Array.new
|
||||
@order_items = Array.new
|
||||
@sale_data = Array.new
|
||||
@current_user = current_user
|
||||
|
||||
table_bookings = Booking.where("dining_facility_id = #{dining_id} and sale_id IS NOT NULL")
|
||||
if !table_bookings.nil?
|
||||
table_bookings.each do |table_booking|
|
||||
@sale_data.push(table_booking.sale)
|
||||
end
|
||||
end
|
||||
|
||||
if @booking
|
||||
@booking.booking_orders.each do |booking_order|
|
||||
arr_order_items = Array.new
|
||||
@order = Order.find(booking_order.order_id)
|
||||
if (@order.status == "new")
|
||||
@orders.push(@order)
|
||||
|
||||
@order.order_items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
end
|
||||
item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
|
||||
arr_item = Hash.new
|
||||
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
|
||||
else
|
||||
@booking = nil
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cashier_type = params[:cashier_type]
|
||||
order_ids = params[:order_ids]
|
||||
arr_order_ids = nil
|
||||
if !params[:arr_order_ids].nil?
|
||||
arr_order_ids = JSON.parse(params[:arr_order_ids])
|
||||
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?
|
||||
#create Bill by Booking ID
|
||||
table = 0
|
||||
if !params[:booking_id].empty?
|
||||
booking = Booking.find(params[:booking_id])
|
||||
# for Multiple Cashier by Zone
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(booking.dining_facility_id)
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
else
|
||||
table = nil
|
||||
cashier_zone = nil
|
||||
end
|
||||
|
||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
||||
|
||||
if booking
|
||||
if booking.sale_id.nil?
|
||||
sale = Sale.new
|
||||
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type)
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
else
|
||||
status = true
|
||||
sale_id = booking.sale_id
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
end
|
||||
end
|
||||
else
|
||||
if params[:type] == "Table"
|
||||
type = "TableBooking"
|
||||
else
|
||||
type = "RoomBooking"
|
||||
end
|
||||
|
||||
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
|
||||
:checkin_at => Time.now.utc, :checkin_by => current_user.name,
|
||||
:booking_status => "assign" })
|
||||
|
||||
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
|
||||
|
||||
puts order_id
|
||||
puts order_ids.count
|
||||
puts order_id_count
|
||||
puts order_items.count
|
||||
puts order_item_count
|
||||
|
||||
if !order_id.nil?
|
||||
if order_id_count > 1
|
||||
puts "order_id_count > 1"
|
||||
|
||||
updated_order_id = Array.new
|
||||
arr_order_ids.each do |order|
|
||||
order.each do |odr|
|
||||
data = Order.find(odr[0])
|
||||
if data.order_items.count != odr[1]
|
||||
updated_order_id.push(odr[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts "updated_order_id"
|
||||
puts updated_order_id
|
||||
|
||||
if !updated_order_id.empty?
|
||||
order_ids.each do |odr_id|
|
||||
unless updated_order_id.include?(odr_id)
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
end
|
||||
end
|
||||
|
||||
order_items.each do |order_item|
|
||||
if updated_order_id.include?(order_item["order_id"])
|
||||
update_order_item(order_id, order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
order_ids.each do |odr_id|
|
||||
new_order_status = true
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find_by_order_id(odr_id)
|
||||
if !orderItem.nil?
|
||||
if order_item["id"] == orderItem.order_items_id
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
new_order_status = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts new_order_status
|
||||
|
||||
if new_order_status
|
||||
BookingOrder.find_by_order_id(odr_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = create_order(params,order_type,order_items.count,current_user)
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
puts "order_id_count < 1"
|
||||
new_order_status = true
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if !orderItem.nil?
|
||||
if order_item["id"] == orderItem.order_items_id
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
new_order_status = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts new_order_status
|
||||
|
||||
if new_order_status
|
||||
BookingOrder.find_by_order_id(order_id).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_id, order_item)
|
||||
end
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = create_order(params,order_type,order_items.count,current_user)
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if order_ids.count == 1 && order_item_count == 1
|
||||
if order_id_count == 0
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = create_order(params,order_type,order_items.count,current_user)
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
else
|
||||
BookingOrder.find_by_order_id(order_ids[0]).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_ids[0], order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = create_order(params,order_type,order_items.count,current_user)
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sale = Sale.new
|
||||
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type)
|
||||
end
|
||||
|
||||
Promotion.promo_activate(sale)
|
||||
if ENV["SERVER_MODE"] != 'cloud'
|
||||
ActionCable.server.broadcast "bill_channel",table: table
|
||||
end
|
||||
render :json => { status: status }
|
||||
else
|
||||
render :json => { status: false, error_message: 'No Current Open Shift!'}
|
||||
end
|
||||
end
|
||||
|
||||
def create_order(params,order_type,items_count,current_user)
|
||||
order = Order.new
|
||||
order.source = "cashier"
|
||||
order.order_type = order_type
|
||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
order.item_count = items_count
|
||||
order.status = "new"
|
||||
order.table_id = params[:dining_id] # this is dining facilities's id
|
||||
order.waiters = current_user.name
|
||||
order.employee_name = current_user.name
|
||||
order.guest_info = nil
|
||||
order.save!
|
||||
|
||||
return order
|
||||
end
|
||||
|
||||
def update_order_item(order_id, order_item)
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
set_menu_items_obj = Array.new
|
||||
if !orderItem.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(orderItem.set_menu_items)
|
||||
instance_item_sets.each_with_index do |instance_item, instance_index|
|
||||
instance_item_sets[instance_index]["quantity"] = (instance_item["quantity"].to_i - order_item['qty'].to_i).to_s
|
||||
set_menu_items_obj.push({'item_instance_code' => instance_item["item_instance_code"], 'quantity' => order_item['qty'].to_i, 'price' => instance_item["price"]})
|
||||
end
|
||||
orderItem.set_menu_items = instance_item_sets.to_json
|
||||
end
|
||||
|
||||
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)
|
||||
|
||||
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
|
||||
else
|
||||
orderItem.order_id = order_id
|
||||
end
|
||||
orderItem.save!
|
||||
end
|
||||
|
||||
def update_sale
|
||||
sale = Sale.find(params[:sale_id])
|
||||
sale.equal_persons = params[:total_customer].to_i
|
||||
sale.save!
|
||||
|
||||
render :json => { status: true }
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,40 +1,97 @@
|
||||
class Origami::SurveysController < BaseOrigamiController
|
||||
def new
|
||||
@webview = false
|
||||
if check_mobile
|
||||
@webview = true
|
||||
end
|
||||
|
||||
@survey = Survey.new
|
||||
@id = params[:id]
|
||||
@cashier_type = params[:type]
|
||||
|
||||
if(@id[0,3] == "SAL")
|
||||
@sale = Sale.find(@id)
|
||||
@receipt_no = @sale.receipt_no
|
||||
@grand_total = @sale.grand_total
|
||||
@booking = Booking.find_by_sale_id(@id)
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
|
||||
if @booking.dining_facility_id.to_i>0
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||
survey_process = Survey.find_by_receipt_no(@receipt_no)
|
||||
if !survey_process.nil?
|
||||
@survey_data = survey_process
|
||||
end
|
||||
else
|
||||
@dining_facility = nil
|
||||
@table_type = nil
|
||||
end
|
||||
|
||||
else
|
||||
@dining_facility = DiningFacility.find(@id)
|
||||
@table_type = @dining_facility.type
|
||||
@receipt_no = nil
|
||||
@grand_total = nil
|
||||
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@dining_facility = DiningFacility.find(params[:table_id])
|
||||
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
||||
@type = params[:cashier_type]
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@survey = Survey.new(survey_params)
|
||||
@survey.foreigner = params["survey"]["foreigner"].to_json
|
||||
# respond_to do |format|
|
||||
if @survey.save
|
||||
redirect_to @url
|
||||
end
|
||||
# end
|
||||
if params[:table_id].to_i>0
|
||||
@dining_facility = DiningFacility.find(params[:table_id])
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
else
|
||||
sale = Sale.find(@sale_id)
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
|
||||
end
|
||||
|
||||
if @type == "quick_service"
|
||||
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
|
||||
else
|
||||
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
||||
end
|
||||
|
||||
|
||||
if params[:survey_id].nil? || params[:survey_id] == ""
|
||||
@survey = Survey.new(survey_params)
|
||||
@survey.shift_id = shift_by_terminal.id
|
||||
@survey.foreigner = params["survey"]["foreigner"].to_json
|
||||
# respond_to do |format|
|
||||
if @survey.save
|
||||
redirect_to @url
|
||||
end
|
||||
# end
|
||||
else
|
||||
survey = Survey.find_by_id(params[:survey_id])
|
||||
survey.child = params["survey"]["child"]
|
||||
survey.adult = params["survey"]["adult"]
|
||||
survey.male = params["survey"]["male"]
|
||||
survey.female = params["survey"]["female"]
|
||||
survey.local = params["survey"]["local"]
|
||||
survey.dining_name = params["survey"]["dining_name"]
|
||||
survey.receipt_no = params["survey"]["receipt_no"]
|
||||
survey.shift_id = shift_by_terminal.id
|
||||
survey.created_by = params["survey"]["created_by"]
|
||||
survey.total_customer = params["survey"]["total_customer"]
|
||||
survey.total_amount = params["survey"]["total_amount"]
|
||||
survey.foreigner = params["survey"]["foreigner"].to_json
|
||||
if survey.save!
|
||||
redirect_to @url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def survey_params
|
||||
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount)
|
||||
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Origami::TableInvoicesController < BaseOrigamiController
|
||||
def index
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
shop = Shop.first
|
||||
puts "table bookig lenght"
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
@@ -9,7 +10,18 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
if booking.sale_id.nil?
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
|
||||
# rounding adjustment
|
||||
if shop.is_rounding_adj
|
||||
a = sale.grand_total % 25 # Modulus
|
||||
b = sale.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(sale.grand_total)
|
||||
sale.rounding_adjustment = new_total-sale.grand_total
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
if sale.sale_status != "completed"
|
||||
@sale_array.push(sale)
|
||||
end
|
||||
@@ -19,12 +31,27 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
|
||||
def show
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
shop = Shop.first
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
if booking.sale_id.nil?
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
|
||||
sale = Sale.find(booking.sale_id)
|
||||
# rounding adjustment
|
||||
if shop.is_rounding_adj
|
||||
a = sale.grand_total % 25 # Modulus
|
||||
b = sale.grand_total / 25 # Division
|
||||
#not calculate rounding if modulus is 0 and division is even
|
||||
#calculate rounding if modulus is zero or not zero and division are not even
|
||||
if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
|
||||
new_total = Sale.get_rounding_adjustment(sale.grand_total)
|
||||
sale.rounding_adjustment = new_total-sale.grand_total
|
||||
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_array.push(sale)
|
||||
end
|
||||
@@ -35,6 +62,14 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
@date = @sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@customer = @sale.customer
|
||||
#for split bill
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
75
app/controllers/origami/unionpay_controller.rb
Normal file
75
app/controllers/origami/unionpay_controller.rb
Normal file
@@ -0,0 +1,75 @@
|
||||
class Origami::UnionpayController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
# limit unionpay_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = 0
|
||||
@unionpaycount = 0
|
||||
@shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_unionpay = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "unionpay"
|
||||
@unionpaycount = @unionpaycount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_unionpay = total - @unionpaycount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.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)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
#end rounding adjustment
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
78
app/controllers/origami/visa_controller.rb
Executable file → Normal file
78
app/controllers/origami/visa_controller.rb
Executable file → Normal file
@@ -1,53 +1,75 @@
|
||||
class Origami::VisaController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
|
||||
@cashier_type = params[:type]
|
||||
# limit visa_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
total = 0
|
||||
@visacount = 0
|
||||
others = 0
|
||||
@shop = Shop.first
|
||||
@rounding_adj = 0
|
||||
@can_visa = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
others = 0
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "visa"
|
||||
@visacount = @visacount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_visa = total - @visacount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "visa"
|
||||
@visacount = @visacount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
@can_visa = total - @visacount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
shop_details = Shop.first
|
||||
|
||||
# rounding adjustment
|
||||
if shop_details.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)
|
||||
end
|
||||
# if shop_details.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)
|
||||
# end
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
# saleObj = Sale.find(sale_id)
|
||||
#end rounding adjustment
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,10 +3,16 @@ class Origami::VoidController < BaseOrigamiController
|
||||
def overall_void
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
|
||||
remark = params[:remark]
|
||||
order_source = params[:type] #tax profile source
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
|
||||
|
||||
if sale.discount_type == "member_discount"
|
||||
sale.update_attributes(total_discount: 0)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||
end
|
||||
|
||||
# update count for shift sale
|
||||
if(sale.sale_status == "completed")
|
||||
if sale.shift_sale_id != nil
|
||||
@@ -21,7 +27,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
shift.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
@@ -35,61 +41,94 @@ class Origami::VoidController < BaseOrigamiController
|
||||
# end
|
||||
# end
|
||||
|
||||
table_avaliable = true
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.sale.sale_status == 'new'
|
||||
table_avaliable = false
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if table_avaliable == true
|
||||
table.status = 'available'
|
||||
table.save
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
end
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.id
|
||||
remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
action_by = current_user.name
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" )
|
||||
|
||||
# For Print
|
||||
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
end
|
||||
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance)
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
|
||||
#end print
|
||||
|
||||
@@ -102,4 +141,5 @@ class Origami::VoidController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -8,7 +8,7 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
@vouchercount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
@shop = Shop.first
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
@@ -54,7 +54,7 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
|
||||
129
app/controllers/origami/waste_spoile_controller.rb
Executable file
129
app/controllers/origami/waste_spoile_controller.rb
Executable file
@@ -0,0 +1,129 @@
|
||||
class Origami::WasteSpoileController < BaseOrigamiController
|
||||
def waste_and_spoilage
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
remark = params[:remark]
|
||||
order_source = params[:type] #tax profile source
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax|
|
||||
existing_tax.delete
|
||||
end
|
||||
sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0)
|
||||
sale.payment_status = remark
|
||||
sale.sale_status = remark
|
||||
sale.save
|
||||
|
||||
# sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||
# add to sale item with foc
|
||||
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
|
||||
|
||||
sale.sale_items.each do|item|
|
||||
# SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
|
||||
item.status = remark
|
||||
item.remark = remark
|
||||
item.save
|
||||
end
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
end
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,remark )
|
||||
|
||||
# For Print
|
||||
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
end
|
||||
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
|
||||
#end print
|
||||
|
||||
# update complete order items in oqs
|
||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||
aoi.delivery_status = 1
|
||||
aoi.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,6 +2,8 @@ class PrintSettingsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_print_setting, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
# GET /print_settings
|
||||
# GET /print_settings.json
|
||||
def index
|
||||
@@ -16,10 +18,12 @@ class PrintSettingsController < ApplicationController
|
||||
# GET /print_settings/new
|
||||
def new
|
||||
@print_setting = PrintSetting.new
|
||||
@server_mode = ENV["SERVER_MODE"]
|
||||
end
|
||||
|
||||
# GET /print_settings/1/edit
|
||||
def edit
|
||||
@server_mode = ENV["SERVER_MODE"]
|
||||
end
|
||||
|
||||
# POST /print_settings
|
||||
@@ -62,6 +66,17 @@ class PrintSettingsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def get_printer_options
|
||||
printer_name = params[:printer_name]
|
||||
printer_options = Printer::PrinterWorker.printer_options(printer_name)
|
||||
options = {
|
||||
:url => printer_options['device-uri'],
|
||||
:model => printer_options['printer-info'],
|
||||
}
|
||||
|
||||
render :json => options.to_json
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_print_setting
|
||||
@@ -70,6 +85,11 @@ class PrintSettingsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def print_setting_params
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :font,:header_font_size, :item_font_size, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,8 @@ class Reports::CommissionController < BaseReportController
|
||||
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
@@ -48,5 +49,6 @@ class Reports::CommissionController < BaseReportController
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ authorize_resource :class => false
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@@ -58,4 +59,5 @@ authorize_resource :class => false
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -8,6 +8,8 @@ class Reports::DailysaleController < BaseReportController
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
@@ -17,4 +19,5 @@ class Reports::DailysaleController < BaseReportController
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,7 +4,9 @@ class Reports::PaymentMethodController < BaseReportController
|
||||
|
||||
@payments = [["All Payment",''],["Cash Payment","cash"], ["Credit Payment","creditnote"],
|
||||
["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"],
|
||||
["Master Payment","master"], ["JCB Payment","jcb"], ["Redeem Payment","paypar"]]
|
||||
["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"],
|
||||
["Alipay Payment","alipay"],["Paymal Payment", "paymal"],["Dinga Payment","dinga"],
|
||||
["JunctionPay","junctionpay"],["Redeem Payment","paypar"]]
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@@ -23,7 +25,8 @@ class Reports::PaymentMethodController < BaseReportController
|
||||
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type)
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@@ -60,4 +63,5 @@ class Reports::PaymentMethodController < BaseReportController
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
27
app/controllers/reports/product_sale_controller.rb
Normal file
27
app/controllers/reports/product_sale_controller.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
class Reports::ProductSaleController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
|
||||
def index
|
||||
@order_by = 'desc'
|
||||
if !params[:order_by].nil?
|
||||
@order_by = params[:order_by]
|
||||
end
|
||||
|
||||
@sale_data = Sale.get_menu_item_query(@order_by)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -23,7 +23,8 @@ authorize_resource :class => false
|
||||
@tax_profiles = TaxProfile.order('order_by asc')
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@@ -60,4 +61,5 @@ authorize_resource :class => false
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,19 +3,28 @@ class Reports::SaleitemController < BaseReportController
|
||||
def index
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale_range = ''
|
||||
|
||||
shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
@sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
@type = params[:sale_type]
|
||||
@sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
|
||||
@@ -25,7 +34,7 @@ class Reports::SaleitemController < BaseReportController
|
||||
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
|
||||
|
||||
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
|
||||
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
|
||||
|
||||
|
||||
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
@@ -33,6 +42,9 @@ class Reports::SaleitemController < BaseReportController
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
if shift.present?
|
||||
shift.each do |sh|
|
||||
@@ -50,8 +62,8 @@ class Reports::SaleitemController < BaseReportController
|
||||
|
||||
def show
|
||||
from, to, report_type = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
puts "aaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
@@ -64,11 +76,14 @@ class Reports::SaleitemController < BaseReportController
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
# @totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
# @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -17,7 +17,8 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
@shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@shift_data = @shift
|
||||
end
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
@@ -46,5 +47,6 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ class Reports::StockCheckController < BaseReportController
|
||||
@transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code)
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
@@ -45,5 +46,6 @@ class Reports::StockCheckController < BaseReportController
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ authorize_resource :class => false
|
||||
|
||||
@from = from
|
||||
@to = to
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
if @shift.present?
|
||||
@shift.each do |sh|
|
||||
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
@@ -57,4 +58,5 @@ authorize_resource :class => false
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
19
app/controllers/reports/waste_and_spoilage_controller.rb
Executable file
19
app/controllers/reports/waste_and_spoilage_controller.rb
Executable file
@@ -0,0 +1,19 @@
|
||||
class Reports::WasteAndSpoilageController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
@sale_type = params[:sale_type]
|
||||
@sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type)
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,6 +1,7 @@
|
||||
class Settings::CommissionersController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
# GET /commissioners
|
||||
# GET /commissioners.json
|
||||
@@ -82,7 +83,11 @@ class Settings::CommissionersController < ApplicationController
|
||||
end
|
||||
render json: @transactions
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commissioner
|
||||
@@ -91,6 +96,6 @@ class Settings::CommissionersController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commissioner_params
|
||||
params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active)
|
||||
params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active, :image_path)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Settings::CommissionsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_commission, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
# GET /commissions
|
||||
# GET /commissions.json
|
||||
@@ -68,6 +69,12 @@ class Settings::CommissionsController < ApplicationController
|
||||
# end
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commission
|
||||
|
||||
11
app/controllers/settings/display_images_controller.rb
Normal file
11
app/controllers/settings/display_images_controller.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class Settings::DisplayImagesController < ApplicationController
|
||||
def destroy
|
||||
#byebug
|
||||
@item_photo = DisplayImage.find(params[:shop_id])
|
||||
item = @item_photo.id
|
||||
@item_photo.destroy
|
||||
respond_to do |format|
|
||||
format.html {redirect_to settings_shops_url+'/1/edit', notice: 'Image was successfully destroyed.'}
|
||||
end
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user