class ItemView < ActiveRecord::Base self.table_name = 'items_view' self.primary_key = 'id' has_many :items, :foreign_key => 'order_id' has_many :people, :foreign_key => 'person_id' has_many :shows, :foreign_key => 'show_id' set_watch_for :created_at, :local_to => :self, :as => :organization set_watch_for :datetime, :local_to => :self, :as => :organization default_scope order('created_at desc') def self.sales_export_filename_for(organization) "exports/Artfully-Ticket-Sales-Export-#{organization.id}.csv" end comma :donation do created_at_local_to_organization("Date") email("Email") first_name("First Name") last_name("Last Name") address1("Address1") address2("Address2") city("City") state("State") zip("Zip") payment_method("Payment Method") price("Deductible Amount") { |cents| ((cents || 0) / 100.00) } nongift_amount("Non-Deductible Amount") { |cents| ((cents || 0) / 100.00) } special_instructions("Special Instructions") notes("Notes") end comma :ticket_sale do created_at_local_to_organization("Date of Purchase") email("Email") first_name("First Name") last_name("Last Name") address1("Address1") address2("Address2") city("City") state("State") zip("Zip") event_name("Performance Title") datetime_local_to_organization("Performance Date-Time") payment_method("Payment Method") price("Ticket Price") { |cents| number_to_currency(cents.to_f/100) } special_instructions("Special Instructions") notes("Notes") end end