Class: MOCO::Deal
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- MOCO::Deal
- Defined in:
- lib/moco/entities/deal.rb
Overview
Represents a MOCO deal/lead
Required attributes for create:
name - String, deal name (e.g., "Website Relaunch")
currency - String, 3-letter code (e.g., "EUR", "USD")
money - Float/Integer, deal value (e.g., 25000)
reminder_date - String, "YYYY-MM-DD" format for follow-up
user_id - Integer, responsible user ID
deal_category_id - Integer, deal category/stage ID
Optional attributes:
company_id - Integer, associated company ID
person_id - Integer, associated contact ID
info - String, additional information
status - String, one of: "potential", "pending", "won", "lost", "dropped"
(default: "pending")
closed_on - String, "YYYY-MM-DD" when deal was closed
service_period_from - String, "YYYY-MM-DD" (must be 1st of month)
service_period_to - String, "YYYY-MM-DD" (must be last of month)
tags - Array of Strings, e.g., ["Important", "Q1"]
custom_properties - Hash, e.g., {"Source": "Website"}
Read-only attributes (returned by API):
id, user (Hash), company (Hash), person (Hash), category (Hash),
created_at, updated_at
Example:
moco.deals.create(
name: "New Website Project",
currency: "EUR",
money: 50000,
reminder_date: "2024-02-01",
user_id: 123,
deal_category_id: 456,
company_id: 789,
status: "pending"
)
Instance Attribute Summary
Attributes inherited from BaseEntity
Instance Method Summary collapse
- #category ⇒ Object
-
#company ⇒ Object
Associations.
- #to_s ⇒ Object
- #user ⇒ Object
Methods inherited from BaseEntity
#==, #association, #destroy, #eql?, #has_many, #hash, #id, #initialize, #inspect, #reload, #save, #to_h, #to_json, #update
Constructor Details
This class inherits a constructor from MOCO::BaseEntity
Instance Method Details
#category ⇒ Object
52 53 54 |
# File 'lib/moco/entities/deal.rb', line 52 def category association(:category, "DealCategory") end |
#company ⇒ Object
Associations
44 45 46 |
# File 'lib/moco/entities/deal.rb', line 44 def company association(:company) || association(:customer, "Company") end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/moco/entities/deal.rb', line 56 def to_s "#{name} (#{company&.name})" end |
#user ⇒ Object
48 49 50 |
# File 'lib/moco/entities/deal.rb', line 48 def user association(:user) end |