spree_cm_commissioner 2.7.1.pre.pre8 → 2.7.1.pre.pre9
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/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/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/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 +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 185d0800fe2226d15f68f7bac984f9c4ba88b084a3669351f8cde12154b12707
|
|
4
|
+
data.tar.gz: 6d9ca32ab0abf773108964da4955281cb88c9490c671c8ddb36056343d2db8a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5826bd3e8bcc01930818656e09b6ed5b2358d369f1a6bbbe89f0d6365889fd033db7e3a176fbbfda075d59460d5e23c2bc34450c20aec0477e6ce614ae21a3cc
|
|
7
|
+
data.tar.gz: 251e572fe4b88c535c90a3b87b21a557a07e232eed3551dd8679d16f14cbd8d0e517f2a8c3c1e1b0a34f4fdeff0db4570df9b6990d5eb9305c27add3d85deee1
|
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
|
|
@@ -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.7.1.pre.
|
|
4
|
+
version: 2.7.1.pre.pre9
|
|
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-07 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
|