Sha256: e3070023d01eedd00e424e74506379b2e32ec0869c5ab9731ff65f4258c07384

Contents?: true

Size: 790 Bytes

Versions: 4

Compression:

Stored size: 790 Bytes

Contents

class Activity::Adjustment < ActiveRecord::Base
  include ExtensibleObjectHelper
  include ActivityTypeModelHelper
  
  validates_presence_of :label
  
  def name
    type_quick_namer '%s for %s on %s', label, client
  end

  def as_legacy_ledger_row
    
    if label and comments and label.length > 0 and comments.length > 0
      description = '%s - %s' % [label, comments]
    else
      description = (comments and comments.length > 0) ? comments : label
    end
    
    [
    1,
    activity.cost,
    activity.cost,
    'Adjustment',
    occurred_on.strftime('%m/%d/%y'),
    description.tr("\r\n", '')
    ]
  end

  handle_extensions
end

Activity.class_eval do
  has_one :adjustment, :class_name => 'Activity::Adjustment', :dependent => :destroy, :foreign_key => :activity_id
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brisk-bills-0.8.2 app/models/activity/adjustment.rb
brisk-bills-0.8.1 app/models/activity/adjustment.rb
brisk-bills-0.7.0 app/models/activity/adjustment.rb
brisk-bills-0.6.0 app/models/activity/adjustment.rb