Class: MOCO::PurchasePayment
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- MOCO::PurchasePayment
- Defined in:
- lib/moco/entities/purchase_payment.rb
Overview
Represents a MOCO purchase payment record (Ausgaben / Zahlungen) For tracking payments made for purchases
Required attributes for create:
date - String, "YYYY-MM-DD" payment date
total - Float, payment amount
Optional attributes:
purchase_id - Integer, purchase being paid (required unless description set)
description - String, payment description (required if no purchase_id)
Read-only attributes:
id, purchase (Hash), created_at, updated_at
Example:
moco.purchase_payments.create(
date: "2024-01-20",
purchase_id: 456,
total: 1500.0
)
Bulk create:
moco.post("purchases/payments/bulk", {
bulk_data: [
{ date: "2024-01-20", purchase_id: 123, total: 500 },
{ date: "2024-01-21", description: "Salaries", total: 10000 }
]
})
Filtering:
moco.purchase_payments.where(purchase_id: 456)
moco.purchase_payments.where(date_from: "2024-01-01", date_to: "2024-01-31")
Instance Attribute Summary
Attributes inherited from BaseEntity
Class Method Summary collapse
-
.entity_path ⇒ Object
Custom path since it’s nested under purchases.
Instance Method Summary collapse
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
.entity_path ⇒ Object
Custom path since it’s nested under purchases
39 40 41 |
# File 'lib/moco/entities/purchase_payment.rb', line 39 def self.entity_path "purchases/payments" end |
Instance Method Details
#purchase ⇒ Object
43 44 45 |
# File 'lib/moco/entities/purchase_payment.rb', line 43 def purchase association(:purchase, "Purchase") end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/moco/entities/purchase_payment.rb', line 47 def to_s "PurchasePayment #{id}: #{total} on #{date}" end |