solidus_friendly_promotions 1.0.1 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile +1 -1
  4. data/MIGRATING.md +1 -1
  5. data/README.md +22 -16
  6. data/app/assets/config/solidus_friendly_promotions/manifest.js +7 -1
  7. data/app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb +85 -0
  8. data/app/controllers/solidus_friendly_promotions/admin/conditions_controller.rb +69 -0
  9. data/app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb +3 -3
  10. data/app/decorators/models/solidus_friendly_promotions/adjustment_decorator.rb +4 -4
  11. data/app/decorators/models/solidus_friendly_promotions/line_item_decorator.rb +2 -2
  12. data/app/decorators/models/solidus_friendly_promotions/order_decorator.rb +6 -6
  13. data/app/helpers/solidus_friendly_promotions/admin/benefits_helper.rb +19 -0
  14. data/app/helpers/solidus_friendly_promotions/admin/conditions_helper.rb +12 -0
  15. data/app/javascript/solidus_friendly_promotions/controllers/product_option_values_controller.js +1 -1
  16. data/app/javascript/solidus_friendly_promotions/web_components/number_with_currency.js +35 -0
  17. data/app/javascript/solidus_friendly_promotions/{jquery → web_components}/option_value_picker.js +8 -0
  18. data/app/javascript/solidus_friendly_promotions/web_components/product_picker.js +7 -0
  19. data/app/javascript/solidus_friendly_promotions/web_components/select_two.js +11 -0
  20. data/app/javascript/solidus_friendly_promotions/web_components/taxon_picker.js +7 -0
  21. data/app/javascript/solidus_friendly_promotions/web_components/user_picker.js +7 -0
  22. data/app/javascript/solidus_friendly_promotions/web_components/variant_picker.js +7 -0
  23. data/app/javascript/solidus_friendly_promotions.js +7 -11
  24. data/app/models/concerns/solidus_friendly_promotions/{actions/order_level_action.rb → benefits/order_benefit.rb} +2 -2
  25. data/app/models/concerns/solidus_friendly_promotions/{rules/line_item_applicable_order_rule.rb → conditions/line_item_applicable_order_condition.rb} +2 -2
  26. data/app/models/concerns/solidus_friendly_promotions/{rules/line_item_level_rule.rb → conditions/line_item_level_condition.rb} +2 -2
  27. data/app/models/concerns/solidus_friendly_promotions/{rules/order_level_rule.rb → conditions/order_level_condition.rb} +2 -2
  28. data/app/models/concerns/solidus_friendly_promotions/{rules/shipment_level_rule.rb → conditions/shipment_level_condition.rb} +2 -2
  29. data/app/models/solidus_friendly_promotions/{promotion_action.rb → benefit.rb} +48 -11
  30. data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_line_item.rb +6 -2
  31. data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_line_item_quantity_groups.rb +3 -3
  32. data/app/models/solidus_friendly_promotions/{actions → benefits}/adjust_shipment.rb +6 -2
  33. data/app/models/solidus_friendly_promotions/{actions → benefits}/create_discounted_item.rb +6 -7
  34. data/app/models/solidus_friendly_promotions/calculators/distributed_amount.rb +1 -1
  35. data/app/models/solidus_friendly_promotions/calculators/tiered_flat_rate.rb +1 -1
  36. data/app/models/solidus_friendly_promotions/calculators/tiered_percent.rb +1 -1
  37. data/app/models/solidus_friendly_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb +4 -2
  38. data/app/models/solidus_friendly_promotions/{promotion_rule.rb → condition.rb} +13 -7
  39. data/app/models/solidus_friendly_promotions/condition_product.rb +8 -0
  40. data/app/models/solidus_friendly_promotions/condition_store.rb +8 -0
  41. data/app/models/solidus_friendly_promotions/condition_taxon.rb +8 -0
  42. data/app/models/solidus_friendly_promotions/{promotion_rules_user.rb → condition_user.rb} +2 -2
  43. data/app/models/solidus_friendly_promotions/{rules → conditions}/discounted_item_total.rb +3 -3
  44. data/app/models/solidus_friendly_promotions/{rules → conditions}/first_order.rb +3 -3
  45. data/app/models/solidus_friendly_promotions/{rules → conditions}/first_repeat_purchase_since.rb +3 -3
  46. data/app/models/solidus_friendly_promotions/{rules → conditions}/item_total.rb +5 -5
  47. data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_option_value.rb +3 -3
  48. data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_product.rb +8 -8
  49. data/app/models/solidus_friendly_promotions/{rules → conditions}/line_item_taxon.rb +8 -8
  50. data/app/models/solidus_friendly_promotions/{rules → conditions}/minimum_quantity.rb +8 -8
  51. data/app/models/solidus_friendly_promotions/{rules → conditions}/nth_order.rb +5 -5
  52. data/app/models/solidus_friendly_promotions/{rules → conditions}/one_use_per_user.rb +3 -3
  53. data/app/models/solidus_friendly_promotions/{rules → conditions}/option_value.rb +3 -3
  54. data/app/models/solidus_friendly_promotions/{rules → conditions}/product.rb +9 -9
  55. data/app/models/solidus_friendly_promotions/{rules → conditions}/shipping_method.rb +3 -3
  56. data/app/models/solidus_friendly_promotions/{rules → conditions}/store.rb +6 -6
  57. data/app/models/solidus_friendly_promotions/{rules → conditions}/taxon.rb +12 -12
  58. data/app/models/solidus_friendly_promotions/{rules → conditions}/user.rb +7 -7
  59. data/app/models/solidus_friendly_promotions/{rules → conditions}/user_logged_in.rb +3 -3
  60. data/app/models/solidus_friendly_promotions/{rules → conditions}/user_role.rb +3 -3
  61. data/app/models/solidus_friendly_promotions/eligibility_result.rb +1 -1
  62. data/app/models/solidus_friendly_promotions/eligibility_results.rb +7 -7
  63. data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/discount_order.rb +28 -29
  64. data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/load_promotions.rb +10 -11
  65. data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster/persist_discounted_order.rb +2 -2
  66. data/app/models/solidus_friendly_promotions/order_promotion.rb +1 -1
  67. data/app/models/solidus_friendly_promotions/permission_sets/friendly_promotion_management.rb +1 -1
  68. data/app/models/solidus_friendly_promotions/promotion.rb +14 -43
  69. data/app/models/solidus_friendly_promotions/promotion_advertiser.rb +10 -0
  70. data/app/models/solidus_friendly_promotions/promotion_code.rb +1 -1
  71. data/app/models/solidus_friendly_promotions/shipping_rate_discount.rb +1 -1
  72. data/app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_line_item.html.erb +6 -0
  73. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/actions → benefit_fields}/_adjust_line_item_quantity_groups.html.erb +4 -4
  74. data/app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_shipment.html.erb +6 -0
  75. data/app/views/solidus_friendly_promotions/admin/benefit_fields/_calculator_fields.erb +11 -0
  76. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/actions → benefit_fields}/_create_discounted_item.html.erb +8 -6
  77. data/app/views/solidus_friendly_promotions/admin/benefits/_benefit.html.erb +50 -0
  78. data/app/views/solidus_friendly_promotions/admin/benefits/_calculator_select.html.erb +16 -0
  79. data/app/views/solidus_friendly_promotions/admin/benefits/_form.html.erb +3 -0
  80. data/app/views/solidus_friendly_promotions/admin/benefits/_new_benefit.html.erb +33 -0
  81. data/app/views/solidus_friendly_promotions/admin/benefits/_type_select.html.erb +16 -0
  82. data/app/views/solidus_friendly_promotions/admin/benefits/edit.html.erb +19 -0
  83. data/app/views/solidus_friendly_promotions/admin/benefits/new.html.erb +1 -0
  84. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/_default_fields.html.erb +1 -1
  85. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/distributed_amount/_fields.html.erb +3 -3
  86. data/app/views/solidus_friendly_promotions/admin/calculator_fields/flat_rate/_fields.html.erb +6 -0
  87. data/app/views/solidus_friendly_promotions/admin/calculator_fields/flexi_rate/_fields.html.erb +24 -0
  88. data/app/views/solidus_friendly_promotions/admin/calculator_fields/percent/_fields.html.erb +6 -0
  89. data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb +32 -0
  90. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_flat_rate/_tier_fields.html.erb +7 -8
  91. data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb +47 -0
  92. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_percent/_tier_fields.html.erb +8 -7
  93. data/app/views/solidus_friendly_promotions/admin/{promotion_actions/calculators → calculator_fields}/tiered_percent_on_eligible_item_quantity/_fields.html.erb +11 -9
  94. data/app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +35 -0
  95. data/app/views/solidus_friendly_promotions/admin/condition_fields/_first_order.html.erb +3 -0
  96. data/app/views/solidus_friendly_promotions/admin/condition_fields/_first_repeat_purchase_since.html.erb +7 -0
  97. data/app/views/solidus_friendly_promotions/admin/condition_fields/_item_total.html.erb +15 -0
  98. data/app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_option_value.html.erb +25 -0
  99. data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_line_item_product.html.erb +7 -7
  100. data/app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_taxon.html.erb +17 -0
  101. data/app/views/solidus_friendly_promotions/admin/condition_fields/_minimum_quantity.html.erb +5 -0
  102. data/app/views/solidus_friendly_promotions/admin/condition_fields/_nth_order.html.erb +15 -0
  103. data/app/views/solidus_friendly_promotions/admin/condition_fields/_one_use_per_user.html.erb +3 -0
  104. data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_option_value.html.erb +10 -10
  105. data/app/views/solidus_friendly_promotions/admin/condition_fields/_product.html.erb +28 -0
  106. data/app/views/solidus_friendly_promotions/admin/{promotion_rules/rules → condition_fields}/_shipping_method.html.erb +3 -3
  107. data/app/views/solidus_friendly_promotions/admin/condition_fields/_store.html.erb +9 -0
  108. data/app/views/solidus_friendly_promotions/admin/condition_fields/_taxon.html.erb +28 -0
  109. data/app/views/solidus_friendly_promotions/admin/condition_fields/_user.html.erb +7 -0
  110. data/app/views/solidus_friendly_promotions/admin/condition_fields/_user_logged_in.html.erb +3 -0
  111. data/app/views/solidus_friendly_promotions/admin/condition_fields/_user_role.html.erb +15 -0
  112. data/app/views/solidus_friendly_promotions/admin/condition_fields/line_item_option_value/_option_value_fields.html.erb +21 -0
  113. data/app/views/solidus_friendly_promotions/admin/conditions/_condition.html.erb +26 -0
  114. data/app/views/solidus_friendly_promotions/admin/conditions/_new_condition.html.erb +26 -0
  115. data/app/views/solidus_friendly_promotions/admin/conditions/_type_select.html.erb +20 -0
  116. data/app/views/solidus_friendly_promotions/admin/conditions/new.html.erb +1 -0
  117. data/app/views/solidus_friendly_promotions/admin/promotion_code_batches/_form_fields.html.erb +5 -5
  118. data/app/views/solidus_friendly_promotions/admin/promotions/_form.html.erb +4 -4
  119. data/app/views/solidus_friendly_promotions/admin/promotions/_table_filter.html.erb +6 -6
  120. data/app/views/solidus_friendly_promotions/admin/promotions/edit.html.erb +7 -41
  121. data/app/views/solidus_friendly_promotions/admin/shared/_number_with_currency.html.erb +20 -0
  122. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_boolean.html.erb +14 -0
  123. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_decimal.html.erb +12 -0
  124. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
  125. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_integer.html.erb +12 -0
  126. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_password.html.erb +12 -0
  127. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_string.html.erb +12 -0
  128. data/app/views/solidus_friendly_promotions/admin/shared/preference_fields/_text.html.erb +12 -0
  129. data/bin/sandbox +3 -3
  130. data/config/importmap.rb +2 -0
  131. data/config/locales/en.yml +128 -94
  132. data/config/routes.rb +3 -2
  133. data/db/migrate/20231011120928_add_db_comments_to_friendly_promotion_rules_taxons.rb +2 -2
  134. data/db/migrate/20231011142040_add_db_comments_to_friendly_promotion_rules_users.rb +1 -1
  135. data/db/migrate/20231011190222_add_db_comments_to_friendly_promotion_actions.rb +1 -1
  136. data/db/migrate/20240409093831_add_action_reference_to_rules.rb +34 -0
  137. data/db/migrate/20240506142650_remove_promotion_rules_promotion_id.rb +5 -0
  138. data/db/migrate/20240508080834_rename_promotion_rules_to_conditions.rb +19 -0
  139. data/db/migrate/20240508131514_rename_friendly_promotion_actions_to_friendly_benefits.rb +19 -0
  140. data/db/migrate/20240612113608_update_column_comments_for_benefits.rb +31 -0
  141. data/db/migrate/20240612114132_update_column_comments_for_conditions.rb +30 -0
  142. data/db/migrate/20240612115209_update_column_comments_for_condition_stores.rb +23 -0
  143. data/db/migrate/20240612115749_update_column_comments_for_condition_products.rb +22 -0
  144. data/db/migrate/20240612120411_update_column_comments_for_condition_taxons.rb +24 -0
  145. data/db/migrate/20240612121049_update_column_comments_for_condition_users.rb +23 -0
  146. data/lib/generators/solidus_friendly_promotions/install/templates/initializer.rb +30 -30
  147. data/lib/solidus_friendly_promotions/configuration.rb +11 -3
  148. data/lib/solidus_friendly_promotions/migrate_adjustments.rb +11 -11
  149. data/lib/solidus_friendly_promotions/promotion_map.rb +17 -17
  150. data/lib/solidus_friendly_promotions/promotion_migrator.rb +16 -16
  151. data/lib/solidus_friendly_promotions/testing_support/factories/friendly_promotion_factory.rb +8 -34
  152. data/lib/solidus_friendly_promotions/testing_support/factories/friendly_shipping_rate_discount_factory.rb +2 -2
  153. data/lib/solidus_friendly_promotions/version.rb +1 -1
  154. data/lib/tasks/solidus_friendly_promotions/migrate_adjustments.rake +2 -2
  155. data/solidus_friendly_promotions.gemspec +2 -2
  156. metadata +114 -86
  157. data/.rubocop_todo.yml +0 -157
  158. data/app/controllers/solidus_friendly_promotions/admin/promotion_actions_controller.rb +0 -103
  159. data/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb +0 -105
  160. data/app/helpers/solidus_friendly_promotions/admin/promotion_actions_helper.rb +0 -23
  161. data/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb +0 -25
  162. data/app/models/solidus_friendly_promotions/products_promotion_rule.rb +0 -8
  163. data/app/models/solidus_friendly_promotions/promotion_rules_store.rb +0 -8
  164. data/app/models/solidus_friendly_promotions/promotion_rules_taxon.rb +0 -8
  165. data/app/views/solidus_friendly_promotions/admin/promotion_actions/_calculator_select.html.erb +0 -16
  166. data/app/views/solidus_friendly_promotions/admin/promotion_actions/_form.html.erb +0 -3
  167. data/app/views/solidus_friendly_promotions/admin/promotion_actions/_promotion_action.html.erb +0 -29
  168. data/app/views/solidus_friendly_promotions/admin/promotion_actions/_type_select.html.erb +0 -14
  169. data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_line_item.html.erb +0 -6
  170. data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_shipment.html.erb +0 -6
  171. data/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_calculator_fields.erb +0 -9
  172. data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/flat_rate/_fields.html.erb +0 -6
  173. data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_flat_rate/_fields.html.erb +0 -34
  174. data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent/_fields.html.erb +0 -34
  175. data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb +0 -27
  176. data/app/views/solidus_friendly_promotions/admin/promotion_actions/edit.html.erb +0 -23
  177. data/app/views/solidus_friendly_promotions/admin/promotion_actions/new.html.erb +0 -26
  178. data/app/views/solidus_friendly_promotions/admin/promotion_rules/_promotion_rule.html.erb +0 -22
  179. data/app/views/solidus_friendly_promotions/admin/promotion_rules/_type_select.html.erb +0 -20
  180. data/app/views/solidus_friendly_promotions/admin/promotion_rules/new.html.erb +0 -24
  181. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_order.html.erb +0 -3
  182. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_repeat_purchase_since.html.erb +0 -6
  183. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_item_total.html.erb +0 -17
  184. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_option_value.html.erb +0 -25
  185. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_taxon.html.erb +0 -17
  186. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_minimum_quantity.html.erb +0 -5
  187. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_nth_order.html.erb +0 -15
  188. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_one_use_per_user.html.erb +0 -3
  189. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_product.html.erb +0 -44
  190. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_store.html.erb +0 -9
  191. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_taxon.html.erb +0 -44
  192. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user.html.erb +0 -7
  193. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_logged_in.html.erb +0 -3
  194. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_role.html.erb +0 -15
  195. data/app/views/solidus_friendly_promotions/admin/promotion_rules/rules/line_item_option_value/_option_value_fields.html.erb +0 -17
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_friendly_promotions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-07 00:00:00.000000000 Z
11
+ date: 2024-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 4.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5'
22
+ version: '4.4'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 4.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5'
32
+ version: '4.4'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: solidus_support
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -169,7 +169,6 @@ files:
169
169
  - ".gitignore"
