Class: LedgerProject
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- LedgerProject
- Includes:
- Models::Auditable, Models::Lineage
- Defined in:
- app/models/ledger_project.rb
Overview
== Schema Information
Table name: ledger_projects
Database name: primary
id :integer not null, primary key
description :string(255) not null
project_number :integer not null
type :string(255)
created_at :datetime
updated_at :datetime
creator_id :integer
parent_id :integer
updater_id :integer
Indexes
idx_ledger_projects_where_id (type) WHERE (id IS NULL)
index_ledger_projects_on_type (type)
project_number_type (project_number,type)
Direct Known Subclasses
Constant Summary collapse
- PROJECT_TYPES =
Recognised project types.
{ "Detail" => "LedgerDetailProject", "Summary" => "LedgerSummaryProject" }.freeze
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
- #description ⇒ Object readonly
-
#do_not_set_project_number ⇒ Object
Returns the value of attribute do_not_set_project_number.
- #project_number ⇒ Object readonly
- #type ⇒ Object readonly
Has many collapse
Class Method Summary collapse
-
.is_valid_type?(project_type) ⇒ Boolean
Whether
project_typeis one of PROJECT_TYPES. -
.select_options ⇒ Array<Array(String, Integer)>
[label, id]pairs of every project for project-tagging dropdowns, ordered by project number. -
.types_for_select ⇒ Array<Array(String, String)>
Detail-vs-Summary STI options for the new-project form.
Instance Method Summary collapse
-
#name_for_select ⇒ String
Same shape as #summary_name — kept separate because some subclasses override the dropdown label without overriding the breadcrumb form.
-
#summary_name ⇒ String
"<project_number> <description>"label for breadcrumbs.
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #creator, #should_not_save_version, #stamp_record, #updater
Methods included from Models::Lineage
#ancestors, #ancestors_ids, #children_and_roots, #descendants, #descendants_ids, #ensure_non_recursive_lineage, #family_members, #generate_full_name, #generate_full_name_array, #lineage, #lineage_array, #lineage_simple, #root, #root_id, #self_ancestors_and_descendants, #self_ancestors_and_descendants_ids, #self_and_ancestors, #self_and_ancestors_ids, #self_and_children, #self_and_descendants, #self_and_descendants_ids, #self_and_siblings, #self_and_siblings_ids, #siblings, #siblings_ids
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#description ⇒ Object (readonly)
33 |
# File 'app/models/ledger_project.rb', line 33 validates :project_number, :description, :type, presence: true |
#do_not_set_project_number ⇒ Object
Returns the value of attribute do_not_set_project_number.
31 32 33 |
# File 'app/models/ledger_project.rb', line 31 def do_not_set_project_number @do_not_set_project_number end |
#project_number ⇒ Object (readonly)
33 |
# File 'app/models/ledger_project.rb', line 33 validates :project_number, :description, :type, presence: true |
#type ⇒ Object (readonly)
33 |
# File 'app/models/ledger_project.rb', line 33 validates :project_number, :description, :type, presence: true |
Class Method Details
.is_valid_type?(project_type) ⇒ Boolean
Returns whether project_type is one of PROJECT_TYPES.
64 65 66 |
# File 'app/models/ledger_project.rb', line 64 def self.is_valid_type?(project_type) PROJECT_TYPES.values.include? project_type end |
.select_options ⇒ Array<Array(String, Integer)>
[label, id] pairs of every project for project-tagging
dropdowns, ordered by project number.
51 52 53 54 |
# File 'app/models/ledger_project.rb', line 51 def self. # LedgerProject.all.order(:project_number).pluck("concat(project_number, ' ', description)", "id") LedgerProject.order(:project_number).map { |lp| [lp.name_for_select, lp.id] } end |
.types_for_select ⇒ Array<Array(String, String)>
Detail-vs-Summary STI options for the new-project form.
58 59 60 |
# File 'app/models/ledger_project.rb', line 58 def self.types_for_select PROJECT_TYPES.map { |k, v| [k, v] } end |
Instance Method Details
#budgets ⇒ ActiveRecord::Relation<Budget>
27 |
# File 'app/models/ledger_project.rb', line 27 has_many :budgets |
#name_for_select ⇒ String
Same shape as #summary_name — kept separate because some
subclasses override the dropdown label without overriding
the breadcrumb form.
72 73 74 |
# File 'app/models/ledger_project.rb', line 72 def name_for_select "#{project_number} #{description}" end |
#summary_name ⇒ String
"<project_number> <description>" label for breadcrumbs.
44 45 46 |
# File 'app/models/ledger_project.rb', line 44 def summary_name "#{project_number} #{description}" end |