Tipalti.API.Payer.create_or_update_invoices

You're seeing just the function create_or_update_invoices, go back to Tipalti.API.Payer module for more information.
Link to this function

create_or_update_invoices(invoices_params)

View Source

Specs

create_or_update_invoices([invoice()]) ::
  {:ok,
   [
     %{
       error_message: String.t() | nil,
       ref_code: String.t(),
       succeeded: boolean()
     }
   ]}
  | {:error, Tipalti.RequestError.t()}

Create new invoices or update existing ones.

Returns a list of invoice responses for each invoice, indicating if it succeeded and what the errors were if it didn't.

See https://support.tipalti.com/Content/Topics/Development/APIs/PayeeAPI/Intro.htm for details.

Parameters

  • invoices[]: List of maps of invoice params.
    • idap: Payee id.
    • ref_code: Uniq id for this invoice (leave null for auto-generated id).
    • date: Invoice value date (estimated date and time the payee receives the funds).
    • due_date: The date and time the invoice is due to be paid.
    • line_items[]: List of invoice lines.
      • currency: Invoice currency.
      • amount: Invoice line amount.
      • description: Description of the invoice line.
      • internal_notes: Notes which are not displayed to the payee.
      • e_wallet_message: A message to attach to the payment. This message is sent to providers and appears on payee bank statements. If no value is provided, the InvoiceRefCode is used..
      • banking_message: A message to attach to the payment. This message is sent to providers and appears on payee bank statements. If a value is not provided, the EWalletMessage is used.
      • custom_fields[]: If custom fields have been defined for the invoice entity, the values of these fields can be set here. The field name must match the defined custom field name.
        • key: The custom field key.
        • value: The custom field value.
      • line_type: ?
      • external_metadata: ?
      • quantity: ?
    • description: Description of the invoice.
    • can_approve: Indicates whether or not the payee is able to approve the invoice.
    • internal_notes: Notes, which are not displayed to the payee.
    • custom_fields[]: If custom fields have been defined for the invoice entity, the values of these fields can be set here. The field name must match the defined custom field name.
      • key: The custom field key.
      • value: The custom field value.
    • is_paid_manually: If true, the invoice is marked as paid manually.
    • income_type: If the Tax Withholding module is enabled and there are multiple income types that can be associated with the payment, then you must enter the IncomeType per payment.
    • status: ?
    • currency: Invoice currency.
    • approvers: ?
    • number: ?
    • payer_entity_name: The name of the payer entity linked to the invoice.
    • subject: The text for the title of the invoice, displays for the payee in the Payee Dashboard or Suppliers Portal.
    • ap_account_number: ?

Returns

{:ok, list} where list is a list of maps contains the following fields:

  • error_message: String; if there was an error creating the invoice.
  • ref_code: String; corresponds to the input invoices.
  • succeeded: Boolean; Indicates if creating the invoice succeeded.

Examples

iex> create_or_update_invoices([%{idap: "somepayee", can_approve: false, is_paid_manually: false, ref_code: "testinvoice1", due_date: "2018-05-01", date: "2018-06-01", subject: "test invoice 1", currency: "USD", line_items: [%{amount: "100.00", description: "test line item"}]}, %{idap: "somepayee", ref_code: "testinvoice2", due_date: "2018-06-01", date: "2018-05-01", subject: "test invoice 2", currency: "USD", line_items: [%{amount: "100.00", description: "test line item"}]}])
{:ok,
[
  %{
    error_message: "Due date cannot be earlier then invoice date",
    ref_code: "testinvoice1",
    succeeded: false
  },
  %{error_message: nil, ref_code: "testinvoice2", succeeded: true}
]}

iex> too_long_description = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
iex> create_or_update_invoices([%{idap: "somepayee", ref_code: "testinvoice3", due_date: "2018-05-01", date: "2018-06-01", description: too_long_description, currency: "USD", line_items: [%{amount: "100.00", description: "test line item"}]}])
{:error, %Tipalti.ClientError{error_code: "UnknownError", error_message: "Internal server errror"}}

iex> custom_fields = [%{key: "foo", value: "bar"}]
...> line_items = [%{amount: "100.00", description: "test line item", custom_fields: custom_fields}]
...> approvers = [%{name: "Mr. Approver", email: "approver@example.com", order: 1}]
...> invoice = %{idap: "somepayee", can_approve: false, is_paid_manually: false, ref_code: "testinvoice", due_date: "2018-06-01", date: "2018-05-01", subject: "test invoice", currency: "USD", line_items: line_items, custom_fields: custom_fields, approvers: approvers}
...> create_or_update_invoices([invoice])
{:ok, [%{error_message: nil, ref_code: "testinvoice", succeeded: true}]}