2019-06-03 16:00:09 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# track of all transactions payed using the given wallet
|
2020-03-25 10:16:47 +01:00
|
|
|
class WalletTransaction < ApplicationRecord
|
2016-07-05 12:30:52 +02:00
|
|
|
include AmountConcern
|
|
|
|
|
2019-06-03 16:00:09 +02:00
|
|
|
belongs_to :invoicing_profile
|
2016-07-04 19:20:10 +02:00
|
|
|
belongs_to :wallet
|
|
|
|
belongs_to :reservation
|
|
|
|
belongs_to :transactable, polymorphic: true
|
2016-07-20 15:07:43 +02:00
|
|
|
has_one :invoice
|
2016-07-05 12:15:26 +02:00
|
|
|
|
2019-06-03 16:00:09 +02:00
|
|
|
validates_inclusion_of :transaction_type, in: %w[credit debit]
|
|
|
|
validates :invoicing_profile, :wallet, presence: true
|
|
|
|
|
|
|
|
def user
|
|
|
|
invoicing_profile.user
|
|
|
|
end
|
2016-07-04 19:20:10 +02:00
|
|
|
end
|