2022-01-13 00:13:50 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class RepositoryLedgerRecord < ApplicationRecord
|
2023-08-22 16:47:58 +08:00
|
|
|
auto_strip_attributes :comment
|
|
|
|
|
2023-09-07 19:12:27 +08:00
|
|
|
belongs_to :repository_stock_value
|
2022-01-20 19:44:57 +08:00
|
|
|
belongs_to :reference, polymorphic: true
|
|
|
|
belongs_to :user
|
2023-09-08 17:35:16 +08:00
|
|
|
belongs_to :repository,
|
|
|
|
(lambda do |repository_ledger_record|
|
|
|
|
repository_ledger_record.reference_type == 'RepositoryBase' ? self : none
|
|
|
|
end),
|
|
|
|
optional: true, foreign_key: :reference_id, inverse_of: :repository_ledger_records
|
|
|
|
belongs_to :my_module_repository_row,
|
|
|
|
(lambda do |repository_ledger_record|
|
|
|
|
repository_ledger_record.reference_type == 'MyModuleRepositoryRow' ? self : none
|
|
|
|
end),
|
|
|
|
optional: true, foreign_key: :reference_id, inverse_of: :repository_ledger_records
|
|
|
|
has_one :repository_row, through: :repository_stock_value
|
2022-01-13 00:13:50 +08:00
|
|
|
end
|