solidus_legacy_promotions 4.4.0 → 4.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9d7efd633c012b29dd74c0586dac9c26b1a39c90e2ba9fb956843913cf00cf5
4
- data.tar.gz: 5ebe9bde3952c34717157d2229f34c12e79e95a43114bb459966457fa433a97f
3
+ metadata.gz: e6ebac885d12110287f2152e42e064669b4f6eaf137ab7a07741e39636135484
4
+ data.tar.gz: 917e5b3e78b24f99b85301fdf3dae18d1a77b946b4500ccfa090027bff78ea03
5
5
  SHA512:
6
- metadata.gz: f8235d2a505e5c77ed0d1c1867e7fc2296ad1c130b225181225b096deb5f027bfba955fc3ef02824383bb9733956a25badbfd385b6466c478d8fd1947520e487
7
- data.tar.gz: 9cd8c70170387dd5c8c2875bcb6a570704410eded75113d7833e816f05948d48acc592de1272661db249add575ae8ac4e0d1b758238e6f1fbae141e8a480c8c2
6
+ metadata.gz: c6165f9b03a15c4c07b08cd3e571c6abd798e1396d182ea2352f56e604b92594b8fcd02e6951b095aa2497e85c88418bfd0c91c06e4cfff459b496d62fc2b825
7
+ data.tar.gz: 87561f7492154ad168c48d91070cfb8a44da8aae324645044e271b9150ac83a24a3b440824e4504680b51f6ee98acb0670e0e81dfb73eea0a924e238f1594260
@@ -1,3 +1,3 @@
1
- @import "spree/backend/themes/classic";
1
+ @import "spree/backend/globals/variables";
2
2
 
3
3
  @import "solidus_legacy_promotions/promotions/edit";
@@ -2,6 +2,11 @@
2
2
 
3
3
  module SolidusLegacyPromotions
4
4
  module SpreeLineItemDecorator
5
+ def self.prepended(base)
6
+ base.has_many :line_item_actions, dependent: :destroy
7
+ base.has_many :actions, through: :line_item_actions
8
+ end
9
+
5
10
  def total_before_tax
6
11
  amount + adjustments.select { |value| !value.tax? && value.eligible? }.sum(&:amount)
7
12
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ class LineItemAction < Spree::Base
5
+ belongs_to :line_item, optional: true
6
+ belongs_to :action, class_name: "Spree::PromotionAction", optional: true
7
+ end
8
+ end
@@ -14,5 +14,14 @@ module Spree
14
14
  def finished?
15
15
  state == "completed"
16
16
  end
17
+
18
+ def process
19
+ if state == "pending"
20
+ update!(state: "processing")
21
+ PromotionCodeBatchJob.perform_later(self)
22
+ else
23
+ raise CantProcessStartedBatch.new("Batch #{id} already started")
24
+ end
25
+ end
17
26
  end
18
27
  end
@@ -1,4 +1,8 @@
1
1
  en:
2
+ solidus_admin:
3
+ menu_item:
4
+ legacy_promotions: Promotions
5
+ legacy_promotion_categories: Promotion Categories
2
6
  spree:
3
7
  admin:
4
8
  promotion_status:
@@ -23,8 +27,8 @@ en:
23
27
  general: General
24
28
  starts_at_placeholder: Immediately
25
29
  tab:
26
- promotion_categories: Promotion Categories
27
- promotions: Promotions
30
+ legacy_promotions: Promotions
31
+ legacy_promotion_categories: Promotion Categories
28
32
  back_to_promotion_categories_list: Back To Promotions Categories List
29
33
  back_to_promotions_list: Back To Promotions List
30
34
  base_amount: Base Amount
@@ -122,5 +122,17 @@ class SolidusOneFourPromotions < ActiveRecord::Migration[5.0]
122
122
  t.index ["starts_at"], name: "index_spree_promotions_on_starts_at"
123
123
  end
124
124
  end
