change rebate calculation formula
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user