Redeem amount validation

This commit is contained in:
Phyo
2017-06-13 12:04:31 +06:30
parent 9e4c8cef68
commit 99d00f6d2a
3 changed files with 37 additions and 33 deletions

View File

@@ -4,6 +4,7 @@ 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)
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)

View File

@@ -241,7 +241,7 @@ class SalePayment < ApplicationRecord
def rebat(sObj)
food_prices, beverage_prices = SaleItem.calculate_food_beverage(sObj.sale_items)
generic_customer_id = sObj.customer.membership_id
if generic_customer_id != nil || generic_customer_id != ""
if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0
paypar = sObj.sale_payments
payparcost = 0
paypar.each do |pp|
@@ -250,10 +250,7 @@ class SalePayment < ApplicationRecord
end
end
total_amount = food_prices - payparcost
puts "aaaa"
puts food_prices
puts payparcost
puts total_amount
if total_amount > 0
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")
@@ -270,6 +267,7 @@ class SalePayment < ApplicationRecord
puts response.to_json
end
end
end
private
def generate_custom_id

View File

@@ -18,6 +18,7 @@
<hr>
</div>
</div>
<p class="">You can rebate upto <span style="color:red;" id="food_prices"><%= @food_prices %></span></p>
</div>
</div>
@@ -123,6 +124,7 @@ $("#redeem").click(function(){
}else if(valid_amount< redeem_amount){
alert(" Insufficient Amount!")
}else{
if(redeem_amount <= "<%= @food_prices %>"){
$.ajax({
type: "POST",
url: "<%=origami_payment_paypar_path%>",
@@ -135,6 +137,9 @@ $("#redeem").click(function(){
}
}
})
}else {
alert("Redeem Amount is over!");
}
}
});
</script>