Payment Vs Tax

This commit is contained in:
Phyo
2017-06-13 16:05:20 +06:30
parent 7c37d9ada3
commit 8a7c1f0d88
3 changed files with 25 additions and 4 deletions

View File

@@ -4,7 +4,25 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
payment_method = params[:payment_method]
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
@food_prices, @beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
# limit redeem_amount
food_prices, beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "paypar"
@payparcount = @payparcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
is_bervage_exceed = others - (beverage_prices + sale_data.total_tax)
if is_bervage_exceed < 0
@food_prices = food_prices - @payparcount
else
@food_prices = food_prices - @payparcount -is_bervage_exceed
end
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)