Sha256: 95ebef03cc354e230e10424769c490acc2fb26e5bb9542932d0b9c9fc9523857
Contents?: true
Size: 906 Bytes
Versions: 4
Compression:
Stored size: 906 Bytes
Contents
# # Encapulates a Cost and a Date, used to track costs by # date so sums for date ranges can be generated. # class DatedCost < ActiveRecord::Base include E9Rails::ActiveRecord::Initialization money_columns :cost belongs_to :costable, :polymorphic => true validates :date, :date => true validates :cost, :numericality => { :greater_than => 0 } attr_accessor :temp_id def self.default_scope order('dated_costs.created_at ASC') end def as_json(options={}) {}.tap do |hash| hash[:id] = self.id hash[:cost] = self.cost hash[:date] = self.date hash[:costable_type] = self.costable_type.try(:underscore) hash[:costable_id] = self.costable_id hash[:errors] = self.errors hash.merge!(options) end end protected def _assign_initialization_defaults self.date ||= Date.today end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
e9_crm-0.1.18 | app/models/dated_cost.rb |
e9_crm-0.1.17 | app/models/dated_cost.rb |
e9_crm-0.1.16 | app/models/dated_cost.rb |
e9_crm-0.1.14 | app/models/dated_cost.rb |