Class: BudgetRule
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- BudgetRule
- Includes:
- Models::Auditable
- Defined in:
- app/models/budget_rule.rb
Overview
== Schema Information
Table name: budget_rules
Database name: primary
id :integer not null, primary key
category :string
is_revenue :boolean
ledger_project_ids :text default([]), is an Array
supplier_ids :text default([]), is an Array
created_at :datetime not null
updated_at :datetime not null
creator_id :integer
ledger_account_id :integer
updater_id :integer
Indexes
index_budget_rules_on_ledger_account_id (ledger_account_id)
Constant Summary collapse
- CATEGORIES =
["avg_last_3_months", "avg_last_12_months", "calculated_percent_net_sales", "previous_year", "sales_forecast", "manual"]
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Instance Attribute Summary collapse
- #category ⇒ Object readonly
- #ledger_account_id ⇒ Object readonly
Belongs to collapse
Methods included from Models::Auditable
Instance Method Summary collapse
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Instance Attribute Details
#category ⇒ Object (readonly)
28 |
# File 'app/models/budget_rule.rb', line 28 validates :category, :ledger_account_id, presence: true |
#ledger_account_id ⇒ Object (readonly)
28 |
# File 'app/models/budget_rule.rb', line 28 validates :category, :ledger_account_id, presence: true |
Instance Method Details
#ledger_account ⇒ LedgerAccount
26 |
# File 'app/models/budget_rule.rb', line 26 belongs_to :ledger_account, optional: true |
#ledger_projects ⇒ Object
30 31 32 |
# File 'app/models/budget_rule.rb', line 30 def ledger_projects ledger_project_ids.nil? ? [] : LedgerProject.where(:id => ledger_project_ids).pluck("concat(project_number, ' ', description)") end |
#suppliers ⇒ Object
34 35 36 |
# File 'app/models/budget_rule.rb', line 34 def suppliers supplier_ids.nil? ? [] : Party.where(:id => supplier_ids).pluck(:full_name) end |
#to_s ⇒ Object
38 39 40 |
# File 'app/models/budget_rule.rb', line 38 def to_s "Budget Rule #{id}" end |