order from app

This commit is contained in:
Myat Zin Wai Maw
2019-11-28 15:52:50 +06:30
parent fe5dc6bb5a
commit 09e7650452
8 changed files with 91 additions and 74 deletions

View File

@@ -64,7 +64,13 @@ class Api::OrdersController < Api::ApiController
def create
Rails.logger.debug "Order Source - " + params[:order_source].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 params[:booking_id].present?
@@ -105,7 +111,7 @@ class Api::OrdersController < Api::ApiController
@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
@@ -133,10 +139,16 @@ class Api::OrdersController < Api::ApiController
# @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
else
return return_json_status_with_code(406, "Checkout time is over!")
end
end
end
# render json for http status code
def return_json_status_with_code(code, msg)

View File

@@ -1,5 +1,5 @@
class Api::PaymentsController < Api::ApiController
skip_before_action :authenticate
#Payment by Invoice ID
# Payment Method - [Cash | CreditNote | VISA | MASTER | etc..]
@@ -27,7 +27,9 @@ class Api::PaymentsController < Api::ApiController
if !sale.nil?
if sale.sale_status == "new"
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
sale_payment = SalePayment.new
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
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)
@out = []
action_by = current_login_employee.name
@status = true
@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
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
@campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s

View File

@@ -18,7 +18,7 @@ module LoginVerification
def current_shop
begin
shop_code ='263'
shop_code ='262'
@shop =Shop.find_by_shop_code(shop_code)
return @shop
rescue
@@ -42,7 +42,7 @@ module LoginVerification
#Shop Name in Navbor
def shop_detail
shop_code ='263'
shop_code ='262'
@shop = Shop.find_by_shop_code(shop_code)
return @shop
end

View File

@@ -168,15 +168,17 @@ class Origami::CustomersController < BaseOrigamiController
sale = Sale.find_by_receipt_no(receipt_no)
@out = []
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
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
@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)
puts membership_data.to_json
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" )

View File

@@ -5,11 +5,12 @@ if @status == true
json.order_items do
json.array! @order.order_items, :item_code, :item_name, :qty, :options, :remark,:price
end
json.sale_id @sale.sale_id
else
json.status :error
if @error_messages
json.error_messages @error_messages
else
json.error_messages @order.errors
json.error_messages @message
end
end

View File

@@ -1 +1 @@
5392
3453