Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/quickbooks/model/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Invoice < BaseModel

#== Constants
REST_RESOURCE = 'invoice'
MINORVERSION = 1
XML_COLLECTION_NODE = "Invoice"
XML_NODE = "Invoice"
EMAIL_STATUS_NEED_TO_SEND = 'NeedToSend'
Expand Down
1 change: 1 addition & 0 deletions lib/quickbooks/model/sales_item_line_detail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class SalesItemLineDetail < BaseModel
xml_accessor :quantity, :from => 'Qty', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }
xml_accessor :tax_code_ref, :from => 'TaxCodeRef', :as => BaseReference
xml_accessor :service_date, :from => 'ServiceDate', :as => Date
xml_accessor :tax_inclusive_amount, :from => 'TaxInclusiveAmt', :as => BigDecimal, :to_xml => Proc.new { |val| val.to_f }

reference_setters :item_ref, :class_ref, :price_level_ref, :tax_code_ref
end
Expand Down
15 changes: 15 additions & 0 deletions lib/quickbooks/service/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ def delete(invoice)
delete_by_query_string(invoice)
end

def url_for_resource(resource)
url = super(resource)
"#{url}?minorversion=#{Quickbooks::Model::Invoice::MINORVERSION}"
end

def fetch_by_id(id, params = {})
url = "#{url_for_base}/invoice/#{id}?minorversion=#{Quickbooks::Model::Invoice::MINORVERSION}"
fetch_object(model, url, params)
end

def url_for_query(query = nil, start_position = 1, max_results = 20, options = {})
url = super(query, start_position, max_results, options)
"#{url}&minorversion=#{Quickbooks::Model::Invoice::MINORVERSION}"
end

def send(invoice, email_address=nil)
query = email_address.present? ? "?sendTo=#{email_address}" : ""
url = "#{url_for_resource(model::REST_RESOURCE)}/#{invoice.id}/send#{query}"
Expand Down