Sha256: 55e063fc507cab98abde3e381cca8af90dfdbe7abb8d6fe3d2e274993088cd16

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Seedy
  class Opportunities < Record
    self.columns = {
      :id => :guid,
      :name => :company,
      :date_entered => :date_time,
      :date_modified => :date_time,
      :modified_user_id => :association,
      :created_by => :association,
      :description => :description,
      :deleted => 0,
      :assigned_user_id => :association,
      :team_id => :association,
      :opportunity_type => :customer_type,
      :amount => :monetary_sum,
      :date_closed => :date_time,
      :next_step => :subject,
      :sales_stage => :subject
    }

    class << self
      def build(user, team, account)
        opportunity = Opportunities.new
        opportunity.associate(user,team,account)
        opportunity
      end
    end
    
    def associate(user, team, account)
      write_attribute(:modified_user_id, user.id)
      write_attribute(:assigned_user_id, user.id)
      write_attribute(:team_id, team)
      write_attribute(:created_by, user.id)
      join("accounts_opportunities", {
        :id => Random.guid, 
        :account_id => account, 
        :opportunity_id => read_attribute(:id), 
        :date_modified => read_attribute(:date_modified)})
    end
  end 
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
seedy-0.6.6 lib/seedy/records/opportunities.rb
seedy-0.6.5 lib/seedy/records/opportunities.rb