Module: Invoicexpress::Client::SimplifiedInvoices
- Included in:
- Invoicexpress::Client
- Defined in:
- lib/invoicexpress/client/simplified_invoices.rb
Instance Method Summary collapse
-
#create_simplified_invoice(simplified_invoice, options = {}) ⇒ Invoicexpress::Models::SimplifiedInvoice
Creates a new simplified invoice.
-
#simplified_invoice(simplified_invoice_id, options = {}) ⇒ Invoicexpress::Models::SimplifiedInvoice
Returns all the information about a simplified invoice: - Basic information (date, status, sequence number) - Client - Document items - Document timeline Document timeline is composed by: - Date, time and the user who created it - Type of the event The complete list of timeline events is: - create - edited - send_email - canceled - deleted - settled - second_copy - archived - unarchived - comment.
-
#simplified_invoice_mail(simplified_invoice_id, message, options = {}) ⇒ Object
Sends the simplified invoice through email.
-
#simplified_invoices(options = {}) ⇒ Invoicexpress::Models::SimplifiedInvoices
Returns all your simplified invoices.
-
#update_simplified_invoice(simplified_invoice, options = {}) ⇒ Object
Updates a simplified invoice It also allows you to create a new client and/or items in the same request.
-
#update_simplified_invoice_state(simplified_invoice_id, simplified_invoice_state, options = {}) ⇒ Invoicexpress::Models::SimplifiedInvoice
Changes the state of a simplified invoice.
Instance Method Details
#create_simplified_invoice(simplified_invoice, options = {}) ⇒ Invoicexpress::Models::SimplifiedInvoice
Creates a new simplified invoice. Also allows to create a new client and/or new items in the same request. If the client name does not exist a new one is created. If items do not exist with the given names, new ones will be created. If item name already exists, the item is updated with the new values. Regarding item taxes, if the tax name is not found, no tax is applyed to that item. Portuguese accounts should also send the IVA exemption reason if the invoice contains exempt items(IVA 0%)
62 63 64 65 66 67 |
# File 'lib/invoicexpress/client/simplified_invoices.rb', line 62 def create_simplified_invoice(simplified_invoice, ={}) raise(ArgumentError, "simplified invoice has the wrong type") unless simplified_invoice.is_a?(Invoicexpress::Models::SimplifiedInvoice) params = { :klass => Invoicexpress::Models::SimplifiedInvoice, :body => simplified_invoice } post("simplified_invoices.xml", params.merge()) end |
#simplified_invoice(simplified_invoice_id, options = {}) ⇒ Invoicexpress::Models::SimplifiedInvoice
Returns all the information about a simplified invoice:
-
Basic information (date, status, sequence number)
-
Client
-
Document items
-
Document timeline
Document timeline is composed by:
-
Date, time and the user who created it
-
Type of the event
The complete list of timeline events is:
-
create
-
edited
-
send_email
-
canceled
-
deleted
-
settled
-
second_copy
-
archived
-
unarchived
-
comment
45 46 47 48 49 |
# File 'lib/invoicexpress/client/simplified_invoices.rb', line 45 def simplified_invoice(simplified_invoice_id, ={}) params = { :klass => Invoicexpress::Models::SimplifiedInvoice } get("simplified_invoices/#{simplified_invoice_id}.xml", params.merge()) end |
#simplified_invoice_mail(simplified_invoice_id, message, options = {}) ⇒ Object
Sends the simplified invoice through email
121 122 123 124 125 126 |
# File 'lib/invoicexpress/client/simplified_invoices.rb', line 121 def simplified_invoice_mail(simplified_invoice_id, , ={}) raise(ArgumentError, "message has the wrong type") unless .is_a?(Invoicexpress::Models::Message) params = { :body => , :klass => Invoicexpress::Models::SimplifiedInvoice } put("simplified_invoices/#{simplified_invoice_id}/email-document.xml", params.merge()) end |
#simplified_invoices(options = {}) ⇒ Invoicexpress::Models::SimplifiedInvoices
Returns all your simplified invoices
13 14 15 16 17 |
# File 'lib/invoicexpress/client/simplified_invoices.rb', line 13 def simplified_invoices(={}) params = { :page => 1, :klass => Invoicexpress::Models::SimplifiedInvoice } get("simplified_invoices.xml", params.merge()) end |
#update_simplified_invoice(simplified_invoice, options = {}) ⇒ Object
Updates a simplified invoice It also allows you to create a new client and/or items in the same request. If the client name does not exist a new client is created. Regarding item taxes, if the tax name is not found, no tax will be applied to that item. If item does not exist with the given name, a new one will be created. If item exists it will be updated with the new values Be careful when updating the document items, any missing items from the original document will be deleted.
81 82 83 84 85 86 87 88 |
# File 'lib/invoicexpress/client/simplified_invoices.rb', line 81 def update_simplified_invoice(simplified_invoice, ={}) raise(ArgumentError, "simplified invoice has the wrong type") unless simplified_invoice.is_a?(Invoicexpress::Models::SimplifiedInvoice) if !simplified_invoice.id raise ArgumentError, "Invoice ID is required" end params = { :klass => Invoicexpress::Models::SimplifiedInvoice, :body => simplified_invoice.to_core } put("simplified_invoices/#{simplified_invoice.id}.xml", params.merge()) end |
#update_simplified_invoice_state(simplified_invoice_id, simplified_invoice_state, options = {}) ⇒ Invoicexpress::Models::SimplifiedInvoice
Changes the state of a simplified invoice. Possible state transitions:
-
draft to final – finalized
-
draft to deleted – deleted
-
settled to final – unsettled
-
final to second copy – second_copy
-
final or second copy to canceled – canceled
-
final or second copy to settled – settled
Any other transitions will fail. When canceling a simplified invoice you must specify a reason.
107 108 109 110 111 112 |
# File 'lib/invoicexpress/client/simplified_invoices.rb', line 107 def update_simplified_invoice_state(simplified_invoice_id, simplified_invoice_state, ={}) raise(ArgumentError, "simplified invoice state has the wrong type") unless simplified_invoice_state.is_a?(Invoicexpress::Models::InvoiceState) params = { :klass => Invoicexpress::Models::SimplifiedInvoice, :body => simplified_invoice_state } put("simplified_invoices/#{simplified_invoice_id}/change-state.xml", params.merge()) end |