add unionpay process for payment

This commit is contained in:
phyusin
2018-01-11 16:08:17 +06:30
parent 2d2a154c17
commit bb2c8694a5
12 changed files with 388 additions and 23 deletions

View File

@@ -155,6 +155,7 @@ class Origami::PaymentsController < BaseOrigamiController
@visacount= 0.0
@jcbcount= 0.0
@mastercount = 0.0
@unionpaycount = 0.0
@credit = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
@balance = 0.00
@@ -216,6 +217,8 @@ class Origami::PaymentsController < BaseOrigamiController
@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 == "creditnote"
@credit += spay.payment_amount
end
@@ -272,7 +275,7 @@ class Origami::PaymentsController < BaseOrigamiController
# Calculate price_by_accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data)
end

View File

@@ -0,0 +1,61 @@
class Origami::UnionpayController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
# limit unionpay_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@unionpaycount = 0
others = 0
@shop = Shop::ShopDetail
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 == "unionpay"
@unionpaycount = @unionpaycount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
puts "unionpaycount"
puts @unionpaycount
@can_unionpay = total - @unionpaycount - 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
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]
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)
#end rounding adjustment
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay")
end
end
end