mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-04 15:24:23 +01:00
6df9724527
This setting was disabled in config/application.rb: `config.active_record.belongs_to_required_by_default = false`, so we must configure the linter accordingly. Also: linting some little bit of code
25 lines
674 B
Ruby
25 lines
674 B
Ruby
# frozen_string_literal: true
|
|
|
|
# track of all transactions payed using the given wallet
|
|
class WalletTransaction < ApplicationRecord
|
|
include AmountConcern
|
|
|
|
belongs_to :invoicing_profile
|
|
belongs_to :wallet
|
|
belongs_to :reservation
|
|
# what was paid with the wallet
|
|
has_one :invoice, dependent: :nullify
|
|
has_one :payment_schedule, dependent: :nullify
|
|
# how the wallet was credited
|
|
has_one :invoice_item, as: :object, dependent: :destroy
|
|
|
|
validates :transaction_type, inclusion: { in: %w[credit debit] }
|
|
validates :invoicing_profile, :wallet, presence: true
|
|
|
|
delegate :user, to: :invoicing_profile
|
|
|
|
def original_invoice
|
|
invoice_item.invoice
|
|
end
|
|
end
|