Class: DailyDonationReport
- Inherits:
-
Object
- Object
- DailyDonationReport
- Extended by:
- ArtfullyOseHelper
- Defined in:
- app/models/daily_donation_report.rb
Defined Under Namespace
Classes: Row
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#donation_total ⇒ Object
Returns the value of attribute donation_total.
-
#organization ⇒ Object
Returns the value of attribute organization.
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize(organization, date = nil) ⇒ DailyDonationReport
constructor
A new instance of DailyDonationReport.
- #to_table ⇒ Object
- #total ⇒ Object
Methods included from ArtfullyOseHelper
action_and_subtype, amount_and_nongift, bootstrapped_type, build_order_location, channel_checkbox, channel_text, check_mark, contextual_menu, credit_card_message, date_field_tag, datetime_field_tag, events_to_options, full_details, 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, select_event_for_sales_search, select_show_for_sales_search, sorted_us_state_abbreviations, sorted_us_state_names, ticket_seller_name, time_zone_description, us_states, verb_for_save, widget_script
Methods included from LinkHelper
#active?, #active_link_to, #active_section, #in_section, #in_sub_section
Constructor Details
#initialize(organization, date = nil) ⇒ DailyDonationReport
Returns a new instance of DailyDonationReport.
5 6 7 8 9 10 11 12 13 14 |
# File 'app/models/daily_donation_report.rb', line 5 def initialize(organization, date=nil) @organization = organization @date = date || 1.day.ago.to_date @orders = organization.orders.csv_not_imported.after(@date).before(@date + 1.day) || [] @rows = [] @orders.each do |order| @rows << Row.new(order) unless order.donations.empty? end end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'app/models/daily_donation_report.rb', line 2 def date @date end |
#donation_total ⇒ Object
Returns the value of attribute donation_total.
2 3 4 |
# File 'app/models/daily_donation_report.rb', line 2 def donation_total @donation_total end |
#organization ⇒ Object
Returns the value of attribute organization.
2 3 4 |
# File 'app/models/daily_donation_report.rb', line 2 def organization @organization end |
#rows ⇒ Object
Returns the value of attribute rows.
2 3 4 |
# File 'app/models/daily_donation_report.rb', line 2 def rows @rows end |
Instance Method Details
#footer ⇒ Object
28 29 30 |
# File 'app/models/daily_donation_report.rb', line 28 def ["Total:", total, ""] end |
#header ⇒ Object
20 21 22 |
# File 'app/models/daily_donation_report.rb', line 20 def header ["Order ID", "Total", "Customer"] end |
#to_table ⇒ Object
24 25 26 |
# File 'app/models/daily_donation_report.rb', line 24 def to_table [header] + @rows.collect {|row| row.to_a.flatten(1)} << end |
#total ⇒ Object
16 17 18 |
# File 'app/models/daily_donation_report.rb', line 16 def total DailyDonationReport.number_to_currency(@orders.sum{|o| o.donations.sum(&:total_price)}.to_f/100) end |