check payment method
This commit is contained in:
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::ShopDetail
|
||||
@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::ShopDetail
|
||||
|
||||
# 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
|
||||
@@ -52,6 +52,7 @@ class Origami::JcbController < BaseOrigamiController
|
||||
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
|
||||
@@ -65,7 +66,7 @@ class Origami::JcbController < BaseOrigamiController
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ class Origami::MasterController < BaseOrigamiController
|
||||
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
|
||||
@@ -63,7 +64,7 @@ class Origami::MasterController < BaseOrigamiController
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ class Origami::MpuController < BaseOrigamiController
|
||||
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
|
||||
@@ -64,7 +65,7 @@ class Origami::MpuController < BaseOrigamiController
|
||||
|
||||
# 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, "alipay",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -226,6 +226,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@jcbcount= 0.0
|
||||
@mastercount = 0.0
|
||||
@unionpaycount = 0.0
|
||||
@alipaycount = 0.0
|
||||
@junctionpaycount = 0.0
|
||||
@credit = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@@ -346,6 +347,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@junctionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
elsif spay.payment_method == "alipay"
|
||||
@alipaycount += spay.payment_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,6 +48,7 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
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
|
||||
@@ -62,7 +63,7 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
# saleObj = Sale.find(sale_id)
|
||||
#end rounding adjustment
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ class Origami::VisaController < BaseOrigamiController
|
||||
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
|
||||
@@ -62,7 +63,7 @@ class Origami::VisaController < BaseOrigamiController
|
||||
# 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user