update customer amount

This commit is contained in:
Aung Myo
2017-06-13 10:36:40 +06:30
parent 92f1f80acb
commit c05a64bae7
13 changed files with 105 additions and 130 deletions

View File

@@ -20,6 +20,31 @@ class Origami::PaymentsController < BaseOrigamiController
@cash = 0.0
@other = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
@balance = 0.00
response["data"].each do |res|
if res["accountable_type"] == "RebateAccount"
@balance = res["balance"]
end
end
#end customer amount
@sale_data.sale_payments.each do |spay|
if spay.payment_method == "cash"
@cash = spay.payment_amount