Codat.BillPay.Payments (codat v1.0.0)

Copy Markdown View Source

Create and track bill payments through the Bill Pay API.

Payments are written to the customer's accounting platform, marking bills as (partially) paid and creating the corresponding payment record.

Example

# Create a bill payment
{:ok, push_op} = Codat.BillPay.Payments.create(
  client, company_id, connection_id,
  %{
    date: "2024-01-20",
    supplierRef: %{id: "supplier-id"},
    lines: [
      %{
        amount: 5000.00,
        links: [
          %{type: "Bill", id: "bill-id", amount: -5000.00}
        ]
      }
    ],
    accountRef: %{id: "bank-account-id"}
  }
)

# Wait for confirmation
{:ok, done} = Codat.Platform.PushOperations.poll_until_done(
  client, company_id, push_op["pushOperationKey"]
)

Summary

Functions

create(client_or_company_id, company_or_conn_id, conn_or_body, body_or_opts \\ %{})

@spec create(
  Codat.Client.t() | String.t(),
  String.t(),
  String.t() | map(),
  map() | keyword()
) ::
  {:ok, map()} | {:error, Codat.Error.t()}

Creates a new billPayments (async). Returns a push operation.

delete(client_or_company_id, company_or_resource_id, resource_id_or_opts \\ [])

@spec delete(Codat.Client.t() | String.t(), String.t(), String.t() | keyword()) ::
  {:ok, nil} | {:error, Codat.Error.t()}

Deletes a billPayments by ID (async).

fetch_all(client_or_company_id, company_id_or_opts \\ [], opts \\ [])

@spec fetch_all(Codat.Client.t() | String.t(), String.t() | keyword(), keyword()) ::
  {:ok, [map()]} | {:error, Codat.Error.t()}

Fetches all billPayments across all pages concurrently.

get(client_or_company_id, company_or_resource_id, resource_id_or_opts \\ [])

@spec get(Codat.Client.t() | String.t(), String.t(), String.t() | keyword()) ::
  {:ok, map()} | {:error, Codat.Error.t()}

Fetches a single billPayments by ID.

get_create_model(client_or_company_id, company_or_conn_id, opts \\ [])

@spec get_create_model(Codat.Client.t() | String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Codat.Error.t()}

Returns the push model for creating billPayments.

list(client_or_company_id, company_id_or_opts \\ [], opts \\ [])

@spec list(Codat.Client.t() | String.t(), String.t() | keyword(), keyword()) ::
  {:ok, Codat.Pagination.t()} | {:error, Codat.Error.t()}

Returns a paginated list of billPayments.

stream(client_or_company_id, company_id_or_opts \\ [], opts \\ [])

@spec stream(Codat.Client.t() | String.t(), String.t() | keyword(), keyword()) ::
  Enumerable.t()

Returns a lazy Stream of all results.