Class: ActsAsCalculator::FormulaVersion

Inherits:
Record
  • Object
show all
Defined in:
app/models/acts_as_calculator/formula_version.rb

Constant Summary collapse

DRAFT =
"draft"
ACTIVE =
"active"
RETIRED =
"retired"
STATUSES =
[DRAFT, ACTIVE, RETIRED].freeze
IMMUTABLE_ONCE_ACTIVE =

effective_to and status stay writable so an active version can be closed out or retired; rewriting what was in force on a date already calculated is what's banned.

%w[formula_id version_number expression effective_from].freeze

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/models/acts_as_calculator/formula_version.rb', line 48

def active?
  status == ACTIVE
end

#covers?(date) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
55
56
# File 'app/models/acts_as_calculator/formula_version.rb', line 52

def covers?(date)
  return false if effective_from.nil? || effective_from > date

  effective_to.nil? || effective_to >= date
end