solidus_friendly_promotions 1.0.0.rc.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +154 -0
  3. data/MIGRATING.md +6 -2
  4. data/README.md +12 -3
  5. data/app/controllers/solidus_friendly_promotions/admin/base_controller.rb +5 -1
  6. data/app/controllers/solidus_friendly_promotions/admin/promotion_actions_controller.rb +1 -1
  7. data/app/controllers/solidus_friendly_promotions/admin/promotion_code_batches_controller.rb +12 -0
  8. data/app/controllers/solidus_friendly_promotions/admin/promotion_rules_controller.rb +1 -1
  9. data/app/helpers/solidus_friendly_promotions/admin/promotion_rules_helper.rb +1 -1
  10. data/app/models/concerns/solidus_friendly_promotions/rules/line_item_applicable_order_rule.rb +1 -1
  11. data/app/models/solidus_friendly_promotions/friendly_promotion_adjuster.rb +2 -1
  12. data/app/models/solidus_friendly_promotions/promotion.rb +4 -2
  13. data/app/models/solidus_friendly_promotions/promotion_action.rb +11 -1
  14. data/app/models/solidus_friendly_promotions/promotion_code.rb +2 -0
  15. data/app/views/solidus_friendly_promotions/admin/promotion_actions/_promotion_action.html.erb +1 -1
  16. data/app/views/solidus_friendly_promotions/admin/promotion_actions/calculators/distributed_amount/_fields.html.erb +1 -39
  17. data/app/views/solidus_friendly_promotions/admin/promotion_actions/new.html.erb +1 -1
  18. data/app/views/solidus_friendly_promotions/admin/promotion_code_batches/_form_fields.html.erb +22 -0
  19. data/app/views/solidus_friendly_promotions/admin/promotion_code_batches/download.csv.ruby +8 -0
  20. data/app/views/solidus_friendly_promotions/admin/promotion_code_batches/index.html.erb +65 -0
  21. data/app/views/solidus_friendly_promotions/admin/promotion_code_batches/new.html.erb +8 -0
  22. data/app/views/solidus_friendly_promotions/admin/promotions/_table.html.erb +3 -3
  23. data/app/views/solidus_friendly_promotions/admin/promotions/_table_filter.html.erb +9 -0
  24. data/app/views/solidus_friendly_promotions/admin/shared/_promotion_sub_menu.html.erb +2 -2
  25. data/bin/sandbox +1 -0
  26. data/config/locales/en.yml +46 -0
  27. data/db/migrate/20240124104855_add_deleted_at_to_promotions.rb +6 -0
  28. data/db/migrate/20240125102050_drop_deleted_at_from_promotion_actions.rb +5 -0
  29. data/lib/solidus_friendly_promotions/configuration.rb +2 -0
  30. data/lib/solidus_friendly_promotions/promotion_migrator.rb +1 -1
  31. data/lib/solidus_friendly_promotions/version.rb +1 -1
  32. data/lib/solidus_friendly_promotions.rb +9 -4
  33. data/solidus_friendly_promotions.gemspec +2 -2
  34. metadata +12 -8
  35. data/app/models/solidus_friendly_promotions.rb +0 -7
  36. data/config/initializers/solidus_friendly_promotions.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84ea9571f3d2a4a2dfe9e789c0f3887a0aca2d9559a68004806cd67c395fc959
4
- data.tar.gz: 929a14c4f917aad08c6bf7faa7f93c7be071dc43ad72641ddf0394cf336022db
3
+ metadata.gz: 5cc3437f15c2341c8a233e48b1443996b09e923cf84727fb834baa766dd1bee7
4
+ data.tar.gz: 9c534dc4a7ce6f3a09bb6c14d046ea8d6c9e313dbea3c5f1e6767000d8eb0cca
5
5
  SHA512:
6
- metadata.gz: 9e49887ad42376b60165ab1d5a8067942adde8d9861681e165b0617155eb74f42a5ea97f2bd94ce929ee5627156ab249ab392b5259e775ecdb53414444bb94be
7
- data.tar.gz: cc68b4daf7520de18dbe22bd0b74a73e1a4b009d031d8703b86f7e6d5ad11cfd5999159b48cdb0bfc7801235fe8587bc5c7cfe56a76fb18eee3fef7b48c903a4
6
+ metadata.gz: c345c4dbd052db90957b5a2c886c39c7a328452b616822ce326b2b4170d6b2232be827dc43f7374a33e116fc50b2f9229c5d0b34c46ca3d2a09e26a486319143
7
+ data.tar.gz: 9a2ef29fa7045ae95d884903fe80beadacfc6e89f5fa096f61c5c53709f836f3cf76b6483e11fc488d9140ad1720dee41cdd7cb78f22c1649b1bb107540ef609
data/CHANGELOG.md CHANGED
@@ -1 +1,155 @@
1
1
  # Changelog
