Class: Cashboard::Invoice
- Inherits:
-
Base
- Object
- OpenStruct
- TypecastedOpenStruct
- Struct
- Base
- Cashboard::Invoice
- Defined in:
- lib/cashboard/invoice.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #get_import_xml_options(project_ids, start_date, end_date) ⇒ Object
-
#import_uninvoiced_items(project_ids = {}, start_date = nil, end_date = nil) ⇒ Object
Imports uninvoiced items (time entries, expenses, flat fee tasks) that belong to the same client that this invoice was created for.
-
#line_items(options = {}) ⇒ Object
Returns all associated LineItems.
Methods inherited from Base
authenticate, clear_authentication, create, #delete, #links, list, new_from_url, #to_xml, #update
Methods inherited from Struct
Methods inherited from TypecastedOpenStruct
Constructor Details
This class inherits a constructor from Cashboard::Struct
Instance Method Details
#get_import_xml_options(project_ids, start_date, end_date) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cashboard/invoice.rb', line 62 def (project_ids, start_date, end_date) = '' xml = Builder::XmlMarkup.new(:target => , :indent => 2) xml.instruct! xml.projects do project_ids.each {|pid| xml.id pid} if project_ids end xml.start_date start_date xml.end_date end_date return end |
#import_uninvoiced_items(project_ids = {}, start_date = nil, end_date = nil) ⇒ Object
Imports uninvoiced items (time entries, expenses, flat fee tasks) that belong to the same client that this invoice was created for.
Either raises a Cashboard error (errors.rb) or returns a collection of Cashboard::InvoiceLineItem objects.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cashboard/invoice.rb', line 47 def import_uninvoiced_items(project_ids={}, start_date=nil, end_date=nil) = (project_ids, start_date, end_date) = self.class.() .merge!({:body => }) response = self.class.put(self.links[:import_uninvoiced_items], ) self.class.check_status_code(response) collection = response.parsed_response[Cashboard::InvoiceLineItem.resource_name.singularize] collection.map do |h| Cashboard::InvoiceLineItem.new(h) end end |
#line_items(options = {}) ⇒ Object
Returns all associated LineItems
36 37 38 39 40 |
# File 'lib/cashboard/invoice.rb', line 36 def line_items(={}) self.class.get_collection( self.links[:line_items], Cashboard::InvoiceLineItem, ) end |