Method: Invoicexpress::Client::Invoices#update_invoice_state

Defined in:
lib/invoicexpress/client/invoices.rb

#update_invoice_state(invoice_id, invoice_state, options = {}) ⇒ Invoicexpress::Models::Invoice

Changes the state of an invoice. Possible state transitions:

  • draft to final – finalized

  • final to second copy – second_copy

  • final or second copy to canceled – canceled

  • final or second copy to settled – settled

  • settled to final – unsettled

Any other transitions will fail. When canceling an invoice you must specify a reason.

Parameters:

Returns:

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::UnprocessableEntity When there are errors on the submission

  • Invoicexpress::NotFound When the invoice doesn’t exist



84
85
86
87
88
89
# File 'lib/invoicexpress/client/invoices.rb', line 84

def update_invoice_state(invoice_id, invoice_state, options={})
  raise(ArgumentError, "invoice_state has the wrong type") unless invoice_state.is_a?(Invoicexpress::Models::InvoiceState)

  params = { :klass => Invoicexpress::Models::Invoice, :body => invoice_state }
  put("invoices/#{invoice_id}/change-state.xml", params.merge(options))
end