artfully_ose 1.0.0.rc4 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +661 -0
- data/app/assets/fonts/FontAwesome.otf +0 -0
- data/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fontawesome-webfont.svg +284 -0
- data/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/images/chosen-sprite.png +0 -0
- data/app/assets/javascripts/application.js +88 -44
- data/app/assets/javascripts/box-office.js +7 -3
- data/app/assets/javascripts/custom/grouped-form.js +1 -1
- data/app/assets/javascripts/custom/modernizr.custom.12828.js +4 -0
- data/app/assets/javascripts/custom/people.js +30 -1
- data/app/assets/javascripts/jquery-lib/chosen.jquery.js +1026 -0
- data/app/assets/javascripts/jquery-lib/jquery.jeditable.js +1 -1
- data/app/assets/javascripts/jquery-lib/jquery.mask-money.js +90 -60
- data/app/assets/javascripts/store/store.js +112 -67
- data/app/assets/stylesheets/application.sass +174 -1
- data/app/assets/stylesheets/bootstrap-overrides.css +51 -13
- data/app/assets/stylesheets/bootstrap.css +4 -379
- data/app/assets/stylesheets/font-awesome.sass +759 -0
- data/app/assets/stylesheets/jquery/chosen.scss +397 -0
- data/app/assets/stylesheets/printing.css +5 -1
- data/app/assets/stylesheets/sass/store.sass +18 -3
- data/app/concerns/itemable.rb +11 -0
- data/app/concerns/oh_noes.rb +24 -0
- data/app/controllers/actions_controller.rb +39 -20
- data/app/controllers/addresses_controller.rb +2 -2
- data/app/controllers/artfully_ose_controller.rb +15 -1
- data/app/controllers/charts_controller.rb +6 -2
- data/app/controllers/contributions_controller.rb +28 -1
- data/app/controllers/discounts_controller.rb +65 -0
- data/app/controllers/discounts_reports_controller.rb +22 -0
- data/app/controllers/events_controller.rb +48 -45
- data/app/controllers/exchanges_controller.rb +10 -10
- data/app/controllers/imports_controller.rb +38 -20
- data/app/controllers/index_controller.rb +1 -1
- data/app/controllers/memberships_controller.rb +1 -0
- data/app/controllers/merges_controller.rb +1 -1
- data/app/controllers/orders_controller.rb +6 -12
- data/app/controllers/organizations_controller.rb +0 -1
- data/app/controllers/people_controller.rb +10 -12
- data/app/controllers/refunds_controller.rb +2 -2
- data/app/controllers/returns_controller.rb +0 -1
- data/app/controllers/sales_controller.rb +9 -6
- data/app/controllers/searches_controller.rb +53 -0
- data/app/controllers/sections_controller.rb +12 -1
- data/app/controllers/segments_controller.rb +23 -10
- data/app/controllers/shows_controller.rb +37 -28
- data/app/controllers/slices_controller.rb +37 -0
- data/app/controllers/statements_controller.rb +4 -4
- data/app/controllers/store/checkouts_controller.rb +14 -12
- data/app/controllers/store/events_controller.rb +1 -1
- data/app/controllers/store/orders_controller.rb +32 -5
- data/app/controllers/store/store_controller.rb +4 -0
- data/app/controllers/venues_controller.rb +6 -2
- data/app/helpers/artfully_ose_helper.rb +31 -5
- data/app/helpers/discounts_helper.rb +3 -0
- data/app/helpers/people_helper.rb +2 -19
- data/app/mailers/order_mailer.rb +21 -3
- data/app/mailers/producer_mailer.rb +9 -1
- data/app/mailers/reports_mailer.rb +12 -0
- data/app/models/action.rb +29 -3
- data/app/models/actions/get_action.rb +4 -0
- data/app/models/actions/go_action.rb +18 -0
- data/app/models/actions/refund_action.rb +14 -0
- data/app/models/address.rb +6 -16
- data/app/models/adjustments.rb +10 -0
- data/app/models/box_office.rb +1 -1
- data/app/models/carts/cart.rb +35 -24
- data/app/models/chart.rb +16 -8
- data/app/models/checkout.rb +32 -9
- data/app/models/comp.rb +2 -8
- data/app/models/contribution.rb +111 -25
- data/app/models/daily_donation_report.rb +45 -0
- data/app/models/daily_ticket_report.rb +51 -0
- data/app/models/discount.rb +137 -0
- data/app/models/discounts/buy_one_get_one_free_discount_type.rb +20 -0
- data/app/models/discounts/discount_type.rb +66 -0
- data/app/models/discounts/dollars_off_tickets_discount_type.rb +32 -0
- data/app/models/discounts/percentage_off_tickets_discount_type.rb +25 -0
- data/app/models/discounts_report.rb +87 -0
- data/app/models/donation.rb +2 -0
- data/app/models/door_list.rb +5 -4
- data/app/models/event.rb +45 -16
- data/app/models/exchange.rb +26 -15
- data/app/models/ext/delayed_indexing.rb +24 -0
- data/app/models/ext/due.rb +7 -0
- data/app/models/ext/ext.rb +37 -0
- data/app/models/ext/integrations.rb +30 -0
- data/app/models/ext/resellable.rb +8 -1
- data/app/models/gateway_transaction.rb +47 -0
- data/app/models/import.rb +83 -101
- data/app/models/import_error.rb +1 -1
- data/app/models/import_row.rb +1 -1
- data/app/models/imports/donations_import.rb +103 -0
- data/app/models/imports/events_import.rb +207 -0
- data/app/models/imports/people_import.rb +41 -0
- data/app/models/imports/processing.rb +53 -0
- data/app/models/imports/rollback.rb +11 -0
- data/app/models/imports/status.rb +48 -0
- data/app/models/imports/validations.rb +31 -0
- data/app/models/item.rb +112 -29
- data/app/models/job/action_job.rb +29 -0
- data/app/models/job/daily_email_report_job.rb +11 -0
- data/app/models/job/tag_job.rb +15 -0
- data/app/models/kit.rb +14 -6
- data/app/models/kits/mailchimp_kit.rb +448 -0
- data/app/models/kits/reseller_kit.rb +2 -2
- data/app/models/kits/sponsored_donation_kit.rb +2 -2
- data/app/models/orders/application_order.rb +3 -1
- data/app/models/orders/comp_order.rb +15 -2
- data/app/models/orders/exchange_order.rb +8 -0
- data/app/models/orders/imported_order.rb +7 -0
- data/app/models/orders/order.rb +164 -51
- data/app/models/orders/refund_order.rb +14 -1
- data/app/models/orders/unrefundable.rb +5 -0
- data/app/models/orders/web_order.rb +1 -1
- data/app/models/organization.rb +38 -7
- data/app/models/parsed_row.rb +167 -0
- data/app/models/payments/comp_payment.rb +10 -1
- data/app/models/payments/credit_card_payment.rb +63 -10
- data/app/models/payments/payment.rb +28 -0
- data/app/models/person.rb +115 -43
- data/app/models/refund.rb +28 -28
- data/app/models/return.rb +2 -0
- data/app/models/sale.rb +8 -5
- data/app/models/search.rb +117 -0
- data/app/models/section.rb +18 -0
- data/app/models/segment.rb +14 -4
- data/app/models/show.rb +14 -4
- data/app/models/slices.rb +82 -0
- data/app/models/statement.rb +170 -3
- data/app/models/temp_discount.rb +14 -0
- data/app/models/ticket.rb +42 -134
- data/app/models/ticket/pricing.rb +45 -0
- data/app/models/ticket/reports.rb +10 -7
- data/app/models/ticket/sale_transitions.rb +44 -0
- data/app/models/ticket/transfers.rb +50 -0
- data/app/models/user.rb +10 -2
- data/app/models/valuation/lifetime_donations.rb +35 -0
- data/app/models/venue.rb +12 -1
- data/app/presenters/event_presenter.rb +41 -0
- data/app/views/actions/_list.html.haml +1 -2
- data/app/views/actions/new.html.haml +1 -1
- data/app/views/contributions/_form.html.haml +40 -0
- data/app/views/contributions/_sidebar.html.haml +12 -0
- data/app/views/contributions/edit.html.haml +11 -0
- data/app/views/contributions/index.html.haml +2 -2
- data/app/views/contributions/new.html.haml +5 -35
- data/app/views/discounts/_discount_section_fields.html.haml +25 -0
- data/app/views/discounts/_form.html.haml +95 -0
- data/app/views/discounts/edit.html.haml +16 -0
- data/app/views/discounts/index.html.haml +33 -0
- data/app/views/discounts/new.html.haml +16 -0
- data/app/views/discounts_reports/index.html.haml +76 -0
- data/app/views/events/_discount_section_fields.html.haml +25 -0
- data/app/views/events/_glance.html.haml +4 -1
- data/app/views/events/_list.html.haml +2 -4
- data/app/views/events/_menu.html.haml +3 -3
- data/app/views/events/_section_fields.html.haml +32 -15
- data/app/views/events/_share_and_sell.haml +2 -1
- data/app/views/events/edit.html.haml +7 -6
- data/app/views/events/image.html.haml +1 -0
- data/app/views/events/index.html.haml +3 -1
- data/app/views/events/messages.html.haml +1 -0
- data/app/views/events/prices.html.haml +2 -1
- data/app/views/events/resell.html.haml +1 -1
- data/app/views/events/show.html.haml +25 -1
- data/app/views/events/storefront_link.html.haml +1 -1
- data/app/views/events/temp_discount_form.html.haml +108 -0
- data/app/views/events/temp_discounts_index.html.haml +38 -0
- data/app/views/events/widget.html.haml +14 -1
- data/app/views/exchanges/new.html.haml +50 -73
- data/app/views/imports/{_imported.html.haml → donations/_approved.html.haml} +2 -5
- data/app/views/imports/donations/_caching.html.haml +17 -0
- data/app/views/imports/donations/_failed.html.haml +5 -0
- data/app/views/imports/donations/_imported.html.haml +9 -0
- data/app/views/imports/donations/_importing.html.haml +12 -0
- data/app/views/imports/donations/_invalid.html.haml +5 -0
- data/app/views/imports/donations/_new.html.haml +99 -0
- data/app/views/imports/donations/_pending.html.haml +41 -0
- data/app/views/imports/events/_approved.html.haml +10 -0
- data/app/views/imports/events/_caching.html.haml +17 -0
- data/app/views/imports/events/_failed.html.haml +5 -0
- data/app/views/imports/events/_imported.html.haml +9 -0
- data/app/views/imports/events/_importing.html.haml +12 -0
- data/app/views/imports/events/_invalid.html.haml +5 -0
- data/app/views/imports/events/_new.html.haml +95 -0
- data/app/views/imports/events/_pending.html.haml +35 -0
- data/app/views/imports/index.html.haml +41 -18
- data/app/views/imports/new.html.haml +1 -93
- data/app/views/imports/{_approved.html.haml → people/_approved.html.haml} +0 -1
- data/app/views/imports/{_caching.html.haml → people/_caching.html.haml} +0 -0
- data/app/views/imports/people/_failed.html.haml +5 -0
- data/app/views/imports/people/_imported.html.haml +25 -0
- data/app/views/imports/{_importing.html.haml → people/_importing.html.haml} +1 -2
- data/app/views/imports/people/_invalid.html.haml +5 -0
- data/app/views/imports/people/_new.html.haml +120 -0
- data/app/views/imports/people/_pending.html.haml +39 -0
- data/app/views/imports/shared/_date_format.html.haml +14 -0
- data/app/views/imports/shared/_failed.html.haml +18 -0
- data/app/views/imports/shared/_inspect_modal.html.haml +11 -0
- data/app/views/imports/shared/_invalid.html.haml +18 -0
- data/app/views/imports/shared/_knowledge_base.haml +2 -0
- data/app/views/imports/shared/_sidebar.html.haml +5 -0
- data/app/views/imports/show.html.haml +2 -2
- data/app/views/index/dashboard.html.haml +4 -2
- data/app/views/layouts/_custom_css_includes.haml +0 -0
- data/app/views/layouts/_custom_js_includes.haml +0 -0
- data/app/views/layouts/_google_analytics.html.haml +3 -3
- data/app/views/layouts/_menu.html.haml +6 -2
- data/app/views/layouts/application.html.haml +4 -0
- data/app/views/layouts/{devise.html.haml → devise_layout.html.haml} +0 -0
- data/app/views/order_mailer/confirmation_for.html.haml +3 -2
- data/app/views/order_mailer/confirmation_for.text.haml +3 -2
- data/app/views/orders/_grouped_form_help.haml +4 -0
- data/app/views/orders/_item_table.haml +15 -4
- data/app/views/orders/_order_sidebar.html.haml +27 -6
- data/app/views/orders/index.html.haml +1 -12
- data/app/views/orders/show.html.haml +1 -1
- data/app/views/organizations/_form.html.haml +20 -6
- data/app/views/organizations/edit.html.haml +2 -1
- data/app/views/organizations/new.html.haml +1 -0
- data/app/views/organizations/show.html.haml +7 -1
- data/app/views/people/_form.html.haml +5 -2
- data/app/views/people/_key_relationships.html.haml +1 -1
- data/app/views/people/_list.html.haml +1 -12
- data/app/views/people/_person_summary_sidebar.html.haml +82 -50
- data/app/views/people/_relationship_table_row.html.haml +1 -1
- data/app/views/people/edit.html.haml +3 -1
- data/app/views/people/index.html.haml +7 -1
- data/app/views/people/new.html.haml +2 -0
- data/app/views/people/show.html.haml +2 -0
- data/app/views/refunds/new.html.haml +4 -6
- data/app/views/reports_mailer/daily.html.haml +67 -0
- data/app/views/reports_mailer/daily.text.erb +16 -0
- data/app/views/sales/new.html.haml +5 -20
- data/app/views/searches/_form.html.haml +43 -0
- data/app/views/searches/_person.html.haml +7 -0
- data/app/views/searches/new.html.haml +10 -0
- data/app/views/searches/show.html.haml +64 -0
- data/app/views/sections/edit.html.haml +12 -0
- data/app/views/segments/index.html.haml +8 -4
- data/app/views/segments/show.html.haml +39 -5
- data/app/views/shared/_door_list_table.haml +24 -0
- data/app/views/shared/_event_image_icon.html.haml +1 -1
- data/app/views/shared/_preload_assets.html.haml +2 -0
- data/app/views/shared/_tags.html.haml +3 -2
- data/app/views/shows/_glance.html.haml +8 -2
- data/app/views/shows/_ticket_table.html.haml +17 -10
- data/app/views/shows/_upcoming.html.haml +1 -1
- data/app/views/shows/door_list.html.haml +2 -24
- data/app/views/shows/index.html.haml +3 -3
- data/app/views/shows/new.html.haml +2 -2
- data/app/views/shows/show.html.haml +1 -1
- data/app/views/slices/_data.json +50 -0
- data/app/views/slices/index.html.haml +58 -0
- data/app/views/statements/_discounts_table.html.haml +26 -0
- data/app/views/statements/_order_location_table.html.haml +20 -0
- data/app/views/statements/_payment_method_table.haml +20 -0
- data/app/views/statements/{_played_shows.html.haml → _shows.html.haml} +3 -3
- data/app/views/statements/_ticket_type_table.haml +20 -0
- data/app/views/statements/_top_stats.haml +12 -0
- data/app/views/statements/show.html.haml +24 -32
- data/app/views/store/events/_show.html.haml +11 -5
- data/app/views/store/events/show.html.haml +24 -5
- data/app/views/users/registrations/edit.html.erb +1 -1
- data/app/views/venues/edit.html.haml +1 -0
- data/config/artfully.yml.sample +3 -0
- data/config/initializers/active_model_serializer.rb +3 -0
- data/config/initializers/braintree_error_mapping.rb +5 -0
- data/config/initializers/devise.rb +1 -1
- data/config/locales/en.yml +1 -0
- data/config/routes.rb +31 -8
- data/db/migrate/0000_set_up_artfully.rb +9 -11
- data/db/migrate/20120809212802_add_do_not_email_to_people.rb +5 -0
- data/db/migrate/20120831200120_create_advanced_search.rb +30 -0
- data/db/migrate/20120926201927_add_email_to_organization.rb +5 -0
- data/db/migrate/20121001143351_add_import_id_orders_events.rb +6 -0
- data/db/migrate/20121006024736_add_import_to_actions.rb +5 -0
- data/db/migrate/20121011180654_add_type_to_imports.rb +14 -0
- data/db/migrate/20121024143846_create_discounts.rb +15 -0
- data/db/migrate/20121026131454_deleted_at_to_orders_items_actions.rb +7 -0
- data/db/migrate/20121026203948_add_initial_price_to_tickets.rb +5 -0
- data/db/migrate/20121029183949_change_initial_price_to_cart_price.rb +5 -0
- data/db/migrate/20121113144826_migrate_donation_types.rb +41 -0
- data/db/migrate/20121115020441_add_salutation_to_people.rb +5 -0
- data/db/migrate/20121130004314_add_visibility_to_sections.rb +6 -0
- data/db/migrate/20121205184343_add_discount_to_ticket.rb +6 -0
- data/db/migrate/20121206212835_add_discount_to_carts_and_items.rb +7 -0
- data/db/migrate/20121211193728_add_deleted_at_to_discounts.rb +5 -0
- data/db/migrate/20121212022026_add_uuid_to_show_and_event.rb +9 -0
- data/db/migrate/20121212023203_set_uuids.rb +11 -0
- data/db/migrate/20121217201422_add_minimum_ticket_count_to_discounts.rb +5 -0
- data/db/migrate/20121221154152_add_shows_and_sections_to_discounts.rb +5 -0
- data/db/migrate/20130103153946_make_shows_and_sections_habtm.rb +19 -0
- data/db/migrate/20130108213102_add_original_price_to_items.rb +10 -0
- data/db/migrate/20130111211929_convert_discounts_sections_to_array_of_strings.rb +14 -0
- data/db/migrate/20130114200128_add_discount_code_to_search.rb +5 -0
- data/db/migrate/20130114212408_add_limit_to_discounts.rb +5 -0
- data/db/migrate/20130116203331_add_title_to_person.rb +5 -0
- data/db/migrate/20130122143845_install_audited.rb +28 -0
- data/db/migrate/20130131024955_add_gateway_transactions.rb +13 -0
- data/db/migrate/20130301144159_add_receive_daily_sales_report_boolean_to_organizations.rb +5 -0
- data/db/migrate/20130306213416_add_subscribed_lists_to_people.rb +5 -0
- data/db/migrate/20130308193328_people_arent_dummies.rb +6 -0
- data/db/migrate/20130312173340_add_categories_to_events.rb +6 -0
- data/db/migrate/20130319110520_add_transaction_id_index.rb +6 -0
- data/db/migrate/20130320192827_add_index_to_notes.rb +8 -0
- data/db/migrate/20130324173939_add_index_to_import_rows.rb +5 -0
- data/db/migrate/20130325190110_add_indexes_to_actions.rb +9 -0
- data/db/migrate/20130326173653_add_lifetime_donations_to_people_and_searches.rb +9 -0
- data/lib/artfully_ose.rb +5 -1
- data/lib/artfully_ose/common_abilities.rb +6 -9
- data/lib/artfully_ose/engine.rb +19 -5
- data/lib/artfully_ose/version.rb +1 -1
- data/lib/email_validator.rb +6 -0
- metadata +442 -138
- data/MIT-LICENSE +0 -20
- data/app/controllers/pages_controller.rb +0 -29
- data/app/models/import_person.rb +0 -78
- data/app/views/imports/_failed.html.haml +0 -20
- data/app/views/imports/_pending.html.haml +0 -35
- data/app/views/index/splash.html.erb +0 -160
- data/app/views/segments/new.html.haml +0 -20
@@ -1,6 +1,6 @@
|
|
1
1
|
class ResellerKit < Kit
|
2
2
|
|
3
|
-
acts_as_kit :with_approval => true do
|
3
|
+
acts_as_kit :with_approval => true, :admin_only => true do
|
4
4
|
activate :unless => :no_owner?
|
5
5
|
approve :unless => :no_bank_account?
|
6
6
|
|
@@ -14,7 +14,7 @@ class ResellerKit < Kit
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def pitch
|
17
|
-
"Resell tickets"
|
17
|
+
"Resell tickets from other producers on your own website."
|
18
18
|
end
|
19
19
|
|
20
20
|
def no_owner?
|
@@ -27,11 +27,11 @@ class SponsoredDonationKit < Kit
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def pitch
|
30
|
-
"Contact support@
|
30
|
+
"Contact support@fracturedatlas.org to learn about Fiscal Sponsorship through Fractured Atlas."
|
31
31
|
end
|
32
32
|
|
33
33
|
def connected?
|
34
|
-
errors.add(:requirements, "You need to connect to your Fractured Atlas Membership to active this kit") unless organization.connected?
|
34
|
+
errors.add(:requirements, "You need to connect to your Fractured Atlas Membership to active this kit.") unless organization.connected?
|
35
35
|
organization.connected?
|
36
36
|
end
|
37
37
|
|
@@ -1,5 +1,18 @@
|
|
1
|
-
class CompOrder < Order
|
2
|
-
|
1
|
+
class CompOrder < Order
|
2
|
+
include Unrefundable
|
3
|
+
|
4
|
+
def self.location
|
3
5
|
"Artful.ly"
|
4
6
|
end
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
self.payment_method = ::CompPayment.payment_method
|
11
|
+
end
|
12
|
+
|
13
|
+
def sell_tickets
|
14
|
+
all_tickets.each do |item|
|
15
|
+
item.product.comp_to(self.person, self.created_at)
|
16
|
+
end
|
17
|
+
end
|
5
18
|
end
|
data/app/models/orders/order.rb
CHANGED
@@ -3,18 +3,23 @@
|
|
3
3
|
class Order < ActiveRecord::Base
|
4
4
|
include ActionView::Helpers::NumberHelper
|
5
5
|
include ActionView::Helpers::TextHelper
|
6
|
-
include ArtfullyOseHelper
|
7
6
|
include Ext::Integrations::Order
|
7
|
+
include OhNoes::Destroy
|
8
|
+
include ArtfullyOseHelper
|
8
9
|
|
9
10
|
#This is a lambda used to by the items to calculate their net
|
10
11
|
attr_accessor :per_item_processing_charge
|
11
12
|
|
13
|
+
attr_accessible :person_id, :organization_id, :person, :organization, :details
|
14
|
+
|
12
15
|
belongs_to :person
|
13
16
|
belongs_to :organization
|
17
|
+
belongs_to :import
|
14
18
|
belongs_to :parent, :class_name => "Order", :foreign_key => "parent_id"
|
19
|
+
belongs_to :gateway_transaction, :primary_key => :transaction_id, :foreign_key => :transaction_id
|
15
20
|
has_many :children, :class_name => "Order", :foreign_key => "parent_id"
|
16
|
-
has_many :items
|
17
|
-
has_many :actions, :foreign_key => "subject_id"
|
21
|
+
has_many :items, :dependent => :destroy
|
22
|
+
has_many :actions, :foreign_key => "subject_id", :dependent => :destroy
|
18
23
|
|
19
24
|
attr_accessor :skip_actions
|
20
25
|
|
@@ -24,16 +29,57 @@ class Order < ActiveRecord::Base
|
|
24
29
|
validates_presence_of :person_id
|
25
30
|
validates_presence_of :organization_id
|
26
31
|
|
32
|
+
# Both of these are handle_asynchronously
|
27
33
|
after_create :create_purchase_action, :unless => :skip_actions
|
28
34
|
after_create :create_donation_actions, :unless => :skip_actions
|
29
35
|
|
36
|
+
after_create :sell_tickets
|
37
|
+
|
30
38
|
default_scope :order => 'orders.created_at DESC'
|
31
39
|
scope :before, lambda { |time| where("orders.created_at < ?", time) }
|
32
40
|
scope :after, lambda { |time| where("orders.created_at > ?", time) }
|
33
41
|
scope :imported, where("fa_id IS NOT NULL")
|
34
42
|
scope :not_imported, where("fa_id IS NULL")
|
43
|
+
scope :csv_imported, where("import_id IS NOT NULL")
|
44
|
+
scope :csv_not_imported, where("import_id IS NULL")
|
35
45
|
scope :artfully, where("transaction_id IS NOT NULL")
|
36
46
|
|
47
|
+
searchable do
|
48
|
+
text :details, :id, :type, :location, :transaction_id, :payment_method, :special_instructions
|
49
|
+
|
50
|
+
[:first_name, :last_name, :email].each do |person_field|
|
51
|
+
text person_field do
|
52
|
+
person.send(person_field) unless person.nil?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
text :organization_id do
|
57
|
+
organization.id
|
58
|
+
end
|
59
|
+
|
60
|
+
text :organization_name do
|
61
|
+
organization.name
|
62
|
+
end
|
63
|
+
|
64
|
+
text :event_name do
|
65
|
+
items.map{ |item| item.show.event.name unless item.show.nil? }
|
66
|
+
end
|
67
|
+
|
68
|
+
string :details, :id, :type, :location, :transaction_id, :payment_method, :special_instructions
|
69
|
+
string :organization_id do
|
70
|
+
organization.id
|
71
|
+
end
|
72
|
+
|
73
|
+
string :organization_name do
|
74
|
+
organization.name
|
75
|
+
end
|
76
|
+
|
77
|
+
string :event_name, :multiple => true do
|
78
|
+
items.map{ |item| item.show.event.name unless item.show.nil? }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
include Ext::DelayedIndexing
|
82
|
+
|
37
83
|
def self.in_range(start, stop, organization_id = nil)
|
38
84
|
query = after(start).before(stop).includes(:items, :person, :organization).order("created_at DESC")
|
39
85
|
if organization_id.present?
|
@@ -48,6 +94,10 @@ class Order < ActiveRecord::Base
|
|
48
94
|
end
|
49
95
|
|
50
96
|
def location
|
97
|
+
self.class.location
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.location
|
51
101
|
""
|
52
102
|
end
|
53
103
|
|
@@ -58,13 +108,13 @@ class Order < ActiveRecord::Base
|
|
58
108
|
def nongift_amount
|
59
109
|
all_items.inject(0) {|sum, item| sum + item.nongift_amount.to_i }
|
60
110
|
end
|
61
|
-
|
62
|
-
def
|
63
|
-
|
111
|
+
|
112
|
+
def destroyable?
|
113
|
+
( (type.eql? "ApplicationOrder") || (type.eql? "ImportedOrder") ) && !is_fafs? && !artfully? && has_single_donation?
|
64
114
|
end
|
65
|
-
|
66
|
-
def
|
67
|
-
|
115
|
+
|
116
|
+
def editable?
|
117
|
+
( (type.eql? "ApplicationOrder") || (type.eql? "ImportedOrder") ) && !is_fafs? && !artfully? && has_single_donation?
|
68
118
|
end
|
69
119
|
|
70
120
|
def for_organization(org)
|
@@ -76,12 +126,12 @@ class Order < ActiveRecord::Base
|
|
76
126
|
end
|
77
127
|
|
78
128
|
def payment
|
79
|
-
|
129
|
+
CreditCardPayment.new(:transaction_id => transaction_id)
|
80
130
|
end
|
81
131
|
|
82
|
-
def record_exchange!
|
83
|
-
items.
|
84
|
-
item.to_exchange!
|
132
|
+
def record_exchange!(exchanged_items)
|
133
|
+
items.each_with_index do |item, index|
|
134
|
+
item.to_exchange! exchanged_items[index]
|
85
135
|
end
|
86
136
|
end
|
87
137
|
|
@@ -93,15 +143,30 @@ class Order < ActiveRecord::Base
|
|
93
143
|
all_items.select(&:ticket?)
|
94
144
|
end
|
95
145
|
|
146
|
+
#TODO: Undupe these methods
|
147
|
+
def tickets
|
148
|
+
items.select(&:ticket?)
|
149
|
+
end
|
150
|
+
|
96
151
|
def all_donations
|
97
152
|
all_items.select(&:donation?)
|
98
153
|
end
|
99
154
|
|
155
|
+
def donations
|
156
|
+
items.select(&:donation?)
|
157
|
+
end
|
158
|
+
#End dupes
|
159
|
+
|
160
|
+
def has_single_donation?
|
161
|
+
(donations.size == 1) && tickets.empty?
|
162
|
+
end
|
163
|
+
|
100
164
|
def settleable_donations
|
101
165
|
all_donations.reject(&:modified?)
|
102
166
|
end
|
103
167
|
|
104
168
|
def refundable_items
|
169
|
+
return [] unless Payment.create(payment_method).refundable?
|
105
170
|
items.select(&:refundable?)
|
106
171
|
end
|
107
172
|
|
@@ -109,6 +174,10 @@ class Order < ActiveRecord::Base
|
|
109
174
|
items.select(&:exchangeable?)
|
110
175
|
end
|
111
176
|
|
177
|
+
def returnable_items
|
178
|
+
items.select { |i| i.returnable? and i.comped? and not i.refundable? }
|
179
|
+
end
|
180
|
+
|
112
181
|
def num_tickets
|
113
182
|
all_tickets.size
|
114
183
|
end
|
@@ -122,11 +191,22 @@ class Order < ActiveRecord::Base
|
|
122
191
|
end
|
123
192
|
|
124
193
|
def sum_donations
|
125
|
-
all_donations.collect{|item| item.
|
194
|
+
all_donations.collect{|item| item.total_price.to_i}.sum
|
195
|
+
end
|
196
|
+
|
197
|
+
#
|
198
|
+
# Will return an array of all discount codes on all items on this order
|
199
|
+
#
|
200
|
+
def discounts_used
|
201
|
+
items.map{|i| i.discount.try(:code)}.reject(&:blank?).uniq
|
126
202
|
end
|
127
203
|
|
128
204
|
def ticket_details
|
129
|
-
|
205
|
+
discount_string = ""
|
206
|
+
unless discounts_used.empty?
|
207
|
+
discount_string = ", used #{'discount'.pluralize(discounts_used.length)} " + discounts_used.join(",")
|
208
|
+
end
|
209
|
+
Ticket.to_sentence(self.tickets.map(&:product)) + discount_string
|
130
210
|
end
|
131
211
|
|
132
212
|
def to_comp!
|
@@ -141,16 +221,11 @@ class Order < ActiveRecord::Base
|
|
141
221
|
|
142
222
|
def donation_details
|
143
223
|
if is_fafs?
|
144
|
-
|
145
|
-
"#{number_as_cents sum_donations} donation via Fractured Atlas for the benefit of #{o.fiscally_sponsored_project.name}"
|
224
|
+
"#{number_as_cents sum_donations} donation made through Fractured Atlas"
|
146
225
|
else
|
147
226
|
"#{number_as_cents sum_donations} donation"
|
148
227
|
end
|
149
228
|
end
|
150
|
-
|
151
|
-
def returnable_items
|
152
|
-
items.select { |i| i.returnable? and not i.refundable? }
|
153
|
-
end
|
154
229
|
|
155
230
|
def ticket_summary
|
156
231
|
summary = TicketSummary.new
|
@@ -161,46 +236,84 @@ class Order < ActiveRecord::Base
|
|
161
236
|
end
|
162
237
|
|
163
238
|
def credit?
|
164
|
-
payment_method.eql?
|
239
|
+
payment_method.eql? CreditCardPayment.payment_method
|
240
|
+
end
|
241
|
+
|
242
|
+
def cash?
|
243
|
+
payment_method.eql? CashPayment.payment_method
|
244
|
+
end
|
245
|
+
|
246
|
+
def original_order
|
247
|
+
if self.parent.nil?
|
248
|
+
return self
|
249
|
+
else
|
250
|
+
return self.parent.original_order
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
#
|
255
|
+
# If this order has no transaction_id, run up the parent chain until we hit one
|
256
|
+
# This is needed for exchanges that ultimately need to be refunded
|
257
|
+
#
|
258
|
+
def transaction_id
|
259
|
+
read_attribute(:transaction_id) || self.parent.try(:transaction_id)
|
260
|
+
end
|
261
|
+
|
262
|
+
def sell_tickets
|
263
|
+
all_tickets.each do |item|
|
264
|
+
item.product.sell_to(self.person, self.created_at)
|
265
|
+
end
|
165
266
|
end
|
166
267
|
|
167
268
|
def time_zone
|
168
269
|
"Eastern Time (US & Canada)"
|
169
270
|
end
|
170
271
|
|
171
|
-
|
272
|
+
def contact_email
|
273
|
+
items.try(:first).try(:show).try(:event).try(:contact_email)
|
274
|
+
end
|
172
275
|
|
173
|
-
|
174
|
-
|
175
|
-
|
276
|
+
def create_donation_actions
|
277
|
+
items.select(&:donation?).collect do |item|
|
278
|
+
action = GiveAction.new
|
279
|
+
action.person = person
|
280
|
+
action.subject = self
|
281
|
+
action.organization_id = organization.id
|
282
|
+
action.details = donation_details
|
283
|
+
action.occurred_at = created_at
|
284
|
+
action.subtype = "Monetary"
|
285
|
+
action.save!
|
286
|
+
action
|
287
|
+
end
|
288
|
+
end
|
289
|
+
handle_asynchronously :create_donation_actions
|
290
|
+
|
291
|
+
def create_purchase_action
|
292
|
+
unless all_tickets.empty?
|
293
|
+
action = purchase_action_class.new
|
294
|
+
action.person = person
|
295
|
+
action.subject = self
|
296
|
+
action.organization = organization
|
297
|
+
action.details = ticket_details
|
298
|
+
action.occurred_at = created_at
|
299
|
+
|
300
|
+
#Weird, but Rails can't initialize these so the subtype is hardcoded in the model
|
301
|
+
action.subtype = action.subtype
|
302
|
+
action.import = self.import if self.import
|
303
|
+
action.save!
|
304
|
+
action
|
176
305
|
end
|
306
|
+
end
|
307
|
+
handle_asynchronously :create_purchase_action
|
177
308
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
action.person = person
|
182
|
-
action.subject = self
|
183
|
-
action.organization_id = organization.id
|
184
|
-
action.details = ticket_details
|
185
|
-
action.occurred_at = created_at
|
186
|
-
action.subtype = "Purchase"
|
309
|
+
def purchase_action_class
|
310
|
+
GetAction
|
311
|
+
end
|
187
312
|
|
188
|
-
|
189
|
-
action
|
190
|
-
end
|
191
|
-
end
|
313
|
+
private
|
192
314
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
action.person = person
|
197
|
-
action.subject = self
|
198
|
-
action.organization_id = organization.id
|
199
|
-
action.details = donation_details
|
200
|
-
action.occurred_at = created_at
|
201
|
-
action.subtype = "Donation"
|
202
|
-
action.save!
|
203
|
-
action
|
204
|
-
end
|
315
|
+
#this used to do more. Now it only does this
|
316
|
+
def merge_and_sort_items
|
317
|
+
items
|
205
318
|
end
|
206
319
|
end
|
@@ -1,5 +1,18 @@
|
|
1
1
|
class RefundOrder < Order
|
2
|
-
|
2
|
+
include Unrefundable
|
3
|
+
|
4
|
+
def self.location
|
3
5
|
"Artful.ly"
|
4
6
|
end
|
7
|
+
|
8
|
+
def sell_tickets
|
9
|
+
end
|
10
|
+
|
11
|
+
def purchase_action_class
|
12
|
+
RefundAction
|
13
|
+
end
|
14
|
+
|
15
|
+
def ticket_details
|
16
|
+
"received refund for " + pluralize(num_tickets, "ticket")
|
17
|
+
end
|
5
18
|
end
|
data/app/models/organization.rb
CHANGED
@@ -3,12 +3,13 @@ class Organization < ActiveRecord::Base
|
|
3
3
|
include Ext::Resellable::Organization
|
4
4
|
include Ext::Integrations::Organization
|
5
5
|
|
6
|
-
attr_accessible :name, :time_zone
|
6
|
+
attr_accessible :name, :time_zone, :ein, :legal_organization_name, :email, :receive_daily_sales_report
|
7
7
|
|
8
8
|
has_many :events
|
9
9
|
has_many :charts
|
10
10
|
has_many :shows
|
11
11
|
has_many :tickets
|
12
|
+
has_many :discounts
|
12
13
|
|
13
14
|
has_many :people
|
14
15
|
has_many :segments
|
@@ -23,10 +24,12 @@ class Organization < ActiveRecord::Base
|
|
23
24
|
|
24
25
|
has_many :imports
|
25
26
|
|
26
|
-
validates_presence_of :name
|
27
|
+
validates_presence_of :name, :email
|
27
28
|
validates :ein, :presence => true, :if => :updating_tax_info
|
28
29
|
validates :legal_organization_name, :presence => true, :if => :updating_tax_info
|
29
30
|
|
31
|
+
scope :receiving_sales_email, where(:receive_daily_sales_report => true)
|
32
|
+
|
30
33
|
#
|
31
34
|
# We aren't interested in FAFS donations, so override lifetime_orders
|
32
35
|
# to only include Artfully orders see: Valuation::LifetimeValue
|
@@ -35,6 +38,33 @@ class Organization < ActiveRecord::Base
|
|
35
38
|
orders.where('transaction_id is not null')
|
36
39
|
end
|
37
40
|
|
41
|
+
#
|
42
|
+
# Returns Tag objects. For an array of tag strings, call unique_tag_strings_for
|
43
|
+
#
|
44
|
+
# This has been supersceded by tags_on and tag_counts_on in acts_as_taggable_on
|
45
|
+
# But those methods have not been added to a release yet.
|
46
|
+
#
|
47
|
+
def tags_for(tagged_association)
|
48
|
+
|
49
|
+
#Yak
|
50
|
+
begin
|
51
|
+
self.send(tagged_association.to_sym)
|
52
|
+
rescue NoMethodError
|
53
|
+
raise NoMethodError, "No tagged has_many association found for #{tagged_association.to_sym}"
|
54
|
+
end
|
55
|
+
|
56
|
+
table_name = Kernel.const_get(tagged_association.to_s.classify).table_name
|
57
|
+
|
58
|
+
ActsAsTaggableOn::Tag.joins("INNER JOIN taggings ON tags.id = taggings.tag_id")
|
59
|
+
.joins("INNER JOIN #{table_name} ON #{table_name}.id = taggings.taggable_id")
|
60
|
+
.joins("INNER JOIN organizations ON organizations.id = #{table_name}.organization_id")
|
61
|
+
.where("organizations.id = ?", self.id)
|
62
|
+
end
|
63
|
+
|
64
|
+
def unique_tag_strings_for(tagged_association)
|
65
|
+
self.tags_for(tagged_association).all.map(&:name).uniq
|
66
|
+
end
|
67
|
+
|
38
68
|
def owner
|
39
69
|
users.first
|
40
70
|
end
|
@@ -53,7 +83,8 @@ class Organization < ActiveRecord::Base
|
|
53
83
|
@updating_tax_info = true
|
54
84
|
update_attributes({
|
55
85
|
:ein => params[:ein],
|
56
|
-
:legal_organization_name => params[:legal_organization_name]
|
86
|
+
:legal_organization_name => params[:legal_organization_name],
|
87
|
+
:email => params[:email]
|
57
88
|
})
|
58
89
|
end
|
59
90
|
|
@@ -62,7 +93,7 @@ class Organization < ActiveRecord::Base
|
|
62
93
|
end
|
63
94
|
|
64
95
|
def available_kits
|
65
|
-
Kit.pad_with_new_kits(kits)
|
96
|
+
Kit.pad_with_new_kits(kits)
|
66
97
|
end
|
67
98
|
|
68
99
|
def authorization_hash
|
@@ -72,11 +103,11 @@ class Organization < ActiveRecord::Base
|
|
72
103
|
end
|
73
104
|
|
74
105
|
def donations
|
75
|
-
Item.
|
106
|
+
Item.includes(:order => [:person => :address]).where(:product_type => "Donation", :orders => { :organization_id => id })
|
76
107
|
end
|
77
108
|
|
78
109
|
def ticket_sales
|
79
|
-
Item.
|
110
|
+
Item.includes(:show, :order => [:person => :address]).where(:product_type => "Ticket", :orders => { :organization_id => id })
|
80
111
|
end
|
81
112
|
|
82
113
|
def has_kit?(name)
|
@@ -90,7 +121,7 @@ class Organization < ActiveRecord::Base
|
|
90
121
|
private
|
91
122
|
|
92
123
|
def check_for_duplicates(kit)
|
93
|
-
raise Kit::DuplicateError if kits.
|
124
|
+
raise Kit::DuplicateError if kits.find{|k| k.type == kit.type}
|
94
125
|
end
|
95
126
|
|
96
127
|
def donation_type
|