Ramp.Accounting (ramp v1.0.0)

Copy Markdown View Source

The Accounting resource: ERP connections, general ledger accounts, custom accounting dimensions ("fields") and their selectable options, and reporting sync status back to Ramp.

This is the largest resource in the API, so it's organized into five sections, each its own set of functions on this module:

Summary

Functions

Creates a new custom accounting dimension. input_type is typically "SINGLE_CATEGORY_SELECT" or "MULTI_CATEGORY_SELECT" -- see the Ramp API reference for the full set of supported field input types.

Creates one or more selectable options for field_id in a single batch request.

Creates one or more GL accounts in a single batch request.

Deletes a custom accounting field.

Deletes a field option.

Deletes a GL account.

Removes the currently active accounting connection.

Returns all configured accounting connections.

Returns a specific accounting connection by ID.

Fetches a single GL account by ID.

Returns a lazily auto-paginating Stream of Ramp.Accounting.FieldOptions for field_id.

Fetches a single page of field options. See Ramp.Page.

Fetches a single page of custom fields. See Ramp.Page.

Fetches a single page of GL accounts. See Ramp.Page.

Marks a batch of objects (by ID) as ready for ERP sync.

Reports a batch of ERP sync results back to Ramp.

Updates a custom field's name, active status, and/or required status.

Updates a field option's name, code, active status, and/or visibility.

Updates a GL account's name, code, and/or active status.

Types

create_field_opt()

@type create_field_opt() :: {:remote_id, String.t()} | {:is_required, boolean()}

create_field_option()

@type create_field_option() :: %{
  :name => String.t(),
  optional(:code) => String.t(),
  optional(:remote_id) => String.t()
}

create_gl_account()

@type create_gl_account() :: %{
  :name => String.t(),
  optional(:code) => String.t(),
  optional(:remote_id) => String.t()
}

field_list_opt()

@type field_list_opt() ::
  {:start, String.t()}
  | {:page_size, pos_integer()}
  | {:remote_id, String.t()}
  | {:accounting_connection_id, String.t()}
  | {:is_active, boolean()}

field_option_list_opt()

@type field_option_list_opt() ::
  {:start, String.t()}
  | {:page_size, pos_integer()}
  | {:remote_id, String.t()}
  | {:accounting_connection_id, String.t()}
  | {:is_active, boolean()}
  | {:visibility, String.t()}

gl_list_opt()

@type gl_list_opt() ::
  {:start, String.t()}
  | {:page_size, pos_integer()}
  | {:remote_id, String.t()}
  | {:code, String.t()}
  | {:accounting_connection_id, String.t()}
  | {:is_active, boolean()}

sync_entry()

@type sync_entry() :: %{
  :object_id => String.t(),
  :object_type => String.t(),
  :sync_status => String.t(),
  optional(:error_message) => String.t()
}

update_field_opt()

@type update_field_opt() ::
  {:name, String.t()} | {:is_active, boolean()} | {:is_required, boolean()}

update_field_option_opt()

@type update_field_option_opt() ::
  {:name, String.t()}
  | {:code, String.t()}
  | {:is_active, boolean()}
  | {:visibility, String.t()}

update_gl_account_opt()

@type update_gl_account_opt() ::
  {:name, String.t()} | {:code, String.t()} | {:is_active, boolean()}

Functions

create_field(client, name, input_type, opts \\ [])

@spec create_field(Ramp.Client.t(), String.t(), String.t(), [create_field_opt()]) ::
  {:ok, Ramp.Accounting.CustomField.t()} | {:error, Ramp.Error.t()}

Creates a new custom accounting dimension. input_type is typically "SINGLE_CATEGORY_SELECT" or "MULTI_CATEGORY_SELECT" -- see the Ramp API reference for the full set of supported field input types.

create_field_options(client, field_id, options)

@spec create_field_options(Ramp.Client.t(), String.t(), [create_field_option()]) ::
  {:ok, [Ramp.Accounting.FieldOption.t()]} | {:error, Ramp.Error.t()}

Creates one or more selectable options for field_id in a single batch request.

create_gl_accounts(client, accounts)

@spec create_gl_accounts(Ramp.Client.t(), [create_gl_account()]) ::
  {:ok, [Ramp.Accounting.GLAccount.t()]} | {:error, Ramp.Error.t()}

Creates one or more GL accounts in a single batch request.

delete_field(client, field_id)

@spec delete_field(Ramp.Client.t(), String.t()) :: :ok | {:error, Ramp.Error.t()}

Deletes a custom accounting field.

