credit payment function
This commit is contained in:
@@ -2,8 +2,13 @@ class Origami::MpuController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
path = request.fullpath
|
||||
# limit mpu_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
|
||||
@mpucount = 0
|
||||
@shop = Shop.first
|
||||
@@ -18,14 +23,19 @@ class Origami::MpuController < BaseOrigamiController
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
if @shop.is_rounding_adj && (!path.include? ("credit_payment"))
|
||||
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 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 == "mpu"
|
||||
@mpucount = @mpucount + sale_payment.payment_amount
|
||||
else
|
||||
@@ -64,8 +74,13 @@ class Origami::MpuController < 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, "mpu",ref_no)
|
||||
@status, @sale = sale_payment.process_payment(saleObj, current_user.name, cash, "mpu",ref_no,payment_for)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user