Class: Magento::Invoice

Inherits:
Base
  • Object
show all
Defined in:
lib/magento/invoice.rb

Overview

www.magentocommerce.com/wiki/doc/webservices-api/api/sales_order_invoice 100 Requested shipment does not exists. 101 Invalid filters given. Details in error message. 102 Invalid data given. Details in error message. 103 Requested order does not exists 104 Invoice status not changed.

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Methods included from Base::ClassMethods

#api_path, #commit

Methods included from Base::InstanceMethods

#id, #id=, #initialize, #method_missing, #object_attributes=

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Magento::Base::InstanceMethods

Class Method Details

.add_comment(*args) ⇒ Object

sales_order_invoice.addComment Add new comment to shipment

Arguments:

string invoiceIncrementId - invoice increment id string comment - invoice comment boolean email - send invoice on e-mail (optional) boolean includeComment - include comments in e-mail (optional)



62
63
64
# File 'lib/magento/invoice.rb', line 62

def add_comment(*args)
  commit('addComment', *args)
end

.cancel(*args) ⇒ Object

sales_order_invoice.cancel Cancel invoice

Return: boolean

Arguments:

string invoiceIncrementId - invoice increment id



112
113
114
# File 'lib/magento/invoice.rb', line 112

def cancel(*args)
  commit('cancel', *args)
end

.capture(*args) ⇒ Object

sales_order_invoice.capture Capture invoice

Return: boolean

Arguments:

string invoiceIncrementId - invoice increment id

Notes:

You should check the invoice to see if can be captured before attempting to capture an invoice, otherwise the API call with generate an error.

Invoices have states as defined in the model Mage_Sales_Model_Order_Invoice:

STATE_OPEN = 1 STATE_PAID = 2 STATE_CANCELED = 3 Also note there is a method call in the model that checks this for you canCapture(), and it also verifies that the payment is able to be captured, so the invoice state might not be the only condition that’s required to allow it to be captured.



88
89
90
# File 'lib/magento/invoice.rb', line 88

def capture(*args)
  commit('capture', *args)
end

.create(*args) ⇒ Object

sales_order_invoice.create Create new invoice for order

Return: string

Arguments:

string orderIncrementId - order increment id array itemsQty - items qty to invoice string comment - invoice comment (optional) boolean email - send invoice on e-mail (optional) boolean includeComment - include comments in e-mail (optional)



47
48
49
50
51
# File 'lib/magento/invoice.rb', line 47

def create(*args)
  id = commit("create", *args)
  record = info(id)
  record
end

.find(find_type, options = {}) ⇒ Object



120
121
122
123
124
125
126
127
128
129
# File 'lib/magento/invoice.rb', line 120

def find(find_type, options = {})
  filters = {}
  options.each_pair { |k, v| filters[k] = {:eq => v} }
  results = list(filters)
  if find_type == :first
    results.first
  else
    results
  end
end

.find_by_id(id) ⇒ Object



116
117
118
# File 'lib/magento/invoice.rb', line 116

def find_by_id(id)
  info(id)
end

.info(*args) ⇒ Object

sales_order_invoice.info Retrieve invoice information

Return: array

Arguments:

string invoiceIncrementId - invoice increment id



31
32
33
# File 'lib/magento/invoice.rb', line 31

def info(*args)
  new(commit("info", *args))
end

.list(*args) ⇒ Object

sales_order_invoice.list Retrieve list of invoices by filters

Return: array Arguments:

array filters - filters for invoices list (optional)



16
17
18
19
20
21
# File 'lib/magento/invoice.rb', line 16

def list(*args)
  results = commit("list", *args)
  results.collect do |result|
    new(result)
  end
end

.void(*args) ⇒ Object

sales_order_invoice.void Void invoice

Return: boolean

Arguments:

string invoiceIncrementId - invoice increment id



100
101
102
# File 'lib/magento/invoice.rb', line 100

def void(*args)
  commit('void', *args)
end