Добавление миграций БД и моделей
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
class Auditor < ApplicationRecord
|
||||
has_many :yearly_files, dependent: :nullify
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class DocumentType < ApplicationRecord
|
||||
has_many :financial_statements, dependent: :restrict_with_error
|
||||
|
||||
validates :name, presence: true
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class FinancialStatement < ApplicationRecord
|
||||
belongs_to :yearly_file
|
||||
belongs_to :document_type
|
||||
|
||||
validates :data, presence: true
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class Organization < ApplicationRecord
|
||||
has_many :yearly_files, dependent: :destroy
|
||||
has_many :financial_statements, through: :yearly_files
|
||||
|
||||
validates :inn, presence: true
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
class YearlyFile < ApplicationRecord
|
||||
belongs_to :organization
|
||||
belongs_to :auditor, optional: true
|
||||
|
||||
has_many :financial_statements, dependent: :destroy
|
||||
|
||||
has_one_attached :file
|
||||
|
||||
validates :year, presence: true
|
||||
end
|
||||
Reference in New Issue
Block a user