Class: LedgerClosingPeriod

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

Instance Method Summary collapse

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

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.company_in_all_orActiveRecord::Relation<LedgerClosingPeriod>

A relation of LedgerClosingPeriods that are company in all or. Active Record Scope

Returns:

See Also:



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_inActiveRecord::Relation<LedgerClosingPeriod>

A relation of LedgerClosingPeriods that are transaction type in. Active Record Scope

Returns:

See Also:



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_orActiveRecord::Relation<LedgerClosingPeriod>

A relation of LedgerClosingPeriods that are transaction type in all or. Active Record Scope

Returns:

See Also:



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_itselfvoid

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