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 =
Categories.
%w[avg_last_3_months avg_last_12_months calculated_percent_net_sales previous_year sales_forecast manual].freeze
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
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 Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#category ⇒ Object (readonly)
30 |
# File 'app/models/budget_rule.rb', line 30 validates :category, :ledger_account_id, presence: true |
#ledger_account_id ⇒ Object (readonly)
30 |
# File 'app/models/budget_rule.rb', line 30 validates :category, :ledger_account_id, presence: true |
Instance Method Details
#ledger_account ⇒ LedgerAccount
28 |
# File 'app/models/budget_rule.rb', line 28 belongs_to :ledger_account, optional: true |
#ledger_projects ⇒ Object
32 33 34 |
# File 'app/models/budget_rule.rb', line 32 def ledger_projects ledger_project_ids.nil? ? [] : LedgerProject.where(id: ledger_project_ids).pluck("concat(project_number, ' ', description)") end |
#suppliers ⇒ Object
36 37 38 |
# File 'app/models/budget_rule.rb', line 36 def suppliers supplier_ids.nil? ? [] : Party.where(id: supplier_ids).pluck(:full_name) end |
#to_s ⇒ Object
40 41 42 |
# File 'app/models/budget_rule.rb', line 40 def to_s "Budget Rule #{id}" end |