2
+
3
+ ## [v1.0.0](https://github.com/friendlycart/solidus_friendly_promotions/tree/v1.0.0) (2024-01-25)
4
+
5
+ [Full Changelog](https://github.com/friendlycart/solidus_friendly_promotions/compare/v1.0.0.rc.3...v1.0.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Implement better soft-delete [\#30](https://github.com/friendlycart/solidus_friendly_promotions/issues/30)
10
+
11
+ **Closed issues:**
12
+
13
+ - Cannot delete promotion with promotion code [\#94](https://github.com/friendlycart/solidus_friendly_promotions/issues/94)
14
+ - Missing action for button: Promotion code batch [\#93](https://github.com/friendlycart/solidus_friendly_promotions/issues/93)
15
+
16
+ **Merged pull requests:**
17
+
18
+ - Improve soft-deletion faculty [\#102](https://github.com/friendlycart/solidus_friendly_promotions/pull/102) ([mamhoff](https://github.com/mamhoff))
19
+ - Add missing association between promo codes and order promotions [\#101](https://github.com/friendlycart/solidus_friendly_promotions/pull/101) ([mamhoff](https://github.com/mamhoff))
20
+ - Revert "Temporarily disable running specs for Solidus main" [\#100](https://github.com/friendlycart/solidus_friendly_promotions/pull/100) ([mamhoff](https://github.com/mamhoff))
21
+ - Add admin UI for promotion code batches [\#99](https://github.com/friendlycart/solidus_friendly_promotions/pull/99) ([mamhoff](https://github.com/mamhoff))
22
+ - Define SolidusFriendlyPromotions.table\_name\_prefix early [\#98](https://github.com/friendlycart/solidus_friendly_promotions/pull/98) ([mamhoff](https://github.com/mamhoff))
23
+
24
+ ## [v1.0.0.rc.3](https://github.com/friendlycart/solidus_friendly_promotions/tree/v1.0.0.rc.3) (2024-01-16)
25
+
26
+ [Full Changelog](https://github.com/friendlycart/solidus_friendly_promotions/compare/v1.0.0.rc.2...v1.0.0.rc.3)
27
+
28
+ **Closed issues:**
29
+
30
+ - Provide Integration Instructions for Starter Frontend [\#90](https://github.com/friendlycart/solidus_friendly_promotions/issues/90)
31
+
32
+ **Merged pull requests:**
33
+
34
+ - Add configuration option: `recalculate_complete_orders` [\#97](https://github.com/friendlycart/solidus_friendly_promotions/pull/97) ([mamhoff](https://github.com/mamhoff))
35
+ - Fix standardrb violations [\#96](https://github.com/friendlycart/solidus_friendly_promotions/pull/96) ([mamhoff](https://github.com/mamhoff))
36
+ - Fix admin sub menu entry visibility condition [\#92](https://github.com/friendlycart/solidus_friendly_promotions/pull/92) ([mickenorlen](https://github.com/mickenorlen))
37
+ - Documentation fixes [\#91](https://github.com/friendlycart/solidus_friendly_promotions/pull/91) ([mamhoff](https://github.com/mamhoff))
38
+ - Fix typo [\#89](https://github.com/friendlycart/solidus_friendly_promotions/pull/89) ([jarednorman](https://github.com/jarednorman))
39
+ - Pass untranslated strings through i18n [\#88](https://github.com/friendlycart/solidus_friendly_promotions/pull/88) ([mamhoff](https://github.com/mamhoff))
40
+
41
+ ## [v1.0.0.rc.2](https://github.com/friendlycart/solidus_friendly_promotions/tree/v1.0.0.rc.2) (2023-11-11)
42
+
43
+ [Full Changelog](https://github.com/friendlycart/solidus_friendly_promotions/compare/v1.0.0.rc.1...v1.0.0.rc.2)
44
+
45
+ **Merged pull requests:**
46
+
47
+ - Refactor: Extract `Promotion#applicable_line_items` [\#86](https://github.com/friendlycart/solidus_friendly_promotions/pull/86) ([mamhoff](https://github.com/mamhoff))
48
+ - Coupon Promo Handler: Fix flaky spec [\#84](https://github.com/friendlycart/solidus_friendly_promotions/pull/84) ([mamhoff](https://github.com/mamhoff))
49
+ - Use Remix icons if Solidus' admin\_updated\_navbar is enabled [\#83](https://github.com/friendlycart/solidus_friendly_promotions/pull/83) ([tvdeyen](https://github.com/tvdeyen))
50
+ - Tiered calculators [\#82](https://github.com/friendlycart/solidus_friendly_promotions/pull/82) ([mamhoff](https://github.com/mamhoff))
51
+ - Allow changing quantity for automatic line items [\#81](https://github.com/friendlycart/solidus_friendly_promotions/pull/81) ([mamhoff](https://github.com/mamhoff))
52
+ - Update MIGRATING.md [\#80](https://github.com/friendlycart/solidus_friendly_promotions/pull/80) ([tvdeyen](https://github.com/tvdeyen))
53
+ - Promotions index improvements [\#79](https://github.com/friendlycart/solidus_friendly_promotions/pull/79) ([mamhoff](https://github.com/mamhoff))
54
+ - Lint: Fix standardrb error [\#78](https://github.com/friendlycart/solidus_friendly_promotions/pull/78) ([mamhoff](https://github.com/mamhoff))
55
+
56
+ ## [v1.0.0.rc.1](https://github.com/friendlycart/solidus_friendly_promotions/tree/v1.0.0.rc.1) (2023-11-07)
57
+
58
+ [Full Changelog](https://github.com/friendlycart/solidus_friendly_promotions/compare/v1.0.0.pre...v1.0.0.rc.1)
59
+
60
+ **Implemented enhancements:**
61
+
62
+ - Implement Free items [\#31](https://github.com/friendlycart/solidus_friendly_promotions/issues/31)
63
+
64
+ **Merged pull requests:**
65
+
66
+ - Goodies! [\#75](https://github.com/friendlycart/solidus_friendly_promotions/pull/75) ([mamhoff](https://github.com/mamhoff))
67
+ - Add a null promotion handler [\#71](https://github.com/friendlycart/solidus_friendly_promotions/pull/71) ([mamhoff](https://github.com/mamhoff))
68
+
69
+ ## [v1.0.0.pre](https://github.com/friendlycart/solidus_friendly_promotions/tree/v1.0.0.pre) (2023-11-07)
70
+
71
+ [Full Changelog](https://github.com/friendlycart/solidus_friendly_promotions/compare/e14802957fdb55d7f4e2730341e4cbb118ebf993...v1.0.0.pre)
72
+
73
+ **Implemented enhancements:**
74
+
75
+ - Migrator: Copy promotion codes [\#34](https://github.com/friendlycart/solidus_friendly_promotions/issues/34)
76
+ - Add original\_promotion\_{action\_}id on promotions and promotion actions [\#33](https://github.com/friendlycart/solidus_friendly_promotions/issues/33)
77
+
78
+ **Fixed bugs:**
79
+
80
+ - Migrator: Add support for promotion categories [\#37](https://github.com/friendlycart/solidus_friendly_promotions/issues/37)
81
+
82
+ **Closed issues:**
83
+
84
+ - Document DB tables [\#35](https://github.com/friendlycart/solidus_friendly_promotions/issues/35)
85
+
86
+ **Merged pull requests:**
87
+
88
+ - Use new NestedClassSet for configuring calculators [\#77](https://github.com/friendlycart/solidus_friendly_promotions/pull/77) ([mamhoff](https://github.com/mamhoff))
89
+ - Refactor to FriendlyPromotion::FriendlyPromotionAdjuster [\#76](https://github.com/friendlycart/solidus_friendly_promotions/pull/76) ([mamhoff](https://github.com/mamhoff))
90
+ - Add bundler/gem\_tasks [\#74](https://github.com/friendlycart/solidus_friendly_promotions/pull/74) ([mamhoff](https://github.com/mamhoff))
91
+ - Fix order discounter spec [\#73](https://github.com/friendlycart/solidus_friendly_promotions/pull/73) ([mamhoff](https://github.com/mamhoff))
92
+ - Quantity tiered calculator [\#72](https://github.com/friendlycart/solidus_friendly_promotions/pull/72) ([mamhoff](https://github.com/mamhoff))
93
+ - Add PromotionHandler::Page [\#70](https://github.com/friendlycart/solidus_friendly_promotions/pull/70) ([mamhoff](https://github.com/mamhoff))
94
+ - Never create adjustments with a zero amount [\#69](https://github.com/friendlycart/solidus_friendly_promotions/pull/69) ([mamhoff](https://github.com/mamhoff))
95
+ - Ignore shipping rates that have no cost [\#68](https://github.com/friendlycart/solidus_friendly_promotions/pull/68) ([davecandlescience](https://github.com/davecandlescience))
96
+ - Refactor promotions eligibility [\#67](https://github.com/friendlycart/solidus_friendly_promotions/pull/67) ([mamhoff](https://github.com/mamhoff))
97
+ - Refactor order promotions migrator [\#66](https://github.com/friendlycart/solidus_friendly_promotions/pull/66) ([mamhoff](https://github.com/mamhoff))
98
+ - Add migrate order promotions rake task [\#65](https://github.com/friendlycart/solidus_friendly_promotions/pull/65) ([davecandlescience](https://github.com/davecandlescience))
99
+ - Add missing relation: SolidusFriendlyPromotions\#order\_promotions [\#64](https://github.com/friendlycart/solidus_friendly_promotions/pull/64) ([mamhoff](https://github.com/mamhoff))
100
+ - Promo Migrator: Ignore missing rules and actions [\#63](https://github.com/friendlycart/solidus_friendly_promotions/pull/63) ([mamhoff](https://github.com/mamhoff))
101
+ - Improve spec for product rule [\#62](https://github.com/friendlycart/solidus_friendly_promotions/pull/62) ([mamhoff](https://github.com/mamhoff))
102
+ - Do not call Spree::PromotionHandler::Shipping when SFP is active [\#61](https://github.com/friendlycart/solidus_friendly_promotions/pull/61) ([mamhoff](https://github.com/mamhoff))
103
+ - Add a migration guide [\#60](https://github.com/friendlycart/solidus_friendly_promotions/pull/60) ([mamhoff](https://github.com/mamhoff))
104
+ - Add a PromotionHandler::Coupon [\#59](https://github.com/friendlycart/solidus_friendly_promotions/pull/59) ([mamhoff](https://github.com/mamhoff))
105
+ - Backports minimum quantity promotion rule from Solidus [\#58](https://github.com/friendlycart/solidus_friendly_promotions/pull/58) ([mamhoff](https://github.com/mamhoff))
106
+ - Backport promotion code batch fix from Solidus [\#57](https://github.com/friendlycart/solidus_friendly_promotions/pull/57) ([mamhoff](https://github.com/mamhoff))
107
+ - Add a rake task to migrate adjustments from legacy promotions [\#56](https://github.com/friendlycart/solidus_friendly_promotions/pull/56) ([mamhoff](https://github.com/mamhoff))
108
+ - Add missing shipping\_rate translation [\#55](https://github.com/friendlycart/solidus_friendly_promotions/pull/55) ([davecandlescience](https://github.com/davecandlescience))
109
+ - Fix shipping rate discount factory [\#54](https://github.com/friendlycart/solidus_friendly_promotions/pull/54) ([mamhoff](https://github.com/mamhoff))
110
+ - Order Discounter: Create valid shipping rate discounts [\#53](https://github.com/friendlycart/solidus_friendly_promotions/pull/53) ([mamhoff](https://github.com/mamhoff))
111
+ - FriendlyPromotionDiscounter: Always return @order [\#52](https://github.com/friendlycart/solidus_friendly_promotions/pull/52) ([mamhoff](https://github.com/mamhoff))
112
+ - Line Item Product Rule: Add error messaging [\#50](https://github.com/friendlycart/solidus_friendly_promotions/pull/50) ([mamhoff](https://github.com/mamhoff))
113
+ - Fix: SolidusFriendlyPromotions, not Shipping [\#49](https://github.com/friendlycart/solidus_friendly_promotions/pull/49) ([mamhoff](https://github.com/mamhoff))
114
+ - Import eligiblity error messages from Solidus [\#48](https://github.com/friendlycart/solidus_friendly_promotions/pull/48) ([mamhoff](https://github.com/mamhoff))
115
+ - Faster promotion code migration [\#47](https://github.com/friendlycart/solidus_friendly_promotions/pull/47) ([mamhoff](https://github.com/mamhoff))
116
+ - Migrator: Store original promotion and promotion action [\#46](https://github.com/friendlycart/solidus_friendly_promotions/pull/46) ([mamhoff](https://github.com/mamhoff))
117
+ - Lint with standardrb in CI [\#45](https://github.com/friendlycart/solidus_friendly_promotions/pull/45) ([mamhoff](https://github.com/mamhoff))
118
+ - Migrator: Migrate promotion codes and promotion code batches [\#44](https://github.com/friendlycart/solidus_friendly_promotions/pull/44) ([mamhoff](https://github.com/mamhoff))
119
+ - Migrate promotion categories and association [\#43](https://github.com/friendlycart/solidus_friendly_promotions/pull/43) ([davecandlescience](https://github.com/davecandlescience))
120
+ - On the fly order promotions [\#42](https://github.com/friendlycart/solidus_friendly_promotions/pull/42) ([mamhoff](https://github.com/mamhoff))
121
+ - Add back references to promotions and actions [\#41](https://github.com/friendlycart/solidus_friendly_promotions/pull/41) ([davecandlescience](https://github.com/davecandlescience))
122
+ - Fix spec warning in promotion rules spec [\#40](https://github.com/friendlycart/solidus_friendly_promotions/pull/40) ([mamhoff](https://github.com/mamhoff))
123
+ - Transparently replace promotion adjustments [\#39](https://github.com/friendlycart/solidus_friendly_promotions/pull/39) ([mamhoff](https://github.com/mamhoff))
124
+ - Add DB comments to tables [\#38](https://github.com/friendlycart/solidus_friendly_promotions/pull/38) ([mamhoff](https://github.com/mamhoff))
125
+ - Fix Promotion Map [\#36](https://github.com/friendlycart/solidus_friendly_promotions/pull/36) ([mamhoff](https://github.com/mamhoff))
126
+ - Fix specs [\#29](https://github.com/friendlycart/solidus_friendly_promotions/pull/29) ([mamhoff](https://github.com/mamhoff))
127
+ - Add Promotion Migrator [\#28](https://github.com/friendlycart/solidus_friendly_promotions/pull/28) ([mamhoff](https://github.com/mamhoff))
128
+ - Polyvalent rules [\#27](https://github.com/friendlycart/solidus_friendly_promotions/pull/27) ([mamhoff](https://github.com/mamhoff))
129
+ - Fix Turbo frame tags for Turbo 1.5 [\#26](https://github.com/friendlycart/solidus_friendly_promotions/pull/26) ([mamhoff](https://github.com/mamhoff))
130
+ - Allow destroying promotions [\#25](https://github.com/friendlycart/solidus_friendly_promotions/pull/25) ([mamhoff](https://github.com/mamhoff))
131
+ - Fix class name option in line item taxon association [\#24](https://github.com/friendlycart/solidus_friendly_promotions/pull/24) ([mamhoff](https://github.com/mamhoff))
132
+ - Move factories to factories folder [\#23](https://github.com/friendlycart/solidus_friendly_promotions/pull/23) ([mamhoff](https://github.com/mamhoff))
133
+ - Add links to legacy promotions in Solidus 4.1 [\#22](https://github.com/friendlycart/solidus_friendly_promotions/pull/22) ([mamhoff](https://github.com/mamhoff))
134
+ - Make lanes configurable [\#21](https://github.com/friendlycart/solidus_friendly_promotions/pull/21) ([mamhoff](https://github.com/mamhoff))
135
+ - Allow order rules per lane [\#20](https://github.com/friendlycart/solidus_friendly_promotions/pull/20) ([mamhoff](https://github.com/mamhoff))
136
+ - Add PermissionSet for Friendly Promotions [\#19](https://github.com/friendlycart/solidus_friendly_promotions/pull/19) ([mamhoff](https://github.com/mamhoff))
137
+ - Add "only" match policy to product rule [\#18](https://github.com/friendlycart/solidus_friendly_promotions/pull/18) ([mamhoff](https://github.com/mamhoff))
138
+ - Require solidus [\#17](https://github.com/friendlycart/solidus_friendly_promotions/pull/17) ([mamhoff](https://github.com/mamhoff))
139
+ - Customer label [\#16](https://github.com/friendlycart/solidus_friendly_promotions/pull/16) ([mamhoff](https://github.com/mamhoff))
140
+ - System specs with turbo [\#15](https://github.com/friendlycart/solidus_friendly_promotions/pull/15) ([mamhoff](https://github.com/mamhoff))
141
+ - Reference our own I18n namespace in views [\#14](https://github.com/friendlycart/solidus_friendly_promotions/pull/14) ([mamhoff](https://github.com/mamhoff))
142
+ - Use different path for friendly promotions [\#13](https://github.com/friendlycart/solidus_friendly_promotions/pull/13) ([mamhoff](https://github.com/mamhoff))
143
+ - Add dependent: :destroy to Spree::Order\#friendly\_promotions [\#12](https://github.com/friendlycart/solidus_friendly_promotions/pull/12) ([mamhoff](https://github.com/mamhoff))
144
+ - Extract promotion loading from promo discounter [\#11](https://github.com/friendlycart/solidus_friendly_promotions/pull/11) ([mamhoff](https://github.com/mamhoff))
145
+ - Remove delegators [\#10](https://github.com/friendlycart/solidus_friendly_promotions/pull/10) ([mamhoff](https://github.com/mamhoff))
146
+ - Fix standardrb error in promotion rule spec [\#8](https://github.com/friendlycart/solidus_friendly_promotions/pull/8) ([mamhoff](https://github.com/mamhoff))
147
+ - Stacking Promotions [\#7](https://github.com/friendlycart/solidus_friendly_promotions/pull/7) ([mamhoff](https://github.com/mamhoff))
148
+ - Add "Lane" enum to Promotion [\#6](https://github.com/friendlycart/solidus_friendly_promotions/pull/6) ([mamhoff](https://github.com/mamhoff))
149
+ - Lint using standardrb gem [\#5](https://github.com/friendlycart/solidus_friendly_promotions/pull/5) ([mamhoff](https://github.com/mamhoff))
150
+ - Promotion Actions: Implement "edit" action [\#4](https://github.com/friendlycart/solidus_friendly_promotions/pull/4) ([mamhoff](https://github.com/mamhoff))
151
+ - Initializer: Use new MenuItem API from Solidus 4.2 onwards [\#3](https://github.com/friendlycart/solidus_friendly_promotions/pull/3) ([mamhoff](https://github.com/mamhoff))
152
+
153
+
154
+
155
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/MIGRATING.md CHANGED
@@ -23,7 +23,7 @@ For the time being, comment out the following lines:
23
23
 
24
24
  ```rb
25
25
  # Spree::Config.order_contents_class = "SolidusFriendlyPromotions::SimpleOrderContents"
26
- # Spree::Config.promotion_adjuster_class = "SolidusFriendlyPromotions::OrderDiscounter"
26
+ # Spree::Config.promotion_adjuster_class = "SolidusFriendlyPromotions::FriendlyPromotionAdjuster"
27
27
  ```
28
28
 
29
29
  This makes sure that the behavior of the current promotion system does not change - yet.
@@ -46,7 +46,7 @@ Now, change `config/initializers/solidus_friendly_promotions.rb` to use your new
46
46
  # Stops running the stock `Spree::PromotionHandler::Cart`
47
47
  Spree::Config.order_contents_class = "SolidusFriendlyPromotions::SimpleOrderContents"
48
48
  # Adjusts all items in an order according to the currently eligible promotions
49
- Spree::Config.promotion_adjuster_class = "SolidusFriendlyPromotions::OrderDiscounter"
49
+ Spree::Config.promotion_adjuster_class = "SolidusFriendlyPromotions::FriendlyPromotionAdjuster"
50
50
  ```
51
51
 
52
52
  From a user's perspective, your promotions should work as before.
@@ -68,6 +68,10 @@ bundle exec rails solidus_friendly_promotions:migrate_order_promotions:down
68
68
 
69
69
  Both of these tasks only work if every promotion and promotion action have an equivalent in SolidusFrienndlyPromotions. Promotion Actions are connected to their originals using the `SolidusFriendlyPromotions#original_promotion_action_id`, Promotions are connected to their originals using the `SolidusFriendlyPromotions#original_promotion_id`.
70
70
 
71
+ ## Solidus Starter Frontend (and other custom frontends)
72
+
73
+ Stores that have a custom coupon codes controller, such as Solidus' starter frontend, have to change the coupon promotion handler to the one from this gem. If you are on a very recent Solidus version, you can change any reference to `Spree::PromotionHandler::Coupon` to `Spree::Config.coupon_code_handler_class`. If your version of Solidus does not have that method yet, replace `Spree::PromotionHandler::Coupon` with `SolidusFriendlyPromotions::PromotionHandler::Coupon`
74
+
71
75
  ## Migrating custom rules and actions
72
76
 
73
77
  If you have custom promotion rules or actions, you need to create new promotion rules and actions.
data/README.md CHANGED
@@ -8,7 +8,7 @@ The basic architecture is very similar to the one in core Solidus, but with a fe
8
8
 
9
9
  ## Architecture
10
10
 
11
- This extension centralizes promotion handling in the order updater. A service class, the `SolidusFriendlyPromotions::OrderDiscounter` applies the current promotion configuration to the order, adjusting or removing adjustments as necessary.
11
+ This extension centralizes promotion handling in the order updater. A service class, the `SolidusFriendlyPromotions::FriendlyPromotionAdjuster` applies the current promotion configuration to the order, adjusting or removing adjustments as necessary.
12
12
 
13
13
  In Solidus Core, Promotion adjustments get recalculated twice on every change to the cart; once in `Spree::OrderContents#after_add_or_remove` and in `Spree::OrderUpdater#update_promotions`. To make things more complicated, `Spree::OrderContents` leverages the `Spree::PromotionHandler#cart`, while the order updater goes through `Spree::Adjustment#recalculate`.
14
14
 
@@ -51,13 +51,22 @@ One way of connecting orders to promotions is via a promotion code.
51
51
 
52
52
  Promotion categories simply allow admins to group promotion actions. They have no further significance with regards to the functionality of the promotion system. This is the same behavior as in core.
53
53
 
54
+ ### Promotion recalculation
55
+
56
+ Solidus allows changing orders up until when they are shipped. SolidusFriendlyPromotions therefore will recalculate orders up until when they are shipped as well. If your admins change promotions rather than add new ones and carefully manage the start and end dates of promotions, you might want to disable this feature:
57
+
58
+ ```rb
59
+ SolidusFriendlyPromotions.configure do |config|
60
+ config.recalculate_complete_orders = false
61
+ end
62
+ ```
54
63
 
55
64
  ## Installation
56
65
 
57
66
  Add solidus_friendly_promotions to your Gemfile:
58
67
 
59
68
  ```ruby
60
- gem 'solidus_friendly_promotions', github: 'friendlycart/solidus_friendly_promotion', branch: 'main'
69
+ gem 'solidus_friendly_promotions'
61
70
  ```
62
71
 
63
72
  Once this project is out of the research phase, a proper gem release will follow.
@@ -71,7 +80,7 @@ bin/rails generate solidus_friendly_promotions:install
71
80
  This will create the tables for this extension. It will also replace the promotion administration system under
72
81
  `/admin/promotions` with a new one that needs `turbo-rails`.
73
82
 
74
- It will also create an initializer within which Solidus is configured to use this extension's `SimpleOrderContents` and `OrderDiscounter` classes. Feel free to override with your own implementations!
83
+ It will also create an initializer within which Solidus is configured to use this extension's `SimpleOrderContents` and `FriendlyPromotionAdjuster` classes. Feel free to override with your own implementations!
75
84
 
76
85
  ## Usage
77
86
 
@@ -7,7 +7,7 @@ module SolidusFriendlyPromotions
7
7
  @parent ||= self.class.parent_data[:model_class]
8
8
  .includes(self.class.parent_data[:includes])
9
9
  .find_by!(self.class.parent_data[:find_by] => params["#{parent_model_name}_id"])
10
- instance_variable_set("@#{parent_model_name}", @parent)
10
+ instance_variable_set(:"@#{parent_model_name}", @parent)
11
11
  rescue ActiveRecord::RecordNotFound => e
12
12
  resource_not_found(flash_class: e.model.constantize, redirect_url: routes_proxy.polymorphic_url([:admin, parent_model_name.pluralize.to_sym]))
13
13
  end
@@ -49,6 +49,10 @@ module SolidusFriendlyPromotions
49
49
  def routes_proxy
50
50
  solidus_friendly_promotions
51
51
  end
52
+
53
+ def parent_model_name
54
+ self.class.parent_data[:model_name].gsub("solidus_friendly_promotions/", "")
55
+ end
52
56
  end
53
57
  end
54
58
  end
@@ -53,7 +53,7 @@ module SolidusFriendlyPromotions
53
53
 
54
54
  def destroy
55
55
  @promotion_action = @promotion.actions.find(params[:id])
56
- if @promotion_action.discard
56
+ if @promotion_action.destroy
57
57
  flash[:success] =
58
58
  t("spree.successfully_removed", resource: SolidusFriendlyPromotions::PromotionAction.model_name.human)
59
59
  end
@@ -25,6 +25,18 @@ module SolidusFriendlyPromotions
25
25
  def build_promotion_code_batch
26
26
  @promotion_code_batch.process
27
27
  end
28
+
29
+ def model_class
30
+ SolidusFriendlyPromotions::PromotionCodeBatch
31
+ end
32
+
33
+ def collection
34
+ parent.code_batches
35
+ end
36
+
37
+ def build_resource
38
+ parent.code_batches.build
39
+ end
28
40
  end
29
41
  end
30
42
  end
@@ -63,7 +63,7 @@ module SolidusFriendlyPromotions
63
63
 
64
64
  def validate_promotion_rule_type
65
65
  requested_type = params[:promotion_rule].delete(:type)
66
- promotion_rule_types = SolidusFriendlyPromotions.config.send("#{@level}_rules")
66
+ promotion_rule_types = SolidusFriendlyPromotions.config.send(:"#{@level}_rules")
67
67
  @promotion_rule_type = promotion_rule_types.detect do |klass|
68
68
  klass.name == requested_type
69
69
  end
@@ -5,7 +5,7 @@ module SolidusFriendlyPromotions
5
5
  module PromotionRulesHelper
6
6
  def options_for_promotion_rule_types(promotion_rule, level)
7
7
  existing = promotion_rule.promotion.rules.select(&:persisted?).map { |rule| rule.class.name }
8
- rules = SolidusFriendlyPromotions.config.send("#{level}_rules").reject { |rule| existing.include? rule.name }
8
+ rules = SolidusFriendlyPromotions.config.send(:"#{level}_rules").reject { |rule| existing.include? rule.name }
9
9
  options = rules.map { |rule| [rule.model_name.human, rule.name] }
10
10
  options_for_select(options, promotion_rule.type.to_s)
11
11
  end
@@ -12,7 +12,7 @@ module SolidusFriendlyPromotions
12
12
  end
13
13
 
14
14
  def eligible?(promotable)
15
- send("#{promotable.class.name.demodulize.underscore}_eligible?", promotable)
15
+ send(:"#{promotable.class.name.demodulize.underscore}_eligible?", promotable)
16
16
  end
17
17
 
18
18
  def level
@@ -13,7 +13,8 @@ module SolidusFriendlyPromotions
13
13
  def call
14
14
  order.reset_current_discounts
15
15
 
16
- return order if order.shipped?
16
+ return order if (!SolidusFriendlyPromotions.config.recalculate_complete_orders && order.complete?) || order.shipped?
17
+
17
18
  discounted_order = DiscountOrder.new(order, promotions, dry_run: dry_run).call
18
19
 
19
20
  PersistDiscountedOrder.new(discounted_order).call unless dry_run
@@ -2,11 +2,13 @@
2
2
 
3
3
  module SolidusFriendlyPromotions
4
4
  class Promotion < Spree::Base
5
+ include Spree::SoftDeletable
6
+
5
7
  belongs_to :category, class_name: "SolidusFriendlyPromotions::PromotionCategory",
6
8
  foreign_key: :promotion_category_id, optional: true
7
9
  belongs_to :original_promotion, class_name: "Spree::Promotion", optional: true
8
10
  has_many :rules, class_name: "SolidusFriendlyPromotions::PromotionRule", dependent: :destroy
9
- has_many :actions, class_name: "SolidusFriendlyPromotions::PromotionAction", dependent: :nullify
11
+ has_many :actions, class_name: "SolidusFriendlyPromotions::PromotionAction", dependent: :destroy
10
12
  has_many :codes, class_name: "SolidusFriendlyPromotions::PromotionCode", dependent: :destroy
11
13
  has_many :code_batches, class_name: "SolidusFriendlyPromotions::PromotionCodeBatch", dependent: :destroy
12
14
  has_many :order_promotions, class_name: "SolidusFriendlyPromotions::OrderPromotion", dependent: :destroy
@@ -49,7 +51,7 @@ module SolidusFriendlyPromotions
49
51
 
50
52
  self.allowed_ransackable_associations = ["codes"]
51
53
  self.allowed_ransackable_attributes = %w[name customer_label path promotion_category_id lane updated_at]
52
- self.allowed_ransackable_scopes = %i[active]
54
+ self.allowed_ransackable_scopes = %i[active with_discarded]
53
55
 
54
56
  # All orders that have been discounted using this promotion
55
57
  def discounted_orders
@@ -9,9 +9,10 @@ module SolidusFriendlyPromotions
9
9
  # by an event and determined to be eligible.
10
10
  class PromotionAction < Spree::Base
11
11
  include Spree::Preferences::Persistable
12
- include Spree::SoftDeletable
13
12
  include Spree::CalculatedAdjustments
14
13
  include Spree::AdjustmentSource
14
+ before_destroy :remove_adjustments_from_incomplete_orders
15
+ before_destroy :raise_for_adjustments_for_completed_orders
15
16
 
16
17
  belongs_to :promotion, inverse_of: :actions
17
18
  belongs_to :original_promotion_action, class_name: "Spree::PromotionAction", optional: true
@@ -69,5 +70,14 @@ module SolidusFriendlyPromotions
69
70
  def available_calculators
70
71
  SolidusFriendlyPromotions.config.promotion_calculators[self.class] || (raise NotImplementedError)
71
72
  end
73
+
74
+ private
75
+
76
+ def raise_for_adjustments_for_completed_orders
77
+ if adjustments.joins(:order).merge(Spree::Order.complete).any?
78
+ errors.add(:base, :cannot_destroy_if_order_completed)
79
+ throw(:abort)
80
+ end
81
+ end
72
82
  end
73
83
  end
@@ -4,6 +4,8 @@ module SolidusFriendlyPromotions
4
4
  class PromotionCode < Spree::Base
5
5
  belongs_to :promotion, inverse_of: :codes
6
6
  belongs_to :promotion_code_batch, inverse_of: :promotion_codes, optional: true
7
+
8
+ has_many :order_promotions, class_name: "SolidusFriendlyPromotions::OrderPromotion", dependent: :destroy
7
9
  has_many :adjustments, class_name: "Spree::Adjustment"
8
10
 
9
11
  before_validation :normalize_code
@@ -21,7 +21,7 @@
21
21
  <%= render 'solidus_friendly_promotions/admin/promotion_actions/form', form: form %>
22
22
  <div class="row">
23
23
  <div class="col-12">
24
- <%= button_tag "Update", class: "btn btn-secondary float-right" %>
24
+ <%= button_tag t(:update, scope: [:solidus_friendly_promotions, :crud]), class: "btn btn-secondary float-right" %>
25
25
  </div>
26
26
  </div>
27
27
  <% end %>
@@ -9,45 +9,7 @@
9
9
  <p>
10
10
  <%= admin_hint(
11
11
  calculator.model_name.human,
12
- """
13
- <p>
14
- This amount will be distributed to line items weighted relative to
15
- their price. More expensive line items will receive a greater share
16
- of the adjustment.
17
- </p>
18
-
19
- <p>
20
- For example, with three line items and a preferred amount of $15 we
21
- would end up with the following distribution:
22
- </p>
23
-
24
- <table>
25
- <thead>
26
- <tr>
27
- <th></th>
28
- <th>Price</th>
29
- <th>Weighted Adj.</th>
30
- </tr>
31
- </thead>
32
- <tbody>
33
- <tr>
34
- <td>Socks</td>
35
- <td>$5</td>
36
- <td>-$1.5</td>
37
- </tr>
38
- <tr>
39
- <td>Shoes</td>
40
- <td>$30</td>
41
- <td>-$9</td>
42
- </tr>
43
- <tr>
44
- <td>Slippers</td>
45
- <td>$15</td>
46
- <td>-$4.5</td>
47
- </tr>
48
- </tbody>
49
- </table>
50
- """
12
+ calculator.class.human_attribute_name(:explanation)
51
13
  ) %>
52
14
 
53
15
  This amount will be the <strong>total</strong> discount spread amongst all
@@ -16,7 +16,7 @@
16
16
  <%= render 'form', form: form %>
17
17
  <div class="row">
18
18
  <div class="col-12">
19
- <%= button_tag "Add", class: "btn btn-secondary float-right" %>
19
+ <%= button_tag t(:add, scope: [:solidus_friendly_promotions, :crud]), class: "btn btn-secondary float-right" %>
20
20
  </div>
21
21
  </div>
22
22
  <% end %>
@@ -0,0 +1,22 @@
1
+ <div class="field">
2
+ <%= batch.label :base_code, class: "required" %>
3
+ <%= batch.text_field :base_code, class: "fullwidth", required: true %>
4
+ </div>
5
+ <div class="field">
6
+ <%= batch.label :number_of_codes, class: "required" %>
7
+ <%= batch.number_field :number_of_codes, class: "fullwidth", min: 1, required: true %>
8
+ </div>
9
+ <div class="field">
10
+ <%= batch.label :join_characters %>
11
+ <%= batch.text_field :join_characters, class: "fullwidth" %>
12
+ </div>
13
+ <% unless promotion_id %>
14
+ <div class="field">
15
+ <%= f.label :per_code_usage_limit %>
16
+ <%= f.text_field :per_code_usage_limit, class: "fullwidth" %>
17
+ </div>
18
+ <% end %>
19
+ <div class="field">
20
+ <%= batch.label :email %>
21
+ <%= batch.text_field :email, class: "fullwidth" %>
22
+ </div>
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ CSV.generate do |csv|
4
+ csv << ["Code"]
5
+ @promotion_code_batch.promotion_codes.order(:id).pluck(:value).each do |value|
6
+ csv << [value]
7
+ end
8
+ end
@@ -0,0 +1,65 @@
1
+ <% admin_breadcrumb(link_to plural_resource_name(SolidusFriendlyPromotions::Promotion), solidus_friendly_promotions.admin_promotions_path) %>
2
+ <% admin_breadcrumb(link_to @promotion.name, solidus_friendly_promotions.edit_admin_promotion_path(@promotion.id)) %>
3
+ <% admin_breadcrumb(plural_resource_name(SolidusFriendlyPromotions::PromotionCodeBatch)) %>
4
+
5
+ <% content_for :page_actions do %>
6
+ <li>
7
+ <% if can?(:create, SolidusFriendlyPromotions::PromotionCodeBatch) %>
8
+ <%= link_to t('solidus_friendly_promotions.new_promotion_code_batch'), new_object_url, class: 'btn btn-primary' %>
9
+ <% end %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <% if @promotion_code_batches.any? %>
14
+ <table>
15
+ <thead>
16
+ <tr>
17
+ <th><%= SolidusFriendlyPromotions::PromotionCodeBatch.human_attribute_name(:base_code) %></th>
18
+ <th><%= SolidusFriendlyPromotions::PromotionCodeBatch.human_attribute_name(:total_codes) %></th>
19
+ <th><%= SolidusFriendlyPromotions::PromotionCodeBatch.human_attribute_name(:status) %></th>
20
+ <th><%= SolidusFriendlyPromotions::PromotionCodeBatch.human_attribute_name(:email) %></th>
21
+ </tr>
22
+ </thead>
23
+ <tbody>
24
+ <% @promotion_code_batches.each do |promotion_code_batch| %>
25
+ <tr>
26
+ <td><%= promotion_code_batch.base_code %></td>
27
+ <td><%= promotion_code_batch.number_of_codes %></td>
28
+ <td>
29
+ <% if promotion_code_batch.error.present? %>
30
+ <%= t(
31
+ "solidus_friendly_promotions.promotion_code_batches.errored",
32
+ error: promotion_code_batch.error
33
+ ) %>
34
+ <% elsif promotion_code_batch.finished? %>
35
+ <%= t(
36
+ "solidus_friendly_promotions.promotion_code_batches.finished",
37
+ number_of_codes: promotion_code_batch.number_of_codes
38
+ ) %>
39
+ <%= link_to(
40
+ t('solidus_friendly_promotions.download_promotion_codes_list'),
41
+ admin_promotion_promotion_code_batch_download_path(
42
+ promotion_code_batch_id: promotion_code_batch.id,
43
+ format: :csv
44
+ )
45
+ ) %>
46
+ <% else %>
47
+ <%= t(
48
+ "solidus_friendly_promotions.promotion_code_batches.processing",
49
+ number_of_codes: promotion_code_batch.number_of_codes,
50
+ number_of_codes_processed: promotion_code_batch.promotion_codes.count
51
+ ) %>
52
+ <% end %>
53
+ </td>
54
+ <td><%= promotion_code_batch.email %></td>
55
+ </tr>
56
+ <% end %>
57
+ </tbody>
58
+ </table>
59
+ <% else %>
60
+ <div class="no-objects-found">
61
+ <%= render 'spree/admin/shared/no_objects_found',
62
+ resource: SolidusFriendlyPromotions::PromotionCodeBatch,
63
+ new_resource_url: new_object_url %>
64
+ </div>
65
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <% admin_breadcrumb(link_to plural_resource_name(Spree::Promotion), spree.admin_promotions_path) %>
2
+ <% admin_breadcrumb(link_to @promotion.name, spree.admin_promotion_path(@promotion.id)) %>
3
+ <% admin_breadcrumb(plural_resource_name(Spree::PromotionCodeBatch)) %>
4
+ <%= form_for :promotion_code_batch, url: collection_url do |batch| %>
5
+ <%= batch.hidden_field :promotion_id, value: params[:promotion_id] %>
6
+ <%= render partial: 'form_fields', locals: {batch: batch, promotion_id: params[:promotion_id]} %>
7
+ <%= batch.submit t('spree.actions.create'), class: 'btn btn-primary' %>
8
+ <% end %>
@@ -14,7 +14,7 @@
14
14
  </thead>
15
15
  <tbody>
16
16
  <% promotions.each do |promotion| %>
17
- <tr id="<%= spree_dom_id promotion %>">
17
+ <tr class="<%= 'deleted' if promotion.discarded? %>" id="<%= spree_dom_id promotion %>">
18
18
  <td><%= promotion.name %></td>
19
19
  <td>
20
20
  <%= (promotion.codes.size == 1) ? promotion.codes.pluck(:value).first : t('solidus_friendly_promotions.number_of_codes', count: promotion.codes.size) %>
@@ -43,10 +43,10 @@
43
43
  <%= l(promotion.updated_at, format: :short) %>
44
44
  </td>
45
45
  <td class="actions">
46
- <% if can?(:edit, promotion) %>
46
+ <% if can?(:edit, promotion) && !promotion.discarded? %>
47
47
  <%= link_to_edit promotion, no_text: true %>
48
48
  <% end %>
49
- <% if can?(:destroy, promotion) %>
49
+ <% if can?(:destroy, promotion) && !promotion.discarded? %>
50
50
  <%= link_to_delete promotion, no_text: true %>
51
51
  <% end %>
52
52
  </td>
@@ -43,6 +43,15 @@
43
43
  </div>
44
44
  </div>
45
45
 
46
+ <div class="col-2">
47
+ <div class="field checkbox">
48
+ <label>
49
+ <%= f.check_box :with_discarded, { checked: params[:q][:with_discarded] == 'true', class: 'js-with-discarded-input' }, 'true', 'false' %>
50
+ <%= t('spree.show_deleted') %>
51
+ </label>
52
+ </div>
53
+ </div>
54
+
46
55
  <div class="col-2">
47
56
  <div class="field">
48
57
  <%= label_tag :q_promotion_category_id_eq, SolidusFriendlyPromotions::PromotionCategory.model_name.human %><br>
@@ -5,10 +5,10 @@
5
5
  <% if can? :admin, SolidusFriendlyPromotions::PromotionCategory %>
6
6
  <%= tab url: solidus_friendly_promotions.admin_promotion_categories_path, label: :promotion_categories %>
7
7
  <% end %>
8
- <% if can? :admin, Spree::Promotion && Spree::Promotion.any? %>
8
+ <% if can?(:admin, Spree::Promotion) && Spree::Promotion.any? %>
9
9
  <%= tab url: spree.admin_promotions_path, label: :legacy_promotions %>
10
10
  <% end %>
11
- <% if can? :admin, Spree::PromotionCategory && Spree::PromotionCategory.any? %>
11
+ <% if can?(:admin, Spree::PromotionCategory) && Spree::PromotionCategory.any? %>
12
12
  <%= tab url: spree.admin_promotion_categories_path, label: :legacy_promotion_categories %>
13
13
  <% end %>
14
14
  </ul>
data/bin/sandbox CHANGED
@@ -65,6 +65,7 @@ unbundled bundle exec rake db:drop db:create
65
65
 
66
66
  unbundled bin/rails generate solidus:install \
67
67
  --auto-accept \
68
+ --admin_preview=false \
68
69
  $@
69
70
 
70
71
  unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
@@ -39,6 +39,9 @@ en:
39
39
  no_rules_added: No Rules Added
40
40
  promotion_successfully_created: Promotion has been successfully created!
41
41
  promotion_total_changed_before_complete: One or more of the promotions on your order have become ineligible and were removed. Please check the new order amounts and try again.
42
+ promotion_code_batches:
43
+ finished: Finished
44
+ errored: Errored
42
45
  view_promotion_codes_list: View codes list
43
46
  promotion_rules:
44
47
  line_item_product:
@@ -190,6 +193,9 @@ en:
190
193
  solidus_friendly_promotions/rules/user: User
191
194
  solidus_friendly_promotions/rules/user_logged_in: User Logged In
192
195
  solidus_friendly_promotions/rules/user_role: User Role(s)
196
+ solidus_friendly_promotions/promotion_code_batch:
197
+ one: Code batch
198
+ other: Code batches
193
199
  attributes:
194
200
  solidus_friendly_promotions/promotion:
195
201
  active: Active
@@ -269,9 +275,49 @@ en:
269
275
  description: Provides a discount calculated by percent of the discountable amount of the item being discounted
270
276
  solidus_friendly_promotions/calculators/distributed_amount:
271
277
  description: Distributed the configured amount among all eligible line items of the order
278
+ explanation: |
279
+ <p>
280
+ This amount will be distributed to line items weighted relative to
281
+ their price. More expensive line items will receive a greater share
282
+ of the adjustment.
283
+ </p>
284
+ <p>
285
+ For example, with three line items and a preferred amount of $15 we
286
+ would end up with the following distribution:
287
+ </p>
288
+ <table>
289
+ <thead>
290
+ <tr>
291
+ <th></th>
292
+ <th>Price</th>
293
+ <th>Weighted Adj.</th>
294
+ </tr>
295
+ </thead>
296
+ <tbody>
297
+ <tr>
298
+ <td>Socks</td>
299
+ <td>$5</td>
300
+ <td>-$1.5</td>
301
+ </tr>
302
+ <tr>
303
+ <td>Shoes</td>
304
+ <td>$30</td>
305
+ <td>-$9</td>
306
+ </tr>
307
+ <tr>
308
+ <td>Slippers</td>
309
+ <td>$15</td>
310
+ <td>-$4.5</td>
311
+ </tr>
312
+ </tbody>
313
+ </table>
272
314
 
273
315
  errors:
274
316
  models:
317
+ solidus_friendly_promotions/promotion_action:
318
+ attributes:
319
+ base:
320
+ cannot_destroy_if_order_completed: Action has been applied to complete orders. It cannot be destroyed.
275
321
  solidus_friendly_promotions/promotion_code:
276
322
  attributes:
277
323
  base:
@@ -0,0 +1,6 @@
1
+ class AddDeletedAtToPromotions < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :friendly_promotions, :deleted_at, :datetime
4
+ add_index :friendly_promotions, :deleted_at
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class DropDeletedAtFromPromotionActions < ActiveRecord::Migration[7.0]
2
+ def change
3
+ remove_column :friendly_promotion_actions, :deleted_at, :datetime, null: true
4
+ end
5
+ end
@@ -5,10 +5,12 @@ require "spree/core/environment_extension"
5
5
  module SolidusFriendlyPromotions
6
6
  class Configuration < Spree::Preferences::Configuration
7
7
  attr_accessor :sync_order_promotions
8
+ attr_accessor :recalculate_complete_orders
8
9
  attr_accessor :promotion_calculators
9
10
 
10
11
  def initialize
11
12
  @sync_order_promotions = true
13
+ @recalculate_complete_orders = true
12
14
  @promotion_calculators = NestedClassSet.new
13
15
  end
14
16
 
@@ -94,7 +94,7 @@ module SolidusFriendlyPromotions
94
94
  else
95
95
  new_rule = new_promo_rule_class.new(old_promotion_rule.attributes.except(*PROMOTION_IGNORED_ATTRIBUTES))
96
96
  new_rule.preload_relations.each do |relation|
97
- new_rule.send("#{relation}=", old_promotion_rule.send(relation))
97
+ new_rule.send(:"#{relation}=", old_promotion_rule.send(relation))
98
98
  end
99
99
  [new_rule]
100
100
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusFriendlyPromotions
4
- VERSION = "1.0.0.rc.2"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -7,13 +7,18 @@ require "turbo-rails"
7
7
  require "importmap-rails"
8
8
  require "stimulus-rails"
9
9
  require "ransack-enum"
10
- require "solidus_friendly_promotions/nested_class_set"
11
- require "solidus_friendly_promotions/configuration"
12
- require "solidus_friendly_promotions/version"
13
- require "solidus_friendly_promotions/engine"
14
10
 
15
11
  module SolidusFriendlyPromotions
12
+ def self.table_name_prefix
13
+ "friendly_"
14
+ end
15
+
16
16
  # JS Importmap instance
17
17
  singleton_class.attr_accessor :importmap
18
18
  self.importmap = Importmap::Map.new
19
19
  end
20
+
21
+ require "solidus_friendly_promotions/nested_class_set"
22
+ require "solidus_friendly_promotions/configuration"
23
+ require "solidus_friendly_promotions/version"
24
+ require "solidus_friendly_promotions/engine"
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "BSD-3-Clause"
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "https://github.com/solidusio-contrib/solidus_friendly_promotions"
18
- spec.metadata["changelog_uri"] = "https://github.com/solidusio-contrib/solidus_friendly_promotions/blob/master/CHANGELOG.md"
17
+ spec.metadata["source_code_uri"] = "https://github.com/friendlycart/solidus_friendly_promotions"
18
+ spec.metadata["changelog_uri"] = "https://github.com/friendlycart/solidus_friendly_promotions/blob/master/CHANGELOG.md"
19
19
 
20
20
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5", "< 4")
21
21
 
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.0.rc.2
4
+ version: 1.0.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: 2023-11-11 00:00:00.000000000 Z
11
+ date: 2024-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -209,7 +209,6 @@ files:
209
209
  - app/models/concerns/solidus_friendly_promotions/rules/line_item_level_rule.rb
210
210
  - app/models/concerns/solidus_friendly_promotions/rules/order_level_rule.rb
211
211
  - app/models/concerns/solidus_friendly_promotions/rules/shipment_level_rule.rb
212
- - app/models/solidus_friendly_promotions.rb
213
212
  - app/models/solidus_friendly_promotions/actions/adjust_line_item.rb
214
213
  - app/models/solidus_friendly_promotions/actions/adjust_line_item_quantity_groups.rb
215
214
  - app/models/solidus_friendly_promotions/actions/adjust_shipment.rb
@@ -291,6 +290,10 @@ files:
291
290
  - app/views/solidus_friendly_promotions/admin/promotion_categories/edit.html.erb
292
291
  - app/views/solidus_friendly_promotions/admin/promotion_categories/index.html.erb
293
292
  - app/views/solidus_friendly_promotions/admin/promotion_categories/new.html.erb
293
+ - app/views/solidus_friendly_promotions/admin/promotion_code_batches/_form_fields.html.erb
294
+ - app/views/solidus_friendly_promotions/admin/promotion_code_batches/download.csv.ruby
295
+ - app/views/solidus_friendly_promotions/admin/promotion_code_batches/index.html.erb
296
+ - app/views/solidus_friendly_promotions/admin/promotion_code_batches/new.html.erb
294
297
  - app/views/solidus_friendly_promotions/admin/promotion_codes/index.csv.ruby
295
298
  - app/views/solidus_friendly_promotions/admin/promotion_codes/index.html.erb
296
299
  - app/views/solidus_friendly_promotions/admin/promotion_codes/new.html.erb
@@ -335,7 +338,6 @@ files:
335
338
  - bin/sandbox
336
339
  - bin/setup
337
340
  - config/importmap.rb
338
- - config/initializers/solidus_friendly_promotions.rb
339
341
  - config/locales/en.yml
340
342
  - config/routes.rb
341
343
  - db/migrate/20230703101637_create_promotions.rb
@@ -363,6 +365,8 @@ files:
363
365
  - db/migrate/20231012120928_add_db_comments_to_friendly_promotion_categories.rb
364
366
  - db/migrate/20231013181921_add_original_promotion_ids.rb
365
367
  - db/migrate/20231104135812_add_managed_by_order_action_to_line_items.rb
368
+ - db/migrate/20240124104855_add_deleted_at_to_promotions.rb
369
+ - db/migrate/20240125102050_drop_deleted_at_from_promotion_actions.rb
366
370
  - lib/generators/solidus_friendly_promotions/install/install_generator.rb
367
371
  - lib/generators/solidus_friendly_promotions/install/templates/initializer.rb
368
372
  - lib/solidus_friendly_promotions.rb
@@ -390,8 +394,8 @@ licenses:
390
394
  - BSD-3-Clause
391
395
  metadata:
392
396
  homepage_uri: https://github.com/solidusio-contrib/solidus_friendly_promotions#readme
393
- source_code_uri: https://github.com/solidusio-contrib/solidus_friendly_promotions
394
- changelog_uri: https://github.com/solidusio-contrib/solidus_friendly_promotions/blob/master/CHANGELOG.md
397
+ source_code_uri: https://github.com/friendlycart/solidus_friendly_promotions
398
+ changelog_uri: https://github.com/friendlycart/solidus_friendly_promotions/blob/master/CHANGELOG.md
395
399
  post_install_message:
396
400
  rdoc_options: []
397
401
  require_paths:
@@ -406,9 +410,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
406
410
  version: '4'
407
411
  required_rubygems_version: !ruby/object:Gem::Requirement
408
412
  requirements:
409
- - - ">"
413
+ - - ">="
410
414
  - !ruby/object:Gem::Version
411
- version: 1.3.1
415
+ version: '0'
412
416
  requirements: []
413
417
  rubygems_version: 3.4.20
414
418
  signing_key:
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SolidusFriendlyPromotions
4
- def self.table_name_prefix
5
- "friendly_"
6
- end
7
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative SolidusFriendlyPromotions::Engine.root.join("app/models/solidus_friendly_promotions.rb")