1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-02 13:24:20 +01:00
fab-manager/app/services/orders/order_delivered_service.rb

14 lines
474 B
Ruby
Raw Normal View History

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