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

21 lines
612 B
Ruby
Raw Normal View History

2022-08-19 19:59:13 +02:00
# frozen_string_literal: true
# Order is a model for the user hold information of order
class Order < ApplicationRecord
belongs_to :statistic_profile
has_many :order_items, dependent: :destroy
ALL_STATES = %w[cart in_progress ready canceled return].freeze
2022-08-19 19:59:13 +02:00
enum state: ALL_STATES.zip(ALL_STATES).to_h
PAYMENT_STATES = %w[paid failed refunded].freeze
2022-08-25 08:52:17 +02:00
enum payment_state: PAYMENT_STATES.zip(PAYMENT_STATES).to_h
2022-08-19 19:59:13 +02:00
validates :token, :state, presence: true
2022-08-26 11:19:09 +02:00
def set_wallet_transaction(amount, transaction_id)
self.wallet_amount = amount
self.wallet_transaction_id = transaction_id
end
2022-08-19 19:59:13 +02:00
end