solidus_friendly_promotions 1.0.0.rc.2 → 1.0.0.rc.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84ea9571f3d2a4a2dfe9e789c0f3887a0aca2d9559a68004806cd67c395fc959
4
- data.tar.gz: 929a14c4f917aad08c6bf7faa7f93c7be071dc43ad72641ddf0394cf336022db
3
+ metadata.gz: bb47848b0ee568a1116d827ac87f0071afd5790eff84d501860c0ed68eb37ac1
4
+ data.tar.gz: fd5c9d4ac486641ab72f87129cfbf7a7a44ea5b3c1a18970c479794f410dcd9f
5
5
  SHA512:
6
- metadata.gz: 9e49887ad42376b60165ab1d5a8067942adde8d9861681e165b0617155eb74f42a5ea97f2bd94ce929ee5627156ab249ab392b5259e775ecdb53414444bb94be
7
- data.tar.gz: cc68b4daf7520de18dbe22bd0b74a73e1a4b009d031d8703b86f7e6d5ad11cfd5999159b48cdb0bfc7801235fe8587bc5c7cfe56a76fb18eee3fef7b48c903a4
6
+ metadata.gz: 71269bc48e02192efa3d41c83fe461bed7b3b0c8b1d123cfa555671ee5baea159f7e49521d203124ec1c23e2bedecc641e2a6b44ff5b18ad013438c2255fee50
7
+ data.tar.gz: 91b12062bff9c7324c9efdce8398ce6eac5ffd50b353848b1249c9a4146411b137c8354fee594861d03f490db9e4a05d0556f5bade2160596d04c56a7e3c452b
data/.circleci/config.yml CHANGED
@@ -21,7 +21,7 @@ jobs:
21
21
  - checkout
22
22
  - solidusio_extensions/dependencies
23
23
  - solidusio_extensions/run-tests-solidus-current
24
- - solidusio_extensions/run-tests-solidus-main
24
+ # - solidusio_extensions/run-tests-solidus-main
25
25
  run-specs-with-postgres:
26
26
  executor:
27
27
  name: solidusio_extensions/postgres
@@ -31,7 +31,7 @@ jobs:
31
31
  - checkout
32
32
  - solidusio_extensions/dependencies
33
33
  - solidusio_extensions/run-tests-solidus-current
34
- - solidusio_extensions/run-tests-solidus-main
34
+ # - solidusio_extensions/run-tests-solidus-main
35
35
  run-specs-with-sqlite:
36
36
  executor:
37
37
  name: solidusio_extensions/sqlite
@@ -41,7 +41,7 @@ jobs:
41
41
  - checkout
42
42
  - solidusio_extensions/dependencies
43
43
  - solidusio_extensions/run-tests-solidus-current
44
- - solidusio_extensions/run-tests-solidus-main
44
+ # - solidusio_extensions/run-tests-solidus-main
45
45
  workflows:
46
46
  Run specs on supported Solidus versions:
47
47
  jobs:
data/CHANGELOG.md CHANGED
@@ -1 +1,113 @@
1
1
  # Changelog
