1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/models/wallet_transaction.rb

27 lines
633 B
Ruby
Raw Normal View History

# 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
belongs_to :invoicing_profile
2016-07-04 19:20:10 +02:00
belongs_to :wallet
belongs_to :reservation
# what was paid with the wallet
has_one :invoice
has_one :payment_schedule
# how the wallet was credited
has_one :invoice_item, as: :object, dependent: :destroy
validates_inclusion_of :transaction_type, in: %w[credit debit]
validates :invoicing_profile, :wallet, presence: true
def user
invoicing_profile.user
end
def original_invoice
invoice_item.invoice
end
2016-07-04 19:20:10 +02:00
end