Sha256: dca8c230c3cff99f2deb686d895d77eac08647d3aeb5c0c68e5de2923c0d1dda

Contents?: true

Size: 569 Bytes

Versions: 19

Compression:

Stored size: 569 Bytes

Contents

class Ish::Payment
  include Mongoid::Document
  include Mongoid::Timestamps

  belongs_to :invoice, :class_name => 'Ish::Invoice', optional: true
  belongs_to :profile, :class_name => 'IshModels::UserProfile' # , :optional => true

  field :amount, :type => Integer # in cents
  field :charge, :type => Hash
  field :email,  :type => String
  
  after_create :compute_paid_invoice_amount

  protected

  def compute_paid_invoice_amount
    if self.invoice
      self.invoice.update_attributes :paid_amount => self.invoice.paid_amount + self.amount
    end
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ish_models-0.0.33.121 lib/ish/payment.rb
ish_models-0.0.33.120 lib/ish/payment.rb
ish_models-0.0.33.119 lib/ish/payment.rb
ish_models-0.0.33.118 lib/ish/payment.rb
ish_models-0.0.33.117 lib/ish/payment.rb
ish_models-0.0.33.116 lib/ish/payment.rb
ish_models-0.0.33.115 lib/ish/payment.rb
ish_models-0.0.33.114 lib/ish/payment.rb
ish_models-0.0.33.113 lib/ish/payment.rb
ish_models-0.0.33.112 lib/ish/payment.rb
ish_models-0.0.33.111 lib/ish/payment.rb
ish_models-0.0.33.110 lib/ish/payment.rb
ish_models-0.0.33.109 lib/ish/payment.rb
ish_models-0.0.33.108 lib/ish/payment.rb
ish_models-0.0.33.107 lib/ish/payment.rb
ish_models-0.0.33.106 lib/ish/payment.rb
ish_models-0.0.33.105 lib/ish/payment.rb
ish_models-0.0.33.104 lib/ish/payment.rb
ish_models-0.0.33.103 lib/ish/payment.rb