Class: MOCO::Expense
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- MOCO::Expense
- Defined in:
- lib/moco/entities/expense.rb
Overview
Represents a MOCO expense Provides methods for expense-specific operations and associations
Instance Attribute Summary
Attributes inherited from BaseEntity
Class Method Summary collapse
- .bulk_create(client, project_id, expenses) ⇒ Object
-
.disregard(client, expense_ids:) ⇒ Object
Class methods for bulk operations.
-
.entity_path ⇒ Object
Override entity_path to use the global expenses endpoint Note: Expenses can also be accessed via projects/BaseEntity#id/expenses.
Instance Method Summary collapse
-
#project ⇒ 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
Class Method Details
.bulk_create(client, project_id, expenses) ⇒ Object
18 19 20 |
# File 'lib/moco/entities/expense.rb', line 18 def self.bulk_create(client, project_id, expenses) client.post("projects/#{project_id}/expenses/bulk", { expenses: }) end |
.disregard(client, expense_ids:) ⇒ Object
Class methods for bulk operations
14 15 16 |
# File 'lib/moco/entities/expense.rb', line 14 def self.disregard(client, expense_ids:) client.post("projects/expenses/disregard", { expense_ids: }) end |
.entity_path ⇒ Object
Override entity_path to use the global expenses endpoint Note: Expenses can also be accessed via projects/BaseEntity#id/expenses
9 10 11 |
# File 'lib/moco/entities/expense.rb', line 9 def self.entity_path "projects/expenses" end |
Instance Method Details
#project ⇒ Object
Associations
23 24 25 26 |
# File 'lib/moco/entities/expense.rb', line 23 def project # Use the association method which handles embedded objects association(:project, "Project") end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/moco/entities/expense.rb', line 33 def to_s "#{date} - #{title} (#{amount})" end |
#user ⇒ Object
28 29 30 31 |
# File 'lib/moco/entities/expense.rb', line 28 def user # Use the association method which handles embedded objects association(:user, "User") end |