170
170
  - ".rspec"
171
171
  - ".rubocop.yml"
172
- - ".rubocop_todo.yml"
173
172
  - ".standard.yml"
174
173
  - CHANGELOG.md
175
174
  - Gemfile
@@ -179,11 +178,11 @@ files:
179
178
  - Rakefile
180
179
  - app/assets/config/solidus_friendly_promotions/manifest.js
181
180
  - app/controllers/solidus_friendly_promotions/admin/base_controller.rb
182
- - app/controllers/solidus_friendly_promotions/admin/promotion_actions_controller.rb
181
+ - app/controllers/solidus_friendly_promotions/admin/benefits_controller.rb
182
+ - app/controllers/solidus_friendly_promotions/admin/conditions_controller.rb
183
183
  - app/controllers/solidus_friendly_promotions/admin/promotion_categories_controller.rb
184
184
  - app/controllers/solidus_friendly_promotions/admin/promotion_code_batches_controller.rb
185
185
  - app/controllers/solidus_friendly_promotions/admin/promotion_codes_controller.rb
186
- - app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb
187
186
  - app/controllers/solidus_friendly_promotions/admin/promotions_controller.rb
188
187
  - app/decorators/models/solidus_friendly_promotions/adjustment_decorator.rb
189
188
  - app/decorators/models/solidus_friendly_promotions/line_item_decorator.rb
