kbzpay
This commit is contained in:
@@ -105,14 +105,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
#TODO :: KBZPAY ( QR )
|
||||
# On/Off setting ( show or not qr )
|
||||
# qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD"
|
||||
kbz_pay_setting = PaymentMethodSetting.where(:payment_method => 'KBZPay').last
|
||||
kbz_pay_setting = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
|
||||
|
||||
status = false
|
||||
qr = nil
|
||||
|
||||
if !kbz_pay_setting.nil?
|
||||
if kbz_pay_setting.is_active == true
|
||||
status, qr = KbzPay.pay(sale_data.grand_total, sale_data.receipt_no)
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending')
|
||||
|
||||
status, qr = KbzPay.pay(sale_data.grand_total, sale_payment.sale_payment_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -124,6 +127,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# status, qr = KbzPay.query(sale_payment.sale_payment_id)
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
@@ -137,6 +142,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
tax_type = params[:tax_type]
|
||||
path = request.fullpath
|
||||
latest_order_no = nil
|
||||
is_kbz = params[:is_kbz]
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
@@ -158,12 +164,22 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "cash", nil, true)
|
||||
else
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||
# if pay_from = 'kbzpay'
|
||||
# salePayment = SalePayment.find(sale_payment_id)
|
||||
# salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid')
|
||||
# else
|
||||
# sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last
|
||||
if sp.nil? #is_kbz
|
||||
Rails.logger.info '################ CASH PAYMENT #################'
|
||||
sale_payment = SalePayment.new
|
||||
if path.include? ("credit_payment")
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "cash", nil, true)
|
||||
else
|
||||
sale_payment.process_payment(saleObj, current_user, cash, "cash")
|
||||
end
|
||||
end
|
||||
|
||||
# end
|
||||
|
||||
if !path.include? ("credit_payment")
|
||||
rebate_amount = nil
|
||||
@@ -233,7 +249,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
#orders print out
|
||||
if params[:type] == "quick_service"
|
||||
if type == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table_id = booking.dining_facility_id
|
||||
@@ -284,13 +300,22 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
|
||||
|
||||
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
|
||||
|
||||
# status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, nil, nil)
|
||||
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
|
||||
|
||||
# def kbz_query
|
||||
# sale_id = params[:sale_id]
|
||||
# table_id = params[:table_id]
|
||||
# sp = SalePayment.where('sale_id=?', sale_id).last
|
||||
# status, table_id = KbzPay.query(sp.sale_payment_id)
|
||||
# render json: JSON.generate({:status => status, :table_id => table_id, :message => @message})
|
||||
# end
|
||||
|
||||
def show
|
||||
display_type = Lookup.find_by_lookup_type("display_type")
|
||||
if !display_type.nil? && display_type.value.to_i ==2
|
||||
@@ -317,6 +342,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
@cash = 0.0
|
||||
@kbz_pay_amount = 0.0
|
||||
@other = 0.0
|
||||
@ppamount = 0.0
|
||||
@visacount= 0.0
|
||||
@@ -341,6 +367,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@pdf_view = @lookup_pdf.value
|
||||
end
|
||||
|
||||
amount = SalePayment.get_kbz_pay_amount(sale_id, current_user)
|
||||
@kbz_pay_amount += amount.to_f
|
||||
|
||||
#for changable on/off
|
||||
@changable_tax = true
|
||||
lookup_changable_tax = Lookup.collection_of('changable_tax')
|
||||
@@ -463,39 +492,40 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
else
|
||||
@sale_payment_data = SalePayment.get_sale_payments(@sale_data)
|
||||
end
|
||||
@sale_payment_data.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash += spay.payment_amount
|
||||
end
|
||||
if spay.payment_method !="creditnote"
|
||||
@other_payment += spay.payment_amount
|
||||
end
|
||||
@sale_payment_data.each do |spay|
|
||||
if spay.payment_method == "cash"
|
||||
@cash += spay.payment_amount
|
||||
end
|
||||
if spay.payment_method !="creditnote"
|
||||
@other_payment += 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 == "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
|
||||
elsif spay.payment_method == "giftvoucher"
|
||||
@giftvouchercount += 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 == "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
|
||||
elsif spay.payment_method == "giftvoucher"
|
||||
@giftvouchercount += spay.payment_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user