spree_cm_commissioner 2.7.1.pre.pre8 → 2.8.0.pre.patch1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +1 -0
- data/Gemfile.lock +1 -1
- data/app/controllers/spree/api/v2/storefront/pricing_previews_controller.rb +5 -1
- data/app/controllers/spree/api/v2/tenant/pricing_previews_controller.rb +7 -0
- data/app/models/concerns/spree_cm_commissioner/store_metadata.rb +10 -1
- data/app/models/spree_cm_commissioner/inventory_item.rb +0 -3
- data/app/models/spree_cm_commissioner/maintenance_tasks/cache_invalidation.rb +2 -0
- data/app/models/spree_cm_commissioner/route.rb +3 -0
- data/app/models/spree_cm_commissioner/stock_item_decorator.rb +14 -1
- data/app/serializers/spree/v2/tenant/preview_adjustment_serializer.rb +10 -0
- data/app/serializers/spree/v2/tenant/pricing_preview_serializer.rb +1 -3
- data/app/serializers/spree_cm_commissioner/v2/storefront/preview_adjustment_serializer.rb +10 -0
- data/app/serializers/spree_cm_commissioner/v2/storefront/pricing_preview_serializer.rb +1 -3
- data/app/services/spree_cm_commissioner/pricing_models/activate.rb +0 -3
- data/config/initializers/spree_permitted_attributes.rb +1 -0
- data/db/migrate/20260504100000_add_public_and_private_metadata_to_cm_routes.rb +6 -0
- data/lib/spree_cm_commissioner/pricing_models/order_context.rb +0 -2
- data/lib/spree_cm_commissioner/pricing_models/preview_adjustment.rb +2 -12
- data/lib/spree_cm_commissioner/pricing_models/pricing_preview.rb +2 -1
- data/lib/spree_cm_commissioner/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 624d077988823212d28d3809a7fb549cea92fd6f057f92d160d3eac8acfd6af5
|
|
4
|
+
data.tar.gz: 19203d0d9a970fc41900bf4cb2c37c9c6441f3c08a9445300d4f76d5fbf3a6bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62f6d0064ceb620aa87db423ffcfba07d7cbdd15e9184174562fdb4c4ba4e0a563830f5f4dfbfc5ad70f623af48a0f8e2948111ff4cc429605d7ddaa1c7c8f47
|
|
7
|
+
data.tar.gz: 736b84fb19babcba6a9e25074c8616cb4a12921f758e00c4d7c683b9550117a014543e75d47c8e8b83a50268bc83e71228d7aad04d0f24da7736f8b5ae0fa169
|
data/.env.example
CHANGED
|
@@ -34,6 +34,7 @@ DISTANCE_SIGNING_KEY=hei********************VY
|
|
|
34
34
|
|
|
35
35
|
# Cache durations (in seconds) for different content types
|
|
36
36
|
# See: app/controllers/concerns/spree_cm_commissioner/content_cachable.rb
|
|
37
|
+
CACHE_AUTO_INVALIDATION_DISABLED="" # Set to yes to disable CDN cache invalidation entirely (kill switch)
|
|
37
38
|
CACHE_CDN_MAX_AGE=86400 # CDN/server-side cache duration for all responses
|
|
38
39
|
CACHE_STATIC_MAX_AGE=86400 # Static content (countries, provinces, seat layouts, CMS pages) - 1 day
|
|
39
40
|
CACHE_SEMI_STATIC_MAX_AGE=3600 # Semi-static content (menus, homepage backgrounds, routes) - 1 hour
|
data/Gemfile.lock
CHANGED
|
@@ -38,8 +38,12 @@ module Spree
|
|
|
38
38
|
render_error_payload(e.message, 422)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
# override
|
|
42
|
+
def default_resource_includes
|
|
43
|
+
['pricing_adjustments']
|
|
44
|
+
end
|
|
42
45
|
|
|
46
|
+
# override
|
|
43
47
|
def resource_serializer
|
|
44
48
|
SpreeCmCommissioner::V2::Storefront::PricingPreviewSerializer
|
|
45
49
|
end
|
|
@@ -19,6 +19,7 @@ module Spree
|
|
|
19
19
|
|
|
20
20
|
cached_result = Rails.cache.fetch(cache_key, expires_in: 60.seconds) do
|
|
21
21
|
result = SpreeCmCommissioner::PricingModels::Preview.call(order_context: order_context)
|
|
22
|
+
|
|
22
23
|
if result.success?
|
|
23
24
|
{
|
|
24
25
|
success: true,
|
|
@@ -43,6 +44,12 @@ module Spree
|
|
|
43
44
|
|
|
44
45
|
private
|
|
45
46
|
|
|
47
|
+
# override
|
|
48
|
+
def default_resource_includes
|
|
49
|
+
['pricing_adjustments']
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# override
|
|
46
53
|
def resource_serializer
|
|
47
54
|
Spree::V2::Tenant::PricingPreviewSerializer
|
|
48
55
|
end
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
# Supported types:
|
|
11
11
|
# - boolean
|
|
12
12
|
# - string
|
|
13
|
+
# - text
|
|
13
14
|
# - integer
|
|
14
15
|
# - array
|
|
15
16
|
# - datetime
|
|
@@ -105,7 +106,7 @@ module SpreeCmCommissioner
|
|
|
105
106
|
ActiveModel::Type::Boolean.new.cast(raw_value)
|
|
106
107
|
when :integer
|
|
107
108
|
raw_value.to_i
|
|
108
|
-
when :string
|
|
109
|
+
when :string, :text
|
|
109
110
|
raw_value.to_s
|
|
110
111
|
when :array
|
|
111
112
|
Array(raw_value)
|
|
@@ -136,6 +137,14 @@ module SpreeCmCommissioner
|
|
|
136
137
|
end
|
|
137
138
|
when :string
|
|
138
139
|
validates key, length: { maximum: 255 }, allow_nil: true
|
|
140
|
+
when :text
|
|
141
|
+
validate do
|
|
142
|
+
metadata = send(column_name) || {}
|
|
143
|
+
raw_value = metadata[key.to_s]
|
|
144
|
+
next if raw_value.nil?
|
|
145
|
+
|
|
146
|
+
errors.add(key, 'must be a string') unless raw_value.is_a?(String)
|
|
147
|
+
end
|
|
139
148
|
when :array
|
|
140
149
|
validate do
|
|
141
150
|
metadata = send(column_name) || {}
|
|
@@ -23,9 +23,6 @@ module SpreeCmCommissioner
|
|
|
23
23
|
|
|
24
24
|
before_save -> { self.product_type = variant.product_type }, if: -> { product_type.nil? }
|
|
25
25
|
|
|
26
|
-
# Create maintaining task to purge product related caches
|
|
27
|
-
after_commit { SpreeCmCommissioner::MaintenanceTasks::CacheInvalidation.pending.create_or_find_by(maintainable: variant.product) }
|
|
28
|
-
|
|
29
26
|
def public_quantity_available
|
|
30
27
|
[quantity_available, MAX_DISPLAY_STOCK].min
|
|
31
28
|
end
|
|
@@ -3,6 +3,8 @@ module SpreeCmCommissioner
|
|
|
3
3
|
module MaintenanceTasks
|
|
4
4
|
class CacheInvalidation < MaintenanceTask
|
|
5
5
|
def maintain
|
|
6
|
+
return if ENV['CACHE_AUTO_INVALIDATION_DISABLED'] == 'yes'
|
|
7
|
+
|
|
6
8
|
if maintainable.is_a?(SpreeCmCommissioner::HomepageBackground) || maintainable.is_a?(Spree::Menu)
|
|
7
9
|
SpreeCmCommissioner::HomepageDataLoader.clear_cache
|
|
8
10
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
class Route < Base
|
|
3
3
|
include SpreeCmCommissioner::RouteType
|
|
4
|
+
include SpreeCmCommissioner::StoreMetadata
|
|
4
5
|
|
|
5
6
|
belongs_to :vendor, class_name: 'Spree::Vendor', optional: false
|
|
6
7
|
belongs_to :tenant, class_name: 'SpreeCmCommissioner::Tenant', optional: true
|
|
@@ -29,6 +30,8 @@ module SpreeCmCommissioner
|
|
|
29
30
|
|
|
30
31
|
delegate :multi_leg?, to: :route_stops
|
|
31
32
|
|
|
33
|
+
store_public_metadata :terms_and_conditions, :text
|
|
34
|
+
|
|
32
35
|
def prices_for(currency)
|
|
33
36
|
route_prices.for_currency(currency)
|
|
34
37
|
end
|
|
@@ -8,7 +8,20 @@ module SpreeCmCommissioner
|
|
|
8
8
|
base.after_commit :adjust_inventory_items_async, on: :destroy
|
|
9
9
|
|
|
10
10
|
# Create maintaining task to purge product related caches
|
|
11
|
-
base.after_commit
|
|
11
|
+
base.after_commit :schedule_product_cache_invalidation
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def schedule_product_cache_invalidation
|
|
15
|
+
return unless saved_change_to_count_on_hand?
|
|
16
|
+
|
|
17
|
+
# Only invalidate when transitioning between in-stock and out-of-stock:
|
|
18
|
+
# - out-of-stock → in-stock (0 → N): invalidate
|
|
19
|
+
# - in-stock → out-of-stock (N → 0): invalidate
|
|
20
|
+
# - non-zero to non-zero (5 → 3): skip — cached in_stock value is unchanged
|
|
21
|
+
old_val, new_val = saved_change_to_count_on_hand
|
|
22
|
+
return if old_val.to_i.positive? && new_val.to_i.positive?
|
|
23
|
+
|
|
24
|
+
SpreeCmCommissioner::MaintenanceTasks::CacheInvalidation.pending.create_or_find_by(maintainable: variant.product)
|
|
12
25
|
end
|
|
13
26
|
|
|
14
27
|
def update_vendor_total_inventory
|
|
@@ -6,9 +6,7 @@ module Spree
|
|
|
6
6
|
|
|
7
7
|
attributes :item_total, :total, :pricing_adjustment_total
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
object.pricing_adjustments.map(&:to_h)
|
|
11
|
-
end
|
|
9
|
+
has_many :pricing_adjustments, serializer: Spree::V2::Tenant::PreviewAdjustmentSerializer
|
|
12
10
|
end
|
|
13
11
|
end
|
|
14
12
|
end
|
|
@@ -6,9 +6,7 @@ module SpreeCmCommissioner
|
|
|
6
6
|
|
|
7
7
|
attributes :item_total, :total, :pricing_adjustment_total
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
object.pricing_adjustments.map(&:to_h)
|
|
11
|
-
end
|
|
9
|
+
has_many :pricing_adjustments, serializer: SpreeCmCommissioner::V2::Storefront::PreviewAdjustmentSerializer
|
|
12
10
|
end
|
|
13
11
|
end
|
|
14
12
|
end
|
|
@@ -4,9 +4,6 @@ module SpreeCmCommissioner
|
|
|
4
4
|
prepend ::Spree::ServiceModule::Base
|
|
5
5
|
|
|
6
6
|
def call(order:)
|
|
7
|
-
return failure(:order_is_not_persisted) unless order.persisted?
|
|
8
|
-
return failure(:order_not_completed) unless order.completed?
|
|
9
|
-
|
|
10
7
|
order_context = OrderContext.build_from_context(fallback_order: order)
|
|
11
8
|
|
|
12
9
|
preview_result = Preview.call(order_context: order_context)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
module PricingModels
|
|
3
3
|
class PreviewAdjustment
|
|
4
|
-
attr_reader :label, :amount, :action_type, :pricing_action,
|
|
4
|
+
attr_reader :id, :label, :amount, :action_type, :pricing_action,
|
|
5
5
|
:adjustable_type, :adjustable_id, :line_item_id, :guest_ids
|
|
6
6
|
|
|
7
7
|
def initialize(options = {})
|
|
8
|
+
@id = SecureRandom.uuid
|
|
8
9
|
@label = options[:label]
|
|
9
10
|
@amount = options[:amount]
|
|
10
11
|
@action_type = options[:action_type]
|
|
@@ -14,17 +15,6 @@ module SpreeCmCommissioner
|
|
|
14
15
|
@line_item_id = options[:line_item_id]
|
|
15
16
|
@guest_ids = Array(options[:guest_ids])
|
|
16
17
|
end
|
|
17
|
-
|
|
18
|
-
def to_h
|
|
19
|
-
{
|
|
20
|
-
label: label,
|
|
21
|
-
amount: amount,
|
|
22
|
-
action_type: action_type,
|
|
23
|
-
pricing_action_id: pricing_action&.id,
|
|
24
|
-
line_item_id: line_item_id,
|
|
25
|
-
guest_ids: guest_ids.presence
|
|
26
|
-
}.compact
|
|
27
|
-
end
|
|
28
18
|
end
|
|
29
19
|
end
|
|
30
20
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
module PricingModels
|
|
3
3
|
class PricingPreview
|
|
4
|
-
attr_reader :id, :item_total, :total, :pricing_adjustment_total, :pricing_adjustments
|
|
4
|
+
attr_reader :id, :item_total, :total, :pricing_adjustment_total, :pricing_adjustments, :pricing_adjustment_ids
|
|
5
5
|
|
|
6
6
|
def initialize(id:, item_total:, total:, pricing_adjustment_total:, pricing_adjustments:)
|
|
7
7
|
@id = id
|
|
@@ -9,6 +9,7 @@ module SpreeCmCommissioner
|
|
|
9
9
|
@total = total
|
|
10
10
|
@pricing_adjustment_total = pricing_adjustment_total
|
|
11
11
|
@pricing_adjustments = pricing_adjustments
|
|
12
|
+
@pricing_adjustment_ids = pricing_adjustments.map(&:id)
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_cm_commissioner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.8.0.pre.patch1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|
|
@@ -1923,6 +1923,7 @@ files:
|
|
|
1923
1923
|
- app/serializers/spree/v2/tenant/order_serializer.rb
|
|
1924
1924
|
- app/serializers/spree/v2/tenant/payment_method_group_serializer.rb
|
|
1925
1925
|
- app/serializers/spree/v2/tenant/payment_method_serializer.rb
|
|
1926
|
+
- app/serializers/spree/v2/tenant/preview_adjustment_serializer.rb
|
|
1926
1927
|
- app/serializers/spree/v2/tenant/pricing_preview_serializer.rb
|
|
1927
1928
|
- app/serializers/spree/v2/tenant/product_dynamic_field_serializer.rb
|
|
1928
1929
|
- app/serializers/spree/v2/tenant/product_serializer.rb
|
|
@@ -2001,6 +2002,7 @@ files:
|
|
|
2001
2002
|
- app/serializers/spree_cm_commissioner/v2/storefront/menu_serializer_decorator.rb
|
|
2002
2003
|
- app/serializers/spree_cm_commissioner/v2/storefront/payment_method_group_serializer.rb
|
|
2003
2004
|
- app/serializers/spree_cm_commissioner/v2/storefront/pin_code_serializer.rb
|
|
2005
|
+
- app/serializers/spree_cm_commissioner/v2/storefront/preview_adjustment_serializer.rb
|
|
2004
2006
|
- app/serializers/spree_cm_commissioner/v2/storefront/price_serializer.rb
|
|
2005
2007
|
- app/serializers/spree_cm_commissioner/v2/storefront/pricing_preview_serializer.rb
|
|
2006
2008
|
- app/serializers/spree_cm_commissioner/v2/storefront/product_dynamic_field_serializer.rb
|
|
@@ -3157,6 +3159,7 @@ files:
|
|
|
3157
3159
|
- db/migrate/20260330032108_add_vendor_id_to_spree_taxonomies.rb
|
|
3158
3160
|
- db/migrate/20260401080000_create_cm_route_prices.rb
|
|
3159
3161
|
- db/migrate/20260410080000_add_payment_locked_at_to_cm_reserved_blocks.rb
|
|
3162
|
+
- db/migrate/20260504100000_add_public_and_private_metadata_to_cm_routes.rb
|
|
3160
3163
|
- db/migrate/20260506090000_remove_default_from_cm_guests_nationality_group.rb
|
|
3161
3164
|
- docker-compose.yml
|
|
3162
3165
|
- docs/api/scoped-access-token-endpoints.md
|