solidus_product_assembly 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +35 -0
- data/.gem_release.yml +5 -0
- data/.github/dependabot.yml +7 -0
- data/.github/stale.yml +17 -0
- data/.gitignore +14 -2
- data/.rspec +2 -2
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +192 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile +21 -9
- data/LICENSE +26 -0
- data/README.md +52 -18
- data/Rakefile +4 -19
- data/app/controllers/spree/admin/parts_controller.rb +13 -11
- data/app/decorators/controllers/solidus_product_assembly/spree/checkout_controller_decorator.rb +13 -0
- data/app/decorators/helpers/solidus_product_assembly/spree/admin/orders_helper_decorator.rb +19 -0
- data/app/decorators/models/solidus_product_assembly/spree/inventory_unit_decorator.rb +19 -0
- data/app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb +52 -0
- data/app/decorators/models/solidus_product_assembly/spree/product_decorator.rb +70 -0
- data/app/decorators/models/solidus_product_assembly/spree/return_item_decorator.rb +15 -0
- data/app/decorators/models/solidus_product_assembly/spree/shipment_decorator.rb +55 -0
- data/app/decorators/models/solidus_product_assembly/spree/stock/availability_validator_decorator.rb +37 -0
- data/app/decorators/models/solidus_product_assembly/spree/stock/inventory_unit_builder_decorator.rb +39 -0
- data/app/decorators/models/solidus_product_assembly/spree/stock/inventory_units_finalizer_decorator.rb +33 -0
- data/app/decorators/models/solidus_product_assembly/spree/stock/inventory_validator_decorator.rb +22 -0
- data/app/decorators/models/solidus_product_assembly/spree/variant_decorator.rb +26 -0
- data/app/models/spree/assemblies_part.rb +6 -4
- data/app/models/spree/calculator/returns/assemblies_default_refund_amount.rb +17 -0
- data/app/models/spree/order_inventory_assembly.rb +11 -2
- data/app/overrides/add_admin_product_form_fields.rb +7 -5
- data/app/overrides/add_admin_tabs.rb +7 -5
- data/app/overrides/add_line_item_description.rb +7 -5
- data/app/overrides/spree/admin/orders/_carton_manifest/_assembly_parts_price.html.erb.deface +9 -0
- data/app/overrides/spree/admin/orders/_carton_manifest/_assembly_parts_total_price.html.erb.deface +9 -0
- data/app/overrides/spree/admin/orders/_shipment/stock_contents.html.erb.deface +7 -1
- data/app/overrides/spree/products/show/add_links_to_parts.html.erb.deface +2 -2
- data/app/views/spree/admin/orders/_assemblies.html.erb +8 -17
- data/app/views/spree/admin/orders/_stock_contents.html.erb +2 -62
- data/app/views/spree/admin/orders/_stock_contents_2_3.html.erb +69 -0
- data/app/views/spree/admin/orders/_stock_contents_2_4.html.erb +70 -0
- data/app/views/spree/admin/orders/_stock_item.html.erb +13 -10
- data/app/views/spree/admin/parts/_parts_table.html.erb +17 -11
- data/app/views/spree/admin/parts/available.html.erb +10 -8
- data/app/views/spree/admin/parts/available.js.erb +9 -7
- data/app/views/spree/admin/parts/index.html.erb +1 -1
- data/app/views/spree/admin/products/_product_assembly_fields.html.erb +2 -2
- data/app/views/spree/admin/shared/_product_assembly_product_tabs.html.erb +1 -1
- data/app/views/spree/api/line_items/show.v1.rabl +27 -0
- data/app/views/spree/checkout/_line_item_manifest.html.erb +3 -1
- data/bin/console +17 -0
- data/bin/rails +12 -4
- data/bin/setup +8 -0
- data/config/routes.rb +2 -2
- data/db/migrate/20091028152124_add_many_to_many_relation_to_products.rb +7 -5
- data/db/migrate/20091029165620_add_parts_fields_to_products.rb +18 -16
- data/db/migrate/20120316141830_namespace_product_assembly_for_spree_one.rb +3 -1
- data/db/migrate/20140620223938_add_id_to_spree_assemblies_parts.rb +4 -2
- data/lib/generators/solidus_product_assembly/install/install_generator.rb +13 -8
- data/lib/solidus_product_assembly/engine.rb +11 -8
- data/lib/solidus_product_assembly/testing_support/factories.rb +4 -0
- data/lib/solidus_product_assembly/version.rb +3 -1
- data/lib/solidus_product_assembly.rb +5 -1
- data/lib/tasks/spree2_upgrade.rake +12 -12
- data/solidus_product_assembly.gemspec +25 -20
- data/spec/features/admin/orders_spec.rb +114 -16
- data/spec/features/admin/parts_spec.rb +5 -3
- data/spec/features/admin/return_items_spec.rb +151 -0
- data/spec/features/checkout_spec.rb +103 -21
- data/spec/models/spree/assemblies_part_spec.rb +3 -1
- data/spec/models/spree/inventory_unit_spec.rb +15 -6
- data/spec/models/spree/line_item_spec.rb +6 -4
- data/spec/models/spree/order_contents_spec.rb +6 -5
- data/spec/models/spree/order_inventory_assembly_spec.rb +8 -6
- data/spec/models/spree/order_inventory_spec.rb +7 -3
- data/spec/models/spree/product_spec.rb +15 -14
- data/spec/models/spree/shipment_spec.rb +20 -13
- data/spec/models/spree/stock/availability_validator_spec.rb +22 -33
- data/spec/models/spree/stock/coordinator_spec.rb +11 -3
- data/spec/models/spree/stock/inventory_unit_builder_spec.rb +5 -7
- data/spec/models/spree/variant_spec.rb +3 -1
- data/spec/spec_helper.rb +18 -47
- data/spec/support/shared_contexts/order_with_bundle.rb +2 -0
- metadata +80 -102
- data/.travis.yml +0 -21
- data/LICENSE.md +0 -13
- data/app/controllers/spree/checkout_controller_decorator.rb +0 -9
- data/app/helpers/spree/admin/orders_helper_decorator.rb +0 -9
- data/app/models/spree/inventory_unit_decorator.rb +0 -13
- data/app/models/spree/line_item_decorator.rb +0 -44
- data/app/models/spree/product_decorator.rb +0 -56
- data/app/models/spree/shipment_decorator.rb +0 -50
- data/app/models/spree/stock/availability_validator.rb +0 -28
- data/app/models/spree/stock/inventory_unit_builder_decorator.rb +0 -30
- data/app/models/spree/stock/inventory_validator_decorator.rb +0 -12
- data/app/models/spree/variant_decorator.rb +0 -13
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_product_assembly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Smirnov
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: deface
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: solidus_core
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
@@ -19,7 +33,7 @@ dependencies:
|
|
19
33
|
version: '1.0'
|
20
34
|
- - "<"
|
21
35
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
36
|
+
version: '4'
|
23
37
|
type: :runtime
|
24
38
|
prerelease: false
|
25
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,23 +43,23 @@ dependencies:
|
|
29
43
|
version: '1.0'
|
30
44
|
- - "<"
|
31
45
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
46
|
+
version: '4'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
48
|
+
name: solidus_support
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
36
50
|
requirements:
|
37
51
|
- - "~>"
|
38
52
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
type: :
|
53
|
+
version: '0.8'
|
54
|
+
type: :runtime
|
41
55
|
prerelease: false
|
42
56
|
version_requirements: !ruby/object:Gem::Requirement
|
43
57
|
requirements:
|
44
58
|
- - "~>"
|
45
59
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
60
|
+
version: '0.8'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
62
|
+
name: github_changelog_generator
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
50
64
|
requirements:
|
51
65
|
- - ">="
|
@@ -59,7 +73,7 @@ dependencies:
|
|
59
73
|
- !ruby/object:Gem::Version
|
60
74
|
version: '0'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
76
|
+
name: selenium-webdriver
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
79
|
- - ">="
|
@@ -73,63 +87,7 @@ dependencies:
|
|
73
87
|
- !ruby/object:Gem::Version
|
74
88
|
version: '0'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '4.4'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '4.4'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: capybara
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '2.7'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '2.7'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: poltergeist
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '1.9'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '1.9'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: database_cleaner
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '1.3'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '1.3'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: simplecov
|
90
|
+
name: solidus_dev_support
|
133
91
|
requirement: !ruby/object:Gem::Requirement
|
134
92
|
requirements:
|
135
93
|
- - ">="
|
@@ -148,11 +106,17 @@ executables: []
|
|
148
106
|
extensions: []
|
149
107
|
extra_rdoc_files: []
|
150
108
|
files:
|
109
|
+
- ".circleci/config.yml"
|
110
|
+
- ".gem_release.yml"
|
111
|
+
- ".github/dependabot.yml"
|
112
|
+
- ".github/stale.yml"
|
151
113
|
- ".gitignore"
|
152
114
|
- ".rspec"
|
153
|
-
- ".
|
115
|
+
- ".rubocop.yml"
|
116
|
+
- ".rubocop_todo.yml"
|
117
|
+
- CHANGELOG.md
|
154
118
|
- Gemfile
|
155
|
-
- LICENSE
|
119
|
+
- LICENSE
|
156
120
|
- README.md
|
157
121
|
- Rakefile
|
158
122
|
- app/assets/images/spinner.gif
|
@@ -161,21 +125,26 @@ files:
|
|
161
125
|
- app/assets/stylesheets/spree/backend/solidus_product_assembly.css
|
162
126
|
- app/assets/stylesheets/spree/frontend/solidus_product_assembly.css
|
163
127
|
- app/controllers/spree/admin/parts_controller.rb
|
164
|
-
- app/controllers/spree/checkout_controller_decorator.rb
|
165
|
-
- app/helpers/spree/admin/orders_helper_decorator.rb
|
128
|
+
- app/decorators/controllers/solidus_product_assembly/spree/checkout_controller_decorator.rb
|
129
|
+
- app/decorators/helpers/solidus_product_assembly/spree/admin/orders_helper_decorator.rb
|
130
|
+
- app/decorators/models/solidus_product_assembly/spree/inventory_unit_decorator.rb
|
131
|
+
- app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb
|
132
|
+
- app/decorators/models/solidus_product_assembly/spree/product_decorator.rb
|
133
|
+
- app/decorators/models/solidus_product_assembly/spree/return_item_decorator.rb
|
134
|
+
- app/decorators/models/solidus_product_assembly/spree/shipment_decorator.rb
|
135
|
+
- app/decorators/models/solidus_product_assembly/spree/stock/availability_validator_decorator.rb
|
136
|
+
- app/decorators/models/solidus_product_assembly/spree/stock/inventory_unit_builder_decorator.rb
|
137
|
+
- app/decorators/models/solidus_product_assembly/spree/stock/inventory_units_finalizer_decorator.rb
|
138
|
+
- app/decorators/models/solidus_product_assembly/spree/stock/inventory_validator_decorator.rb
|
139
|
+
- app/decorators/models/solidus_product_assembly/spree/variant_decorator.rb
|
166
140
|
- app/models/spree/assemblies_part.rb
|
167
|
-
- app/models/spree/
|
168
|
-
- app/models/spree/line_item_decorator.rb
|
141
|
+
- app/models/spree/calculator/returns/assemblies_default_refund_amount.rb
|
169
142
|
- app/models/spree/order_inventory_assembly.rb
|
170
|
-
- app/models/spree/product_decorator.rb
|
171
|
-
- app/models/spree/shipment_decorator.rb
|
172
|
-
- app/models/spree/stock/availability_validator.rb
|
173
|
-
- app/models/spree/stock/inventory_unit_builder_decorator.rb
|
174
|
-
- app/models/spree/stock/inventory_validator_decorator.rb
|
175
|
-
- app/models/spree/variant_decorator.rb
|
176
143
|
- app/overrides/add_admin_product_form_fields.rb
|
177
144
|
- app/overrides/add_admin_tabs.rb
|
178
145
|
- app/overrides/add_line_item_description.rb
|
146
|
+
- app/overrides/spree/admin/orders/_carton_manifest/_assembly_parts_price.html.erb.deface
|
147
|
+
- app/overrides/spree/admin/orders/_carton_manifest/_assembly_parts_total_price.html.erb.deface
|
179
148
|
- app/overrides/spree/admin/orders/_form/inject_product_assemblies.html.erb.deface
|
180
149
|
- app/overrides/spree/admin/orders/_shipment/stock_contents.html.erb.deface
|
181
150
|
- app/overrides/spree/checkout/_delivery/remove_unshippable_markup.html.erb.deface
|
@@ -185,6 +154,8 @@ files:
|
|
185
154
|
- app/overrides/spree/shared/_order_details/part_description.html.erb.deface
|
186
155
|
- app/views/spree/admin/orders/_assemblies.html.erb
|
187
156
|
- app/views/spree/admin/orders/_stock_contents.html.erb
|
157
|
+
- app/views/spree/admin/orders/_stock_contents_2_3.html.erb
|
158
|
+
- app/views/spree/admin/orders/_stock_contents_2_4.html.erb
|
188
159
|
- app/views/spree/admin/orders/_stock_item.html.erb
|
189
160
|
- app/views/spree/admin/parts/_parts_table.html.erb
|
190
161
|
- app/views/spree/admin/parts/available.html.erb
|
@@ -193,9 +164,12 @@ files:
|
|
193
164
|
- app/views/spree/admin/parts/update_parts_table.js.erb
|
194
165
|
- app/views/spree/admin/products/_product_assembly_fields.html.erb
|
195
166
|
- app/views/spree/admin/shared/_product_assembly_product_tabs.html.erb
|
167
|
+
- app/views/spree/api/line_items/show.v1.rabl
|
196
168
|
- app/views/spree/checkout/_line_item_manifest.html.erb
|
197
169
|
- app/views/spree/orders/_cart_description.html.erb
|
170
|
+
- bin/console
|
198
171
|
- bin/rails
|
172
|
+
- bin/setup
|
199
173
|
- config/locales/en.yml
|
200
174
|
- config/locales/fr.yml
|
201
175
|
- config/locales/ru.yml
|
@@ -208,11 +182,13 @@ files:
|
|
208
182
|
- lib/generators/solidus_product_assembly/install/install_generator.rb
|
209
183
|
- lib/solidus_product_assembly.rb
|
210
184
|
- lib/solidus_product_assembly/engine.rb
|
185
|
+
- lib/solidus_product_assembly/testing_support/factories.rb
|
211
186
|
- lib/solidus_product_assembly/version.rb
|
212
187
|
- lib/tasks/spree2_upgrade.rake
|
213
188
|
- solidus_product_assembly.gemspec
|
214
189
|
- spec/features/admin/orders_spec.rb
|
215
190
|
- spec/features/admin/parts_spec.rb
|
191
|
+
- spec/features/admin/return_items_spec.rb
|
216
192
|
- spec/features/checkout_spec.rb
|
217
193
|
- spec/models/spree/assemblies_part_spec.rb
|
218
194
|
- spec/models/spree/inventory_unit_spec.rb
|
@@ -229,9 +205,12 @@ files:
|
|
229
205
|
- spec/spec_helper.rb
|
230
206
|
- spec/support/shared_contexts/order_with_bundle.rb
|
231
207
|
homepage: https://solidus.io
|
232
|
-
licenses:
|
233
|
-
|
234
|
-
|
208
|
+
licenses:
|
209
|
+
- BSD-3-Clause
|
210
|
+
metadata:
|
211
|
+
homepage_uri: https://solidus.io
|
212
|
+
source_code_uri: https://github.com/solidusio-contrib/solidus_product_assembly
|
213
|
+
post_install_message:
|
235
214
|
rdoc_options: []
|
236
215
|
require_paths:
|
237
216
|
- lib
|
@@ -239,34 +218,33 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
218
|
requirements:
|
240
219
|
- - ">="
|
241
220
|
- !ruby/object:Gem::Version
|
242
|
-
version:
|
221
|
+
version: '2.4'
|
243
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
223
|
requirements:
|
245
224
|
- - ">="
|
246
225
|
- !ruby/object:Gem::Version
|
247
226
|
version: '0'
|
248
|
-
requirements:
|
249
|
-
|
250
|
-
|
251
|
-
rubygems_version: 2.5.1
|
252
|
-
signing_key:
|
227
|
+
requirements: []
|
228
|
+
rubygems_version: 3.2.20
|
229
|
+
signing_key:
|
253
230
|
specification_version: 4
|
254
231
|
summary: Adds oportunity to make bundle of products to your Spree store
|
255
232
|
test_files:
|
256
|
-
- spec/
|
233
|
+
- spec/spec_helper.rb
|
234
|
+
- spec/features/admin/return_items_spec.rb
|
257
235
|
- spec/features/admin/parts_spec.rb
|
236
|
+
- spec/features/admin/orders_spec.rb
|
258
237
|
- spec/features/checkout_spec.rb
|
259
|
-
- spec/models/spree/assemblies_part_spec.rb
|
260
|
-
- spec/models/spree/inventory_unit_spec.rb
|
261
|
-
- spec/models/spree/line_item_spec.rb
|
262
|
-
- spec/models/spree/order_contents_spec.rb
|
263
|
-
- spec/models/spree/order_inventory_assembly_spec.rb
|
264
|
-
- spec/models/spree/order_inventory_spec.rb
|
265
|
-
- spec/models/spree/product_spec.rb
|
266
238
|
- spec/models/spree/shipment_spec.rb
|
267
|
-
- spec/models/spree/
|
239
|
+
- spec/models/spree/product_spec.rb
|
240
|
+
- spec/models/spree/variant_spec.rb
|
241
|
+
- spec/models/spree/order_inventory_assembly_spec.rb
|
242
|
+
- spec/models/spree/order_contents_spec.rb
|
243
|
+
- spec/models/spree/line_item_spec.rb
|
244
|
+
- spec/models/spree/inventory_unit_spec.rb
|
268
245
|
- spec/models/spree/stock/coordinator_spec.rb
|
246
|
+
- spec/models/spree/stock/availability_validator_spec.rb
|
269
247
|
- spec/models/spree/stock/inventory_unit_builder_spec.rb
|
270
|
-
- spec/models/spree/
|
271
|
-
- spec/
|
248
|
+
- spec/models/spree/order_inventory_spec.rb
|
249
|
+
- spec/models/spree/assemblies_part_spec.rb
|
272
250
|
- spec/support/shared_contexts/order_with_bundle.rb
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
cache: bundler
|
3
|
-
language: ruby
|
4
|
-
rvm:
|
5
|
-
- 2.3.1
|
6
|
-
env:
|
7
|
-
matrix:
|
8
|
-
- SOLIDUS_BRANCH=v1.0 DB=postgres
|
9
|
-
- SOLIDUS_BRANCH=v1.1 DB=postgres
|
10
|
-
- SOLIDUS_BRANCH=v1.2 DB=postgres
|
11
|
-
- SOLIDUS_BRANCH=v1.3 DB=postgres
|
12
|
-
- SOLIDUS_BRANCH=v1.4 DB=postgres
|
13
|
-
- SOLIDUS_BRANCH=v2.0 DB=postgres
|
14
|
-
- SOLIDUS_BRANCH=master DB=postgres
|
15
|
-
- SOLIDUS_BRANCH=v1.0 DB=mysql
|
16
|
-
- SOLIDUS_BRANCH=v1.1 DB=mysql
|
17
|
-
- SOLIDUS_BRANCH=v1.2 DB=mysql
|
18
|
-
- SOLIDUS_BRANCH=v1.3 DB=mysql
|
19
|
-
- SOLIDUS_BRANCH=v1.4 DB=mysql
|
20
|
-
- SOLIDUS_BRANCH=v2.0 DB=mysql
|
21
|
-
- SOLIDUS_BRANCH=master DB=mysql
|
data/LICENSE.md
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
Spree Product Assembly License
|
2
|
-
==============================
|
3
|
-
|
4
|
-
Copyright © 2007-2014, Spree Commerce Inc. and other contributors.
|
5
|
-
All rights reserved.
|
6
|
-
|
7
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
8
|
-
|
9
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
10
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
11
|
-
* Neither the name of Spree Commerce Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
12
|
-
|
13
|
-
_This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner of contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage._
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
InventoryUnit.class_eval do
|
3
|
-
def percentage_of_line_item
|
4
|
-
product = line_item.product
|
5
|
-
if product.assembly?
|
6
|
-
total_value = line_item.quantity_by_variant.map { |part, quantity| part.price * quantity }.sum
|
7
|
-
variant.price / total_value
|
8
|
-
else
|
9
|
-
1 / BigDecimal.new(line_item.quantity)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
LineItem.class_eval do
|
3
|
-
scope :assemblies, -> { joins(:product => :parts).uniq }
|
4
|
-
|
5
|
-
def any_units_shipped?
|
6
|
-
inventory_units.any? { |unit| unit.shipped? }
|
7
|
-
end
|
8
|
-
|
9
|
-
# The parts that apply to this particular LineItem. Usually `product#parts`, but
|
10
|
-
# provided as a hook if you want to override and customize the parts for a specific
|
11
|
-
# LineItem.
|
12
|
-
def parts
|
13
|
-
product.parts
|
14
|
-
end
|
15
|
-
|
16
|
-
# The number of the specified variant that make up this LineItem. By default, calls
|
17
|
-
# `product#count_of`, but provided as a hook if you want to override and customize
|
18
|
-
# the parts available for a specific LineItem. Note that if you only customize whether
|
19
|
-
# a variant is included in the LineItem, and don't customize the quantity of that part
|
20
|
-
# per LineItem, you shouldn't need to override this method.
|
21
|
-
def count_of(variant)
|
22
|
-
product.count_of(variant)
|
23
|
-
end
|
24
|
-
|
25
|
-
def quantity_by_variant
|
26
|
-
if self.product.assembly?
|
27
|
-
{}.tap { |hash| self.product.assemblies_parts.each { |ap| hash[ap.part] = ap.count * self.quantity } }
|
28
|
-
else
|
29
|
-
{ self.variant => self.quantity }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
def update_inventory
|
35
|
-
if (changed? || target_shipment.present?) && self.order.has_checkout_step?("delivery")
|
36
|
-
if self.product.assembly?
|
37
|
-
OrderInventoryAssembly.new(self).verify(target_shipment)
|
38
|
-
else
|
39
|
-
OrderInventory.new(self.order, self).verify(target_shipment)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
Spree::Product.class_eval do
|
2
|
-
has_and_belongs_to_many :parts, :class_name => "Spree::Variant",
|
3
|
-
:join_table => "spree_assemblies_parts",
|
4
|
-
:foreign_key => "assembly_id", :association_foreign_key => "part_id"
|
5
|
-
|
6
|
-
has_many :assemblies_parts, :class_name => "Spree::AssembliesPart",
|
7
|
-
:foreign_key => "assembly_id"
|
8
|
-
|
9
|
-
scope :individual_saled, -> { where(individual_sale: true) }
|
10
|
-
|
11
|
-
scope :search_can_be_part, ->(query){ not_deleted.available.joins(:master)
|
12
|
-
.where(arel_table["name"].matches("%#{query}%").or(Spree::Variant.arel_table["sku"].matches("%#{query}%")))
|
13
|
-
.where(can_be_part: true)
|
14
|
-
.limit(30)
|
15
|
-
}
|
16
|
-
|
17
|
-
validate :assembly_cannot_be_part, :if => :assembly?
|
18
|
-
|
19
|
-
def add_part(variant, count = 1)
|
20
|
-
set_part_count(variant, count_of(variant) + count)
|
21
|
-
end
|
22
|
-
|
23
|
-
def remove_part(variant)
|
24
|
-
set_part_count(variant, 0)
|
25
|
-
end
|
26
|
-
|
27
|
-
def set_part_count(variant, count)
|
28
|
-
ap = assemblies_part(variant)
|
29
|
-
if count > 0
|
30
|
-
ap.count = count
|
31
|
-
ap.save
|
32
|
-
else
|
33
|
-
ap.destroy
|
34
|
-
end
|
35
|
-
reload
|
36
|
-
end
|
37
|
-
|
38
|
-
def assembly?
|
39
|
-
parts.present?
|
40
|
-
end
|
41
|
-
|
42
|
-
def count_of(variant)
|
43
|
-
ap = assemblies_part(variant)
|
44
|
-
# This checks persisted because the default count is 1
|
45
|
-
ap.persisted? ? ap.count : 0
|
46
|
-
end
|
47
|
-
|
48
|
-
def assembly_cannot_be_part
|
49
|
-
errors.add(:can_be_part, Spree.t(:assembly_cannot_be_part)) if can_be_part
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
def assemblies_part(variant)
|
54
|
-
Spree::AssembliesPart.get(self.id, variant.id)
|
55
|
-
end
|
56
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
Shipment.class_eval do
|
3
|
-
# Overriden from Spree core as a product bundle part should not be put
|
4
|
-
# together with an individual product purchased (even though they're the
|
5
|
-
# very same variant) That is so we can tell the store admin which units
|
6
|
-
# were purchased individually and which ones as parts of the bundle
|
7
|
-
#
|
8
|
-
# Account for situations where we can't track the line_item for a variant.
|
9
|
-
# This should avoid exceptions when users upgrade from spree 1.3
|
10
|
-
#
|
11
|
-
# TODO Can possibly be removed as well. We already override the manifest
|
12
|
-
# partial so we can get the product there
|
13
|
-
def manifest
|
14
|
-
items = []
|
15
|
-
inventory_units.joins(:variant).includes(:variant, :line_item).group_by(&:variant).each do |variant, units|
|
16
|
-
|
17
|
-
units.group_by(&:line_item).each do |line_item, units|
|
18
|
-
states = {}
|
19
|
-
units.group_by(&:state).each { |state, iu| states[state] = iu.count }
|
20
|
-
line_item ||= order.find_line_item_by_variant(variant)
|
21
|
-
|
22
|
-
part = line_item ? line_item.product.assembly? : false
|
23
|
-
items << OpenStruct.new(part: part,
|
24
|
-
product: line_item.try(:product),
|
25
|
-
line_item: line_item,
|
26
|
-
variant: variant,
|
27
|
-
quantity: units.length,
|
28
|
-
states: states)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
items
|
32
|
-
end
|
33
|
-
|
34
|
-
# There might be scenarios where we don't want to display every single
|
35
|
-
# variant on the shipment. e.g. when ordering a product bundle that includes
|
36
|
-
# 5 other parts. Frontend users should only see the product bundle as a
|
37
|
-
# single item to ship
|
38
|
-
def line_item_manifest
|
39
|
-
inventory_units.includes(:line_item, :variant).group_by(&:line_item).map do |line_item, units|
|
40
|
-
states = {}
|
41
|
-
units.group_by(&:state).each { |state, iu| states[state] = iu.count }
|
42
|
-
OpenStruct.new(line_item: line_item, variant: line_item.variant, quantity: units.length, states: states)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def inventory_units_for_item(line_item, variant)
|
47
|
-
inventory_units.where(line_item_id: line_item.id, variant_id: variant.id)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Stock
|
3
|
-
# Overridden from spree core to make it also check for assembly parts stock
|
4
|
-
class AvailabilityValidator < ActiveModel::Validator
|
5
|
-
def validate(line_item)
|
6
|
-
line_item.quantity_by_variant.each do |variant, variant_quantity|
|
7
|
-
inventory_units = line_item.inventory_units.where(variant: variant).count
|
8
|
-
quantity = variant_quantity - inventory_units
|
9
|
-
|
10
|
-
next if quantity <= 0
|
11
|
-
next unless variant
|
12
|
-
|
13
|
-
quantifier = Stock::Quantifier.new(variant)
|
14
|
-
|
15
|
-
unless quantifier.can_supply? quantity
|
16
|
-
display_name = %Q{#{variant.name}}
|
17
|
-
display_name += %Q{ (#{variant.options_text})} unless variant.options_text.blank?
|
18
|
-
|
19
|
-
line_item.errors[:quantity] << Spree.t(
|
20
|
-
:selected_quantity_not_available,
|
21
|
-
item: display_name.inspect
|
22
|
-
)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Stock
|
3
|
-
InventoryUnitBuilder.class_eval do
|
4
|
-
def units
|
5
|
-
@order.line_items.flat_map do |line_item|
|
6
|
-
line_item.quantity_by_variant.flat_map do |variant, quantity|
|
7
|
-
quantity.times.map { build_inventory_unit(variant, line_item) }
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def build_inventory_unit(variant, line_item)
|
13
|
-
@order.inventory_units.includes(
|
14
|
-
variant: {
|
15
|
-
product: {
|
16
|
-
shipping_category: {
|
17
|
-
shipping_methods: [:calculator, { zones: :zone_members }]
|
18
|
-
}
|
19
|
-
}
|
20
|
-
}
|
21
|
-
).build(
|
22
|
-
pending: true,
|
23
|
-
variant: variant,
|
24
|
-
line_item: line_item,
|
25
|
-
order: @order
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
Spree::Stock::InventoryValidator.class_eval do
|
2
|
-
def validate(line_item)
|
3
|
-
total_quantity = line_item.quantity_by_variant.values.sum
|
4
|
-
|
5
|
-
if line_item.inventory_units.count != total_quantity
|
6
|
-
line_item.errors[:inventory] << Spree.t(
|
7
|
-
:inventory_not_available,
|
8
|
-
item: line_item.variant.name
|
9
|
-
)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Spree::Variant.class_eval do
|
2
|
-
has_and_belongs_to_many :assemblies, :class_name => "Spree::Product",
|
3
|
-
:join_table => "spree_assemblies_parts",
|
4
|
-
:foreign_key => "part_id", :association_foreign_key => "assembly_id"
|
5
|
-
|
6
|
-
def assemblies_for(products)
|
7
|
-
assemblies.where(id: products)
|
8
|
-
end
|
9
|
-
|
10
|
-
def part?
|
11
|
-
assemblies.exists?
|
12
|
-
end
|
13
|
-
end
|