@@ -191,8 +190,8 @@ files:
191
190
  - app/decorators/models/solidus_friendly_promotions/order_recalculator_decorator.rb
192
191
  - app/decorators/models/solidus_friendly_promotions/shipment_decorator.rb
193
192
  - app/decorators/models/solidus_friendly_promotions/shipping_rate_decorator.rb
194
- - app/helpers/solidus_friendly_promotions/admin/promotion_actions_helper.rb
195
- - app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb
193
+ - app/helpers/solidus_friendly_promotions/admin/benefits_helper.rb
194
+ - app/helpers/solidus_friendly_promotions/admin/conditions_helper.rb
196
195
  - app/helpers/solidus_friendly_promotions/admin/promotions_helper.rb
197
196
  - app/javascript/solidus_friendly_promotions.js
198
197
  - app/javascript/solidus_friendly_promotions/controllers/application.js
@@ -200,20 +199,27 @@ files:
200
199
  - app/javascript/solidus_friendly_promotions/controllers/flash_controller.js
201
200
  - app/javascript/solidus_friendly_promotions/controllers/index.js
202
201
  - app/javascript/solidus_friendly_promotions/controllers/product_option_values_controller.js
203
- - app/javascript/solidus_friendly_promotions/jquery/option_value_picker.js
202
+ - app/javascript/solidus_friendly_promotions/web_components/number_with_currency.js
203
+ - app/javascript/solidus_friendly_promotions/web_components/option_value_picker.js
204
+ - app/javascript/solidus_friendly_promotions/web_components/product_picker.js
205
+ - app/javascript/solidus_friendly_promotions/web_components/select_two.js
206
+ - app/javascript/solidus_friendly_promotions/web_components/taxon_picker.js
207
+ - app/javascript/solidus_friendly_promotions/web_components/user_picker.js
208
+ - app/javascript/solidus_friendly_promotions/web_components/variant_picker.js
204
209
  - app/jobs/solidus_friendly_promotions/promotion_code_batch_job.rb
