change rebate calculation formula

This commit is contained in:
phyusin
2018-12-18 16:05:36 +06:30
parent 04d5e86291
commit da96c57c8c
2 changed files with 39 additions and 21 deletions

View File

@@ -101,20 +101,25 @@ class SaleAudit < ApplicationRecord
end
def self.paymal_search(sale_id)
amount = nil
paymal = SaleAudit.where("sale_id =? and action = 'PAYMAL'",sale_id)
remark = paymal[0].remark.split("}")
response = "["+remark[0]+'}]'
response = JSON.parse(response)
puts response
if response[0]["status"] == true
if response[0]["current_rebate_amount"].present?
amount = response[0]["current_rebate_amount"]
if !paymal.nil?
if paymal[0]
remark = paymal[0].remark.split("}")
response = "["+remark[0]+'}]'
response = JSON.parse(response)
puts response
if response[0]["status"] == true
if response[0]["current_rebate_amount"].present?
amount = response[0]["current_rebate_amount"]
else
amount = response[0]["current_balance_amount"]
end
else
amount = response[0]["current_balance_amount"]
amount = nil
end
else
amount = nil
end
end
end
return amount
end