Class: DailyTicketReport
- Inherits:
-
Object
- Object
- DailyTicketReport
- Extended by:
- ArtfullyOseHelper
- Defined in:
- app/models/daily_ticket_report.rb
Defined Under Namespace
Classes: ExchangeRow, Row
Instance Attribute Summary collapse
-
#exchange_rows ⇒ Object
Returns the value of attribute exchange_rows.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#rows ⇒ Object
Returns the value of attribute rows.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
Instance Method Summary collapse
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize(organization, date = nil) ⇒ DailyTicketReport
constructor
A new instance of DailyTicketReport.
- #to_table ⇒ Object
- #total ⇒ Object
Methods included from ArtfullyOseHelper
amount_and_nongift, bootstrapped_type, build_action_path, build_order_location, channel_checkbox, channel_text, check_mark, clean_full_error_messages, contextual_menu, credit_card_message, date_field_tag, datetime_field_tag, events_to_options, fully_qualified_asset_path, get_selected_class, icon_link_to, icon_tag, link_to_add_fields, link_to_remove_fields, nav_dropdown, number_as_cents, number_to_dollars, pluralize_word, refund_header, select_event_for_sales_search, select_membership_type_for_sales_search, select_pass_type_for_sales_search, select_show_for_sales_search, sorted_us_state_abbreviations, sorted_us_state_names, thanks_message, ticket_seller_name, time_ago_sentence, time_zone_description, us_states, verb_for_save, widget_script, with_kit
Methods included from LinkHelper
#active?, #active_link_to, #active_section, #calendar_active_link_to, #in_section, #in_section?, #in_sub_section
Constructor Details
#initialize(organization, date = nil) ⇒ DailyTicketReport
Returns a new instance of DailyTicketReport.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/daily_ticket_report.rb', line 5 def initialize(organization, date=nil) @organization = organization @start_date = (date || 1.day.ago).in_time_zone(@organization.time_zone).midnight @end_date = @start_date + 1.day orders = organization.orders.includes(:person, :items => :product) orders = orders.csv_not_imported.after(@start_date).before(@end_date) || [] @rows = [] @exchange_rows = [] orders.each do |order| next if order.tickets.empty? #TODO: Now that revenue_applies_Aa is a column on orders, this can be cleaned up quite a bit @exchange_rows << ExchangeRow.new(order) if order.is_a? ExchangeOrder @rows << Row.new(order) if order.revenue_applies_to_range(@start_date, @end_date) end end |
Instance Attribute Details
#exchange_rows ⇒ Object
Returns the value of attribute exchange_rows.
2 3 4 |
# File 'app/models/daily_ticket_report.rb', line 2 def exchange_rows @exchange_rows end |
#organization ⇒ Object
Returns the value of attribute organization.
2 3 4 |
# File 'app/models/daily_ticket_report.rb', line 2 def organization @organization end |
#rows ⇒ Object
Returns the value of attribute rows.
2 3 4 |
# File 'app/models/daily_ticket_report.rb', line 2 def rows @rows end |
#start_date ⇒ Object
Returns the value of attribute start_date.
2 3 4 |
# File 'app/models/daily_ticket_report.rb', line 2 def start_date @start_date end |
Instance Method Details
#footer ⇒ Object
35 36 37 |
# File 'app/models/daily_ticket_report.rb', line 35 def ["Total:", DailyTicketReport.number_to_currency(total/100.0), "", "", ""] end |
#header ⇒ Object
27 28 29 |
# File 'app/models/daily_ticket_report.rb', line 27 def header ["Order ID", "Total", "Customer", "Details", "Special Instructions"] end |
#to_table ⇒ Object
31 32 33 |
# File 'app/models/daily_ticket_report.rb', line 31 def to_table [header] + @rows.collect {|row| row.to_a.flatten(1)} << end |
#total ⇒ Object
23 24 25 |
# File 'app/models/daily_ticket_report.rb', line 23 def total @rows.collect(&:order).sum{|o| o.tickets.reject(&:exchanged?).sum(&:price)} end |