update rebate for credit and redeem

This commit is contained in:
Aung Myo
2017-11-15 17:54:59 +06:30
parent ef253cd1dc
commit bf0a8135f6
6 changed files with 31 additions and 18 deletions

View File

@@ -264,8 +264,6 @@ class SalePayment < ApplicationRecord
end
def sale_update_payment_status(paid_amount)
puts paid_amount
puts "parid Masssssssssssssssssssssssssssssssssssssssss"
#update amount_outstanding
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
self.sale.save!
@@ -316,8 +314,6 @@ class SalePayment < ApplicationRecord
self.sale.rebate_status = nil
end
end
puts "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"
puts response.to_json
end
self.sale.save!
@@ -375,7 +371,8 @@ class SalePayment < ApplicationRecord
paypar.each do |pp|
if pp.payment_method == "paypar"
payparcost = payparcost + pp.payment_amount
elsif pp.payment_method == "creditnote"
end
if pp.payment_method == "creditnote"
credit = 1
end
end
@@ -410,7 +407,9 @@ class SalePayment < ApplicationRecord
rescue SocketError
response = { "status": false, "message": "Can't connect server"}
end
puts response.to_json
puts payparcost
puts overall_dis
redeem_amount = payparcost + overall_dis
total_percentage = 0
@@ -431,15 +430,19 @@ class SalePayment < ApplicationRecord
data = {:type => a[:type], :amount => a[:amount]}
type_arr.each do |si|
if si[:type] == a[:type]
amount = (redeem_amount / total_percentage)*si[:percentage]
actual = a[:amount] - amount
data[:amount] = actual
if credit == 1
data[:amount] = 0
else
amount = (redeem_amount / total_percentage)*si[:percentage]
actual = a[:amount] - amount
data[:amount] = actual
end
end
end
rebate_arr.push(data)
end
total_amount = rebate_prices - payparcost - overall_dis
if credit == 1
@@ -485,6 +488,7 @@ class SalePayment < ApplicationRecord
response = { "status": "no_member", "message": "Not membership"}
end
end