1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/models/order.rb
2022-08-26 15:56:20 +02:00

32 lines
814 B
Ruby

# frozen_string_literal: true
# Order is a model for the user hold information of order
class Order < PaymentDocument
belongs_to :statistic_profile
belongs_to :operator_profile, class_name: 'InvoicingProfile'
has_many :order_items, dependent: :destroy
has_one :payment_gateway_object, as: :item
ALL_STATES = %w[cart in_progress ready canceled return].freeze
enum state: ALL_STATES.zip(ALL_STATES).to_h
PAYMENT_STATES = %w[paid failed refunded].freeze
enum payment_state: PAYMENT_STATES.zip(PAYMENT_STATES).to_h
validates :token, :state, presence: true
before_create :add_environment
def footprint_children
order_items
end
def paid_by_card?
!payment_gateway_object.nil? && payment_method == 'card'
end
def self.columns_out_of_footprint
%w[payment_method]
end
end