spree_cm_commissioner 2.13.3.pre.pre2 → 2.13.3
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 +0 -1
- data/Gemfile.lock +1 -1
- data/app/controllers/spree/admin/integrations_controller.rb +7 -5
- data/app/controllers/spree/admin/inventory_items_controller.rb +0 -12
- data/app/controllers/spree/api/v2/storefront/draft_orders_controller.rb +41 -3
- data/app/controllers/spree/api/v2/storefront/guest_qrs_controller.rb +2 -0
- data/app/controllers/spree_cm_commissioner/api/v2/storefront/checkout_controller_decorator.rb +0 -3
- data/app/factory/spree_cm_commissioner/order_telegram_message_factory.rb +2 -6
- data/app/models/concerns/spree_cm_commissioner/line_item_bundleable.rb +38 -0
- data/app/models/concerns/spree_cm_commissioner/vehicle_kind.rb +1 -1
- data/app/models/spree_cm_commissioner/guest.rb +8 -0
- data/app/models/spree_cm_commissioner/integration.rb +0 -46
- data/app/models/spree_cm_commissioner/integrations/stadium_x_v1.rb +10 -4
- data/app/models/spree_cm_commissioner/inventory_item.rb +0 -18
- data/app/models/spree_cm_commissioner/line_item_decorator.rb +1 -0
- data/app/models/spree_cm_commissioner/order_decorator.rb +0 -2
- data/app/models/spree_cm_commissioner/place.rb +0 -2
- data/app/models/spree_cm_commissioner/redis_stock/cached_inventory_items_builder.rb +1 -2
- data/app/models/spree_cm_commissioner/route.rb +0 -1
- data/app/models/spree_cm_commissioner/seat_layout.rb +0 -1
- data/app/models/spree_cm_commissioner/stock/availability_checker.rb +1 -1
- data/app/models/spree_cm_commissioner/stock/order_availability_checker.rb +1 -1
- data/app/models/spree_cm_commissioner/stock_item_decorator.rb +0 -4
- data/app/models/spree_cm_commissioner/trip.rb +1 -2
- data/app/models/spree_cm_commissioner/trip_stop.rb +0 -2
- data/app/models/spree_cm_commissioner/variant_decorator.rb +0 -5
- data/app/models/spree_cm_commissioner/vehicle.rb +0 -3
- data/app/models/spree_cm_commissioner/vehicle_type.rb +0 -1
- data/app/models/spree_cm_commissioner/vendor_decorator.rb +0 -17
- data/app/models/spree_cm_commissioner/vendor_place.rb +0 -2
- data/app/serializers/spree/v2/storefront/line_item_serializer_decorator.rb +2 -1
- data/app/serializers/spree_cm_commissioner/v2/storefront/cart_serializer_decorator.rb +2 -1
- data/app/services/spree_cm_commissioner/integrations/base/sync_manager.rb +2 -1
- data/app/services/spree_cm_commissioner/integrations/base/sync_result.rb +0 -11
- data/app/services/spree_cm_commissioner/integrations/stadium_x_v1/external_client/client.rb +15 -14
- data/app/services/spree_cm_commissioner/integrations/stadium_x_v1/polling/sync_matches.rb +4 -7
- data/app/services/spree_cm_commissioner/integrations/stadium_x_v1/polling/sync_zones.rb +3 -6
- data/app/services/spree_cm_commissioner/integrations/stadium_x_v1/sync_manager.rb +3 -0
- data/app/services/spree_cm_commissioner/integrations/stadium_x_v1/sync_strategies/full_sync_strategy.rb +3 -1
- data/app/services/spree_cm_commissioner/integrations/stadium_x_v1/sync_strategies/incremental_sync_strategy.rb +3 -1
- data/app/services/spree_cm_commissioner/integrations/stadium_x_v1/sync_strategies/webhook_sync_strategy.rb +2 -1
- data/app/services/spree_cm_commissioner/inventory_items/bulk_adjust_quantities_by_variant.rb +0 -4
- data/app/services/spree_cm_commissioner/inventory_items/reset.rb +0 -4
- data/app/services/spree_cm_commissioner/order_holds/hold.rb +0 -17
- data/app/services/spree_cm_commissioner/order_holds/release.rb +0 -17
- data/app/services/spree_cm_commissioner/seat_layouts/update.rb +4 -0
- data/app/services/spree_cm_commissioner/transit_order/create.rb +8 -2
- data/app/services/spree_cm_commissioner/users/backfill_device_tokens_count.rb +48 -0
- data/app/views/spree/admin/integrations/_form.html.erb +0 -16
- data/app/views/spree/admin/integrations/index.html.erb +1 -1
- data/config/locales/en.yml +0 -2
- data/config/locales/km.yml +0 -2
- data/config/routes.rb +0 -25
- data/db/migrate/20260925000000_change_commission_rate_default_on_spree_vendors.rb +5 -0
- data/db/migrate/20260925090000_add_parent_id_and_relation_type_to_spree_line_items.rb +6 -0
- data/lib/spree_cm_commissioner/cached_inventory_item.rb +1 -7
- data/lib/spree_cm_commissioner/test_helper/factories/integration_factory.rb +0 -17
- data/lib/spree_cm_commissioner/version.rb +1 -1
- data/lib/tasks/backfill_device_tokens_count.rake +8 -0
- metadata +8 -161
- data/app/controllers/spree/api/switch_cm/base_controller.rb +0 -98
- data/app/controllers/spree/api/switch_cm/ota/avail_notifs_controller.rb +0 -17
- data/app/controllers/spree/api/switch_cm/ota/base_controller.rb +0 -27
- data/app/controllers/spree/api/switch_cm/ota/product_notifs_controller.rb +0 -44
- data/app/controllers/spree/api/switch_cm/ota/pushes_controller.rb +0 -46
- data/app/controllers/spree/api/switch_cm/ota/rate_amount_notifs_controller.rb +0 -17
- data/app/controllers/spree/api/switch_cm/ota/res_modify_notifs_controller.rb +0 -31
- data/app/controllers/spree/api/switch_cm/ota/res_notifs_controller.rb +0 -29
- data/app/controllers/spree/api/switch_cm/ota/reservation_streams_controller.rb +0 -83
- data/app/controllers/spree/api/switch_cm/tokens_controller.rb +0 -68
- data/app/controllers/spree/api/switch_cm/xml/availabilities_controller.rb +0 -39
- data/app/controllers/spree/api/switch_cm/xml/base_controller.rb +0 -37
- data/app/controllers/spree/api/switch_cm/xml/reservation_summaries_controller.rb +0 -28
- data/app/controllers/spree/api/switch_cm/xml/reservations_controller.rb +0 -56
- data/app/controllers/spree/api/switch_cm/xml/room_rate_availabilities_controller.rb +0 -56
- data/app/controllers/spree/api/switch_cm/xml/room_rates_controller.rb +0 -32
- data/app/controllers/spree/api/v2/storefront/transit/item_availabilities_controller.rb +0 -66
- data/app/jobs/spree_cm_commissioner/audit_event_job.rb +0 -29
- data/app/models/concerns/spree_cm_commissioner/audit_wrapper.rb +0 -139
- data/app/models/concerns/spree_cm_commissioner/integrations/inventory_sync_cachable.rb +0 -9
- data/app/models/concerns/spree_cm_commissioner/variant_metadata.rb +0 -24
- data/app/models/spree_cm_commissioner/audit_event.rb +0 -11
- data/app/models/spree_cm_commissioner/currency_rate.rb +0 -15
- data/app/models/spree_cm_commissioner/integrations/book_me_bus_v1.rb +0 -64
- data/app/models/spree_cm_commissioner/integrations/larryta.rb +0 -81
- data/app/models/spree_cm_commissioner/integrations/switch_cm.rb +0 -86
- data/app/models/spree_cm_commissioner/integrations/vireak_buntham.rb +0 -82
- data/app/serializables/spree_cm_commissioner/item_availability_sync.rb +0 -10
- data/app/serializers/spree_cm_commissioner/v2/storefront/item_availability_sync_serializer.rb +0 -10
- data/app/services/spree_cm_commissioner/audit_logger.rb +0 -59
- data/app/services/spree_cm_commissioner/currency_converter/create.rb +0 -27
- data/app/services/spree_cm_commissioner/currency_rates/manage.rb +0 -99
- data/app/services/spree_cm_commissioner/google_maps_geocoder.rb +0 -41
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/external_client/client.rb +0 -230
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/external_client/connection.rb +0 -147
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/inventory/external_inventory_item_status.rb +0 -52
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/inventory/external_inventory_items.rb +0 -91
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/inventory/unstock_inventory.rb +0 -188
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_inventory.rb +0 -79
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_item_availability.rb +0 -354
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_locations.rb +0 -103
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_nationality_pricing.rb +0 -93
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_product.rb +0 -70
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_route_stops.rb +0 -121
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_routes.rb +0 -128
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_seat_layout.rb +0 -412
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_service_calendars.rb +0 -59
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_trip_stop.rb +0 -224
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_trips.rb +0 -769
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_variant.rb +0 -69
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/sync_vehicle_types.rb +0 -92
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/polling/time_parser.rb +0 -19
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/base.rb +0 -40
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/inventory_item_status.rb +0 -148
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb +0 -55
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/reservation_cart.rb +0 -85
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/seat.rb +0 -128
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/seat_layout.rb +0 -386
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb +0 -84
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/trip.rb +0 -237
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/wallet_payment.rb +0 -48
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/sync_manager.rb +0 -22
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/sync_strategies/full_sync_strategy.rb +0 -116
- data/app/services/spree_cm_commissioner/integrations/book_me_bus_v1/sync_strategies/incremental_sync_strategy.rb +0 -63
- data/app/services/spree_cm_commissioner/integrations/larryta/external_client/client.rb +0 -314
- data/app/services/spree_cm_commissioner/integrations/larryta/external_client/connection.rb +0 -74
- data/app/services/spree_cm_commissioner/integrations/larryta/inventory/external_inventory_item_status.rb +0 -53
- data/app/services/spree_cm_commissioner/integrations/larryta/inventory/external_inventory_items.rb +0 -106
- data/app/services/spree_cm_commissioner/integrations/larryta/inventory/hold_seats.rb +0 -143
- data/app/services/spree_cm_commissioner/integrations/larryta/inventory/release_seats.rb +0 -90
- data/app/services/spree_cm_commissioner/integrations/larryta/inventory/unstock_inventory.rb +0 -143
- data/app/services/spree_cm_commissioner/integrations/larryta/polling/sync_item_availability.rb +0 -325
- data/app/services/spree_cm_commissioner/integrations/larryta/polling/sync_product.rb +0 -72
- data/app/services/spree_cm_commissioner/integrations/larryta/polling/sync_routes.rb +0 -142
- data/app/services/spree_cm_commissioner/integrations/larryta/polling/sync_seat_layout.rb +0 -255
- data/app/services/spree_cm_commissioner/integrations/larryta/polling/sync_stock_item.rb +0 -55
- data/app/services/spree_cm_commissioner/integrations/larryta/polling/sync_trip_stop.rb +0 -171
- data/app/services/spree_cm_commissioner/integrations/larryta/polling/sync_trips.rb +0 -397
- data/app/services/spree_cm_commissioner/integrations/larryta/polling/sync_variant.rb +0 -63
- data/app/services/spree_cm_commissioner/integrations/larryta/polling/sync_vehicle_type.rb +0 -79
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/base.rb +0 -39
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/booking.rb +0 -113
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/booking_session.rb +0 -43
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb +0 -236
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb +0 -71
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb +0 -48
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/schedule.rb +0 -150
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/seat.rb +0 -31
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/seat_availability.rb +0 -49
- data/app/services/spree_cm_commissioner/integrations/larryta/resources/seat_layout.rb +0 -211
- data/app/services/spree_cm_commissioner/integrations/larryta/sync_manager.rb +0 -17
- data/app/services/spree_cm_commissioner/integrations/larryta/sync_strategies/full_sync_strategy.rb +0 -79
- data/app/services/spree_cm_commissioner/integrations/larryta/sync_strategies/incremental_sync_strategy.rb +0 -58
- data/app/services/spree_cm_commissioner/integrations/switch_cm/accept_push.rb +0 -101
- data/app/services/spree_cm_commissioner/integrations/switch_cm/accommodation_lock.rb +0 -41
- data/app/services/spree_cm_commissioner/integrations/switch_cm/acknowledge_reservations.rb +0 -43
- data/app/services/spree_cm_commissioner/integrations/switch_cm/apply_ari.rb +0 -119
- data/app/services/spree_cm_commissioner/integrations/switch_cm/ari_update.rb +0 -24
- data/app/services/spree_cm_commissioner/integrations/switch_cm/availability_readback.rb +0 -86
- data/app/services/spree_cm_commissioner/integrations/switch_cm/mark_seen.rb +0 -53
- data/app/services/spree_cm_commissioner/integrations/switch_cm/ota/avail_notif_parser.rb +0 -60
- data/app/services/spree_cm_commissioner/integrations/switch_cm/ota/base_parser.rb +0 -60
- data/app/services/spree_cm_commissioner/integrations/switch_cm/ota/push_response.rb +0 -38
- data/app/services/spree_cm_commissioner/integrations/switch_cm/ota/rate_amount_notif_parser.rb +0 -46
- data/app/services/spree_cm_commissioner/integrations/switch_cm/ota/reservation_presenter.rb +0 -99
- data/app/services/spree_cm_commissioner/integrations/switch_cm/ota/response_builder.rb +0 -52
- data/app/services/spree_cm_commissioner/integrations/switch_cm/pushed_nights.rb +0 -79
- data/app/services/spree_cm_commissioner/integrations/switch_cm/reservation.rb +0 -118
- data/app/services/spree_cm_commissioner/integrations/switch_cm/reservation_feed.rb +0 -143
- data/app/services/spree_cm_commissioner/integrations/switch_cm/room_catalog.rb +0 -56
- data/app/services/spree_cm_commissioner/integrations/switch_cm/sync_manager.rb +0 -16
- data/app/services/spree_cm_commissioner/integrations/switch_cm/sync_strategies/full_sync_strategy.rb +0 -39
- data/app/services/spree_cm_commissioner/integrations/switch_cm/sync_strategies/incremental_sync_strategy.rb +0 -51
- data/app/services/spree_cm_commissioner/integrations/switch_cm/unseen_room_nights.rb +0 -39
- data/app/services/spree_cm_commissioner/integrations/switch_cm/validate_ari_updates.rb +0 -136
- data/app/services/spree_cm_commissioner/integrations/switch_cm/xml/availability_parser.rb +0 -103
- data/app/services/spree_cm_commissioner/integrations/switch_cm/xml/push_response.rb +0 -45
- data/app/services/spree_cm_commissioner/integrations/switch_cm/xml/reservation_presenter.rb +0 -74
- data/app/services/spree_cm_commissioner/integrations/switch_cm/xml/response_builder.rb +0 -19
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/external_client/client.rb +0 -170
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/external_client/connection.rb +0 -59
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/inventory/external_inventory_item_status.rb +0 -48
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/inventory/external_inventory_items.rb +0 -92
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/inventory/unstock_inventory.rb +0 -230
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_item_availability.rb +0 -270
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_locations.rb +0 -96
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_nationality_pricing.rb +0 -76
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_product.rb +0 -69
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_routes.rb +0 -110
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_seat_layout.rb +0 -207
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_stock_item.rb +0 -43
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_trip_stop.rb +0 -192
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_trips.rb +0 -377
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_variant.rb +0 -56
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_vehicle_type.rb +0 -51
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/base.rb +0 -32
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking.rb +0 -48
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb +0 -46
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/cell.rb +0 -53
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/confirm_booking_request.rb +0 -43
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/location.rb +0 -37
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/schedule.rb +0 -138
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/seat.rb +0 -48
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/seat_layout.rb +0 -79
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/sync_manager.rb +0 -17
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/sync_strategies/full_sync_strategy.rb +0 -87
- data/app/services/spree_cm_commissioner/integrations/vireak_buntham/sync_strategies/incremental_sync_strategy.rb +0 -53
- data/app/services/spree_cm_commissioner/inventory_items/generate_permanent_item.rb +0 -48
- data/app/services/spree_cm_commissioner/place_resolver.rb +0 -95
- data/app/views/spree/admin/integrations/_book_me_bus_v1_fields.html.erb +0 -47
- data/app/views/spree/admin/integrations/_larryta_fields.html.erb +0 -58
- data/app/views/spree/admin/integrations/_switch_cm_fields.html.erb +0 -53
- data/app/views/spree/admin/integrations/_vireak_buntham_fields.html.erb +0 -75
- data/db/migrate/20260327143200_create_cm_audit_events.rb +0 -21
- data/db/migrate/20260410045815_create_cm_currency_rates.rb +0 -23
- data/db/migrate/20260411102139_add_metadata_to_cm_inventory_items.rb +0 -6
- data/db/migrate/20260928000000_add_oauth_application_id_to_cm_integrations.rb +0 -5
- data/db/migrate/20260928000001_add_closed_to_cm_inventory_items.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f8c022ba33110958bd0da63395b5e814fb1c5d82469b4801a134b5697dde8a7b
|
|
4
|
+
data.tar.gz: 30f528c86e5b3cd05e22c4ad44fa85d68a0446065c25b1d30b790897afd73f5f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fdb920f19e40a0634796748e15283642dcec8bbcc5d75ff4140628b2c4146e424a987f88c89c14e211e16f0646cae97964af025620aecc69457e518df5cbf1c7
|
|
7
|
+
data.tar.gz: '09ce9911bf7008a80d729b93890f06f24b2deb98e00be9f811550c5803daa49fcb57e94c40decdfdc88e90e8e0a908964984ad7d8c3b146a10e331c93573da15'
|
data/.env.example
CHANGED
|
@@ -87,4 +87,3 @@ PAYMENT_INCOMPLETE_NOTIFICATION_DELAY_IN_MINUTES=5 # Delay before notifying a c
|
|
|
87
87
|
|
|
88
88
|
# See: app/jobs/spree_cm_commissioner/telegram_alerts/order_integrity_check_job.rb
|
|
89
89
|
ORDER_INTEGRITY_TELEGRAM_ALERT_ENABLED="no" # Set to yes to enable the order integrity Telegram alert job (off by default to avoid flooding Telegram rate limits during traffic spikes)
|
|
90
|
-
|
data/Gemfile.lock
CHANGED
|
@@ -47,7 +47,6 @@ module Spree
|
|
|
47
47
|
:full_sync_interval_hours,
|
|
48
48
|
:tenant_id,
|
|
49
49
|
:vendor_id,
|
|
50
|
-
:oauth_application_id,
|
|
51
50
|
public_metadata: {},
|
|
52
51
|
private_metadata: {}
|
|
53
52
|
)
|
|
@@ -63,7 +62,6 @@ module Spree
|
|
|
63
62
|
@conflict_strategy_options ||= enum_to_options(SpreeCmCommissioner::Integration.conflict_strategies)
|
|
64
63
|
@tenants ||= SpreeCmCommissioner::Tenant.select(:id, :name).order(:name)
|
|
65
64
|
@vendors ||= Spree::Vendor.select(:id, :name).order(:name)
|
|
66
|
-
@oauth_applications ||= Spree::OauthApplication.select(:id, :name).order(:name)
|
|
67
65
|
end
|
|
68
66
|
|
|
69
67
|
def enum_to_options(enum_hash)
|
|
@@ -71,10 +69,14 @@ module Spree
|
|
|
71
69
|
end
|
|
72
70
|
|
|
73
71
|
def integration_type_options
|
|
74
|
-
|
|
75
|
-
return [[Spree.t(:type), 'SpreeCmCommissioner::Integration']] if types.blank?
|
|
72
|
+
files = Dir[SpreeCmCommissioner::Engine.root.join('app/models/spree_cm_commissioner/integrations/*.rb')]
|
|
76
73
|
|
|
77
|
-
|
|
74
|
+
return [[Spree.t(:type), 'SpreeCmCommissioner::Integration']] if files.blank?
|
|
75
|
+
|
|
76
|
+
files.map do |path|
|
|
77
|
+
class_name = "SpreeCmCommissioner::Integrations::#{File.basename(path, '.rb').camelize}"
|
|
78
|
+
[class_name, class_name]
|
|
79
|
+
end.sort_by(&:first)
|
|
78
80
|
end
|
|
79
81
|
end
|
|
80
82
|
end
|
|
@@ -2,7 +2,6 @@ module Spree
|
|
|
2
2
|
module Admin
|
|
3
3
|
class InventoryItemsController < StockManagementsController
|
|
4
4
|
before_action :load_parent
|
|
5
|
-
before_action :reject_external_inventory_edits, only: %i[bulk_update_prices bulk_update_stocks]
|
|
6
5
|
|
|
7
6
|
# GET /products/:slug/inventory_items/prices?inventory_item_ids=1,2,3
|
|
8
7
|
def prices
|
|
@@ -79,17 +78,6 @@ module Spree
|
|
|
79
78
|
|
|
80
79
|
redirect_back fallback_location: admin_product_stock_managements_path(@product)
|
|
81
80
|
end
|
|
82
|
-
|
|
83
|
-
private
|
|
84
|
-
|
|
85
|
-
# The partner owns these per-night stocks and prices; its next update would silently overwrite
|
|
86
|
-
# an edit made here.
|
|
87
|
-
def reject_external_inventory_edits
|
|
88
|
-
return unless @product.variants.includes(vendor: :integration).any?(&:inventory_external_wins?)
|
|
89
|
-
|
|
90
|
-
flash[:error] = Spree.t('admin.inventory_external_wins', name: @product.vendor.integration.name)
|
|
91
|
-
redirect_back fallback_location: admin_product_stock_managements_path(@product)
|
|
92
|
-
end
|
|
93
81
|
end
|
|
94
82
|
end
|
|
95
83
|
end
|
|
@@ -12,7 +12,9 @@ module Spree
|
|
|
12
12
|
# Creates a generic draft order from a locally-assembled cart in a single request.
|
|
13
13
|
# Endpoint: POST /api/v2/storefront/draft_orders
|
|
14
14
|
# Params:
|
|
15
|
-
# - line_items: Array of { variant_id:, quantity:, options: {
|
|
15
|
+
# - line_items: Array of { variant_id:, quantity:, options: { from_date:, to_date:, guests_attributes: [] },
|
|
16
|
+
# public_metadata: {}, private_metadata: {} } (required) — guests_attributes fields mirror the checkout
|
|
17
|
+
# API's line_items_attributes.guests_attributes (see Spree::PermittedAttributes checkout_attributes).
|
|
16
18
|
# - st: private sale token granting this order the product's locked stock (optional).
|
|
17
19
|
def create
|
|
18
20
|
result = SpreeCmCommissioner::DraftOrders::Create.call(
|
|
@@ -45,8 +47,44 @@ module Spree
|
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
def draft_order_line_items
|
|
48
|
-
params.permit(
|
|
49
|
-
|
|
50
|
+
params.permit(
|
|
51
|
+
line_items: [
|
|
52
|
+
:variant_id,
|
|
53
|
+
:quantity,
|
|
54
|
+
{
|
|
55
|
+
options: [
|
|
56
|
+
:from_date,
|
|
57
|
+
:to_date,
|
|
58
|
+
{
|
|
59
|
+
guests_attributes: [
|
|
60
|
+
:block_id,
|
|
61
|
+
:first_name,
|
|
62
|
+
:last_name,
|
|
63
|
+
:address,
|
|
64
|
+
:dob,
|
|
65
|
+
:gender,
|
|
66
|
+
:occupation_id,
|
|
67
|
+
:other_occupation,
|
|
68
|
+
:nationality_id,
|
|
69
|
+
:age,
|
|
70
|
+
:emergency_contact,
|
|
71
|
+
:phone_number,
|
|
72
|
+
:other_organization,
|
|
73
|
+
:social_contact,
|
|
74
|
+
:social_contact_platform,
|
|
75
|
+
:expectation,
|
|
76
|
+
:country_code,
|
|
77
|
+
:upload_later,
|
|
78
|
+
:contact,
|
|
79
|
+
{ guest_dynamic_fields_attributes: %i[dynamic_field_id dynamic_field_option_id value] }
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
public_metadata: {},
|
|
84
|
+
private_metadata: {}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
).fetch(:line_items, [])
|
|
50
88
|
end
|
|
51
89
|
|
|
52
90
|
def draft_order_products
|
|
@@ -9,6 +9,8 @@ module Spree
|
|
|
9
9
|
before_action :load_guest, only: [:show]
|
|
10
10
|
|
|
11
11
|
def show
|
|
12
|
+
return head :not_found if @guest.qr_data.blank?
|
|
13
|
+
|
|
12
14
|
respond_to do |format|
|
|
13
15
|
format.png { send_data @guest.generate_png_qr, type: 'image/png', disposition: 'inline' }
|
|
14
16
|
format.svg { send_data @guest.generate_svg_qr, type: 'image/svg+xml', disposition: 'inline' }
|
data/app/controllers/spree_cm_commissioner/api/v2/storefront/checkout_controller_decorator.rb
CHANGED
|
@@ -5,9 +5,6 @@ module SpreeCmCommissioner
|
|
|
5
5
|
module CheckoutControllerDecorator
|
|
6
6
|
def self.prepended(base)
|
|
7
7
|
base.include SpreeCmCommissioner::OrderConcern
|
|
8
|
-
base.include SpreeCmCommissioner::TurnstileProtectable
|
|
9
|
-
|
|
10
|
-
base.before_action -> { verify_turnstile! }, only: %i[create_payment]
|
|
11
8
|
# Sets Current.load_test_bypass from the X-Request-Verify secret so
|
|
12
9
|
# InventoryHolds::ValidateLimits can skip anti-abuse checks for trusted load tests.
|
|
13
10
|
base.include SpreeCmCommissioner::LoadTestBypassable
|
|
@@ -200,14 +200,10 @@ module SpreeCmCommissioner
|
|
|
200
200
|
grouped.map { |nationality_group, guests| customer_type_summary(nationality_group, guests) }.join(', ')
|
|
201
201
|
end
|
|
202
202
|
|
|
203
|
-
# e.g. "Local (Adult x1, Child x1)".
|
|
204
|
-
# the migration, but a dev/staging DB whose column predates that migration (added via
|
|
205
|
-
# `add_column ... if_not_exists: true`, which silently skips the constraint if the column
|
|
206
|
-
# already exists) can still carry real NULL rows - group those under "Unknown" rather than
|
|
207
|
-
# crashing the whole order-completion Telegram notification on nil.humanize.
|
|
203
|
+
# e.g. "Local (Adult x1, Child x1)". age_group is NOT NULL, so it is always present.
|
|
208
204
|
def customer_type_summary(nationality_group, guests)
|
|
209
205
|
age_breakdown = guests
|
|
210
|
-
.group_by { |sg| sg.age_group
|
|
206
|
+
.group_by { |sg| sg.age_group.humanize }
|
|
211
207
|
.map { |age_group, age_guests| "#{age_group} x#{age_guests.count}" }
|
|
212
208
|
.join(', ')
|
|
213
209
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module SpreeCmCommissioner
|
|
2
|
+
# Groups add-on line items (sold via a ProductRelation) under the line item they were bought with.
|
|
3
|
+
#
|
|
4
|
+
# Grouping is display-only: each child keeps its own price, quantity and adjustments, since
|
|
5
|
+
# promotions, tax, service fees, payouts, refunds and open-dated redemption all work per line item.
|
|
6
|
+
# `relation_type` is a snapshot of the ProductRelation type at purchase, so later edits to the
|
|
7
|
+
# relation don't change what the order sold.
|
|
8
|
+
module LineItemBundleable
|
|
9
|
+
extend ActiveSupport::Concern
|
|
10
|
+
|
|
11
|
+
included do
|
|
12
|
+
belongs_to :parent, class_name: 'Spree::LineItem', optional: true, inverse_of: :children
|
|
13
|
+
has_many :children, class_name: 'Spree::LineItem', foreign_key: :parent_id, inverse_of: :parent, dependent: :destroy
|
|
14
|
+
|
|
15
|
+
enum relation_type: SpreeCmCommissioner::ProductRelationType::PRODUCT_RELATION_TYPES.each_with_index.to_h { |type, index| [type, index] },
|
|
16
|
+
_prefix: :relation
|
|
17
|
+
|
|
18
|
+
scope :top_level, -> { where(parent_id: nil) }
|
|
19
|
+
|
|
20
|
+
money_methods :bundle_amount
|
|
21
|
+
|
|
22
|
+
validates :relation_type, presence: true, if: -> { parent_id.present? || parent.present? }
|
|
23
|
+
validates :relation_type, absence: true, if: -> { parent_id.blank? && parent.blank? }
|
|
24
|
+
validate :ensure_valid_parent, if: -> { parent.present? }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def bundle_amount
|
|
28
|
+
amount + children.sum(&:amount)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def ensure_valid_parent
|
|
34
|
+
errors.add(:parent, :invalid) if parent.parent_id.present? || parent == self
|
|
35
|
+
errors.add(:parent, :invalid) if parent.order_id.present? && order_id.present? && parent.order_id != order_id
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -2,7 +2,7 @@ module SpreeCmCommissioner
|
|
|
2
2
|
module VehicleKind
|
|
3
3
|
extend ActiveSupport::Concern
|
|
4
4
|
|
|
5
|
-
VEHICLE_KINDS = %i[suv sedan minivan van sleeping_bus luxury_van air_bus bus ferry
|
|
5
|
+
VEHICLE_KINDS = %i[suv sedan minivan van sleeping_bus luxury_van air_bus bus ferry train].freeze
|
|
6
6
|
|
|
7
7
|
included do
|
|
8
8
|
enum kind: VEHICLE_KINDS if table_exists? && column_names.include?('kind')
|
|
@@ -201,6 +201,8 @@ module SpreeCmCommissioner
|
|
|
201
201
|
end
|
|
202
202
|
|
|
203
203
|
def generate_svg_qr
|
|
204
|
+
return nil if qr_data.blank?
|
|
205
|
+
|
|
204
206
|
qrcode = RQRCode::QRCode.new(qr_data)
|
|
205
207
|
qrcode.as_svg(
|
|
206
208
|
color: '000',
|
|
@@ -213,6 +215,8 @@ module SpreeCmCommissioner
|
|
|
213
215
|
end
|
|
214
216
|
|
|
215
217
|
def generate_png_qr(size = 120)
|
|
218
|
+
return nil if qr_data.blank?
|
|
219
|
+
|
|
216
220
|
qrcode = RQRCode::QRCode.new(qr_data)
|
|
217
221
|
qrcode.as_png(
|
|
218
222
|
bit_depth: 1,
|
|
@@ -228,7 +232,11 @@ module SpreeCmCommissioner
|
|
|
228
232
|
)
|
|
229
233
|
end
|
|
230
234
|
|
|
235
|
+
# Transferred guests no longer own the ticket, so they must not receive any
|
|
236
|
+
# scannable QR data. The ownership moved to the guest created by
|
|
237
|
+
# SpreeCmCommissioner::TicketTransfers::TransferGuest.
|
|
231
238
|
def qr_data
|
|
239
|
+
return nil if transferred?
|
|
232
240
|
return external_qr_data if external_qr_data.present?
|
|
233
241
|
|
|
234
242
|
token
|
|
@@ -14,25 +14,10 @@ module SpreeCmCommissioner
|
|
|
14
14
|
validates :incremental_sync_interval_seconds, presence: true, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 3600 }
|
|
15
15
|
validates :full_sync_interval_hours, presence: true, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 168 }
|
|
16
16
|
|
|
17
|
-
# Listed from the folder rather than `descendants`, which misses subclasses Zeitwerk hasn't
|
|
18
|
-
# loaded yet in dev and test.
|
|
19
|
-
def self.types
|
|
20
|
-
Dir[SpreeCmCommissioner::Engine.root.join('app/models/spree_cm_commissioner/integrations/*.rb')]
|
|
21
|
-
.map { |path| "SpreeCmCommissioner::Integrations::#{File.basename(path, '.rb').camelize}" }
|
|
22
|
-
.sort
|
|
23
|
-
end
|
|
24
|
-
|
|
25
17
|
def sync_manager
|
|
26
18
|
raise NotImplementedError, 'Subclasses must implement the sync_manager method'
|
|
27
19
|
end
|
|
28
20
|
|
|
29
|
-
# Whether the partner, not BookMe+, sets this variant's per-night stock, prices and closings.
|
|
30
|
-
# When true, stock resets and dashboard edits leave its inventory items alone, and new nights
|
|
31
|
-
# start closed until the partner opens them (InventoryItem). Off by default.
|
|
32
|
-
def inventory_external_wins?(_variant)
|
|
33
|
-
false
|
|
34
|
-
end
|
|
35
|
-
|
|
36
21
|
def restock_external_inventory!(_order, _line_items)
|
|
37
22
|
raise NotImplementedError, 'Subclasses must implement the restock_external_inventory! method'
|
|
38
23
|
end
|
|
@@ -40,36 +25,5 @@ module SpreeCmCommissioner
|
|
|
40
25
|
def unstock_external_inventory!(_order, _line_items)
|
|
41
26
|
raise NotImplementedError, 'Subclasses must implement the unstock_external_inventory! method'
|
|
42
27
|
end
|
|
43
|
-
|
|
44
|
-
def sync_item_availability!(_options = {})
|
|
45
|
-
raise NotImplementedError, 'Subclasses must implement the sync_item_availability! method'
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def hold_inventory!(_order, _line_items)
|
|
49
|
-
raise NotImplementedError, 'Subclasses must implement the hold_inventory! method'
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# Integrations that manage external inventory reservations should override this to return true
|
|
53
|
-
def supports_external_inventory_holding?
|
|
54
|
-
false
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# Integrations that support automatically releasing external inventory
|
|
58
|
-
# after reservation expiration or order cancellation should override this to return true
|
|
59
|
-
def supports_auto_release_inventory?
|
|
60
|
-
false
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def release_inventory!(_order, _line_items)
|
|
64
|
-
raise NotImplementedError, 'Subclasses must implement the release_inventory! method'
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def external_inventory_items(_order)
|
|
68
|
-
raise NotImplementedError, 'Subclasses must implement the external_inventory_items method'
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def external_inventory_item_status(_order, _options)
|
|
72
|
-
raise NotImplementedError, 'Subclasses must implement the external_inventory_item_status method'
|
|
73
|
-
end
|
|
74
28
|
end
|
|
75
29
|
end
|
|
@@ -5,7 +5,10 @@ class SpreeCmCommissioner::Integrations::StadiumXV1 < SpreeCmCommissioner::Integ
|
|
|
5
5
|
|
|
6
6
|
# override
|
|
7
7
|
def sync_manager
|
|
8
|
-
SpreeCmCommissioner::Integrations::StadiumXV1::SyncManager.new(
|
|
8
|
+
SpreeCmCommissioner::Integrations::StadiumXV1::SyncManager.new(
|
|
9
|
+
integration: self,
|
|
10
|
+
client: client
|
|
11
|
+
)
|
|
9
12
|
end
|
|
10
13
|
|
|
11
14
|
# override
|
|
@@ -15,6 +18,7 @@ class SpreeCmCommissioner::Integrations::StadiumXV1 < SpreeCmCommissioner::Integ
|
|
|
15
18
|
order: order,
|
|
16
19
|
line_items: line_items
|
|
17
20
|
)
|
|
21
|
+
|
|
18
22
|
raise SpreeCmCommissioner::Integrations::SyncError, result.error unless result.success?
|
|
19
23
|
end
|
|
20
24
|
|
|
@@ -23,9 +27,11 @@ class SpreeCmCommissioner::Integrations::StadiumXV1 < SpreeCmCommissioner::Integ
|
|
|
23
27
|
raise SpreeCmCommissioner::Integrations::SyncError, 'Ticket cannot be cancelled'
|
|
24
28
|
end
|
|
25
29
|
|
|
26
|
-
def sync_item_availability!(_options = {}); end
|
|
27
|
-
|
|
28
30
|
def client
|
|
29
|
-
|
|
31
|
+
SpreeCmCommissioner::Integrations::StadiumXV1::ExternalClient::Client.new(
|
|
32
|
+
public_key: public_key,
|
|
33
|
+
private_key: private_key,
|
|
34
|
+
base_url: base_url
|
|
35
|
+
)
|
|
30
36
|
end
|
|
31
37
|
end
|
|
@@ -2,15 +2,10 @@ module SpreeCmCommissioner
|
|
|
2
2
|
class InventoryItem < Base
|
|
3
3
|
include SpreeCmCommissioner::ProductType
|
|
4
4
|
include SpreeCmCommissioner::StoreMetadata
|
|
5
|
-
include SpreeCmCommissioner::Integrations::IntegrationMappable
|
|
6
5
|
|
|
7
6
|
MAX_DISPLAY_STOCK = 20
|
|
8
7
|
LOW_STOCK_THRESHOLD = 20
|
|
9
8
|
|
|
10
|
-
store_public_metadata :last_synced_at, :datetime
|
|
11
|
-
store_public_metadata :original_price, :integer
|
|
12
|
-
store_public_metadata :currency, :string
|
|
13
|
-
|
|
14
9
|
# Association
|
|
15
10
|
belongs_to :variant, class_name: 'Spree::Variant', optional: false
|
|
16
11
|
|
|
@@ -41,11 +36,6 @@ module SpreeCmCommissioner
|
|
|
41
36
|
|
|
42
37
|
before_save -> { self.product_type = variant.product_type }, if: -> { product_type.nil? }
|
|
43
38
|
|
|
44
|
-
# A night whose inventory a partner owns (Integration#inventory_external_wins?) starts closed: its
|
|
45
|
-
# count is only our seed from the physical room count, which the partner may already have sold
|
|
46
|
-
# elsewhere. The partner's first availability push opens it.
|
|
47
|
-
before_create -> { self.closed = true }, if: -> { permanent_stock? && variant&.inventory_external_wins? }
|
|
48
|
-
|
|
49
39
|
after_commit :schedule_product_cache_invalidation
|
|
50
40
|
after_commit :publish_live_stock_status_to_firestore
|
|
51
41
|
|
|
@@ -119,14 +109,6 @@ module SpreeCmCommissioner
|
|
|
119
109
|
# This method is only used when admin update stock
|
|
120
110
|
def adjust_quantity!(quantity)
|
|
121
111
|
with_lock do
|
|
122
|
-
# Warm the Redis cache from the current DB value BEFORE applying the delta below.
|
|
123
|
-
# adjust_quantity_in_redis treats a missing key as 0, so a negative delta against a
|
|
124
|
-
# never-cached key would compute e.g. 0 - 3 = -3, clamp to 0, and permanently cache the
|
|
125
|
-
# wrong value (the read path only self-heals from a genuinely *missing* key, not a wrong
|
|
126
|
-
# one). This is the same warm-before-delta pattern already used by
|
|
127
|
-
# InventoryItems::AdjustAvailableQuantity for the same reason.
|
|
128
|
-
SpreeCmCommissioner::RedisStock::CachedInventoryItemsBuilder.new([self]).call
|
|
129
|
-
|
|
130
112
|
# IMPORTANT: Apply quantity changes directly without defensive clamping.
|
|
131
113
|
# The model validation will catch any attempts to go negative, surfacing bugs
|
|
132
114
|
# in upstream logic rather than silently losing data.
|
|
@@ -94,6 +94,7 @@ module SpreeCmCommissioner
|
|
|
94
94
|
base.include SpreeCmCommissioner::ProductType
|
|
95
95
|
base.include SpreeCmCommissioner::ProductDelegation
|
|
96
96
|
base.include SpreeCmCommissioner::LineItemOpenDatedTrippable
|
|
97
|
+
base.include SpreeCmCommissioner::LineItemBundleable
|
|
97
98
|
base.include SpreeCmCommissioner::KycBitwise
|
|
98
99
|
end
|
|
99
100
|
|
|
@@ -11,7 +11,6 @@ module SpreeCmCommissioner
|
|
|
11
11
|
base.include SpreeCmCommissioner::OrderScopes
|
|
12
12
|
base.include SpreeCmCommissioner::TicketTransferable
|
|
13
13
|
base.include SpreeCmCommissioner::OrderQrCodeable
|
|
14
|
-
base.include SpreeCmCommissioner::Integrations::IntegrationMappable
|
|
15
14
|
|
|
16
15
|
base.before_create :link_by_phone_number
|
|
17
16
|
base.before_create :associate_customer
|
|
@@ -52,7 +51,6 @@ module SpreeCmCommissioner
|
|
|
52
51
|
base.has_many :reserved_blocks, through: :guests, class_name: 'SpreeCmCommissioner::ReservedBlock'
|
|
53
52
|
base.has_many :guest_card_classes, class_name: 'SpreeCmCommissioner::GuestCardClass', through: :variants
|
|
54
53
|
base.has_many :product_completion_steps, class_name: 'SpreeCmCommissioner::ProductCompletionStep', through: :line_items
|
|
55
|
-
base.has_many :audit_events, class_name: 'SpreeCmCommissioner::AuditEvent', as: :auditable
|
|
56
54
|
|
|
57
55
|
base.delegate :customer, to: :user, allow_nil: true
|
|
58
56
|
|
|
@@ -49,8 +49,7 @@ module SpreeCmCommissioner
|
|
|
49
49
|
quantity_locked_on_hold: cache_inventory(locked_hold_keys[index], item, item.quantity_locked_on_hold, locked_hold[index]),
|
|
50
50
|
max_capacity: item.max_capacity,
|
|
51
51
|
inventory_item_id: item.id,
|
|
52
|
-
variant_id: item.variant_id
|
|
53
|
-
closed: item.closed
|
|
52
|
+
variant_id: item.variant_id
|
|
54
53
|
)
|
|
55
54
|
end
|
|
56
55
|
|
|
@@ -23,7 +23,7 @@ module SpreeCmCommissioner
|
|
|
23
23
|
return true if variant.need_confirmation?
|
|
24
24
|
return false if cached_inventory_items.empty?
|
|
25
25
|
|
|
26
|
-
cached_inventory_items.all? { |item| item.
|
|
26
|
+
cached_inventory_items.all? { |item| item.active? && quantity_in_pool(item, include_locked: include_locked) >= quantity }
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# The cache row carries both pools, so choosing between them is a read, not another Redis trip.
|
|
@@ -45,7 +45,7 @@ module SpreeCmCommissioner
|
|
|
45
45
|
# stock, i.e. read sold out exactly when its allotment was still sellable.
|
|
46
46
|
cached_inventory_items.all? do |item|
|
|
47
47
|
quantity = line_item.locked_stock? ? item.quantity_locked : item.quantity_available
|
|
48
|
-
item.
|
|
48
|
+
item.active? && quantity >= line_item.quantity
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -15,10 +15,6 @@ module SpreeCmCommissioner
|
|
|
15
15
|
private
|
|
16
16
|
|
|
17
17
|
def create_inventory_items
|
|
18
|
-
# Skip automatic inventory generation when variant has manual_generate_inventory_items set to true
|
|
19
|
-
# Use case: For variants where inventory items need to be manually created/managed (e.g., external integrations)
|
|
20
|
-
return if variant.manual_generate_inventory_items?
|
|
21
|
-
|
|
22
18
|
SpreeCmCommissioner::InventoryItems::GenerateInventoryItemsJob.perform_later(variant_id: variant.id)
|
|
23
19
|
end
|
|
24
20
|
|
|
@@ -2,7 +2,6 @@ module SpreeCmCommissioner
|
|
|
2
2
|
class Trip < Base
|
|
3
3
|
include SpreeCmCommissioner::StoreMetadata
|
|
4
4
|
include SpreeCmCommissioner::RouteType
|
|
5
|
-
include SpreeCmCommissioner::Integrations::IntegrationMappable
|
|
6
5
|
include SpreeCmCommissioner::ServiceOrigin
|
|
7
6
|
|
|
8
7
|
attr_accessor :hours, :minutes, :seconds
|
|
@@ -39,7 +38,7 @@ module SpreeCmCommissioner
|
|
|
39
38
|
after_commit :update_route_price_range, on: %i[create update]
|
|
40
39
|
|
|
41
40
|
belongs_to :vendor, class_name: 'Spree::Vendor', inverse_of: :trips, optional: false
|
|
42
|
-
belongs_to :product, class_name: 'Spree::Product', inverse_of: :trip, optional:
|
|
41
|
+
belongs_to :product, class_name: 'Spree::Product', inverse_of: :trip, optional: false
|
|
43
42
|
|
|
44
43
|
belongs_to :service_origin, class_name: 'Spree::Taxon', optional: true
|
|
45
44
|
|
|
@@ -6,7 +6,6 @@ module SpreeCmCommissioner
|
|
|
6
6
|
base.include SpreeCmCommissioner::VariantOptionsConcern
|
|
7
7
|
base.include SpreeCmCommissioner::KycBitwise
|
|
8
8
|
base.include SpreeCmCommissioner::Integrations::IntegrationMappable
|
|
9
|
-
base.include SpreeCmCommissioner::VariantMetadata
|
|
10
9
|
|
|
11
10
|
base.after_commit :update_vendor_price
|
|
12
11
|
base.validate :validate_option_types
|
|
@@ -81,10 +80,6 @@ module SpreeCmCommissioner
|
|
|
81
80
|
delivery_option == 'delivery'
|
|
82
81
|
end
|
|
83
82
|
|
|
84
|
-
def inventory_external_wins?
|
|
85
|
-
vendor&.integration&.inventory_external_wins?(self) || false
|
|
86
|
-
end
|
|
87
|
-
|
|
88
83
|
def non_digital_ecommerce?
|
|
89
84
|
!digital? && ecommerce?
|
|
90
85
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module SpreeCmCommissioner
|
|
2
2
|
class Vehicle < Base
|
|
3
3
|
include SpreeCmCommissioner::VehicleKind
|
|
4
|
-
include SpreeCmCommissioner::Integrations::IntegrationMappable
|
|
5
4
|
|
|
6
5
|
belongs_to :vendor, class_name: 'Spree::Vendor'
|
|
7
6
|
belongs_to :vehicle_type, class_name: 'SpreeCmCommissioner::VehicleType'
|
|
@@ -14,8 +13,6 @@ module SpreeCmCommissioner
|
|
|
14
13
|
validates :name, presence: true
|
|
15
14
|
validates :license_plate, uniqueness: true, allow_blank: true
|
|
16
15
|
|
|
17
|
-
has_one :seat_layout, through: :vehicle_type
|
|
18
|
-
|
|
19
16
|
self.whitelisted_ransackable_attributes = %w[name license_plate kind]
|
|
20
17
|
|
|
21
18
|
def display_name
|
|
@@ -2,7 +2,6 @@ module SpreeCmCommissioner
|
|
|
2
2
|
class VehicleType < Base
|
|
3
3
|
include SpreeCmCommissioner::StoreMetadata
|
|
4
4
|
include SpreeCmCommissioner::VehicleKind
|
|
5
|
-
include SpreeCmCommissioner::Integrations::IntegrationMappable
|
|
6
5
|
|
|
7
6
|
# This model has no seat_layout column (polymorphic association), so we store the preload_seat_layout_id ID in public_metadata.
|
|
8
7
|
# This lets us check if a seat layout exists without triggering a database query.
|
|
@@ -33,7 +33,6 @@ module SpreeCmCommissioner
|
|
|
33
33
|
base.has_many :nearby_places, -> { order(position: :asc) }, class_name: 'SpreeCmCommissioner::VendorPlace', dependent: :destroy
|
|
34
34
|
|
|
35
35
|
base.has_many :stock_items, through: :variants, class_name: 'Spree::StockItem'
|
|
36
|
-
base.has_many :currency_rates, class_name: 'SpreeCmCommissioner::CurrencyRate', dependent: :destroy
|
|
37
36
|
|
|
38
37
|
base.has_many :taxon_vendors, class_name: 'SpreeCmCommissioner::TaxonVendor'
|
|
39
38
|
base.has_many :taxons, through: :taxon_vendors
|
|
@@ -105,7 +104,6 @@ module SpreeCmCommissioner
|
|
|
105
104
|
base.has_many :boarding_trip_stops, through: :trips, class_name: 'SpreeCmCommissioner::TripStop', source: :boarding_trip_stops
|
|
106
105
|
base.has_many :drop_off_trip_stops, through: :trips, class_name: 'SpreeCmCommissioner::TripStop', source: :drop_off_trip_stops
|
|
107
106
|
base.has_many :pricing_models, class_name: 'SpreeCmCommissioner::PricingModel', foreign_key: :vendor_id, dependent: :destroy
|
|
108
|
-
base.has_many :orders, -> { distinct }, through: :variants, source: :orders
|
|
109
107
|
|
|
110
108
|
base.has_many :agency_categories, -> { where(kind: :agency_category) }, class_name: 'Spree::Taxon', foreign_key: :vendor_id
|
|
111
109
|
|
|
@@ -250,21 +248,6 @@ module SpreeCmCommissioner
|
|
|
250
248
|
|
|
251
249
|
delegate :present?, to: :tenant, prefix: true
|
|
252
250
|
|
|
253
|
-
# Returns the exchange rate between two currencies
|
|
254
|
-
# If no direct rate exists, calculates the inverse rate from the reverse pair
|
|
255
|
-
# Returns 1.0 for identical currencies, nil if no rate is found
|
|
256
|
-
def exchange_rate(from_currency, to_currency)
|
|
257
|
-
return 1.0 if from_currency == to_currency
|
|
258
|
-
|
|
259
|
-
pair = currency_rates.by_pair(from_currency, to_currency).first
|
|
260
|
-
return pair.rate if pair.present?
|
|
261
|
-
|
|
262
|
-
reverse_pair = currency_rates.by_pair(to_currency, from_currency).first
|
|
263
|
-
return (1.0 / reverse_pair.rate).round(6) if reverse_pair.present?
|
|
264
|
-
|
|
265
|
-
nil
|
|
266
|
-
end
|
|
267
|
-
|
|
268
251
|
def validate_sellable_product_types
|
|
269
252
|
valid_types = SpreeCmCommissioner::ProductType::PRODUCT_TYPES.map(&:to_s)
|
|
270
253
|
return if sellable_product_types.all? { |type| valid_types.include?(type.to_s) }
|
|
@@ -10,7 +10,8 @@ module Spree
|
|
|
10
10
|
:completion_steps, :available_social_contact_platforms, :allow_anonymous_booking, :discontinue_on,
|
|
11
11
|
:high_demand, :jwt_token,
|
|
12
12
|
:direction, :trip_id, :boarding_trip_stop_id, :drop_off_trip_stop_id,
|
|
13
|
-
:service_fee_total, :display_service_fee_total
|
|
13
|
+
:service_fee_total, :display_service_fee_total,
|
|
14
|
+
:parent_id, :relation_type, :bundle_amount, :display_bundle_amount
|
|
14
15
|
|
|
15
16
|
base.attribute :required_self_check_in_location, &:required_self_check_in_location?
|
|
16
17
|
base.attribute :allowed_self_check_in, &:allowed_self_check_in?
|
|
@@ -10,7 +10,8 @@ module SpreeCmCommissioner
|
|
|
10
10
|
base.attributes :phone_number, :intel_phone_number, :country_code, :request_state,
|
|
11
11
|
:term_accepted_at,
|
|
12
12
|
:channel, :hold_expires_at,
|
|
13
|
-
:service_fee_total, :display_service_fee_total
|
|
13
|
+
:service_fee_total, :display_service_fee_total,
|
|
14
|
+
:order_total_after_store_credit, :display_order_total_after_store_credit
|
|
14
15
|
|
|
15
16
|
base.attribute :has_incomplete_guest_info, &:has_incomplete_guest_info?
|
|
16
17
|
base.attribute :required_payway_payout, &:required_payway_payout?
|