Class: BudgetRule

Inherits:
ApplicationRecord show all
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

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

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

#publish_event

Instance Attribute Details

#categoryObject (readonly)



28
# File 'app/models/budget_rule.rb', line 28

validates :category, :ledger_account_id, presence: true

#ledger_account_idObject (readonly)



28
# File 'app/models/budget_rule.rb', line 28

validates :category, :ledger_account_id, presence: true

Instance Method Details

#ledger_accountLedgerAccount



26
# File 'app/models/budget_rule.rb', line 26

belongs_to :ledger_account, optional: true

#ledger_projectsObject



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

#suppliersObject



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_sObject



38
39
40
# File 'app/models/budget_rule.rb', line 38

def to_s
	"Budget Rule #{id}"
end