Sha256: 2dd530753f56945d3129f2082da34c1fd325ef5061f9e97e7e7f2af7575985be

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 Bytes

Contents

class FinancialTxn < ActiveRecord::Base
  attr_protected :created_at, :updated_at

  acts_as_biz_txn_event
  has_many :charge_line_payment_txns, :as => :payment_txn, :dependent => :destroy
  has_many :charge_lines, :through => :charge_line_payment_txns
  belongs_to :money, :dependent => :destroy
  has_many :payments

  def has_captured_payment?
    has_payments? and self.payments.last.current_state == 'captured'
  end

  def has_pending_payment?
    has_payments? and self.payments.last.current_state == 'pending'
  end

  def is_pending?
    self.is_scheduled? || self.has_pending_payment?
  end

  def is_scheduled?
    ((self.apply_date > Date.today) or (!self.has_payments?))
  end

  def has_payments?
    !self.payments.empty?
  end

  def most_recent_payment
    Payment.order('created_at DESC').where('financial_txn_id = ?', self.id).first
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
erp_txns_and_accts-4.0.0 app/models/financial_txn.rb