Class: PaymentApplication

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/payment_application.rb

Instance Method Summary collapse

Instance Method Details

#apply_paymentObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/payment_application.rb', line 14

def apply_payment
  #check the calculate balance strategy, if it includes payments then do nothing
  #if it doesn't include payments then update the balance on the model
  unless self.payment_applied_to.calculate_balance_strategy_type.nil?
    unless self.payment_applied_to.calculate_balance_strategy_type.iid =~ /payment/
      update_applied_to_balance(:debit)
    end
  else
    update_applied_to_balance(:debit)
  end
end

#is_pending?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/models/payment_application.rb', line 10

def is_pending?
  self.financial_txn.nil? or (self.financial_txn.is_scheduled? or self.financial_txn.is_pending?) 
end

#unapply_paymentObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/payment_application.rb', line 26

def unapply_payment
  #check the calculate balance strategy, if it includes payments then do nothing
  #if it doesn't include payments then update the balance on the model
  if self.payment_applied_to.respond_to? :calculate_balance_strategy_type
    if !self.payment_applied_to.calculate_balance_strategy_type.nil?
      if self.payment_applied_to.calculate_balance_strategy_type.iid !=~ /payment/ and !self.is_pending?
        update_applied_to_balance(:credit)
      end
    elsif !self.is_pending?
      update_applied_to_balance(:credit)
    end
  end
end