205
210
  - app/mailers/solidus_friendly_promotions/promotion_code_batch_mailer.rb
206
- - app/models/concerns/solidus_friendly_promotions/actions/order_level_action.rb
211
+ - app/models/concerns/solidus_friendly_promotions/benefits/order_benefit.rb
207
212
  - app/models/concerns/solidus_friendly_promotions/calculators/promotion_calculator.rb
213
+ - app/models/concerns/solidus_friendly_promotions/conditions/line_item_applicable_order_condition.rb
214
+ - app/models/concerns/solidus_friendly_promotions/conditions/line_item_level_condition.rb
215
+ - app/models/concerns/solidus_friendly_promotions/conditions/order_level_condition.rb
216
+ - app/models/concerns/solidus_friendly_promotions/conditions/shipment_level_condition.rb
208
217
  - app/models/concerns/solidus_friendly_promotions/discountable_amount.rb
209
- - app/models/concerns/solidus_friendly_promotions/rules/line_item_applicable_order_rule.rb
210
- - app/models/concerns/solidus_friendly_promotions/rules/line_item_level_rule.rb
211
- - app/models/concerns/solidus_friendly_promotions/rules/order_level_rule.rb
212
- - app/models/concerns/solidus_friendly_promotions/rules/shipment_level_rule.rb
213
- - app/models/solidus_friendly_promotions/actions/adjust_line_item.rb
214
- - app/models/solidus_friendly_promotions/actions/adjust_line_item_quantity_groups.rb
215
- - app/models/solidus_friendly_promotions/actions/adjust_shipment.rb
216
- - app/models/solidus_friendly_promotions/actions/create_discounted_item.rb
218
+ - app/models/solidus_friendly_promotions/benefit.rb
219
+ - app/models/solidus_friendly_promotions/benefits/adjust_line_item.rb
220
+ - app/models/solidus_friendly_promotions/benefits/adjust_line_item_quantity_groups.rb
221
+ - app/models/solidus_friendly_promotions/benefits/adjust_shipment.rb
222
+ - app/models/solidus_friendly_promotions/benefits/create_discounted_item.rb
217
223
  - app/models/solidus_friendly_promotions/calculators/distributed_amount.rb
218
224
  - app/models/solidus_friendly_promotions/calculators/flat_rate.rb
219
225
  - app/models/solidus_friendly_promotions/calculators/flexi_rate.rb
@@ -221,6 +227,29 @@ files:
221
227
  - app/models/solidus_friendly_promotions/calculators/tiered_flat_rate.rb
222
228
  - app/models/solidus_friendly_promotions/calculators/tiered_percent.rb
223
229
  - app/models/solidus_friendly_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb
230
+ - app/models/solidus_friendly_promotions/condition.rb
231
+ - app/models/solidus_friendly_promotions/condition_product.rb
232
+ - app/models/solidus_friendly_promotions/condition_store.rb
233
+ - app/models/solidus_friendly_promotions/condition_taxon.rb
234
+ - app/models/solidus_friendly_promotions/condition_user.rb
235
+ - app/models/solidus_friendly_promotions/conditions/discounted_item_total.rb
236
+ - app/models/solidus_friendly_promotions/conditions/first_order.rb
237
+ - app/models/solidus_friendly_promotions/conditions/first_repeat_purchase_since.rb
238
+ - app/models/solidus_friendly_promotions/conditions/item_total.rb
239
+ - app/models/solidus_friendly_promotions/conditions/line_item_option_value.rb
240
+ - app/models/solidus_friendly_promotions/conditions/line_item_product.rb
241
+ - app/models/solidus_friendly_promotions/conditions/line_item_taxon.rb
242
+ - app/models/solidus_friendly_promotions/conditions/minimum_quantity.rb
243
+ - app/models/solidus_friendly_promotions/conditions/nth_order.rb
244
+ - app/models/solidus_friendly_promotions/conditions/one_use_per_user.rb
245
+ - app/models/solidus_friendly_promotions/conditions/option_value.rb
246
+ - app/models/solidus_friendly_promotions/conditions/product.rb
247
+ - app/models/solidus_friendly_promotions/conditions/shipping_method.rb
248
+ - app/models/solidus_friendly_promotions/conditions/store.rb
249
+ - app/models/solidus_friendly_promotions/conditions/taxon.rb
250
+ - app/models/solidus_friendly_promotions/conditions/user.rb
251
+ - app/models/solidus_friendly_promotions/conditions/user_logged_in.rb
252
+ - app/models/solidus_friendly_promotions/conditions/user_role.rb
224
253
  - app/models/solidus_friendly_promotions/distributed_amounts_handler.rb
