credit payment function

This commit is contained in:
phyusin
2018-07-10 18:12:25 +06:30
parent d0118d2cfc
commit bf0f76ebc7
29 changed files with 879 additions and 462 deletions

View File

@@ -2,8 +2,13 @@ class Origami::AlipayController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
@cashier_type = params[:type]
path = request.fullpath
# limit alipay_amount
sale_data = Sale.find_by_sale_id(@sale_id)
if path.include? ("credit_payment")
sale_data = Sale.get_sale_data_for_other_payment_credit(@sale_id)
else
sale_data = Sale.find_by_sale_id(@sale_id)
end
total = 0
@alipaycount = 0
@shop = Shop.first
@@ -24,8 +29,13 @@ class Origami::AlipayController < BaseOrigamiController
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
sale_data.sale_payments.each do |sale_payment|
if path.include? ("credit_payment")
sale_payment_data = SalePayment.get_sale_payment_for_credit(sale_data)
else
sale_payment_data = sale_data.sale_payments
end
sale_payment_data.each do |sale_payment|
if sale_payment.payment_method == "alipay"
@alipaycount = @alipaycount + sale_payment.payment_amount
else
@@ -64,8 +74,14 @@ class Origami::AlipayController < BaseOrigamiController
# end
# saleObj = Sale.find(sale_id)
path = request.fullpath
payment_for = false
if path.include? ("credit_payment")
payment_for = true
end
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no)
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no,payment_for)
end
end