1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/app/services/cart/create_service.rb

20 lines
475 B
Ruby

# frozen_string_literal: true
# Provides methods for create cart
class Cart::CreateService
def call(user)
token = GenerateTokenService.new.call(Order)
order_param = {
token: token,
state: 'cart',
total: 0
}
if user
order_param[:statistic_profile_id] = user.statistic_profile.id if user.member?
order_param[:operator_profile_id] = user.invoicing_profile.id if user.privileged?
end
Order.create!(order_param)
end
end