Class: LedgerClosingPeriod
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- LedgerClosingPeriod
- Includes:
- Models::Auditable
- Defined in:
- app/models/ledger_closing_period.rb
Overview
== Schema Information
Table name: ledger_closing_periods
Database name: primary
id :integer not null, primary key
close_to :date
companies :string(255) is an Array
transaction_types :string(255) is an Array
created_at :datetime
updated_at :datetime
creator_id :integer
updater_id :integer
Constant Summary
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Class Method Summary collapse
-
.company_in_all_or ⇒ ActiveRecord::Relation<LedgerClosingPeriod>
A relation of LedgerClosingPeriods that are company in all or.
-
.transaction_type_in ⇒ ActiveRecord::Relation<LedgerClosingPeriod>
A relation of LedgerClosingPeriods that are transaction type in.
-
.transaction_type_in_all_or ⇒ ActiveRecord::Relation<LedgerClosingPeriod>
A relation of LedgerClosingPeriods that are transaction type in all or.
Instance Method Summary collapse
-
#bank_rec_by_itself ⇒ void
Validation:
BANK_RECcannot share a row with other transaction types — bank-rec closing has different semantics from GL closing, so it has to be a row of its own.
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #creator, #should_not_save_version, #stamp_record, #updater
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
Class Method Details
.company_in_all_or ⇒ ActiveRecord::Relation<LedgerClosingPeriod>
A relation of LedgerClosingPeriods that are company in all or. Active Record Scope
25 |
# File 'app/models/ledger_closing_period.rb', line 25 scope :company_in_all_or, ->(company_id) { where("companies && ARRAY[?]::varchar[]", [company_id,"ALL"]) } |
.transaction_type_in ⇒ ActiveRecord::Relation<LedgerClosingPeriod>
A relation of LedgerClosingPeriods that are transaction type in. Active Record Scope
27 |
# File 'app/models/ledger_closing_period.rb', line 27 scope :transaction_type_in, ->(transaction_type) { where.overlap(transaction_types: transaction_type) } |
.transaction_type_in_all_or ⇒ ActiveRecord::Relation<LedgerClosingPeriod>
A relation of LedgerClosingPeriods that are transaction type in all or. Active Record Scope
26 |
# File 'app/models/ledger_closing_period.rb', line 26 scope :transaction_type_in_all_or, ->(transaction_type) { where("transaction_types && ARRAY[?]::varchar[]", [transaction_type,"ALL"]) } |
Instance Method Details
#bank_rec_by_itself ⇒ void
This method returns an undefined value.
Validation: BANK_REC cannot share a row with other
transaction types — bank-rec closing has different semantics
from GL closing, so it has to be a row of its own.
34 35 36 37 38 |
# File 'app/models/ledger_closing_period.rb', line 34 def bank_rec_by_itself if self.transaction_types.present? and self.transaction_types.include?("BANK_REC") and self.transaction_types.length > 1 errors.add(:transaction_types, "must contain only BANK_REC if BANK_REC is present.") end end |