225
254
  - app/models/solidus_friendly_promotions/eligibility_result.rb
226
255
  - app/models/solidus_friendly_promotions/eligibility_results.rb
@@ -233,9 +262,8 @@ files:
233
262
  - app/models/solidus_friendly_promotions/migration_support/order_promotion_syncer.rb
234
263
  - app/models/solidus_friendly_promotions/order_promotion.rb
235
264
  - app/models/solidus_friendly_promotions/permission_sets/friendly_promotion_management.rb
236
- - app/models/solidus_friendly_promotions/products_promotion_rule.rb
237
265
  - app/models/solidus_friendly_promotions/promotion.rb
238
- - app/models/solidus_friendly_promotions/promotion_action.rb
266
+ - app/models/solidus_friendly_promotions/promotion_advertiser.rb
239
267
  - app/models/solidus_friendly_promotions/promotion_category.rb
240
268
  - app/models/solidus_friendly_promotions/promotion_code.rb
241
269
  - app/models/solidus_friendly_promotions/promotion_code/batch_builder.rb
@@ -243,50 +271,53 @@ files:
243
271
  - app/models/solidus_friendly_promotions/promotion_handler/coupon.rb
244
272
  - app/models/solidus_friendly_promotions/promotion_handler/null.rb
245
273
  - app/models/solidus_friendly_promotions/promotion_handler/page.rb
246
- - app/models/solidus_friendly_promotions/promotion_rule.rb
247
- - app/models/solidus_friendly_promotions/promotion_rules_store.rb
248
- - app/models/solidus_friendly_promotions/promotion_rules_taxon.rb
249
- - app/models/solidus_friendly_promotions/promotion_rules_user.rb
250
- - app/models/solidus_friendly_promotions/rules/discounted_item_total.rb
251
- - app/models/solidus_friendly_promotions/rules/first_order.rb
252
- - app/models/solidus_friendly_promotions/rules/first_repeat_purchase_since.rb
253
- - app/models/solidus_friendly_promotions/rules/item_total.rb
254
- - app/models/solidus_friendly_promotions/rules/line_item_option_value.rb
255
- - app/models/solidus_friendly_promotions/rules/line_item_product.rb
256
- - app/models/solidus_friendly_promotions/rules/line_item_taxon.rb
257
- - app/models/solidus_friendly_promotions/rules/minimum_quantity.rb
258
- - app/models/solidus_friendly_promotions/rules/nth_order.rb
259
- - app/models/solidus_friendly_promotions/rules/one_use_per_user.rb
260
- - app/models/solidus_friendly_promotions/rules/option_value.rb
261
- - app/models/solidus_friendly_promotions/rules/product.rb
262
- - app/models/solidus_friendly_promotions/rules/shipping_method.rb
263
- - app/models/solidus_friendly_promotions/rules/store.rb
264
- - app/models/solidus_friendly_promotions/rules/taxon.rb
265
- - app/models/solidus_friendly_promotions/rules/user.rb
266
- - app/models/solidus_friendly_promotions/rules/user_logged_in.rb
267
- - app/models/solidus_friendly_promotions/rules/user_role.rb
268
274
  - app/models/solidus_friendly_promotions/shipping_rate_discount.rb
269
275
  - app/models/solidus_friendly_promotions/simple_order_contents.rb
