Class: Organization
Instance Attribute Summary collapse
Instance Method Summary
collapse
#connected?, #fsp, #has_active_fiscally_sponsored_project?, #has_fiscally_sponsored_project?, included, #items_sold_as_reseller_during, #name_for_donations, #refresh_active_fs_project, #shows_with_sales, #sponsored_kit, #update_kits
#calculate_lifetime_value
Instance Attribute Details
#updating_tax_info ⇒ Object
Returns the value of attribute updating_tax_info.
81
82
83
|
# File 'app/models/organization.rb', line 81
def updating_tax_info
@updating_tax_info
end
|
Instance Method Details
#authorization_hash ⇒ Object
99
100
101
102
103
|
# File 'app/models/organization.rb', line 99
def authorization_hash
{ :authorized => can?(:receive, Donation),
:type => donation_type,
:fsp_name => name_for_donations }
end
|
#available_kits ⇒ Object
95
96
97
|
# File 'app/models/organization.rb', line 95
def available_kits
Kit.pad_with_new_kits(kits)
end
|
#donations ⇒ Object
105
106
107
|
# File 'app/models/organization.rb', line 105
def donations
Item.includes(:order => [:person => :address]).where(:product_type => "Donation", :orders => { :organization_id => id })
end
|
#dummy ⇒ Object
72
73
74
|
# File 'app/models/organization.rb', line 72
def dummy
Person.dummy_for(self)
end
|
#events_with_sales ⇒ Object
117
118
119
|
# File 'app/models/organization.rb', line 117
def events_with_sales
shows_with_sales.map(&:event).uniq
end
|
#has_kit?(name) ⇒ Boolean
113
114
115
|
# File 'app/models/organization.rb', line 113
def has_kit?(name)
kits.where(:state => "activated").map(&:class).map(&:name).include?(name.to_s.camelize + "Kit")
end
|
#has_tax_info? ⇒ Boolean
91
92
93
|
# File 'app/models/organization.rb', line 91
def has_tax_info?
!(ein.blank? or legal_organization_name.blank?)
end
|
#lifetime_orders ⇒ Object
We aren’t interested in FAFS donations, so override lifetime_orders to only include Artfully orders see: Valuation::LifetimeValue
37
38
39
|
# File 'app/models/organization.rb', line 37
def lifetime_orders
orders.where('transaction_id is not null')
end
|
#owner ⇒ Object
68
69
70
|
# File 'app/models/organization.rb', line 68
def owner
users.first
end
|
Returns Tag objects. For an array of tag strings, call unique_tag_strings_for
This has been supersceded by tags_on and tag_counts_on in acts_as_taggable_on But those methods have not been added to a release yet.
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/models/organization.rb', line 47
def tags_for(tagged_association)
begin
self.send(tagged_association.to_sym)
rescue NoMethodError
raise NoMethodError, "No tagged has_many association found for #{tagged_association.to_sym}"
end
table_name = Kernel.const_get(tagged_association.to_s.classify).table_name
ActsAsTaggableOn::Tag.joins("INNER JOIN taggings ON tags.id = taggings.tag_id")
.joins("INNER JOIN #{table_name} ON #{table_name}.id = taggings.taggable_id")
.joins("INNER JOIN organizations ON organizations.id = #{table_name}.organization_id")
.where("organizations.id = ?", self.id)
end
|
#ticket_sales ⇒ Object
109
110
111
|
# File 'app/models/organization.rb', line 109
def ticket_sales
Item.includes(:show, :order => [:person => :address]).where(:product_type => "Ticket", :orders => { :organization_id => id })
end
|
#unique_tag_strings_for(tagged_association) ⇒ Object
64
65
66
|
# File 'app/models/organization.rb', line 64
def unique_tag_strings_for(tagged_association)
self.tags_for(tagged_association).all.map(&:name).uniq
end
|
#update_tax_info(params) ⇒ Object
82
83
84
85
86
87
88
89
|
# File 'app/models/organization.rb', line 82
def update_tax_info(params)
@updating_tax_info = true
update_attributes({
:ein => params[:ein],
:legal_organization_name => params[:legal_organization_name],
:email => params[:email]
})
end
|