Sha256: 12b928bfb9393d1f64a826bba7a248209a1e1d59597d3e621838b099c6db5c82

Contents?: true

Size: 1.24 KB

Versions: 29

Compression:

Stored size: 1.24 KB

Contents

class RegularDonationKit < Kit
  acts_as_kit :with_approval => true do
    activate :if => :has_tax_info?
    activate :if => :exclusive?
    approve :unless => :no_bank_account?

    when_active do |organization|
      organization.can :receive, Donation
    end
  end

  def has_tax_info?
    errors.add(:requirements, "Your organization's tax information is missing or incomplete. Please complete it in order to active this kit.") unless organization.has_tax_info?
    organization.has_tax_info?
  end
  
  def friendly_name
    "Charity Donations"
  end
  
  def pitch
    "Receive donations for a 501(c)(3)"
  end

  def exclusive?
    exclusive = !organization.kits.where(:type => alternatives.collect(&:to_s)).any?
    errors.add(:requirements, "You have already activated a mutually exclusive kit.") unless exclusive
    exclusive
  end

  def no_bank_account?
    errors.add(:requirements, "Your organization needs bank account information first.") if organization.bank_account.nil?
    organization.bank_account.nil?
  end

  # def alternatives
  #   @alternatives ||= [ SponsoredDonationKit ]
  # end

  def on_pending
    AdminMailer.donation_kit_notification(self).deliver
    ProducerMailer.donation_kit_notification(self, organization.owner).deliver
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.27 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.26 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.24 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.23 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.21 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.20 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.19 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.18 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.17 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.16 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.15 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.12 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.11 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.10 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.9 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.8 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.7 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.6 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.5 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.4 app/models/kits/regular_donation_kit.rb