Report abuse

1
2
3
4
5
6
7
8
9
10
class Shipment < ActiveRecord::Base
  after_create :credit_affiliate

  def credit_affiliate
    if self.affiliate
      self.affiliate_credits.create(:account => self.affiliate,
        :amount => (self.total * self.affiliate.percentage(self.id)).round)
    end
  end
end