solidus_subscriptions 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +41 -0
- data/.gem_release.yml +5 -0
- data/.github/stale.yml +17 -0
- data/.github_changelog_generator +2 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.rubocop.yml +12 -0
- data/.rubocop_todo.yml +86 -0
- data/CHANGELOG.md +191 -0
- data/Gemfile +33 -0
- data/LICENSE +26 -0
- data/README.md +221 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/spree/backend/solidus_subscriptions.js +1 -0
- data/app/assets/javascripts/spree/backend/solidus_subscriptions/edit_subscription_payment.js +32 -0
- data/app/controllers/solidus_subscriptions/api/v1/base_controller.rb +13 -0
- data/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb +48 -0
- data/app/controllers/solidus_subscriptions/api/v1/subscriptions_controller.rb +100 -0
- data/app/controllers/spree/admin/installments_controller.rb +25 -0
- data/app/controllers/spree/admin/subscription_events_controller.rb +37 -0
- data/app/controllers/spree/admin/subscription_orders_controller.rb +35 -0
- data/app/controllers/spree/admin/subscriptions_controller.rb +100 -0
- data/app/controllers/spree/admin/users/subscriptions_controller.rb +17 -0
- data/app/decorators/controllers/solidus_subscriptions/spree/api/line_items_controller/create_subscription_line_items.rb +36 -0
- data/app/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items.rb +35 -0
- data/app/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association.rb +26 -0
- data/app/decorators/models/solidus_subscriptions/spree/order/after_create.rb +19 -0
- data/app/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions.rb +23 -0
- data/app/decorators/models/solidus_subscriptions/spree/order/installment_details_association.rb +15 -0
- data/app/decorators/models/solidus_subscriptions/spree/order/subscription_association.rb +15 -0
- data/app/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association.rb +19 -0
- data/app/decorators/models/solidus_subscriptions/spree/product/delegate_subscribable.rb +17 -0
- data/app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb +30 -0
- data/app/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions.rb +20 -0
- data/app/decorators/models/solidus_subscriptions/spree/variant/variant_pretty_name.rb +17 -0
- data/app/decorators/models/solidus_subscriptions/spree/wallet_payment_source/report_default_change_to_subscriptions.rb +28 -0
- data/app/jobs/solidus_subscriptions/process_installment_job.rb +13 -0
- data/app/jobs/solidus_subscriptions/process_subscription_job.rb +31 -0
- data/app/models/solidus_subscriptions/installment.rb +135 -0
- data/app/models/solidus_subscriptions/installment_detail.rb +28 -0
- data/app/models/solidus_subscriptions/interval.rb +26 -0
- data/app/models/solidus_subscriptions/line_item.rb +42 -0
- data/app/models/solidus_subscriptions/promotion/rules/subscription_creation_order.rb +44 -0
- data/app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb +31 -0
- data/app/models/solidus_subscriptions/subscription.rb +392 -0
- data/app/models/solidus_subscriptions/subscription_event.rb +11 -0
- data/app/overrides/views/admin_subscribable_product_checkbox.rb +8 -0
- data/app/overrides/views/admin_subscribable_variant_checkbox.rb +8 -0
- data/app/overrides/views/admin_subscriptions_menu_link.rb +10 -0
- data/app/overrides/views/admin_users_subscriptions_tab.rb +8 -0
- data/app/overrides/views/subscription_line_item_fields.rb +8 -0
- data/app/subscribers/solidus_subscriptions/churn_buster_subscriber.rb +39 -0
- data/app/subscribers/solidus_subscriptions/event_storage_subscriber.rb +64 -0
- data/app/views/spree/admin/installments/_state_pill.html.erb +8 -0
- data/app/views/spree/admin/installments/index.html.erb +42 -0
- data/app/views/spree/admin/products/_subscribable_checkbox.html.erb +8 -0
- data/app/views/spree/admin/promotions/rules/_subscription_creation_order.html.erb +0 -0
- data/app/views/spree/admin/promotions/rules/_subscription_installment_order.html.erb +0 -0
- data/app/views/spree/admin/shared/_subscription_actions.html.erb +35 -0
- data/app/views/spree/admin/shared/_subscription_breadcrumbs.html.erb +4 -0
- data/app/views/spree/admin/shared/_subscription_sidebar.html.erb +18 -0
- data/app/views/spree/admin/shared/_subscription_tab.html.erb +3 -0
- data/app/views/spree/admin/shared/_subscription_tabs.html.erb +18 -0
- data/app/views/spree/admin/subscription_events/_state_pill.html.erb +8 -0
- data/app/views/spree/admin/subscription_events/index.html.erb +42 -0
- data/app/views/spree/admin/subscription_orders/index.html.erb +93 -0
- data/app/views/spree/admin/subscriptions/_form.html.erb +150 -0
- data/app/views/spree/admin/subscriptions/_processing_state_pill.html.erb +9 -0
- data/app/views/spree/admin/subscriptions/_state_pill.html.erb +10 -0
- data/app/views/spree/admin/subscriptions/edit.html.erb +10 -0
- data/app/views/spree/admin/subscriptions/index.html.erb +176 -0
- data/app/views/spree/admin/subscriptions/new.html.erb +5 -0
- data/app/views/spree/admin/users/_subscription_tab.html.erb +5 -0
- data/app/views/spree/admin/users/subscriptions/index.html.erb +44 -0
- data/app/views/spree/admin/variants/_subscribable_checkbox.html.erb +6 -0
- data/app/views/spree/frontend/products/_subscription_line_item_fields.html.erb +30 -0
- data/bin/console +17 -0
- data/bin/rails +7 -0
- data/bin/rails-engine +13 -0
- data/bin/rails-sandbox +16 -0
- data/bin/rake +7 -0
- data/bin/sandbox +86 -0
- data/bin/setup +8 -0
- data/config/initializers/permission_sets.rb +11 -0
- data/config/initializers/subscribers.rb +9 -0
- data/config/locales/en.yml +129 -0
- data/config/routes.rb +34 -0
- data/db/migrate/20160825164850_create_solidus_subscriptions_subscriptions.rb +11 -0
- data/db/migrate/20160825173548_create_solidus_subscriptions_line_items.rb +17 -0
- data/db/migrate/20160825202248_create_solidus_subscriptions_installments.rb +23 -0
- data/db/migrate/20160825211202_create_solidus_subscriptions_installment_details.rb +22 -0
- data/db/migrate/20160825214240_add_subscribable_to_spree_variants.rb +5 -0
- data/db/migrate/20160829201653_change_subscription_line_items_installments_to_max_installments.rb +5 -0
- data/db/migrate/20160902220242_remove_state_from_solidus_susbscriptions_installment_details.rb +5 -0
- data/db/migrate/20160902220604_add_successful_to_solidus_subscriptions_installment_details.rb +5 -0
- data/db/migrate/20160902221218_add_message_to_solidus_subscriptions_installment_details.rb +5 -0
- data/db/migrate/20160922164101_add_interval_length_and_units_to_subscription_line_items.rb +8 -0
- data/db/migrate/20161006191003_add_skip_count_to_solidus_subscriptions_subscriptions.rb +5 -0
- data/db/migrate/20161006191127_add_successive_skip_count_to_solidus_subscriptions_subscriptions.rb +5 -0
- data/db/migrate/20161014212649_allow_spree_line_item_id_to_be_null.rb +5 -0
- data/db/migrate/20161017155749_add_order_id_to_solidus_subscriptions_installment_details.rb +6 -0
- data/db/migrate/20161017175509_remove_order_id_from_solidus_subscriptions_installments.rb +5 -0
- data/db/migrate/20161017201944_add_subscription_order_to_spree_orders.rb +5 -0
- data/db/migrate/20161221155142_add_store_to_solidus_subscriptions_subscriptions.rb +6 -0
- data/db/migrate/20161223152905_add_address_id_to_solidus_subscriptions_subscriptions.rb +7 -0
- data/db/migrate/20170106224713_change_line_item_max_installments_to_end_date.rb +6 -0
- data/db/migrate/20170111224458_change_subscription_actionable_date_to_datetime.rb +5 -0
- data/db/migrate/20170111232801_change_inteval_actionable_date_to_datetime.rb +5 -0
- data/db/migrate/20170112012407_add_config_options_to_subscriptions.rb +7 -0
- data/db/migrate/20200617102749_add_billing_address_to_subscriptions.rb +11 -0
- data/db/migrate/20200617155042_add_payment_source_to_subscriptions.rb +6 -0
- data/db/migrate/20200618092951_add_payment_method_to_subscriptions.rb +11 -0
- data/db/migrate/20200730101242_create_solidus_subscriptions_subscription_events.rb +22 -0
- data/db/migrate/20200917072152_add_subscription_reference_to_orders.rb +11 -0
- data/db/migrate/20201007140032_add_guest_token_to_subscriptions.rb +6 -0
- data/db/migrate/20201123171026_change_actionable_date_to_date.rb +15 -0
- data/db/migrate/20210205140422_add_currency_to_subscription.rb +5 -0
- data/db/migrate/20210323165714_update_promotion_rule_names.rb +22 -0
- data/lib/generators/solidus_subscriptions/install/install_generator.rb +32 -0
- data/lib/generators/solidus_subscriptions/install/templates/initializer.rb +99 -0
- data/lib/solidus_subscriptions.rb +49 -0
- data/lib/solidus_subscriptions/checkout.rb +74 -0
- data/lib/solidus_subscriptions/churn_buster/client.rb +48 -0
- data/lib/solidus_subscriptions/churn_buster/order_serializer.rb +19 -0
- data/lib/solidus_subscriptions/churn_buster/serializer.rb +23 -0
- data/lib/solidus_subscriptions/churn_buster/subscription_customer_serializer.rb +28 -0
- data/lib/solidus_subscriptions/churn_buster/subscription_payment_method_serializer.rb +37 -0
- data/lib/solidus_subscriptions/churn_buster/subscription_serializer.rb +17 -0
- data/lib/solidus_subscriptions/configuration.rb +84 -0
- data/lib/solidus_subscriptions/dispatcher/base.rb +18 -0
- data/lib/solidus_subscriptions/dispatcher/failure_dispatcher.rb +13 -0
- data/lib/solidus_subscriptions/dispatcher/out_of_stock_dispatcher.rb +11 -0
- data/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher.rb +19 -0
- data/lib/solidus_subscriptions/dispatcher/success_dispatcher.rb +17 -0
- data/lib/solidus_subscriptions/engine.rb +56 -0
- data/lib/solidus_subscriptions/permission_sets/default_customer.rb +19 -0
- data/lib/solidus_subscriptions/permission_sets/subscription_management.rb +12 -0
- data/lib/solidus_subscriptions/permitted_attributes.rb +20 -0
- data/lib/solidus_subscriptions/processor.rb +17 -0
- data/lib/solidus_subscriptions/subscription_generator.rb +77 -0
- data/lib/solidus_subscriptions/subscription_line_item_builder.rb +23 -0
- data/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb +11 -0
- data/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb +29 -0
- data/lib/solidus_subscriptions/testing_support/factories/line_item_factory.rb +20 -0
- data/lib/solidus_subscriptions/testing_support/factories/spree/line_item_factory.rb +17 -0
- data/lib/solidus_subscriptions/testing_support/factories/spree/order_factory.rb +17 -0
- data/lib/solidus_subscriptions/testing_support/factories/spree_modification_factory.rb +10 -0
- data/lib/solidus_subscriptions/testing_support/factories/subscription_event_factory.rb +8 -0
- data/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb +56 -0
- data/lib/solidus_subscriptions/version.rb +5 -0
- data/lib/tasks/process_subscriptions.rake +8 -0
- data/reference/solidus_subscriptions.v1.yaml +290 -0
- data/solidus_subscriptions.gemspec +47 -0
- data/spec/controllers/spree/admin/subscriptions_controller_spec.rb +202 -0
- data/spec/controllers/spree/api/line_items_controller_spec.rb +103 -0
- data/spec/controllers/spree/api/orders_controller_spec.rb +57 -0
- data/spec/controllers/spree/api/users_controller_spec.rb +48 -0
- data/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb +80 -0
- data/spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb +10 -0
- data/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb +32 -0
- data/spec/decorators/models/solidus_subscriptions/spree/order/installment_details_association_spec.rb +9 -0
- data/spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb +9 -0
- data/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb +22 -0
- data/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb +25 -0
- data/spec/features/admin/subscription_orders_spec.rb +35 -0
- data/spec/features/admin/subscriptions_spec.rb +63 -0
- data/spec/features/admin_users_subscription_tabs_spec.rb +61 -0
- data/spec/fixtures/cassettes/churn_buster.yml +229 -0
- data/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb +38 -0
- data/spec/jobs/solidus_subscriptions/process_subscription_job_spec.rb +83 -0
- data/spec/lib/solidus_subscriptions/checkout_spec.rb +125 -0
- data/spec/lib/solidus_subscriptions/churn_buster/client_spec.rb +59 -0
- data/spec/lib/solidus_subscriptions/dispatcher/failure_dispatcher_spec.rb +29 -0
- data/spec/lib/solidus_subscriptions/dispatcher/out_of_stock_dispatcher_spec.rb +15 -0
- data/spec/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher_spec.rb +44 -0
- data/spec/lib/solidus_subscriptions/dispatcher/success_dispatcher_spec.rb +30 -0
- data/spec/lib/solidus_subscriptions/permission_sets/default_customer_spec.rb +95 -0
- data/spec/lib/solidus_subscriptions/permission_sets/subscription_management_spec.rb +26 -0
- data/spec/lib/solidus_subscriptions/processor_spec.rb +34 -0
- data/spec/lib/solidus_subscriptions/promotion/rules/subscription_creation_order_spec.rb +57 -0
- data/spec/lib/solidus_subscriptions/promotion/rules/subscription_installment_order_spec.rb +39 -0
- data/spec/lib/solidus_subscriptions/subscription_generator_spec.rb +83 -0
- data/spec/lib/solidus_subscriptions_spec.rb +30 -0
- data/spec/models/solidus_subscriptions/installment_detail_spec.rb +23 -0
- data/spec/models/solidus_subscriptions/installment_spec.rb +201 -0
- data/spec/models/solidus_subscriptions/line_item_spec.rb +29 -0
- data/spec/models/solidus_subscriptions/subscription_spec.rb +814 -0
- data/spec/models/spree/variant_spec.rb +16 -0
- data/spec/models/spree/wallet_payment_source_spec.rb +20 -0
- data/spec/requests/api/v1/line_items_spec.rb +116 -0
- data/spec/requests/api/v1/subscriptions_spec.rb +255 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb +76 -0
- data/spec/support/active_model_mocks.rb +1 -0
- data/spec/support/cancancan.rb +1 -0
- data/spec/support/factories.rb +1 -0
- data/spec/support/helpers/checkout_infrastructure.rb +18 -0
- data/spec/support/helpers/config.rb +13 -0
- data/spec/support/shoulda.rb +7 -0
- data/spec/support/timecop.rb +1 -0
- data/spec/support/vcr.rb +10 -0
- data/spec/support/version_cake.rb +8 -0
- metadata +498 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusSubscriptions
|
4
|
+
class SubscriptionEvent < ApplicationRecord
|
5
|
+
belongs_to :subscription, class_name: 'SolidusSubscriptions::Subscription', inverse_of: :events
|
6
|
+
|
7
|
+
after_initialize do
|
8
|
+
self.details ||= {}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
virtual_path: "spree/admin/products/_form",
|
5
|
+
name: "solidus_subscriptions_product_subscribable_checkbox",
|
6
|
+
insert_after: "[data-hook='admin_product_form_promotionable']",
|
7
|
+
partial: "spree/admin/products/subscribable_checkbox"
|
8
|
+
)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
virtual_path: "spree/admin/variants/_form",
|
5
|
+
name: "solidus_subscriptions_variant_subscribable_checkbox",
|
6
|
+
insert_after: "[data-hook='track_inventory']",
|
7
|
+
partial: "spree/admin/variants/subscribable_checkbox"
|
8
|
+
)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if !Spree::Backend::Config.respond_to?(:menu_items)
|
4
|
+
Deface::Override.new(
|
5
|
+
virtual_path: 'spree/admin/shared/_menu',
|
6
|
+
name: :add_subcriptions_admin_link,
|
7
|
+
insert_bottom: "[data-hook='admin_tabs']",
|
8
|
+
partial: 'spree/admin/shared/subscription_tab'
|
9
|
+
)
|
10
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
virtual_path: 'spree/admin/users/_tabs',
|
5
|
+
name: 'solidus_subscriptions_admin_users_subscriptions_tab',
|
6
|
+
insert_bottom: "[data-hook='admin_user_tab_options']",
|
7
|
+
partial: 'spree/admin/users/subscription_tab'
|
8
|
+
)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(
|
4
|
+
virtual_path: "spree/products/_cart_form",
|
5
|
+
name: "subscription_line_item_fields",
|
6
|
+
insert_after: "[data-hook='inside_product_cart_form']",
|
7
|
+
partial: "spree/frontend/products/subscription_line_item_fields"
|
8
|
+
)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusSubscriptions
|
4
|
+
module ChurnBusterSubscriber
|
5
|
+
include ::Spree::Event::Subscriber
|
6
|
+
|
7
|
+
event_action :report_subscription_cancellation, event_name: 'solidus_subscriptions.subscription_canceled'
|
8
|
+
event_action :report_subscription_ending, event_name: 'solidus_subscriptions.subscription_ended'
|
9
|
+
event_action :report_payment_success, event_name: 'solidus_subscriptions.installment_succeeded'
|
10
|
+
event_action :report_payment_failure, event_name: 'solidus_subscriptions.installment_failed_payment'
|
11
|
+
event_action :report_payment_method_change, event_name: 'solidus_subscriptions.subscription_payment_method_changed'
|
12
|
+
|
13
|
+
def report_subscription_cancellation(event)
|
14
|
+
churn_buster&.report_subscription_cancellation(event.payload.fetch(:subscription))
|
15
|
+
end
|
16
|
+
|
17
|
+
def report_subscription_ending(event)
|
18
|
+
churn_buster&.report_subscription_cancellation(event.payload.fetch(:subscription))
|
19
|
+
end
|
20
|
+
|
21
|
+
def report_payment_success(event)
|
22
|
+
churn_buster&.report_successful_payment(event.payload.fetch(:order))
|
23
|
+
end
|
24
|
+
|
25
|
+
def report_payment_failure(event)
|
26
|
+
churn_buster&.report_failed_payment(event.payload.fetch(:order))
|
27
|
+
end
|
28
|
+
|
29
|
+
def report_payment_method_change(event)
|
30
|
+
churn_buster&.report_payment_method_change(event.payload.fetch(:subscription))
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def churn_buster
|
36
|
+
SolidusSubscriptions.churn_buster
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusSubscriptions
|
4
|
+
module EventStorageSubscriber
|
5
|
+
include ::Spree::Event::Subscriber
|
6
|
+
|
7
|
+
event_action :track_subscription_created, event_name: 'solidus_subscriptions.subscription_created'
|
8
|
+
event_action :track_subscription_activated, event_name: 'solidus_subscriptions.subscription_activated'
|
9
|
+
event_action :track_subscription_canceled, event_name: 'solidus_subscriptions.subscription_canceled'
|
10
|
+
event_action :track_subscription_ended, event_name: 'solidus_subscriptions.subscription_ended'
|
11
|
+
event_action :track_subscription_shipping_address_changed, event_name: 'solidus_subscriptions.subscription_shipping_address_changed'
|
12
|
+
event_action :track_subscription_billing_address_changed, event_name: 'solidus_subscriptions.subscription_billing_address_changed'
|
13
|
+
event_action :track_subscription_frequency_changed, event_name: 'solidus_subscriptions.subscription_frequency_changed'
|
14
|
+
|
15
|
+
def track_subscription_created(event)
|
16
|
+
event.payload.fetch(:subscription).events.create!(
|
17
|
+
event_type: 'subscription_created',
|
18
|
+
details: event.payload.fetch(:subscription).as_json,
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def track_subscription_activated(event)
|
23
|
+
event.payload.fetch(:subscription).events.create!(
|
24
|
+
event_type: 'subscription_activated',
|
25
|
+
details: event.payload.fetch(:subscription).as_json,
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def track_subscription_canceled(event)
|
30
|
+
event.payload.fetch(:subscription).events.create!(
|
31
|
+
event_type: 'subscription_canceled',
|
32
|
+
details: event.payload.fetch(:subscription).as_json,
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def track_subscription_ended(event)
|
37
|
+
event.payload.fetch(:subscription).events.create!(
|
38
|
+
event_type: 'subscription_ended',
|
39
|
+
details: event.payload.fetch(:subscription).as_json,
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def track_subscription_shipping_address_changed(event)
|
44
|
+
event.payload.fetch(:subscription).events.create!(
|
45
|
+
event_type: 'subscription_shipping_address_changed',
|
46
|
+
details: event.payload.fetch(:subscription).as_json,
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def track_subscription_billing_address_changed(event)
|
51
|
+
event.payload.fetch(:subscription).events.create!(
|
52
|
+
event_type: 'subscription_billing_address_changed',
|
53
|
+
details: event.payload.fetch(:subscription).as_json,
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def track_subscription_frequency_changed(event)
|
58
|
+
event.payload.fetch(:subscription).events.create!(
|
59
|
+
event_type: 'subscription_frequency_changed',
|
60
|
+
details: event.payload.fetch(:subscription).as_json,
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<% content_for(:page_title, t('.title')) %>
|
2
|
+
|
3
|
+
<%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %>
|
4
|
+
<%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %>
|
5
|
+
<%= render 'spree/admin/shared/subscription_tabs', current: :installments, subscription: @subscription %>
|
6
|
+
<%= render 'spree/admin/shared/subscription_actions', subscription: @subscription %>
|
7
|
+
|
8
|
+
<fieldset class="no-border-bottom">
|
9
|
+
<legend><%= t('spree.admin.installments.index.title') %></legend>
|
10
|
+
|
11
|
+
<%= paginate @installments, theme: 'solidus_admin' %>
|
12
|
+
|
13
|
+
<table id="listing_installments" class="index">
|
14
|
+
<thead>
|
15
|
+
<tr data-hook="admin_installments_index_headers">
|
16
|
+
<th><%= sort_link(@search, :created_at, SolidusSubscriptions::Installment.human_attribute_name(:created_at)) %></th>
|
17
|
+
<th><%= sort_link(@search, :actionable_date, SolidusSubscriptions::Installment.human_attribute_name(:actionable_date)) %></th>
|
18
|
+
<th><%= SolidusSubscriptions::Installment.human_attribute_name(:fulfilled) %></th>
|
19
|
+
<th data-hook="admin_installments_index_header_actions" class="actions"></th>
|
20
|
+
</tr>
|
21
|
+
</thead>
|
22
|
+
|
23
|
+
<tbody>
|
24
|
+
<% @installments.each do |installment| %>
|
25
|
+
<tr>
|
26
|
+
<td><%= l(installment.created_at) %></td>
|
27
|
+
<td>
|
28
|
+
<% if installment.actionable_date %>
|
29
|
+
<%= l(installment.actionable_date) %>
|
30
|
+
<% else %>
|
31
|
+
—
|
32
|
+
<% end %>
|
33
|
+
</td>
|
34
|
+
<td><%= render 'state_pill', installment: installment %></td>
|
35
|
+
<td class="actions"></td>
|
36
|
+
</tr>
|
37
|
+
<% end %>
|
38
|
+
</tbody>
|
39
|
+
</table>
|
40
|
+
|
41
|
+
<%= paginate @installments, theme: 'solidus_admin' %>
|
42
|
+
</fieldset>
|
File without changes
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<% content_for :page_actions do %>
|
2
|
+
<% if subscription.state_events.include?(:cancel) %>
|
3
|
+
<%=
|
4
|
+
link_to(
|
5
|
+
t('spree.admin.subscriptions.actions.cancel'),
|
6
|
+
spree.cancel_admin_subscription_path(subscription),
|
7
|
+
method: :delete,
|
8
|
+
data: { confirm: t('spree.admin.subscriptions.actions.cancel_alert') },
|
9
|
+
class: 'btn btn-primary'
|
10
|
+
)
|
11
|
+
%>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<% if subscription.state_events.include?(:activate) %>
|
15
|
+
<%=
|
16
|
+
link_to(
|
17
|
+
t('spree.admin.subscriptions.actions.activate'),
|
18
|
+
spree.activate_admin_subscription_path(subscription),
|
19
|
+
method: :post,
|
20
|
+
class: 'btn btn-primary',
|
21
|
+
)
|
22
|
+
%>
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
<% if subscription.active? %>
|
26
|
+
<%=
|
27
|
+
link_to(
|
28
|
+
t('spree.admin.subscriptions.actions.skip'),
|
29
|
+
spree.skip_admin_subscription_path(subscription),
|
30
|
+
method: :post,
|
31
|
+
class: 'btn btn-default',
|
32
|
+
)
|
33
|
+
%>
|
34
|
+
<% end %>
|
35
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% content_for :sidebar_title do %>
|
2
|
+
<%= t("spree.admin.subscriptions.edit.sidebar") %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% content_for :sidebar do %>
|
6
|
+
<nav class="menu">
|
7
|
+
<fieldset class="no-border-top no-border-bottom" data-hook="admin_user_lifetime_stats">
|
8
|
+
<dl id="user-lifetime-stats">
|
9
|
+
<dt><%= SolidusSubscriptions::Subscription.human_attribute_name(:created_at) %>:</dt>
|
10
|
+
<dd><%= l(subscription.created_at.to_date) %></dd>
|
11
|
+
<dt><%= SolidusSubscriptions::Subscription.human_attribute_name(:state) %>:</dt>
|
12
|
+
<dd><%= render 'spree/admin/subscriptions/state_pill', subscription: subscription %></dd>
|
13
|
+
<dt><%= SolidusSubscriptions::Subscription.human_attribute_name(:processing_state) %>:</dt>
|
14
|
+
<dd><%= render 'spree/admin/subscriptions/processing_state_pill', subscription: subscription %></dd>
|
15
|
+
</dl>
|
16
|
+
</fieldset>
|
17
|
+
</nav>
|
18
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% content_for :tabs do %>
|
2
|
+
<nav>
|
3
|
+
<ul class='tabs' data-hook="admin_subscription_tab_options">
|
4
|
+
<li<%== ' class="active"' if current == :details %>>
|
5
|
+
<%= link_to t("spree.admin.subscriptions.edit.details"), spree.edit_admin_subscription_path(subscription) %>
|
6
|
+
</li>
|
7
|
+
<li<%== ' class="active"' if current == :installments %>>
|
8
|
+
<%= link_to t("spree.admin.subscriptions.edit.installments"), spree.admin_subscription_installments_path(subscription) %>
|
9
|
+
</li>
|
10
|
+
<li<%== ' class="active"' if current == :events %>>
|
11
|
+
<%= link_to t("spree.admin.subscriptions.edit.events"), spree.admin_subscription_subscription_events_path(subscription) %>
|
12
|
+
</li>
|
13
|
+
<li<%== ' class="active"' if current == :orders %>>
|
14
|
+
<%= link_to t("spree.admin.subscriptions.edit.orders"), spree.admin_subscription_subscription_orders_path(subscription) %>
|
15
|
+
</li>
|
16
|
+
</ul>
|
17
|
+
</nav>
|
18
|
+
<% end %>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<% content_for(:page_title, t('.title')) %>
|
2
|
+
|
3
|
+
<%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %>
|
4
|
+
<%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %>
|
5
|
+
<%= render 'spree/admin/shared/subscription_tabs', current: :events, subscription: @subscription %>
|
6
|
+
<%= render 'spree/admin/shared/subscription_actions', subscription: @subscription %>
|
7
|
+
|
8
|
+
<fieldset class="no-border-bottom">
|
9
|
+
<legend><%= t('spree.admin.subscription_events.index.title') %></legend>
|
10
|
+
|
11
|
+
<%= paginate @subscription_events, theme: 'solidus_admin' %>
|
12
|
+
|
13
|
+
<table id="listing_subscription_events" class="index">
|
14
|
+
<thead>
|
15
|
+
<tr data-hook="admin_subscription_events_index_headers">
|
16
|
+
<th><%= SolidusSubscriptions::SubscriptionEvent.human_attribute_name(:event_type) %></th>
|
17
|
+
<th><%= SolidusSubscriptions::SubscriptionEvent.human_attribute_name(:details) %></th>
|
18
|
+
<th><%= sort_link(@search, :created_at, SolidusSubscriptions::SubscriptionEvent.human_attribute_name(:created_at)) %></th>
|
19
|
+
</tr>
|
20
|
+
</thead>
|
21
|
+
|
22
|
+
<tbody>
|
23
|
+
<% @subscription_events.each do |event| %>
|
24
|
+
<tr>
|
25
|
+
<td><%= event.event_type %></td>
|
26
|
+
<td>
|
27
|
+
<% if event.details.is_a?(Hash) %>
|
28
|
+
<% event.details.each_pair do |key, value| %>
|
29
|
+
<strong><%= key %></strong>: <%= value %><br>
|
30
|
+
<% end %>
|
31
|
+
<% else %>
|
32
|
+
<%= event.details %>
|
33
|
+
<% end %>
|
34
|
+
</td>
|
35
|
+
<td><%= l event.created_at %></td>
|
36
|
+
</tr>
|
37
|
+
<% end %>
|
38
|
+
</tbody>
|
39
|
+
</table>
|
40
|
+
|
41
|
+
<%= paginate @subscription_events, theme: 'solidus_admin' %>
|
42
|
+
</fieldset>
|
@@ -0,0 +1,93 @@
|
|
1
|
+
<% content_for(:page_title, t('.title')) %>
|
2
|
+
|
3
|
+
<%= render 'spree/admin/shared/subscription_breadcrumbs', subscription: @subscription %>
|
4
|
+
<%= render 'spree/admin/shared/subscription_sidebar', subscription: @subscription %>
|
5
|
+
<%= render 'spree/admin/shared/subscription_tabs', current: :orders, subscription: @subscription %>
|
6
|
+
<%= render 'spree/admin/shared/subscription_actions', subscription: @subscription %>
|
7
|
+
|
8
|
+
<% content_for :table_filter_title do %>
|
9
|
+
<%= t('spree.filter') %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<% content_for :table_filter do %>
|
13
|
+
<div data-hook="admin_orders_index_search">
|
14
|
+
<%= search_form_for [:admin, @search], url: admin_subscription_subscription_orders_path(@subscription) do |f| %>
|
15
|
+
<div class="row">
|
16
|
+
<div class="field-block col-12 col-md-6 col-lg-8">
|
17
|
+
<div class="date-range-filter field">
|
18
|
+
<%= label_tag :q_created_at_gt, t('spree.date_range') %>
|
19
|
+
<div class="date-range-fields input-group">
|
20
|
+
<%= f.text_field :created_at_gt, class: 'datepicker form-control datepicker-from', placeholder: t('spree.start') %>
|
21
|
+
|
22
|
+
<div class="input-group-prepend input-group-append">
|
23
|
+
<span class="input-group-text range-divider">
|
24
|
+
<i class="fa fa-arrow-right"></i>
|
25
|
+
</span>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<%= f.text_field :created_at_lt, class: 'datepicker form-control datepicker-to', placeholder: t('spree.stop') %>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<div class="field-block col-12 col-md-6 col-lg-4">
|
33
|
+
<div class="field">
|
34
|
+
<%= label_tag :q_state_eq, t('spree.status') %>
|
35
|
+
<%= f.select :state_eq, Spree::Order.state_machines[:state].states.collect {|s| [t(s.name, scope: 'spree.order_state'), s.value]}, {include_blank: true}, class: 'custom-select fullwidth' %>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="clearfix"></div>
|
41
|
+
|
42
|
+
<div class="actions filter-actions">
|
43
|
+
<div data-hook="admin_orders_index_search_buttons">
|
44
|
+
<%= button_tag t('spree.filter_results'), class: 'btn btn-primary' %>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
<% end %>
|
48
|
+
</div>
|
49
|
+
<% end %>
|
50
|
+
|
51
|
+
<fieldset class="no-border-bottom">
|
52
|
+
<legend><%= t('spree.admin.subscription_orders.index.title') %></legend>
|
53
|
+
|
54
|
+
<%= paginate @subscription_orders, theme: 'solidus_admin' %>
|
55
|
+
|
56
|
+
<% if @subscription_orders.any? %>
|
57
|
+
<table id="listing_subscription_orders" class="index">
|
58
|
+
<thead>
|
59
|
+
<tr data-hook="admin_subscription_orders_index_headers">
|
60
|
+
<th><%= sort_link @search, :created_at %></th>
|
61
|
+
<th><%= sort_link @search, :number %></th>
|
62
|
+
<th><%= sort_link @search, :state %></th>
|
63
|
+
<th class="align-right"><%= sort_link @search, :total %></th>
|
64
|
+
<th data-hook="admin_orders_index_header_actions" class="actions"></th>
|
65
|
+
</tr>
|
66
|
+
</thead>
|
67
|
+
|
68
|
+
<tbody>
|
69
|
+
<% @subscription_orders.each do |order| %>
|
70
|
+
<tr class="admin_subscription_order">
|
71
|
+
<td><%= l order.created_at.to_date %></td>
|
72
|
+
<td><%= link_to order.number, edit_admin_order_path(order) %></td>
|
73
|
+
<td>
|
74
|
+
<span class="pill pill-<%= order.state %>">
|
75
|
+
<%= t(order.state, scope: 'spree.order_state') %>
|
76
|
+
</span>
|
77
|
+
</td>
|
78
|
+
<td class="align-right"><%= order.display_total.to_html %></td>
|
79
|
+
<td class='actions align-center' data-hook="admin_orders_index_row_actions">
|
80
|
+
<%= link_to_edit_url edit_admin_order_path(order), title: "admin_edit_#{dom_id(order)}", no_text: true %>
|
81
|
+
</td>
|
82
|
+
</tr>
|
83
|
+
<% end %>
|
84
|
+
</tbody>
|
85
|
+
</table>
|
86
|
+
<% else %>
|
87
|
+
<div class="no-objects-found">
|
88
|
+
<%= render 'spree/admin/shared/no_objects_found', resource: Spree::Order %>
|
89
|
+
</div>
|
90
|
+
<% end %>
|
91
|
+
|
92
|
+
<%= paginate @subscription_orders, theme: 'solidus_admin' %>
|
93
|
+
</fieldset>
|