Sha256: 9c32b988b3fc0f232180b641f83dca2069c47e21f4f113c5e1f8b715a849ece6
Contents?: true
Size: 888 Bytes
Versions: 3
Compression:
Stored size: 888 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 => true 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
e9_crm-0.1.21 | app/models/dated_cost.rb |
e9_crm-0.1.20 | app/models/dated_cost.rb |
e9_crm-0.1.19 | app/models/dated_cost.rb |