spree_cm_commissioner 2.6.2.pre.pre.7 → 2.6.2.pre.pre.8
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/queries/spree_cm_commissioner/multi_leg_trips_query.rb +1 -1
- data/app/services/spree_cm_commissioner/guests/update_seat.rb +55 -0
- data/app/services/spree_cm_commissioner/vendor_places/base.rb +2 -7
- data/app/services/spree_cm_commissioner/vendor_places/bulk_create.rb +3 -3
- data/config/locales/en.yml +7 -0
- data/config/locales/km.yml +7 -0
- data/lib/spree_cm_commissioner/version.rb +1 -1
- metadata +3 -3
- data/app/interactors/spree_cm_commissioner/guest_seat_updater.rb +0 -45
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f74e8768a3d439e0ba1fafc54d0869563663241901b103738920a58fbfe87fa
|
|
4
|
+
data.tar.gz: 0bbf916627713c6ff981241743592aa300a99890e3a04b83fb52cdd65491f96c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 96d16699a56539c8b28eb7209a5fa27f286221d12cd70ef1ad370b21ad83c8286b5e3e632086f02001f96f997f38eb6e5ade8210d6a19bfd35717dc8bb5c3d04
|
|
7
|
+
data.tar.gz: 3af96b60312dfc64680a12dbf38af9133dc3bbc7c9de675a21bf52ef0685fc2296c741f971d566bfdeeab10e9fed6339ac448252e88176fe9f21d1d79e7d9103
|
data/Gemfile.lock
CHANGED
|
@@ -111,7 +111,7 @@ module SpreeCmCommissioner
|
|
|
111
111
|
.where(parent: { origin_place_id: origin_id, destination_place_id: destination_id })
|
|
112
112
|
|
|
113
113
|
# Apply filters
|
|
114
|
-
scope = scope.where(parent: { route_type: route_type }) if route_type.present?
|
|
114
|
+
scope = scope.where(parent: { route_type: SpreeCmCommissioner::Trip.route_types[route_type] }) if route_type.present?
|
|
115
115
|
scope = scope.where(parent: { vendor_id: vendor_id }) if vendor_id.present?
|
|
116
116
|
if tenant_id.present?
|
|
117
117
|
scope = scope.joins('INNER JOIN spree_vendors v ON v.id = parent.vendor_id')
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module SpreeCmCommissioner
|
|
2
|
+
module Guests
|
|
3
|
+
class UpdateSeat
|
|
4
|
+
prepend ::Spree::ServiceModule::Base
|
|
5
|
+
|
|
6
|
+
def call(line_item:, guest:, block_id:, updated_by:)
|
|
7
|
+
validate_params(line_item, guest, block_id, updated_by)
|
|
8
|
+
|
|
9
|
+
ApplicationRecord.transaction do
|
|
10
|
+
old_block_id = guest.block_id
|
|
11
|
+
update_reserved_block(guest, block_id, updated_by)
|
|
12
|
+
guest.update!(block_id: block_id) if old_block_id != block_id && block_id.present?
|
|
13
|
+
update_order_preload_blocks(line_item.order, old_block_id, block_id)
|
|
14
|
+
|
|
15
|
+
success(guest: guest, line_item: line_item)
|
|
16
|
+
end
|
|
17
|
+
rescue StandardError => e
|
|
18
|
+
failure(nil, e.message)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def validate_params(line_item, guest, block_id, updated_by)
|
|
24
|
+
raise 'Updated user is required' if updated_by.blank?
|
|
25
|
+
raise 'Line item not found' unless line_item
|
|
26
|
+
raise 'Guest not found' unless guest
|
|
27
|
+
raise 'Block ID is required' if block_id.blank?
|
|
28
|
+
return if block_belongs_to_variant?(block_id, line_item.variant_id)
|
|
29
|
+
|
|
30
|
+
raise "Variant change is not allowed — seat can only be updated for the same variant #{line_item.variant_id}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def update_reserved_block(guest, block_id, updated_by)
|
|
34
|
+
reserve_block = SpreeCmCommissioner::ReservedBlock.find_by(
|
|
35
|
+
guest_id: guest.id,
|
|
36
|
+
block_id: guest.block_id
|
|
37
|
+
)
|
|
38
|
+
reserve_block.update!(block_id: block_id, updated_by_id: updated_by.id) if reserve_block && reserve_block.block_id != block_id
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def update_order_preload_blocks(order, old_block_id, new_block_id)
|
|
42
|
+
preload_block_ids = Array(order.preload_block_ids).map(&:to_i)
|
|
43
|
+
preload_block_ids.delete(old_block_id.to_i)
|
|
44
|
+
preload_block_ids << new_block_id.to_i
|
|
45
|
+
order.update!(preload_block_ids: preload_block_ids.uniq)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def block_belongs_to_variant?(block_id, variant_id)
|
|
49
|
+
return false unless block_id.present? && variant_id.present?
|
|
50
|
+
|
|
51
|
+
SpreeCmCommissioner::Block.exists?(variant_id: variant_id, id: block_id)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -8,14 +8,9 @@ module SpreeCmCommissioner
|
|
|
8
8
|
private
|
|
9
9
|
|
|
10
10
|
def validate_place_type!(place_type)
|
|
11
|
-
return I18n.t('
|
|
11
|
+
return I18n.t('vendor_places.place_type_required') if place_type.nil?
|
|
12
12
|
|
|
13
|
-
unless ALLOWED_PLACE_TYPES.include?(place_type.to_s)
|
|
14
|
-
return I18n.t(
|
|
15
|
-
'controller.vendor_places.invalid_place_type',
|
|
16
|
-
default: "Place type must be one of: #{ALLOWED_PLACE_TYPES.join(', ')}"
|
|
17
|
-
)
|
|
18
|
-
end
|
|
13
|
+
return I18n.t('vendor_places.invalid_place_type', types: ALLOWED_PLACE_TYPES.join(', ')) unless ALLOWED_PLACE_TYPES.include?(place_type.to_s)
|
|
19
14
|
|
|
20
15
|
nil
|
|
21
16
|
end
|
|
@@ -51,9 +51,9 @@ module SpreeCmCommissioner
|
|
|
51
51
|
|
|
52
52
|
def validate_inputs!(place_ids:, place_type:, max_count:, location: nil)
|
|
53
53
|
validate_place_type!(place_type) ||
|
|
54
|
-
(place_ids.blank? && I18n.t('
|
|
55
|
-
(place_ids.size > max_count && I18n.t('
|
|
56
|
-
(requires_location?(place_type: place_type) && location.blank? && I18n.t('
|
|
54
|
+
(place_ids.blank? && I18n.t('vendor_places.place_ids_blank')) ||
|
|
55
|
+
(place_ids.size > max_count && I18n.t('vendor_places.selection_limit', count: max_count)) ||
|
|
56
|
+
(requires_location?(place_type: place_type) && location.blank? && I18n.t('vendor_places.location_required'))
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def build_vendor_place(vendor:, place_id:, place_type:, description:, location: nil)
|
data/config/locales/en.yml
CHANGED
|
@@ -634,6 +634,13 @@ en:
|
|
|
634
634
|
otp_code: "OTP code"
|
|
635
635
|
telegram_verification: "telegram code"
|
|
636
636
|
|
|
637
|
+
vendor_places:
|
|
638
|
+
place_ids_blank: "Please select at least one place"
|
|
639
|
+
selection_limit: "Cannot select more than %{count} places"
|
|
640
|
+
location_required: "Location is required for this place type"
|
|
641
|
+
place_type_required: "Place type is required"
|
|
642
|
+
invalid_place_type: "Place type must be one of: %{types}"
|
|
643
|
+
|
|
637
644
|
notifications:
|
|
638
645
|
spree_cm_commissioner:
|
|
639
646
|
order_complete_notification:
|
data/config/locales/km.yml
CHANGED
|
@@ -461,6 +461,13 @@ km:
|
|
|
461
461
|
update_user_login: "ធ្វើបច្ចុប្បន្នភាពលេខកូដអ្នកប្រើប្រាស់"
|
|
462
462
|
otp_code: "លេខកូដ OTP"
|
|
463
463
|
|
|
464
|
+
vendor_places:
|
|
465
|
+
place_ids_blank: "សូមជ្រើសរើសយ៉ាងហោចណាស់ពេលមួយកន្លែង"
|
|
466
|
+
selection_limit: "មិនអាចជ្រើសរើសលើសពី %{count} កន្លែងបានទេ"
|
|
467
|
+
location_required: "ទីតាំងគឺចាំបាច់សម្រាប់ប្រភេទកន្លែងនេះ"
|
|
468
|
+
place_type_required: "ប្រភេទកន្លែងគឺចាំបាច់"
|
|
469
|
+
invalid_place_type: "ប្រភេទកន្លែងត្រូវតែជាមួយក្នុងចំណោម: %{types}"
|
|
470
|
+
|
|
464
471
|
notifications:
|
|
465
472
|
spree_cm_commissioner:
|
|
466
473
|
order_complete_notification:
|
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.6.2.pre.pre.
|
|
4
|
+
version: 2.6.2.pre.pre.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|
|
@@ -1215,7 +1215,6 @@ files:
|
|
|
1215
1215
|
- app/interactors/spree_cm_commissioner/guest_dynamic_field_notification_sender.rb
|
|
1216
1216
|
- app/interactors/spree_cm_commissioner/guest_dynamic_fields_manager.rb
|
|
1217
1217
|
- app/interactors/spree_cm_commissioner/guest_id_card_manager.rb
|
|
1218
|
-
- app/interactors/spree_cm_commissioner/guest_seat_updater.rb
|
|
1219
1218
|
- app/interactors/spree_cm_commissioner/host_matcher.rb
|
|
1220
1219
|
- app/interactors/spree_cm_commissioner/id_card_image_updater.rb
|
|
1221
1220
|
- app/interactors/spree_cm_commissioner/image_saver.rb
|
|
@@ -2066,6 +2065,7 @@ files:
|
|
|
2066
2065
|
- app/services/spree_cm_commissioner/guests/claim_invite_guest_service.rb
|
|
2067
2066
|
- app/services/spree_cm_commissioner/guests/finalize.rb
|
|
2068
2067
|
- app/services/spree_cm_commissioner/guests/preload_check_in_session_ids.rb
|
|
2068
|
+
- app/services/spree_cm_commissioner/guests/update_seat.rb
|
|
2069
2069
|
- app/services/spree_cm_commissioner/homepage_data.rb
|
|
2070
2070
|
- app/services/spree_cm_commissioner/homepage_data_loader.rb
|
|
2071
2071
|
- app/services/spree_cm_commissioner/imports/orders/base.rb
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
module SpreeCmCommissioner
|
|
2
|
-
class GuestSeatUpdater < BaseInteractor
|
|
3
|
-
delegate :line_item,
|
|
4
|
-
:guest,
|
|
5
|
-
:block_id,
|
|
6
|
-
:updated_by, to: :context
|
|
7
|
-
|
|
8
|
-
def call
|
|
9
|
-
context.fail!(errors: 'Updated user is required') if updated_by.blank?
|
|
10
|
-
context.fail!(errors: 'Line item not found') unless line_item
|
|
11
|
-
context.fail!(errors: 'Guest not found') unless guest
|
|
12
|
-
context.fail!(errors: 'Block ID is required') if block_id.blank?
|
|
13
|
-
|
|
14
|
-
if block_id.present? && !block_belongs_to_variant?(block_id, line_item.variant_id)
|
|
15
|
-
context.fail!(errors: "Variant change is not allowed — seat can only be updated for the same variant #{line_item.variant_id}")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
ActiveRecord::Base.transaction do
|
|
19
|
-
update_seat_for_guest
|
|
20
|
-
end
|
|
21
|
-
rescue StandardError => e
|
|
22
|
-
raise if defined?(Interactor::Failure) && e.is_a?(Interactor::Failure)
|
|
23
|
-
|
|
24
|
-
context.fail!(errors: e.message)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def update_seat_for_guest
|
|
28
|
-
reserve_block = SpreeCmCommissioner::ReservedBlock.find_by(
|
|
29
|
-
guest_id: guest.id,
|
|
30
|
-
block_id: guest.block_id
|
|
31
|
-
)
|
|
32
|
-
reserve_block.update!(block_id: block_id, updated_by_id: updated_by.id) if reserve_block && reserve_block.block_id != block_id
|
|
33
|
-
|
|
34
|
-
guest.update!(block_id: block_id) if guest.block_id != block_id && block_id.present?
|
|
35
|
-
|
|
36
|
-
line_item
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def block_belongs_to_variant?(block_id, variant_id)
|
|
40
|
-
return false unless block_id.present? && variant_id.present?
|
|
41
|
-
|
|
42
|
-
SpreeCmCommissioner::Block.exists?(variant_id: variant_id, id: block_id)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|