order from app
This commit is contained in:
@@ -64,77 +64,89 @@ class Api::OrdersController < Api::ApiController
|
|||||||
def create
|
def create
|
||||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||||
|
@shop = Shop.find_by_shop_code(params[:shop_code])
|
||||||
|
current_shift = ShiftSale.current_shift(@shop.shop_code)
|
||||||
|
if current_shift.nil?
|
||||||
|
@status = false
|
||||||
|
@message = "No Current Open Shift for This Employee"
|
||||||
|
else
|
||||||
|
current_user =Employee.find(current_shift.employee_id)
|
||||||
|
if checkin_checkout_time(params[:booking_id])
|
||||||
|
|
||||||
if checkin_checkout_time(params[:booking_id])
|
if params[:booking_id].present?
|
||||||
|
booking = Booking.find(params[:booking_id])
|
||||||
if params[:booking_id].present?
|
end
|
||||||
booking = Booking.find(params[:booking_id])
|
if params[:table_id].present?
|
||||||
end
|
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
|
||||||
if params[:table_id].present?
|
table = DiningFacility.find(params[:table_id])
|
||||||
if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i
|
booking = table.get_current_booking
|
||||||
table = DiningFacility.find(params[:table_id])
|
end
|
||||||
booking = table.get_current_booking
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
#for extratime
|
#for extratime
|
||||||
is_extra_time = false
|
is_extra_time = false
|
||||||
extra_time = ''
|
extra_time = ''
|
||||||
|
|
||||||
params[:order_items].each { |i|
|
params[:order_items].each { |i|
|
||||||
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
|
||||||
if i["item_instance_code"].include? "ext"
|
if i["item_instance_code"].include? "ext"
|
||||||
is_extra_time = true
|
is_extra_time = true
|
||||||
arr_exts = i["item_instance_code"].split("_")
|
arr_exts = i["item_instance_code"].split("_")
|
||||||
if arr_exts[1].match(/^(\d)+$/)
|
if arr_exts[1].match(/^(\d)+$/)
|
||||||
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
time = arr_exts[1].to_i*60*i["quantity"].to_i
|
||||||
extra_time = Time.at(time)
|
extra_time = Time.at(time)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
#end extra time
|
||||||
|
|
||||||
|
# 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.shop_code =@shop.shop_code
|
||||||
|
@order.is_extra_time = is_extra_time
|
||||||
|
@order.extra_time = extra_time
|
||||||
|
|
||||||
|
#Create Table Booking or Room Booking
|
||||||
|
if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
||||||
|
@order.new_booking = true
|
||||||
|
else
|
||||||
|
@order.new_booking = false
|
||||||
|
@order.booking_id = booking.booking_id
|
||||||
|
end
|
||||||
|
|
||||||
|
@status, @booking = @order.generate
|
||||||
|
if @status && @booking
|
||||||
|
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
||||||
|
end
|
||||||
|
if @order.table_id.to_i > 0
|
||||||
|
table = DiningFacility.find(@booking.dining_facility_id)
|
||||||
|
type = 'order'
|
||||||
|
from = getCloudDomain #get sub domain in cloud mode
|
||||||
|
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
||||||
|
end
|
||||||
|
# # for parallel order
|
||||||
|
# remoteIP = ""
|
||||||
|
# begin
|
||||||
|
# @status, @booking = @order.generate
|
||||||
|
# remoteIP = request.remote_ip
|
||||||
|
# end while request.remote_ip != remoteIP
|
||||||
|
if current_user.role != "waiter" && params[:create_type] == "create_pay"
|
||||||
|
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court') || (@order.source == 'app')
|
||||||
|
@status, @sale = Sale.request_bill(@order,current_user,current_user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
|
||||||
#end extra time
|
|
||||||
|
|
||||||
# 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 booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved'
|
|
||||||
@order.new_booking = true
|
|
||||||
else
|
else
|
||||||
@order.new_booking = false
|
return return_json_status_with_code(406, "Checkout time is over!")
|
||||||
@order.booking_id = booking.booking_id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@status, @booking = @order.generate
|
|
||||||
if @status && @booking
|
|
||||||
Order.process_order_queue(@order.order_id,@order.table_id,@order.source)
|
|
||||||
end
|
|
||||||
if @order.table_id.to_i > 0
|
|
||||||
table = DiningFacility.find(@booking.dining_facility_id)
|
|
||||||
type = 'order'
|
|
||||||
from = getCloudDomain #get sub domain in cloud mode
|
|
||||||
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
|
|
||||||
end
|
|
||||||
# # 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class Api::PaymentsController < Api::ApiController
|
class Api::PaymentsController < Api::ApiController
|
||||||
|
skip_before_action :authenticate
|
||||||
|
|
||||||
#Payment by Invoice ID
|
#Payment by Invoice ID
|
||||||
# Payment Method - [Cash | CreditNote | VISA | MASTER | etc..]
|
# Payment Method - [Cash | CreditNote | VISA | MASTER | etc..]
|
||||||
@@ -27,7 +27,9 @@ class Api::PaymentsController < Api::ApiController
|
|||||||
if !sale.nil?
|
if !sale.nil?
|
||||||
if sale.sale_status == "new"
|
if sale.sale_status == "new"
|
||||||
if !params[:card_no].empty?
|
if !params[:card_no].empty?
|
||||||
@status, @message = send_account_paymal(sale.grand_total, params[:card_no], sale.receipt_no)
|
current_shift = ShiftSale.current_shift(sale.shop_code)
|
||||||
|
current_login_employee =Employee.find(current_shift.employee_id)
|
||||||
|
@status, @message = send_account_paymal(sale.grand_total, params[:card_no], sale.receipt_no,current_login_employee)
|
||||||
if @status
|
if @status
|
||||||
sale_payment = SalePayment.new
|
sale_payment = SalePayment.new
|
||||||
status, @sale, @membership_data = sale_payment.process_payment(sale, current_login_employee, sale.grand_total, "paymal",params[:card_no])
|
status, @sale, @membership_data = sale_payment.process_payment(sale, current_login_employee, sale.grand_total, "paymal",params[:card_no])
|
||||||
@@ -67,15 +69,15 @@ class Api::PaymentsController < Api::ApiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_account_paymal(amount, account_no, receipt_no)
|
def send_account_paymal(amount, account_no, receipt_no,current_login_employee)
|
||||||
sale = Sale.find_by_receipt_no(receipt_no)
|
sale = Sale.find_by_receipt_no(receipt_no)
|
||||||
@out = []
|
@out = []
|
||||||
action_by = current_login_employee.name
|
action_by = current_login_employee.name
|
||||||
@status = true
|
@status = true
|
||||||
@message = ""
|
@message = ""
|
||||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sale.shop_code)
|
||||||
if membership_setting.gateway_url
|
if membership_setting.gateway_url
|
||||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",sale.shop_code)
|
||||||
if member_actions.gateway_url
|
if member_actions.gateway_url
|
||||||
@campaign_type_id = nil
|
@campaign_type_id = nil
|
||||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module LoginVerification
|
|||||||
|
|
||||||
def current_shop
|
def current_shop
|
||||||
begin
|
begin
|
||||||
shop_code ='263'
|
shop_code ='262'
|
||||||
@shop =Shop.find_by_shop_code(shop_code)
|
@shop =Shop.find_by_shop_code(shop_code)
|
||||||
return @shop
|
return @shop
|
||||||
rescue
|
rescue
|
||||||
@@ -42,7 +42,7 @@ module LoginVerification
|
|||||||
|
|
||||||
#Shop Name in Navbor
|
#Shop Name in Navbor
|
||||||
def shop_detail
|
def shop_detail
|
||||||
shop_code ='263'
|
shop_code ='262'
|
||||||
@shop = Shop.find_by_shop_code(shop_code)
|
@shop = Shop.find_by_shop_code(shop_code)
|
||||||
return @shop
|
return @shop
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -168,15 +168,17 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
sale = Sale.find_by_receipt_no(receipt_no)
|
sale = Sale.find_by_receipt_no(receipt_no)
|
||||||
@out = []
|
@out = []
|
||||||
action_by = current_user.name
|
action_by = current_user.name
|
||||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code)
|
||||||
if membership_setting.gateway_url
|
if membership_setting.gateway_url
|
||||||
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
|
member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code)
|
||||||
if member_actions.gateway_url
|
if member_actions.gateway_url
|
||||||
@campaign_type_id = nil
|
@campaign_type_id = nil
|
||||||
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
|
||||||
merchant_uid= member_actions.merchant_account_id
|
merchant_uid= member_actions.merchant_account_id
|
||||||
auth_token = member_actions.auth_token.to_s
|
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)
|
membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no)
|
||||||
|
puts membership_data.to_json
|
||||||
|
|
||||||
if membership_data["status"]==true
|
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]}"
|
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" )
|
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" )
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ if @status == true
|
|||||||
json.order_items do
|
json.order_items do
|
||||||
json.array! @order.order_items, :item_code, :item_name, :qty, :options, :remark,:price
|
json.array! @order.order_items, :item_code, :item_name, :qty, :options, :remark,:price
|
||||||
end
|
end
|
||||||
|
json.sale_id @sale.sale_id
|
||||||
else
|
else
|
||||||
json.status :error
|
json.status :error
|
||||||
if @error_messages
|
if @error_messages
|
||||||
json.error_messages @error_messages
|
json.error_messages @error_messages
|
||||||
else
|
else
|
||||||
json.error_messages @order.errors
|
json.error_messages @message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
0
app/views/api/payments/paymal_payment.json.jbuilder
Normal file
0
app/views/api/payments/paymal_payment.json.jbuilder
Normal file
@@ -1 +1 @@
|
|||||||
5392
|
3453
|
||||||
Reference in New Issue
Block a user