125
+
126
+ unless table_exists?(:spree_line_item_actions)
127
+ create_table "spree_line_item_actions", force: :cascade do |t|
128
+ t.integer "line_item_id", null: false
129
+ t.integer "action_id", null: false
130
+ t.integer "quantity", default: 0
131
+ t.datetime "created_at", precision: 6
132
+ t.datetime "updated_at", precision: 6
133
+ t.index ["action_id"], name: "index_spree_line_item_actions_on_action_id"
134
+ t.index ["line_item_id"], name: "index_spree_line_item_actions_on_line_item_id"
135
+ end
136
+ end
125
137
  end
126
138
  end
@@ -1,20 +1,5 @@
1
1
  en:
2
- columns:
3
- items:
4
- one: 1 Item
5
- other: '%{count} Items'
6
2
  filters:
7
- status: Status
8
- shipment_state: Shipment State
9
- payment_state: Payment State
10
3
  promotions: Promotions
11
- date:
12
- formats:
13
- short: '%d %b %y'
14
4
  scopes:
15
- all_orders: All
16
- canceled: Canceled
17
- complete: Complete
18
- returned: Returned
19
- in_progress: In Progress
20
5
  promotions: Promotions
@@ -9,7 +9,7 @@ module SolidusLegacyPromotions
9
9
  initializer "solidus_legacy_promotions.add_backend_menu_item" do
10
10
  if SolidusSupport.backend_available?
11
11
  promotions_menu_item = Spree::BackendConfiguration::MenuItem.new(
12
- label: :promotions,
12
+ label: :legacy_promotions,
13
13
  icon: Spree::Backend::Config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn",
14
14
  partial: "spree/admin/shared/promotion_sub_menu",
15
15
  condition: -> { can?(:admin, Spree::Promotion) },
@@ -17,12 +17,14 @@ module SolidusLegacyPromotions
17
17
  data_hook: :admin_promotion_sub_tabs,
18
18
  children: [
19
19
  Spree::BackendConfiguration::MenuItem.new(
20
- label: :promotions,
21
- condition: -> { can?(:admin, Spree::Promotion) }
20
+ label: :legacy_promotions,
21
+ condition: -> { can?(:admin, Spree::Promotion) },
22
+ url: :admin_promotions_path
22
23
  ),
23
24
  Spree::BackendConfiguration::MenuItem.new(
24
- label: :promotion_categories,
25
- condition: -> { can?(:admin, Spree::PromotionCategory) }
25
+ label: :legacy_promotion_categories,
26
+ condition: -> { can?(:admin, Spree::PromotionCategory) },
27
+ url: -> { Spree::Core::Engine.routes.url_helpers.admin_promotion_categories_path },
26
28
  )
27
29
  ]
28
30
  )
@@ -41,10 +43,22 @@ module SolidusLegacyPromotions
41
43
  if SolidusSupport.admin_available?
42
44
  SolidusAdmin::Config.configure do |config|
43
45
  config.menu_items << {
44
- key: "promotions",
46
+ key: "legacy_promotions",
45
47
  route: -> { spree.admin_promotions_path },
46
48
  icon: "megaphone-line",
47
- position: 30
49
+ position: 1.5,
50
+ children: [
51
+ {
52
+ key: "legacy_promotions",
53
+ route: -> { spree.admin_promotions_path },
54
+ position: 1
55
+ },
56
+ {
57
+ key: "legacy_promotion_categories",
58
+ route: -> { spree.admin_promotion_categories_path },
59
+ position: 2
60
+ }
61
+ ]
48
62
  }
49
63
  end
50
64
  end
@@ -86,12 +100,17 @@ module SolidusLegacyPromotions
86
100
  end
87
101
 
88
102
  initializer "solidus_legacy_promotions", after: "spree.load_config_initializers" do