270
- - app/views/solidus_friendly_promotions/admin/promotion_actions/_calculator_select.html.erb
271
- - app/views/solidus_friendly_promotions/admin/promotion_actions/_form.html.erb
272
- - app/views/solidus_friendly_promotions/admin/promotion_actions/_promotion_action.html.erb
273
- - app/views/solidus_friendly_promotions/admin/promotion_actions/_type_select.html.erb
274
- - app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_line_item.html.erb
275
- - app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_line_item_quantity_groups.html.erb
276
- - app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_adjust_shipment.html.erb
277
- - app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_calculator_fields.erb
278
- - app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_create_discounted_item.html.erb
279
- - app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/_default_fields.html.erb
280
- - app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/distributed_amount/_fields.html.erb
281
- - app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/flat_rate/_fields.html.erb
282
- - app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_flat_rate/_fields.html.erb
283
- - app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_flat_rate/_tier_fields.html.erb
284
- - app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent/_fields.html.erb
285
- - app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent/_tier_fields.html.erb
286
- - app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent_on_eligible_item_quantity/_fields.html.erb
287
- - app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb
288
- - app/views/solidus_friendly_promotions/admin/promotion_actions/edit.html.erb
289
- - app/views/solidus_friendly_promotions/admin/promotion_actions/new.html.erb
276
+ - app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_line_item.html.erb
277
+ - app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_line_item_quantity_groups.html.erb
278
+ - app/views/solidus_friendly_promotions/admin/benefit_fields/_adjust_shipment.html.erb
279
+ - app/views/solidus_friendly_promotions/admin/benefit_fields/_calculator_fields.erb
280
+ - app/views/solidus_friendly_promotions/admin/benefit_fields/_create_discounted_item.html.erb
281
+ - app/views/solidus_friendly_promotions/admin/benefits/_benefit.html.erb
282
+ - app/views/solidus_friendly_promotions/admin/benefits/_calculator_select.html.erb
283
+ - app/views/solidus_friendly_promotions/admin/benefits/_form.html.erb
284
+ - app/views/solidus_friendly_promotions/admin/benefits/_new_benefit.html.erb
285
+ - app/views/solidus_friendly_promotions/admin/benefits/_type_select.html.erb
286
+ - app/views/solidus_friendly_promotions/admin/benefits/edit.html.erb
287
+ - app/views/solidus_friendly_promotions/admin/benefits/new.html.erb
288
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/_default_fields.html.erb
289
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/distributed_amount/_fields.html.erb
290
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/flat_rate/_fields.html.erb
291
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/flexi_rate/_fields.html.erb
292
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/percent/_fields.html.erb
293
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_flat_rate/_fields.html.erb
294
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_flat_rate/_tier_fields.html.erb
295
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent/_fields.html.erb
296
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent/_tier_fields.html.erb
297
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_fields.html.erb
298
+ - app/views/solidus_friendly_promotions/admin/calculator_fields/tiered_percent_on_eligible_item_quantity/_tier_fields.html.erb
299
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_first_order.html.erb
300
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_first_repeat_purchase_since.html.erb
301
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_item_total.html.erb
302
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_option_value.html.erb
303
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_product.html.erb
304
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_line_item_taxon.html.erb
305
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_minimum_quantity.html.erb
306
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_nth_order.html.erb
307
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_one_use_per_user.html.erb
308
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_option_value.html.erb
309
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_product.html.erb
310
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_shipping_method.html.erb
311
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_store.html.erb
312
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_taxon.html.erb
313
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_user.html.erb
314
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_user_logged_in.html.erb
315
+ - app/views/solidus_friendly_promotions/admin/condition_fields/_user_role.html.erb
316
+ - app/views/solidus_friendly_promotions/admin/condition_fields/line_item_option_value/_option_value_fields.html.erb
317
+ - app/views/solidus_friendly_promotions/admin/conditions/_condition.html.erb
318
+ - app/views/solidus_friendly_promotions/admin/conditions/_new_condition.html.erb
319
+ - app/views/solidus_friendly_promotions/admin/conditions/_type_select.html.erb
320
+ - app/views/solidus_friendly_promotions/admin/conditions/new.html.erb
290
321
  - app/views/solidus_friendly_promotions/admin/promotion_categories/_form.html.erb
291
322
  - app/views/solidus_friendly_promotions/admin/promotion_categories/edit.html.erb
292
323
  - app/views/solidus_friendly_promotions/admin/promotion_categories/index.html.erb
@@ -298,34 +329,21 @@ files:
298
329
  - app/views/solidus_friendly_promotions/admin/promotion_codes/index.csv.ruby
299
330
  - app/views/solidus_friendly_promotions/admin/promotion_codes/index.html.erb
300
331
  - app/views/solidus_friendly_promotions/admin/promotion_codes/new.html.erb
301
- - app/views/solidus_friendly_promotions/admin/promotion_rules/_promotion_rule.html.erb
302
- - app/views/solidus_friendly_promotions/admin/promotion_rules/_type_select.html.erb
303
- - app/views/solidus_friendly_promotions/admin/promotion_rules/new.html.erb
304
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_order.html.erb
305
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_first_repeat_purchase_since.html.erb
306
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_item_total.html.erb
307
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_option_value.html.erb
308
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_product.html.erb
309
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_line_item_taxon.html.erb
310
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_minimum_quantity.html.erb
311
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_nth_order.html.erb
312
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_one_use_per_user.html.erb
313
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_option_value.html.erb
314
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_product.html.erb
315
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_shipping_method.html.erb
316
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_store.html.erb
317
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_taxon.html.erb
318
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user.html.erb
319
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_logged_in.html.erb
320
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/_user_role.html.erb
321
- - app/views/solidus_friendly_promotions/admin/promotion_rules/rules/line_item_option_value/_option_value_fields.html.erb
322
332
  - app/views/solidus_friendly_promotions/admin/promotions/_form.html.erb
323
333
  - app/views/solidus_friendly_promotions/admin/promotions/_table.html.erb
324
334
  - app/views/solidus_friendly_promotions/admin/promotions/_table_filter.html.erb
325
335
  - app/views/solidus_friendly_promotions/admin/promotions/edit.html.erb
326
336
  - app/views/solidus_friendly_promotions/admin/promotions/index.html.erb
327
337
  - app/views/solidus_friendly_promotions/admin/promotions/new.html.erb
338
+ - app/views/solidus_friendly_promotions/admin/shared/_number_with_currency.html.erb
328
339
  - app/views/solidus_friendly_promotions/admin/shared/_promotion_sub_menu.html.erb
340
+ - app/views/solidus_friendly_promotions/admin/shared/preference_fields/_boolean.html.erb
341
+ - app/views/solidus_friendly_promotions/admin/shared/preference_fields/_decimal.html.erb
342
+ - app/views/solidus_friendly_promotions/admin/shared/preference_fields/_encrypted_string.html.erb
343
+ - app/views/solidus_friendly_promotions/admin/shared/preference_fields/_integer.html.erb
344
+ - app/views/solidus_friendly_promotions/admin/shared/preference_fields/_password.html.erb
345
+ - app/views/solidus_friendly_promotions/admin/shared/preference_fields/_string.html.erb
346
+ - app/views/solidus_friendly_promotions/admin/shared/preference_fields/_text.html.erb
329
347
  - app/views/solidus_friendly_promotions/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb
330
348
  - app/views/solidus_friendly_promotions/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb
331
349
  - bin/console
@@ -366,6 +384,16 @@ files:
366
384
  - db/migrate/20231104135812_add_managed_by_order_action_to_line_items.rb
367
385
  - db/migrate/20240124104855_add_deleted_at_to_promotions.rb
368
386
  - db/migrate/20240125102050_drop_deleted_at_from_promotion_actions.rb