delete_field_option(client, option_id)

@spec delete_field_option(Ramp.Client.t(), String.t()) ::
  :ok | {:error, Ramp.Error.t()}

Deletes a field option.

delete_gl_account(client, id)

@spec delete_gl_account(Ramp.Client.t(), String.t()) :: :ok | {:error, Ramp.Error.t()}

Deletes a GL account.

disconnect_connection(client)

@spec disconnect_connection(Ramp.Client.t()) :: :ok | {:error, Ramp.Error.t()}

Removes the currently active accounting connection.

get_all_connections(client)

@spec get_all_connections(Ramp.Client.t()) ::
  {:ok, [Ramp.Accounting.Connection.t()]} | {:error, Ramp.Error.t()}

Returns all configured accounting connections.

get_connection(client, connection_id)

@spec get_connection(Ramp.Client.t(), String.t()) ::
  {:ok, Ramp.Accounting.Connection.t()} | {:error, Ramp.Error.t()}

Returns a specific accounting connection by ID.

get_gl_account(client, id)

@spec get_gl_account(Ramp.Client.t(), String.t()) ::
  {:ok, Ramp.Accounting.GLAccount.t()} | {:error, Ramp.Error.t()}

Fetches a single GL account by ID.

list_field_options(client, field_id, opts \\ [])

Returns a lazily auto-paginating Stream of Ramp.Accounting.FieldOptions for field_id.

list_field_options_page(client, field_id, opts \\ [])

@spec list_field_options_page(Ramp.Client.t(), String.t(), [field_option_list_opt()]) ::
  {:ok, Ramp.Page.t(Ramp.Accounting.FieldOption.t())} | {:error, Ramp.Error.t()}

Fetches a single page of field options. See Ramp.Page.

list_fields(client, opts \\ [])

Returns a lazily auto-paginating Stream of Ramp.Accounting.CustomFields.

list_fields_page(client, opts \\ [])

@spec list_fields_page(Ramp.Client.t(), [field_list_opt()]) ::
  {:ok, Ramp.Page.t(Ramp.Accounting.CustomField.t())} | {:error, Ramp.Error.t()}

Fetches a single page of custom fields. See Ramp.Page.

list_gl_accounts(client, opts \\ [])

@spec list_gl_accounts(Ramp.Client.t(), [gl_list_opt()]) ::
  Enumerable.t(Ramp.Accounting.GLAccount.t())

Returns a lazily auto-paginating Stream of Ramp.Accounting.GLAccounts.

list_gl_accounts_page(client, opts \\ [])

@spec list_gl_accounts_page(Ramp.Client.t(), [gl_list_opt()]) ::
  {:ok, Ramp.Page.t(Ramp.Accounting.GLAccount.t())} | {:error, Ramp.Error.t()}

Fetches a single page of GL accounts. See Ramp.Page.

mark_ready_to_sync(client, object_ids)

@spec mark_ready_to_sync(Ramp.Client.t(), [String.t()]) ::
  :ok | {:error, Ramp.Error.t()}

Marks a batch of objects (by ID) as ready for ERP sync.

post_sync_status(client, syncs, idempotency_key \\ nil)

@spec post_sync_status(Ramp.Client.t(), [sync_entry()], String.t() | nil) ::
  :ok | {:error, Ramp.Error.t()}

Reports a batch of ERP sync results back to Ramp.

object_type is one of "TRANSACTION", "REIMBURSEMENT", "BILL", "STATEMENT", "CASHBACK"; sync_status is "SUCCESS" or "FAILED" (include :error_message when reporting a failure).

idempotency_key prevents duplicate sync reports on network retries; one is generated for you if omitted.

update_field(client, field_id, opts)

@spec update_field(Ramp.Client.t(), String.t(), [update_field_opt()]) ::
  {:ok, Ramp.Accounting.CustomField.t()} | {:error, Ramp.Error.t()}

Updates a custom field's name, active status, and/or required status.

update_field_option(client, option_id, opts)

@spec update_field_option(Ramp.Client.t(), String.t(), [update_field_option_opt()]) ::
  {:ok, Ramp.Accounting.FieldOption.t()} | {:error, Ramp.Error.t()}

Updates a field option's name, code, active status, and/or visibility.

update_gl_account(client, id, opts)

@spec update_gl_account(Ramp.Client.t(), String.t(), [update_gl_account_opt()]) ::
  {:ok, Ramp.Accounting.GLAccount.t()} | {:error, Ramp.Error.t()}

Updates a GL account's name, code, and/or active status.