2022-09-15 20:19:19 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-02-16 11:22:42 +01:00
|
|
|
# Provides a method to set the order state to "in progress"
|
2022-09-15 20:19:19 +02:00
|
|
|
class Orders::SetInProgressService
|
|
|
|
def call(order, current_user)
|
2022-09-16 17:54:41 +02:00
|
|
|
raise ::UpdateOrderStateError if %w[cart payment_failed in_progress canceled refunded delivered].include?(order.state)
|
2022-09-15 20:19:19 +02:00
|
|
|
|
|
|
|
order.state = 'in_progress'
|
|
|
|
order.order_activities.push(OrderActivity.new(activity_type: 'in_progress', operator_profile_id: current_user.invoicing_profile.id))
|
|
|
|
order.save
|
|
|
|
order.reload
|
|
|
|
end
|
|
|
|
end
|