Class: RegularDonationKit

Inherits:
Kit
  • Object
show all
Defined in:
app/models/kits/regular_donation_kit.rb

Constant Summary collapse

ACCESSORS =
[
  :about_organization_text, :donation_ask_text, :donate_now_text, :donation_nudge_text,
  :suggested_gifts, :open_gift_field, :thanks_msg_text, :email_msg_text, :donation_only_storefront,
]

Instance Method Summary collapse

Methods inherited from Kit

#abilities, #activatable?, activate, activation_requirements, acts_as_kit, #admin_approvable?, admin_approval_requirements, admin_approve, #alternatives, #approvable?, approval_requirements, approve, #has_alternatives?, mailchimp, pad_with_new_kits, #requirements_met?, subklasses, visible, when_active

Methods included from Ext::Integrations::Kit

#record_activation, #record_approval

Instance Method Details

#dont_approveObject



31
32
33
# File 'app/models/kits/regular_donation_kit.rb', line 31

def dont_approve
  false
end

#exclusive?Boolean

Returns:

  • (Boolean)


48
49
50
51
52
# File 'app/models/kits/regular_donation_kit.rb', line 48

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

#friendly_nameObject



40
41
42
# File 'app/models/kits/regular_donation_kit.rb', line 40

def friendly_name
  '501(c)(3) Donations'
end

#has_tax_info?Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'app/models/kits/regular_donation_kit.rb', line 35

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

#no_bank_account?Boolean

Returns:

  • (Boolean)


54
55
56
57
# File 'app/models/kits/regular_donation_kit.rb', line 54

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

#on_pendingObject

def alternatives

@alternatives ||= [ SponsoredDonationKit ]

end



63
64
65
66
# File 'app/models/kits/regular_donation_kit.rb', line 63

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

#pitchObject



44
45
46
# File 'app/models/kits/regular_donation_kit.rb', line 44

def pitch
  'Receive donations for a 501(c)(3)'
end

#suggested_gifts=(value) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/models/kits/regular_donation_kit.rb', line 68

def suggested_gifts=(value)
  value = value.values if value.is_a?(Hash)

  value = value.map do |suggested_gift|
    suggested_gift = { :amount => suggested_gift } if [String, Fixnum, Bignum, Float, BigDecimal].any? { |klass| suggested_gift.is_a?(klass) }
    suggested_gift[:amount] = suggested_gift[:amount].to_i
    suggested_gift.delete :level_name if suggested_gift[:level_name].blank?
    suggested_gift.with_indifferent_access
  end.reject do |suggested_gift|
    suggested_gift[:amount].to_i <= 0
  end.sort do |l, r|
    l[:amount] <=> r[:amount]
  end

  self.settings = {} unless self.settings.is_a?(Hash)
  self.settings[:suggested_gifts] = value
  self.settings_will_change!
end