2
+
3
+ ## [Unreleased](https://github.com/FriendlyCart/solidus_friendly_promotions/tree/HEAD)
4
+
5
+ ## [v1.0.0.rc.2](https://github.com/FriendlyCart/solidus_friendly_promotions/tree/v1.0.0.rc.3) (2024-01-16)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Add configuration option: `recalculate_complete_orders` [\#97](https://github.com/friendlycart/solidus_friendly_promotions/pull/97) ([mamhoff](https://github.com/mamhoff))
10
+ - Fix standardrb violations [\#96](https://github.com/friendlycart/solidus_friendly_promotions/pull/96) ([mamhoff](https://github.com/mamhoff))
11
+ - Fix admin sub menu entry visibility condition [\#92](https://github.com/friendlycart/solidus_friendly_promotions/pull/92) ([mickenorlen](https://github.com/mickenorlen))
12
+ - Documentation fixes [\#91](https://github.com/friendlycart/solidus_friendly_promotions/pull/91) ([mamhoff](https://github.com/mamhoff))
13
+ - Fix typo [\#89](https://github.com/friendlycart/solidus_friendly_promotions/pull/89) ([jarednorman](https://github.com/jarednorman))
14
+ - Pass untranslated strings through i18n [\#88](https://github.com/friendlycart/solidus_friendly_promotions/pull/88) ([mamhoff](https://github.com/mamhoff))
15
+
16
+ ## [v1.0.0.rc.2](https://github.com/FriendlyCart/solidus_friendly_promotions/tree/v1.0.0.rc.2) (2023-11-11)
17
+
18
+ [Full Changelog](https://github.com/FriendlyCart/solidus_friendly_promotions/compare/v1.0.0.rc.1...v1.0.0.rc.2)
19
+
20
+ **Merged pull requests:**
21
+
22
+ - Refactor: Extract `Promotion#applicable_line_items` [\#86](https://github.com/friendlycart/solidus_friendly_promotions/pull/86) ([mamhoff](https://github.com/mamhoff))
23
+ - Coupon Promo Handler: Fix flaky spec [\#84](https://github.com/friendlycart/solidus_friendly_promotions/pull/84) ([mamhoff](https://github.com/mamhoff))
24
+ - 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))
25
+ - Tiered calculators [\#82](https://github.com/friendlycart/solidus_friendly_promotions/pull/82) ([mamhoff](https://github.com/mamhoff))
26
+ - Allow changing quantity for automatic line items [\#81](https://github.com/friendlycart/solidus_friendly_promotions/pull/81) ([mamhoff](https://github.com/mamhoff))
27
+ - Update MIGRATING.md [\#80](https://github.com/friendlycart/solidus_friendly_promotions/pull/80) ([tvdeyen](https://github.com/tvdeyen))
28
+ - Promotions index improvements [\#79](https://github.com/friendlycart/solidus_friendly_promotions/pull/79) ([mamhoff](https://github.com/mamhoff))
29
+ - Lint: Fix standardrb error [\#78](https://github.com/friendlycart/solidus_friendly_promotions/pull/78) ([mamhoff](https://github.com/mamhoff))
30
+
31
+ ## [v1.0.0.rc.1](https://github.com/FriendlyCart/solidus_friendly_promotions/tree/v1.0.0.rc.1) (2023-11-07)
32
+
33
+ [Full Changelog](https://github.com/FriendlyCart/solidus_friendly_promotions/compare/v1.0.0.pre...v1.0.0.rc.1)
34
+
35
+ **Merged pull requests:**
36
+
37
+ - Goodies! [\#75](https://github.com/friendlycart/solidus_friendly_promotions/pull/75) ([mamhoff](https://github.com/mamhoff))
38
+ - Add a null promotion handler [\#71](https://github.com/friendlycart/solidus_friendly_promotions/pull/71) ([mamhoff](https://github.com/mamhoff))
39
+
40
+ ## [v1.0.0.pre](https://github.com/FriendlyCart/solidus_friendly_promotions/tree/v1.0.0.pre) (2023-11-07)
41
+
42
+ [Full Changelog](https://github.com/FriendlyCart/solidus_friendly_promotions/compare/e14802957fdb55d7f4e2730341e4cbb118ebf993...v1.0.0.pre)
43
+
44
+ **Merged pull requests:**
45
+
46
+ - Use new NestedClassSet for configuring calculators [\#77](https://github.com/friendlycart/solidus_friendly_promotions/pull/77) ([mamhoff](https://github.com/mamhoff))
47
+ - Refactor to FriendlyPromotion::FriendlyPromotionAdjuster [\#76](https://github.com/friendlycart/solidus_friendly_promotions/pull/76) ([mamhoff](https://github.com/mamhoff))
48
+ - Add bundler/gem\_tasks [\#74](https://github.com/friendlycart/solidus_friendly_promotions/pull/74) ([mamhoff](https://github.com/mamhoff))
49
+ - Fix order discounter spec [\#73](https://github.com/friendlycart/solidus_friendly_promotions/pull/73) ([mamhoff](https://github.com/mamhoff))
50
+ - Quantity tiered calculator [\#72](https://github.com/friendlycart/solidus_friendly_promotions/pull/72) ([mamhoff](https://github.com/mamhoff))
51
+ - Add PromotionHandler::Page [\#70](https://github.com/friendlycart/solidus_friendly_promotions/pull/70) ([mamhoff](https://github.com/mamhoff))
52
+ - Never create adjustments with a zero amount [\#69](https://github.com/friendlycart/solidus_friendly_promotions/pull/69) ([mamhoff](https://github.com/mamhoff))
53
+ - Ignore shipping rates that have no cost [\#68](https://github.com/friendlycart/solidus_friendly_promotions/pull/68) ([davecandlescience](https://github.com/davecandlescience))
54
+ - Refactor promotions eligibility [\#67](https://github.com/friendlycart/solidus_friendly_promotions/pull/67) ([mamhoff](https://github.com/mamhoff))
55
+ - Refactor order promotions migrator [\#66](https://github.com/friendlycart/solidus_friendly_promotions/pull/66) ([mamhoff](https://github.com/mamhoff))
56
+ - Add migrate order promotions rake task [\#65](https://github.com/friendlycart/solidus_friendly_promotions/pull/65) ([davecandlescience](https://github.com/davecandlescience))
57
+ - Add missing relation: SolidusFriendlyPromotions\#order\_promotions [\#64](https://github.com/friendlycart/solidus_friendly_promotions/pull/64) ([mamhoff](https://github.com/mamhoff))
58
+ - Promo Migrator: Ignore missing rules and actions [\#63](https://github.com/friendlycart/solidus_friendly_promotions/pull/63) ([mamhoff](https://github.com/mamhoff))
59
+ - Improve spec for product rule [\#62](https://github.com/friendlycart/solidus_friendly_promotions/pull/62) ([mamhoff](https://github.com/mamhoff))
60
+ - 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))
61
+ - Add a migration guide [\#60](https://github.com/friendlycart/solidus_friendly_promotions/pull/60) ([mamhoff](https://github.com/mamhoff))
62
+ - Add a PromotionHandler::Coupon [\#59](https://github.com/friendlycart/solidus_friendly_promotions/pull/59) ([mamhoff](https://github.com/mamhoff))
63
+ - Backports minimum quantity promotion rule from Solidus [\#58](https://github.com/friendlycart/solidus_friendly_promotions/pull/58) ([mamhoff](https://github.com/mamhoff))
64
+ - Backport promotion code batch fix from Solidus [\#57](https://github.com/friendlycart/solidus_friendly_promotions/pull/57) ([mamhoff](https://github.com/mamhoff))
65
+ - 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))
66
+ - Add missing shipping\_rate translation [\#55](https://github.com/friendlycart/solidus_friendly_promotions/pull/55) ([davecandlescience](https://github.com/davecandlescience))
67
+ - Fix shipping rate discount factory [\#54](https://github.com/friendlycart/solidus_friendly_promotions/pull/54) ([mamhoff](https://github.com/mamhoff))
68
+ - Order Discounter: Create valid shipping rate discounts [\#53](https://github.com/friendlycart/solidus_friendly_promotions/pull/53) ([mamhoff](https://github.com/mamhoff))
69
+ - FriendlyPromotionDiscounter: Always return @order [\#52](https://github.com/friendlycart/solidus_friendly_promotions/pull/52) ([mamhoff](https://github.com/mamhoff))
70
+ - Line Item Product Rule: Add error messaging [\#50](https://github.com/friendlycart/solidus_friendly_promotions/pull/50) ([mamhoff](https://github.com/mamhoff))
71
+ - Fix: SolidusFriendlyPromotions, not Shipping [\#49](https://github.com/friendlycart/solidus_friendly_promotions/pull/49) ([mamhoff](https://github.com/mamhoff))
72
+ - Import eligiblity error messages from Solidus [\#48](https://github.com/friendlycart/solidus_friendly_promotions/pull/48) ([mamhoff](https://github.com/mamhoff))
73
+ - Faster promotion code migration [\#47](https://github.com/friendlycart/solidus_friendly_promotions/pull/47) ([mamhoff](https://github.com/mamhoff))
74
+ - Migrator: Store original promotion and promotion action [\#46](https://github.com/friendlycart/solidus_friendly_promotions/pull/46) ([mamhoff](https://github.com/mamhoff))
75
+ - Lint with standardrb in CI [\#45](https://github.com/friendlycart/solidus_friendly_promotions/pull/45) ([mamhoff](https://github.com/mamhoff))
76
+ - Migrator: Migrate promotion codes and promotion code batches [\#44](https://github.com/friendlycart/solidus_friendly_promotions/pull/44) ([mamhoff](https://github.com/mamhoff))
77
+ - Migrate promotion categories and association [\#43](https://github.com/friendlycart/solidus_friendly_promotions/pull/43) ([davecandlescience](https://github.com/davecandlescience))
78
+ - On the fly order promotions [\#42](https://github.com/friendlycart/solidus_friendly_promotions/pull/42) ([mamhoff](https://github.com/mamhoff))
79
+ - Add back references to promotions and actions [\#41](https://github.com/friendlycart/solidus_friendly_promotions/pull/41) ([davecandlescience](https://github.com/davecandlescience))
80
+ - Fix spec warning in promotion rules spec [\#40](https://github.com/friendlycart/solidus_friendly_promotions/pull/40) ([mamhoff](https://github.com/mamhoff))
81
+ - Transparently replace promotion adjustments [\#39](https://github.com/friendlycart/solidus_friendly_promotions/pull/39) ([mamhoff](https://github.com/mamhoff))
82
+ - Add DB comments to tables [\#38](https://github.com/friendlycart/solidus_friendly_promotions/pull/38) ([mamhoff](https://github.com/mamhoff))
83
+ - Fix Promotion Map [\#36](https://github.com/friendlycart/solidus_friendly_promotions/pull/36) ([mamhoff](https://github.com/mamhoff))
84
+ - Fix specs [\#29](https://github.com/friendlycart/solidus_friendly_promotions/pull/29) ([mamhoff](https://github.com/mamhoff))
85
+ - Add Promotion Migrator [\#28](https://github.com/friendlycart/solidus_friendly_promotions/pull/28) ([mamhoff](https://github.com/mamhoff))
86
+ - Polyvalent rules [\#27](https://github.com/friendlycart/solidus_friendly_promotions/pull/27) ([mamhoff](https://github.com/mamhoff))
87
+ - Fix Turbo frame tags for Turbo 1.5 [\#26](https://github.com/friendlycart/solidus_friendly_promotions/pull/26) ([mamhoff](https://github.com/mamhoff))
88
+ - Allow destroying promotions [\#25](https://github.com/friendlycart/solidus_friendly_promotions/pull/25) ([mamhoff](https://github.com/mamhoff))
89
+ - Fix class name option in line item taxon association [\#24](https://github.com/friendlycart/solidus_friendly_promotions/pull/24) ([mamhoff](https://github.com/mamhoff))
90
+ - Move factories to factories folder [\#23](https://github.com/friendlycart/solidus_friendly_promotions/pull/23) ([mamhoff](https://github.com/mamhoff))
91
+ - Add links to legacy promotions in Solidus 4.1 [\#22](https://github.com/friendlycart/solidus_friendly_promotions/pull/22) ([mamhoff](https://github.com/mamhoff))
92
+ - Make lanes configurable [\#21](https://github.com/friendlycart/solidus_friendly_promotions/pull/21) ([mamhoff](https://github.com/mamhoff))
93
+ - Allow order rules per lane [\#20](https://github.com/friendlycart/solidus_friendly_promotions/pull/20) ([mamhoff](https://github.com/mamhoff))
94
+ - Add PermissionSet for Friendly Promotions [\#19](https://github.com/friendlycart/solidus_friendly_promotions/pull/19) ([mamhoff](https://github.com/mamhoff))
95
+ - Add "only" match policy to product rule [\#18](https://github.com/friendlycart/solidus_friendly_promotions/pull/18) ([mamhoff](https://github.com/mamhoff))
96
+ - Require solidus [\#17](https://github.com/friendlycart/solidus_friendly_promotions/pull/17) ([mamhoff](https://github.com/mamhoff))
97
+ - Customer label [\#16](https://github.com/friendlycart/solidus_friendly_promotions/pull/16) ([mamhoff](https://github.com/mamhoff))
98
+ - System specs with turbo [\#15](https://github.com/friendlycart/solidus_friendly_promotions/pull/15) ([mamhoff](https://github.com/mamhoff))
99
+ - Reference our own I18n namespace in views [\#14](https://github.com/friendlycart/solidus_friendly_promotions/pull/14) ([mamhoff](https://github.com/mamhoff))
100
+ - Use different path for friendly promotions [\#13](https://github.com/friendlycart/solidus_friendly_promotions/pull/13) ([mamhoff](https://github.com/mamhoff))
101
+ - Add dependent: :destroy to Spree::Order\#friendly\_promotions [\#12](https://github.com/friendlycart/solidus_friendly_promotions/pull/12) ([mamhoff](https://github.com/mamhoff))
102
+ - Extract promotion loading from promo discounter [\#11](https://github.com/friendlycart/solidus_friendly_promotions/pull/11) ([mamhoff](https://github.com/mamhoff))
103
+ - Remove delegators [\#10](https://github.com/friendlycart/solidus_friendly_promotions/pull/10) ([mamhoff](https://github.com/mamhoff))
104
+ - Fix standardrb error in promotion rule spec [\#8](https://github.com/friendlycart/solidus_friendly_promotions/pull/8) ([mamhoff](https://github.com/mamhoff))
105
+ - Stacking Promotions [\#7](https://github.com/friendlycart/solidus_friendly_promotions/pull/7) ([mamhoff](https://github.com/mamhoff))
106
+ - Add "Lane" enum to Promotion [\#6](https://github.com/friendlycart/solidus_friendly_promotions/pull/6) ([mamhoff](https://github.com/mamhoff))
107
+ - Lint using standardrb gem [\#5](https://github.com/friendlycart/solidus_friendly_promotions/pull/5) ([mamhoff](https://github.com/mamhoff))
108
+ - Promotion Actions: Implement "edit" action [\#4](https://github.com/friendlycart/solidus_friendly_promotions/pull/4) ([mamhoff](https://github.com/mamhoff))
109
+ - 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))
110
+
111
+
112
+
113
+ \* *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
@@ -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
@@ -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 %>
@@ -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>
@@ -269,6 +269,42 @@ en:
269
269
  description: Provides a discount calculated by percent of the discountable amount of the item being discounted
270
270
  solidus_friendly_promotions/calculators/distributed_amount:
271
271
  description: Distributed the configured amount among all eligible line items of the order
272
+ explanation: |
273
+ <p>
274
+ This amount will be distributed to line items weighted relative to
275
+ their price. More expensive line items will receive a greater share
276
+ of the adjustment.
277
+ </p>
278
+ <p>
279
+ For example, with three line items and a preferred amount of $15 we
280
+ would end up with the following distribution:
281
+ </p>
282
+ <table>
283
+ <thead>
284
+ <tr>
285
+ <th></th>
286
+ <th>Price</th>
287
+ <th>Weighted Adj.</th>
288
+ </tr>
289
+ </thead>
290
+ <tbody>
291
+ <tr>
292
+ <td>Socks</td>
293
+ <td>$5</td>
294
+ <td>-$1.5</td>
295
+ </tr>
296
+ <tr>
297
+ <td>Shoes</td>
298
+ <td>$30</td>
299
+ <td>-$9</td>
300
+ </tr>
301
+ <tr>
302
+ <td>Slippers</td>
303
+ <td>$15</td>
304
+ <td>-$4.5</td>
305
+ </tr>
306
+ </tbody>
307
+ </table>
272
308
 
273
309
  errors:
274
310
  models:
@@ -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.rc.3"
5
5
  end
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.rc.3
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-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core