solidus_legacy_promotions 4.4.2 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/spree/promotion.rb +1 -5
- data/app/{decorators/solidus_legacy_promotions/controllers/solidus_admin/solidus_admin_adjustments_controller_decorator.rb → patches/controllers/solidus_legacy_promotions/solidus_admin_adjustments_controller_patch.rb} +1 -1
- data/app/{decorators/solidus_legacy_promotions/lib/spree_order_state_machine_decorator.rb → patches/lib/solidus_legacy_promotions/spree_order_state_machine_patch.rb} +1 -1
- data/app/{decorators/solidus_legacy_promotions/models/spree_adjustment_decorator.rb → patches/models/solidus_legacy_promotions/spree_adjustment_patch.rb} +1 -1
- data/app/{decorators/solidus_legacy_promotions/models/spree_calculator_returns_default_refund_amount_decorator.rb → patches/models/solidus_legacy_promotions/spree_calculator_returns_default_refund_amount_patch.rb} +1 -1
- data/app/{decorators/solidus_legacy_promotions/models/spree_line_item_decorator.rb → patches/models/solidus_legacy_promotions/spree_line_item_patch.rb} +1 -1
- data/app/{decorators/solidus_legacy_promotions/models/spree_order_decorator.rb → patches/models/solidus_legacy_promotions/spree_order_patch.rb} +1 -1
- data/app/{decorators/solidus_legacy_promotions/models/spree_order_updater_decorator.rb → patches/models/solidus_legacy_promotions/spree_order_updater_patch.rb} +8 -2
- data/app/{decorators/solidus_legacy_promotions/models/spree_product_decorator.rb → patches/models/solidus_legacy_promotions/spree_product_patch.rb} +1 -1
- data/app/{decorators/solidus_legacy_promotions/models/spree_shipment_decorator.rb → patches/models/solidus_legacy_promotions/spree_shipment_patch.rb} +1 -1
- data/config/locales/promotion_categories.en.yml +5 -1
- data/config/routes.rb +1 -1
- data/lib/components/admin/solidus_admin/promotion_categories/edit/component.html.erb +16 -0
- data/lib/components/admin/solidus_admin/promotion_categories/edit/component.rb +4 -0
- data/lib/components/admin/solidus_admin/promotion_categories/edit/component.yml +4 -0
- data/lib/components/admin/solidus_admin/promotion_categories/index/component.rb +21 -8
- data/lib/components/admin/solidus_admin/promotion_categories/new/component.html.erb +16 -0
- data/lib/components/admin/solidus_admin/promotion_categories/new/component.rb +4 -0
- data/lib/components/admin/solidus_admin/promotion_categories/new/component.yml +4 -0
- data/lib/controllers/admin/solidus_admin/promotion_categories_controller.rb +6 -20
- data/lib/solidus_legacy_promotions/engine.rb +3 -1
- data/solidus_legacy_promotions.gemspec +2 -1
- metadata +44 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dabc3ca26441e104f5394fa375a74dc3d91466ecefb926a7209533a37238a72b
|
4
|
+
data.tar.gz: 55aa9a715ad54b4bb8402df2d49e678357354a9269e8bbf92b986966cc6f7e81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c7b7773b72ffa10a90a1b2d5b559b0f8dd790deb3bc5d8bb099bdab21152165cf70d54d09497fb33e2b61628c607e22def196d3e4214cbabdff6e1e5b168103
|
7
|
+
data.tar.gz: 7ef941c441d8fbb2f156158ed96bab406d860622172bbefdfa1fb3f664043e3f7ccb28f8d3debaa71e4c809ea7ac961dedb092d06673af988d064ce5308db3ad
|
@@ -204,11 +204,7 @@ module Spree
|
|
204
204
|
|
205
205
|
if eligible?(order, promotion_code:)
|
206
206
|
rules = eligible_rules(order)
|
207
|
-
|
208
|
-
true
|
209
|
-
else
|
210
|
-
rules.all? { |rule| rule.actionable? line_item }
|
211
|
-
end
|
207
|
+
rules.blank? || rules.all? { |rule| rule.actionable? line_item }
|
212
208
|
else
|
213
209
|
false
|
214
210
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SolidusLegacyPromotions
|
4
|
-
module
|
4
|
+
module SpreeAdjustmentPatch
|
5
5
|
def self.prepended(base)
|
6
6
|
base.belongs_to :promotion_code, class_name: 'Spree::PromotionCode', optional: true
|
7
7
|
base.validates :promotion_code, presence: true, if: :require_promotion_code?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SolidusLegacyPromotions
|
4
|
-
module
|
4
|
+
module SpreeOrderUpdaterPatch
|
5
5
|
def update_adjustment_total
|
6
6
|
recalculate_adjustments
|
7
7
|
|
@@ -17,8 +17,14 @@ module SolidusLegacyPromotions
|
|
17
17
|
|
18
18
|
def update_item_totals
|
19
19
|
[*line_items, *shipments].each do |item|
|
20
|
+
Spree::ItemTotal.new(item).recalculate!
|
21
|
+
|
20
22
|
# The cancellation_total isn't persisted anywhere but is included in
|
21
|
-
# the adjustment_total
|
23
|
+
# the adjustment_total.
|
24
|
+
#
|
25
|
+
# Core doesn't have "eligible" adjustments anymore, so we need to
|
26
|
+
# override the adjustment_total calculation to exclude them for legacy
|
27
|
+
# promotions.
|
22
28
|
item.adjustment_total = item.adjustments.
|
23
29
|
select(&:eligible?).
|
24
30
|
reject(&:included?).
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SolidusLegacyPromotions
|
4
|
-
module
|
4
|
+
module SpreeProductPatch
|
5
5
|
def self.prepended(base)
|
6
6
|
base.has_many :product_promotion_rules, dependent: :destroy
|
7
7
|
base.has_many :promotion_rules, through: :product_promotion_rules
|
@@ -2,5 +2,9 @@ en:
|
|
2
2
|
solidus_admin:
|
3
3
|
promotion_categories:
|
4
4
|
title: "Promotion Categories"
|
5
|
+
create:
|
6
|
+
success: "Promotion category was successfully created."
|
7
|
+
update:
|
8
|
+
success: "Promotion category was successfully updated."
|
5
9
|
destroy:
|
6
|
-
success: "Promotion
|
10
|
+
success: "Promotion categories were successfully removed."
|
data/config/routes.rb
CHANGED
@@ -23,6 +23,6 @@ if SolidusSupport.admin_available?
|
|
23
23
|
extend SolidusAdmin::AdminResources
|
24
24
|
|
25
25
|
admin_resources :promotions, only: [:index, :destroy]
|
26
|
-
admin_resources :promotion_categories,
|
26
|
+
admin_resources :promotion_categories, except: [:show]
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" do %>
|
2
|
+
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
+
<%= form_for @promotion_category, url: form_url, html: { id: form_id } do |f| %>
|
4
|
+
<div class="flex flex-col gap-6 pb-4">
|
5
|
+
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
|
6
|
+
<%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
|
7
|
+
</div>
|
8
|
+
<% modal.with_actions do %>
|
9
|
+
<form method="dialog">
|
10
|
+
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %>
|
11
|
+
</form>
|
12
|
+
<%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
@@ -5,15 +5,24 @@ class SolidusAdmin::PromotionCategories::Index::Component < SolidusAdmin::UI::Pa
|
|
5
5
|
Spree::PromotionCategory
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
|
8
|
+
def title
|
9
|
+
t('solidus_admin.promotion_categories.title')
|
10
|
+
end
|
11
|
+
|
12
|
+
def edit_path(record)
|
13
|
+
solidus_admin.edit_promotion_category_path(record, **search_filter_params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def turbo_frames
|
17
|
+
%w[resource_modal]
|
10
18
|
end
|
11
19
|
|
12
20
|
def page_actions
|
13
21
|
render component("ui/button").new(
|
14
22
|
tag: :a,
|
15
23
|
text: t('.add'),
|
16
|
-
href:
|
24
|
+
href: solidus_admin.new_promotion_category_path(**search_filter_params),
|
25
|
+
data: { turbo_frame: :resource_modal },
|
17
26
|
icon: "add-line",
|
18
27
|
)
|
19
28
|
end
|
@@ -22,7 +31,7 @@ class SolidusAdmin::PromotionCategories::Index::Component < SolidusAdmin::UI::Pa
|
|
22
31
|
[
|
23
32
|
{
|
24
33
|
label: t('.batch_actions.delete'),
|
25
|
-
action: solidus_admin.promotion_categories_path,
|
34
|
+
action: solidus_admin.promotion_categories_path(**search_filter_params),
|
26
35
|
method: :delete,
|
27
36
|
icon: 'delete-bin-7-line',
|
28
37
|
},
|
@@ -39,8 +48,10 @@ class SolidusAdmin::PromotionCategories::Index::Component < SolidusAdmin::UI::Pa
|
|
39
48
|
def name_column
|
40
49
|
{
|
41
50
|
header: :name,
|
42
|
-
data: ->(
|
43
|
-
|
51
|
+
data: ->(record) do
|
52
|
+
link_to record.name, edit_path(record),
|
53
|
+
data: { turbo_frame: :resource_modal },
|
54
|
+
class: 'body-link'
|
44
55
|
end
|
45
56
|
}
|
46
57
|
end
|
@@ -48,8 +59,10 @@ class SolidusAdmin::PromotionCategories::Index::Component < SolidusAdmin::UI::Pa
|
|
48
59
|
def code_column
|
49
60
|
{
|
50
61
|
header: :code,
|
51
|
-
data: ->(
|
52
|
-
|
62
|
+
data: ->(record) do
|
63
|
+
link_to record.code, edit_path(record),
|
64
|
+
data: { turbo_frame: :resource_modal },
|
65
|
+
class: 'body-link'
|
53
66
|
end
|
54
67
|
}
|
55
68
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" do %>
|
2
|
+
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
+
<%= form_for @promotion_category, url: form_url, html: { id: form_id } do |f| %>
|
4
|
+
<div class="flex flex-col gap-6 pb-4">
|
5
|
+
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
|
6
|
+
<%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
|
7
|
+
</div>
|
8
|
+
<% modal.with_actions do %>
|
9
|
+
<form method="dialog">
|
10
|
+
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %>
|
11
|
+
</form>
|
12
|
+
<%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
@@ -1,29 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SolidusAdmin
|
4
|
-
class PromotionCategoriesController < SolidusAdmin::
|
5
|
-
|
4
|
+
class PromotionCategoriesController < SolidusAdmin::ResourcesController
|
5
|
+
private
|
6
6
|
|
7
|
-
def
|
8
|
-
promotion_categories = apply_search_to(
|
9
|
-
Spree::PromotionCategory.all,
|
10
|
-
param: :q,
|
11
|
-
)
|
7
|
+
def resource_class = Spree::PromotionCategory
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
respond_to do |format|
|
16
|
-
format.html { render component('promotion_categories/index').new(page: @page) }
|
17
|
-
end
|
9
|
+
def permitted_resource_params
|
10
|
+
params.require(:promotion_category).permit(:name, :code)
|
18
11
|
end
|
19
12
|
|
20
|
-
def
|
21
|
-
@promotion_categories = Spree::PromotionCategory.where(id: params[:id])
|
22
|
-
|
23
|
-
Spree::PromotionCategory.transaction { @promotion_categories.destroy_all }
|
24
|
-
|
25
|
-
flash[:notice] = t('.success')
|
26
|
-
redirect_back_or_to promotion_categories_path, status: :see_other
|
27
|
-
end
|
13
|
+
def resources_collection = Spree::PromotionCategory.unscoped
|
28
14
|
end
|
29
15
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'solidus_legacy_promotions'
|
4
|
-
|
4
|
+
require 'flickwerk'
|
5
5
|
module SolidusLegacyPromotions
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
include SolidusSupport::EngineExtensions
|
8
8
|
|
9
|
+
include Flickwerk
|
10
|
+
|
9
11
|
initializer "solidus_legacy_promotions.add_backend_menu_item" do
|
10
12
|
if SolidusSupport.backend_available?
|
11
13
|
promotions_menu_item = Spree::BackendConfiguration::MenuItem.new(
|
@@ -23,7 +23,8 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.required_ruby_version = '>= 3.1.0'
|
24
24
|
s.required_rubygems_version = '>= 1.8.23'
|
25
25
|
|
26
|
+
s.add_dependency 'csv', '~> 3.0'
|
26
27
|
s.add_dependency 'solidus_api', s.version
|
27
28
|
s.add_dependency 'solidus_core', s.version
|
28
|
-
s.add_dependency 'solidus_support'
|
29
|
+
s.add_dependency 'solidus_support', '>= 0.13.1', '< 1'
|
29
30
|
end
|
metadata
CHANGED
@@ -1,57 +1,76 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_legacy_promotions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-06 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: csv
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '3.0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '3.0'
|
13
26
|
- !ruby/object:Gem::Dependency
|
14
27
|
name: solidus_api
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
16
29
|
requirements:
|
17
30
|
- - '='
|
18
31
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
32
|
+
version: 4.5.1
|
20
33
|
type: :runtime
|
21
34
|
prerelease: false
|
22
35
|
version_requirements: !ruby/object:Gem::Requirement
|
23
36
|
requirements:
|
24
37
|
- - '='
|
25
38
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
39
|
+
version: 4.5.1
|
27
40
|
- !ruby/object:Gem::Dependency
|
28
41
|
name: solidus_core
|
29
42
|
requirement: !ruby/object:Gem::Requirement
|
30
43
|
requirements:
|
31
44
|
- - '='
|
32
45
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.
|
46
|
+
version: 4.5.1
|
34
47
|
type: :runtime
|
35
48
|
prerelease: false
|
36
49
|
version_requirements: !ruby/object:Gem::Requirement
|
37
50
|
requirements:
|
38
51
|
- - '='
|
39
52
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.
|
53
|
+
version: 4.5.1
|
41
54
|
- !ruby/object:Gem::Dependency
|
42
55
|
name: solidus_support
|
43
56
|
requirement: !ruby/object:Gem::Requirement
|
44
57
|
requirements:
|
45
58
|
- - ">="
|
46
59
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
60
|
+
version: 0.13.1
|
61
|
+
- - "<"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1'
|
48
64
|
type: :runtime
|
49
65
|
prerelease: false
|
50
66
|
version_requirements: !ruby/object:Gem::Requirement
|
51
67
|
requirements:
|
52
68
|
- - ">="
|
53
69
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
70
|
+
version: 0.13.1
|
71
|
+
- - "<"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1'
|
55
74
|
description: Legacy Solidus promotion system
|
56
75
|
email: contact@solidus.io
|
57
76
|
executables: []
|
@@ -74,15 +93,6 @@ files:
|
|
74
93
|
- app/assets/stylesheets/solidus_legacy_promotions/promotions.scss
|
75
94
|
- app/assets/stylesheets/solidus_legacy_promotions/promotions/_edit.scss
|
76
95
|
- app/assets/stylesheets/spree/backend/sections/_adjustments.scss
|
77
|
-
- app/decorators/solidus_legacy_promotions/controllers/solidus_admin/solidus_admin_adjustments_controller_decorator.rb
|
78
|
-
- app/decorators/solidus_legacy_promotions/lib/spree_order_state_machine_decorator.rb
|
79
|
-
- app/decorators/solidus_legacy_promotions/models/spree_adjustment_decorator.rb
|
80
|
-
- app/decorators/solidus_legacy_promotions/models/spree_calculator_returns_default_refund_amount_decorator.rb
|
81
|
-
- app/decorators/solidus_legacy_promotions/models/spree_line_item_decorator.rb
|
82
|
-
- app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb
|
83
|
-
- app/decorators/solidus_legacy_promotions/models/spree_order_updater_decorator.rb
|
84
|
-
- app/decorators/solidus_legacy_promotions/models/spree_product_decorator.rb
|
85
|
-
- app/decorators/solidus_legacy_promotions/models/spree_shipment_decorator.rb
|
86
96
|
- app/helpers/spree/admin/promotions_helper.rb
|
87
97
|
- app/helpers/spree/promotion_rules_helper.rb
|
88
98
|
- app/jobs/spree/promotion_code_batch_job.rb
|
@@ -133,6 +143,15 @@ files:
|
|
133
143
|
- app/models/spree/promotion_rule_store.rb
|
134
144
|
- app/models/spree/promotion_rule_taxon.rb
|
135
145
|
- app/models/spree/promotion_rule_user.rb
|
146
|
+
- app/patches/controllers/solidus_legacy_promotions/solidus_admin_adjustments_controller_patch.rb
|
147
|
+
- app/patches/lib/solidus_legacy_promotions/spree_order_state_machine_patch.rb
|
148
|
+
- app/patches/models/solidus_legacy_promotions/spree_adjustment_patch.rb
|
149
|
+
- app/patches/models/solidus_legacy_promotions/spree_calculator_returns_default_refund_amount_patch.rb
|
150
|
+
- app/patches/models/solidus_legacy_promotions/spree_line_item_patch.rb
|
151
|
+
- app/patches/models/solidus_legacy_promotions/spree_order_patch.rb
|
152
|
+
- app/patches/models/solidus_legacy_promotions/spree_order_updater_patch.rb
|
153
|
+
- app/patches/models/solidus_legacy_promotions/spree_product_patch.rb
|
154
|
+
- app/patches/models/solidus_legacy_promotions/spree_shipment_patch.rb
|
136
155
|
- app/subscribers/spree/order_promotion_subscriber.rb
|
137
156
|
- app/views/spree/order_mailer/cancel_email.html.erb
|
138
157
|
- app/views/spree/order_mailer/cancel_email.text.erb
|
@@ -156,7 +175,13 @@ files:
|
|
156
175
|
- db/migrate/20240621100123_add_promotion_code_id_to_spree_adjustments.rb
|
157
176
|
- db/migrate/20240622113334_move_adjustment_eligible_to_legacy_promotions.rb
|
158
177
|
- lib/components/admin/solidus_admin/orders/show/adjustments/index/source/spree_promotion_action/component.rb
|
178
|
+
- lib/components/admin/solidus_admin/promotion_categories/edit/component.html.erb
|
179
|
+
- lib/components/admin/solidus_admin/promotion_categories/edit/component.rb
|
180
|
+
- lib/components/admin/solidus_admin/promotion_categories/edit/component.yml
|
159
181
|
- lib/components/admin/solidus_admin/promotion_categories/index/component.rb
|
182
|
+
- lib/components/admin/solidus_admin/promotion_categories/new/component.html.erb
|
183
|
+
- lib/components/admin/solidus_admin/promotion_categories/new/component.rb
|
184
|
+
- lib/components/admin/solidus_admin/promotion_categories/new/component.yml
|
160
185
|
- lib/components/admin/solidus_admin/promotions/index/component.rb
|
161
186
|
- lib/components/admin/solidus_admin/promotions/index/component.yml
|
162
187
|
- lib/components/admin/solidus_legacy_promotions/orders/index/component.rb
|
@@ -239,7 +264,6 @@ licenses:
|
|
239
264
|
- BSD-3-Clause
|
240
265
|
metadata:
|
241
266
|
rubygems_mfa_required: 'true'
|
242
|
-
post_install_message:
|
243
267
|
rdoc_options: []
|
244
268
|
require_paths:
|
245
269
|
- lib
|
@@ -254,8 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
278
|
- !ruby/object:Gem::Version
|
255
279
|
version: 1.8.23
|
256
280
|
requirements: []
|
257
|
-
rubygems_version: 3.5
|
258
|
-
signing_key:
|
281
|
+
rubygems_version: 3.6.5
|
259
282
|
specification_version: 4
|
260
283
|
summary: Legacy Solidus promotion system
|
261
284
|
test_files: []
|