Invoice create

Method invoice_create is used for sending invoices through SOAP API.

Return value(s)

This method returns an array that contains return code string and id of successfully created invoice or nil in error situations.

Authentication

This method requires that you have registered to Maventa and received the API key.

Arguments

  1. api_keys (required)
  2. InvoiceParamsIn (required)
  3. CustomerParamsIn (required)
  4. Array of ItemsIn (required)

Example code

 1 require 'soap/wsdlDriver'
 2 
 3 serv = SOAP::WSDLDriverFactory.new("https://secure.maventa.com/api/wsdl").create_rpc_driver
 4 
 5 begin 
 6   api_keys = Hash.new
 7   api_keys[:vendor_api_key] = "" # If you are software vendor, you shall put here API-key for this application
 8   api_keys[:user_api_key] = "" # Put here your API key
 9   api_keys[:company_uuid] = "" # Put here UUID of the Company you are acting for
10 
11   # Gather needed data for invoice customer
12   customer = Hash.new
13   customer[:customer_nr] = "2002" 
14   customer[:name] = "Test Customer" 
15   customer[:email] = "invoices@customer.com" 
16   customer[:bid] = "FI1234567" 
17   customer[:address1] = "Customer address" 
18   customer[:address2] = "" 
19   customer[:post_code] = "00100" 
20   customer[:post_office] = "Helsinki" 
21   customer[:state] = "" 
22   customer[:country] = "FI" 
23   customer[:contact_p] = "John Doe" 
24   customer[:lang] = "FI" 
25   customer[:ovt] = "123123123123" 
26 
27   # Gather invoice items into array
28   items_out = Array.new
29 
30   inv_items = Hash.new
31   inv_items[:subject]    = "Test item" 
32   inv_items[:unit_type]  = "pcs" 
33   inv_items[:amount]     = "10" 
34   inv_items[:price]      = "10" 
35   inv_items[:discount]   = "0" 
36   inv_items[:definition] = "" 
37   inv_items[:tax]        = "22" 
38 
39   items_out.push(inv_items)
40 
41   # Gather invoice data
42   invoice = Hash.new
43   invoice[:invoice_nr] = 1001
44   invoice[:reference_nr] = 10014
45   invoice[:date] = "20080405" 
46   invoice[:date_due] = "20080415" 
47   invoice[:currency] = "EUR" 
48   invoice[:sum] = "100.00" 
49   invoice[:sum_tax] = "122.00" 
50 
51   # Create the invoice
52   result = serv.invoice_create(api_keys, invoice, customer, items_out)
53 
54   puts result
55 rescue Exception => ex 
56   puts ex
57 end

Also available in: HTML TXT