89
- Spree::Config.order_contents_class = "Spree::OrderContents"
90
- Spree::Config.promotions = SolidusLegacyPromotions::Configuration.new
91
- Spree::Config.adjustment_promotion_source_types << "Spree::PromotionAction"
103
+ # Only set these if there is no promotion configuration set. In this case,
104
+ # we're running on a store without the new `solidus_promotions` gem and we
105
+ # need to set the configuration to the legacy one.
106
+ if Spree::Config.promotions.is_a?(Spree::Core::NullPromotionConfiguration)
107
+ Spree::Config.order_contents_class = "Spree::OrderContents"
108
+ Spree::Config.promotions = SolidusLegacyPromotions::Configuration.new
109
+ end
92
110
 
93
111
  Spree::Api::Config.adjustment_attributes << :promotion_code_id
94
112
  Spree::Api::Config.adjustment_attributes << :eligible
113
+ Spree::Config.adjustment_promotion_source_types << "Spree::PromotionAction"
95
114
  end
96
115
  end
97
116
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.metadata['rubygems_mfa_required'] = 'true'
18
18
 
19
19
  s.files = `git ls-files -z`.split("\x0").reject do |f|
20
- f.match(%r{^(spec|script)/})
20
+ f.match(%r{^(spec|bin)/})
21
21
  end
22
22
 
23
23
  s.required_ruby_version = '>= 3.1.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_legacy_promotions
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-12 00:00:00.000000000 Z
11
+ date: 2024-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_api
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.4.0
19
+ version: 4.4.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.4.0
26
+ version: 4.4.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: solidus_core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 4.4.0
33
+ version: 4.4.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 4.4.0
40
+ version: 4.4.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: solidus_support
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,6 @@ files:
82
82
  - app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb
83
83
  - app/decorators/solidus_legacy_promotions/models/spree_order_updater_decorator.rb
84
84
  - app/decorators/solidus_legacy_promotions/models/spree_product_decorator.rb
85
- - app/decorators/solidus_legacy_promotions/models/spree_promotion_code_batch_decorator.rb
86
85
  - app/decorators/solidus_legacy_promotions/models/spree_shipment_decorator.rb
87
86
  - app/helpers/spree/admin/promotions_helper.rb
88
87
  - app/helpers/spree/promotion_rules_helper.rb
@@ -94,6 +93,7 @@ files:
94
93
  - app/models/spree/calculator/percent_on_line_item.rb
95
94
  - app/models/spree/calculator/tiered_flat_rate.rb
96
95
  - app/models/spree/calculator/tiered_percent.rb
96
+ - app/models/spree/line_item_action.rb
97
97
  - app/models/spree/order_contents.rb
98
98
  - app/models/spree/order_promotion.rb
99
99
  - app/models/spree/permission_sets/promotion_display.rb
@@ -140,7 +140,6 @@ files:
140
140
  - app/views/spree/order_mailer/confirm_email.text.erb
141
141
  - app/views/spree/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb
142
142
  - app/views/spree/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb
143
- - bin/rails
144
143
  - config/locales/en.yml
145
144
  - config/locales/promotion_categories.en.yml
146
145
  - config/locales/promotions.en.yml
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SolidusLegacyPromotions
4
- module SpreePromotionCodeBatchDecorator
5
- def process
6
- if state == "pending"
7
- update!(state: "processing")
8
- Spree::PromotionCodeBatchJob.perform_later(self)
9
- else
10
- raise Spree::PromotionCodeBatch::CantProcessStartedBatch.new("Batch #{id} already started")
11
- end
12
- end
13
-
14
- Spree::PromotionCodeBatch.prepend(self)
15
- end
16
- end
data/bin/rails DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails gems
3
- # installed from the root of your application.
4
-
5
- ENGINE_ROOT = File.expand_path('..', __dir__)
6
- ENGINE_PATH = File.expand_path('../lib/solidus_legacy_promotions/engine', __dir__)
7
-
8
- # Set up gems listed in the Gemfile.
9
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __dir__)
10
- require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
11
-
12
- require "rails/all"
13
- require "rails/engine/commands"