387
+ - db/migrate/20240409093831_add_action_reference_to_rules.rb
388
+ - db/migrate/20240506142650_remove_promotion_rules_promotion_id.rb
389
+ - db/migrate/20240508080834_rename_promotion_rules_to_conditions.rb
390
+ - db/migrate/20240508131514_rename_friendly_promotion_actions_to_friendly_benefits.rb
391
+ - db/migrate/20240612113608_update_column_comments_for_benefits.rb
392
+ - db/migrate/20240612114132_update_column_comments_for_conditions.rb
393
+ - db/migrate/20240612115209_update_column_comments_for_condition_stores.rb
394
+ - db/migrate/20240612115749_update_column_comments_for_condition_products.rb
395
+ - db/migrate/20240612120411_update_column_comments_for_condition_taxons.rb
396
+ - db/migrate/20240612121049_update_column_comments_for_condition_users.rb
369
397
  - lib/generators/solidus_friendly_promotions/install/install_generator.rb
370
398
  - lib/generators/solidus_friendly_promotions/install/templates/initializer.rb
371
399
  - lib/solidus_friendly_promotions.rb
@@ -388,11 +416,11 @@ files:
388
416
  - lib/tasks/solidus_friendly_promotions/migrate_existing_promotions.rake
389
417
  - lib/tasks/solidus_friendly_promotions/migrate_order_promotions.rake
390
418
  - solidus_friendly_promotions.gemspec
391
- homepage: https://github.com/solidusio-contrib/solidus_friendly_promotions#readme
419
+ homepage: https://github.com/friendlycart/solidus_friendly_promotions#readme
392
420
  licenses:
393
421
  - BSD-3-Clause
394
422
  metadata:
395
- homepage_uri: https://github.com/solidusio-contrib/solidus_friendly_promotions#readme
423
+ homepage_uri: https://github.com/friendlycart/solidus_friendly_promotions#readme
396
424
  source_code_uri: https://github.com/friendlycart/solidus_friendly_promotions
397
425
  changelog_uri: https://github.com/friendlycart/solidus_friendly_promotions/blob/master/CHANGELOG.md
398
426
  post_install_message:
data/.rubocop_todo.yml DELETED
@@ -1,157 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config --exclude-limit 10000`
3
- # on 2023-07-25 15:26:43 UTC using RuboCop version 1.54.1.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 2
10
- # Configuration parameters: AllowedMethods.
11
- # AllowedMethods: enums
12
- Lint/ConstantDefinitionInBlock:
13
- Exclude:
14
- - 'spec/models/solidus_friendly_promotions/promotion_rule_spec.rb'
15
-
16
- # Offense count: 1
17
- Lint/DuplicateMethods:
18
- Exclude:
19
- - 'app/models/solidus_friendly_promotions/promotion.rb'
20
-
21
- # Offense count: 1
22
- # This cop supports safe autocorrection (--autocorrect).
23
- Lint/RedundantCopDisableDirective:
24
- Exclude:
25
- - 'lib/generators/solidus_friendly_promotions/install/install_generator.rb'
26
-
27
- # Offense count: 8
28
- # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
29
- # SupportedStyles: snake_case, normalcase, non_integer
30
- # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
31
- Naming/VariableNumber:
32
- Exclude:
33
- - 'spec/models/solidus_friendly_promotions/rules/first_repeat_purchase_since_spec.rb'
34
-
35
- # Offense count: 1
36
- RSpec/AnyInstance:
37
- Exclude:
38
- - 'spec/jobs/solidus_friendly_promotions/promotion_code_batch_job_spec.rb'
39
-
40
- # Offense count: 2
41
- # Configuration parameters: IgnoredMetadata.
42
- RSpec/DescribeClass:
43
- Exclude:
44
- - 'spec/lib/solidus_friendly_promotions/testing_support/factories_spec.rb'
45
- - 'spec/models/promotion/integration_spec.rb'
46
-
47
- # Offense count: 2
48
- RSpec/ExpectInHook:
49
- Exclude:
50
- - 'spec/jobs/solidus_friendly_promotions/promotion_code_batch_job_spec.rb'
51
- - 'spec/models/solidus_friendly_promotions/promotion_code/batch_builder_spec.rb'
52
-
53
- # Offense count: 7
54
- # Configuration parameters: AssignmentOnly.
55
- RSpec/InstanceVariable:
56
- Exclude:
57
- - 'spec/models/solidus_friendly_promotions/promotion_spec.rb'
58
-
59
- # Offense count: 2
60
- RSpec/IteratedExpectation:
61
- Exclude:
62
- - 'spec/jobs/solidus_friendly_promotions/promotion_code_batch_job_spec.rb'
63
-
64
- # Offense count: 2
65
- RSpec/LeakyConstantDeclaration:
66
- Exclude:
67
- - 'spec/models/solidus_friendly_promotions/promotion_rule_spec.rb'
68
-
69
- # Offense count: 3
70
- RSpec/MessageChain:
71
- Exclude:
72
- - 'spec/models/solidus_friendly_promotions/rules/first_order_spec.rb'
73
-
74
- # Offense count: 4
75
- # Configuration parameters: AllowSubject.
76
- RSpec/MultipleMemoizedHelpers:
77
- Max: 12
78
-
79
- # Offense count: 1
80
- RSpec/OverwritingSetup:
81
- Exclude:
82
- - 'spec/models/solidus_friendly_promotions/calculators/flexi_rate_spec.rb'
83
-
84
- # Offense count: 2
85
- RSpec/RepeatedExampleGroupBody:
86
- Exclude:
87
- - 'spec/lib/solidus_friendly_promotions/configuration_spec.rb'
88
-
89
- # Offense count: 2
90
- RSpec/RepeatedExampleGroupDescription:
91
- Exclude:
92
- - 'spec/models/solidus_friendly_promotions/calculators/flat_rate_spec.rb'
93
-
94
- # Offense count: 1
95
- RSpec/SubjectStub:
96
- Exclude:
97
- - 'spec/models/solidus_friendly_promotions/promotion_code/batch_builder_spec.rb'
98
-
99
- # Offense count: 2
100
- # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
101
- RSpec/VerifiedDoubles:
102
- Exclude:
103
- - 'spec/models/solidus_friendly_promotions/calculators/percent_spec.rb'
104
-
105
- # Offense count: 1
106
- # Configuration parameters: Include.
107
- # Include: db/**/*.rb
108
- Rails/CreateTableWithTimestamps:
109
- Exclude:
110
- - 'db/migrate/20230725074235_create_shipping_rate_discounts.rb'
111
-
112
- # Offense count: 7
113
- # Configuration parameters: Include.
114
- # Include: app/models/**/*.rb
115
- Rails/HasManyOrHasOneDependent:
116
- Exclude:
117
- - 'app/models/solidus_friendly_promotions/promotion.rb'
118
- - 'app/models/solidus_friendly_promotions/promotion_action.rb'
119
- - 'app/models/solidus_friendly_promotions/promotion_category.rb'
120
- - 'app/models/solidus_friendly_promotions/promotion_code.rb'
121
-
122
- # Offense count: 7
123
- # Configuration parameters: IgnoreScopes, Include.
124
- # Include: app/models/**/*.rb
125
- Rails/InverseOf:
126
- Exclude:
127
- - 'app/models/solidus_friendly_promotions/promotion.rb'
128
- - 'app/models/solidus_friendly_promotions/rules/line_item_product.rb'
129
- - 'app/models/solidus_friendly_promotions/rules/line_item_taxon.rb'
130
- - 'app/models/solidus_friendly_promotions/rules/product.rb'
131
- - 'app/models/solidus_friendly_promotions/rules/store.rb'
132
- - 'app/models/solidus_friendly_promotions/rules/taxon.rb'
133
- - 'app/models/solidus_friendly_promotions/rules/user.rb'
134
-
135
- # Offense count: 2
136
- # This cop supports unsafe autocorrection (--autocorrect-all).
137
- Rails/ReflectionClassName:
138
- Exclude:
139
- - 'app/models/solidus_friendly_promotions/promotion_rules_user.rb'
140
- - 'app/models/solidus_friendly_promotions/rules/user.rb'
141
-
142
- # Offense count: 9
143
- # Configuration parameters: ForbiddenMethods, AllowedMethods.
144
- # ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
145
- Rails/SkipsModelValidations:
146
- Exclude:
147
- - 'lib/solidus_friendly_promotions/testing_support/friendly_order_factory.rb'
148
- - 'spec/models/solidus_friendly_promotions/promotion_code_batch_spec.rb'
149
- - 'spec/models/solidus_friendly_promotions/promotion_code_spec.rb'
150
- - 'spec/models/solidus_friendly_promotions/promotion_spec.rb'
151
-
152
- # Offense count: 5
153
- # This cop supports safe autocorrection (--autocorrect).
154
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
155
- # URISchemes: http, https
156
- Layout/LineLength:
157
- Max: 148
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SolidusFriendlyPromotions
4
- module Admin
5
- class PromotionActionsController < Spree::Admin::BaseController
6
- before_action :validate_level, only: :new
7
- before_action :load_promotion, only: [:create, :destroy, :new, :update, :edit]
8
- before_action :validate_promotion_action_type, only: [:create, :edit]
9
-
10
- def new
11
- if params.dig(:promotion_action, :type)
12
- validate_promotion_action_type
13
- @promotion_action = @promotion.actions.build(type: @promotion_action_type)
14
-
15
- if params.dig(:promotion_action, :calculator_type)
16
- @promotion_action.calculator_type = params[:promotion_action][:calculator_type]
17
- end
18
- end
19
- render layout: false
20
- end
21
-
22
- def create
23
- @promotion_action = @promotion_action_type.new(promotion_action_params)
24
- @promotion_action.promotion = @promotion
25
- if @promotion_action.save(validate: false)
26
- flash[:success] =
27
- t("spree.successfully_created", resource: SolidusFriendlyPromotions::PromotionAction.model_name.human)
28
- redirect_to location_after_save, format: :html
29
- else
30
- render :new, layout: false
31
- end
32
- end
33
-
34
- def edit
35
- @promotion_action = @promotion.actions.find(params[:id])
36
- if params.dig(:promotion_action, :calculator_type)
37
- @promotion_action.calculator_type = params[:promotion_action][:calculator_type]
38
- end
39
- render layout: false
40
- end
41
-
42
- def update
43
- @promotion_action = @promotion.actions.find(params[:id])
44
- @promotion_action.assign_attributes(promotion_action_params)
45
- if @promotion_action.save
46
- flash[:success] =
47
- t("spree.successfully_updated", resource: SolidusFriendlyPromotions::PromotionAction.model_name.human)
48
- redirect_to location_after_save, format: :html
49
- else
50
- render :edit
51
- end
52
- end
53
-
54
- def destroy
55
- @promotion_action = @promotion.actions.find(params[:id])
56
- if @promotion_action.destroy
57
- flash[:success] =
58
- t("spree.successfully_removed", resource: SolidusFriendlyPromotions::PromotionAction.model_name.human)
59
- end
60
- redirect_to location_after_save, format: :html
61
- end
62
-
63
- private
64
-
65
- def location_after_save
66
- solidus_friendly_promotions.edit_admin_promotion_path(@promotion)
67
- end
68
-
69
- def load_promotion
70
- @promotion = SolidusFriendlyPromotions::Promotion.find(params[:promotion_id])
71
- end
72
-
73
- def validate_level
74
- requested_level = params[:level].to_s
75
- if requested_level.in?(["line_item", "shipment"])
76
- @level = requested_level
77
- else
78
- @level = "line_item"
79
- flash.now[:error] = t(:invalid_promotion_rule_level, scope: :solidus_friendly_promotions)
80
- end
81
- end
82
-
83
- def promotion_action_params
84
- params[:promotion_action].try(:permit!) || {}
85
- end
86
-
87
- def validate_promotion_action_type
88
- requested_type = params[:promotion_action].delete(:type)
89
- promotion_action_types = SolidusFriendlyPromotions.config.actions
90
- @promotion_action_type = promotion_action_types.detect do |klass|
91
- klass.name == requested_type
92
- end
93
- return if @promotion_action_type
94
-
95
- flash[:error] = t("solidus_friendly_promotions.invalid_promotion_action")
96
- respond_to do |format|
97
- format.html { redirect_to solidus_friendly_promotions.edit_admin_promotion_path(@promotion) }
98
- format.js { render layout: false }
99
- end
100
- end
101
- end
102
- end
103
- end