credit note payment

This commit is contained in:
Nweni
2017-06-26 17:49:55 +06:30
parent e878275c1b
commit 089848ed4a
8 changed files with 200 additions and 13 deletions

View File

@@ -9,7 +9,6 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status
def process_payment(invoice, action_by, cash_amount, payment_method)
self.sale = invoice
self.received_amount = cash_amount
amount_due = invoice.grand_total
@@ -28,7 +27,7 @@ class SalePayment < ApplicationRecord
when "cash"
payment_status = cash_payment
when "creditnote"
if !self.customer_id.nil?
if !self.sale.customer_id.nil?
payment_status = creditnote_payment(self.customer_id)
end
when "visa"
@@ -142,7 +141,7 @@ class SalePayment < ApplicationRecord
self.payment_method = "creditnote"
self.payment_amount = self.received_amount
self.customer_id = self.customer_id
self.outstanding_amount = 0 - self.received_amount
self.outstanding_amount = 0 - self.received_amount.to_f
self.payment_status = "outstanding"
payment_method = self.save!
@@ -207,10 +206,7 @@ class SalePayment < ApplicationRecord
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
puts 'mmmmmmmmmmmmmmmmmmmmmmmmmmm'
puts membership_data.to_json
puts "amountttttttttttttttttttttt"
puts self.received_amount
if membership_data["status"]==true
self.payment_method = "paypar"
self.payment_amount = self.received_amount
@@ -271,8 +267,7 @@ class SalePayment < ApplicationRecord
def rebat(sObj)
rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items)
puts "eeeeeeeeeeeeeeeeeeeeeeee"
puts rebate_prices
generic_customer_id = sObj.customer.membership_id
if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0
paypar = sObj.sale_payments