lib/harvesting/models/invoice.rb in harvesting-0.3.0 vs lib/harvesting/models/invoice.rb in harvesting-0.4.0
- old
+ new
@@ -1,11 +1,13 @@
module Harvesting
module Models
+ # An invoice record from your Harvest account.
+ #
+ # For more information: https://help.getharvest.com/api-v2/invoices-api/invoices/invoices/
class Invoice < HarvestRecord
attributed :id,
:client_key,
- :line_items,
:number,
:purchase_order,
:amount,
:due_amount,
:tax,
@@ -27,9 +29,14 @@
:paid_at,
:paid_date,
:closed_at,
:created_at,
:updated_at
+
+ def line_items
+ @line_items ||= @attributes['line_items'].map { |line_item_attributes| LineItem.new line_item_attributes, { harvest_client: harvest_client } }
+ end
+
def path
@attributes['id'].nil? ? "invoices" : "invoices/#{@attributes['id']}"
end
end
end