Sha256: 877f5f1ddf6e5b259878e1abcfb260f33f0872b6c0e4002cc1aae9025d4d546d

Contents?: true

Size: 753 Bytes

Versions: 3

Compression:

Stored size: 753 Bytes

Contents

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

  belongs_to :charged_item, :polymorphic => true
  belongs_to :money
  has_many :charge_line_payment_txns, :dependent => :destroy
  has_many :financial_txns, :through => :charge_line_payment_txns, :source => :financial_txn,
           :conditions => ["charge_line_payment_txns.payment_txn_type = ?", 'FinancialTxn']

  def payment_txns
    self.financial_txns
  end

  def add_payment_txn(payment_txn)
    charge_line_payment_txn = ChargeLinePaymentTxn.new
    charge_line_payment_txn.charge_line = self
    charge_line_payment_txn.payment_txn = payment_txn
    charge_line_payment_txn.save
    charge_line_payment_txns << charge_line_payment_txn
    self.save
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
erp_orders-4.0.0 app/models/charge_line.rb
erp_orders-3.1.1 app/models/charge_line.rb
erp_orders-3.1.0 app/models/charge_line.rb