# `Codat.Accounting.Bills`
[🔗](https://github.com/iamkanishka/codat.git/blob/v1.0.0/lib/codat/accounting/bills.ex#L1)

Read and write supplier bills (accounts payable / purchase invoices).

Bills represent money owed **by** your company **to** a supplier.

## Example

    # List unpaid bills
    {:ok, page} = Codat.Accounting.Bills.list(client, "company-id",
      query: "status=Open",
      order_by: "-dueDate"
    )

    # Create a bill
    {:ok, push_op} = Codat.Accounting.Bills.create(client, company_id, conn_id, %{
      issueDate: "2024-01-01",
      dueDate: "2024-01-31",
      supplierRef: %{id: "supplier-id"},
      lineItems: [%{description: "Office supplies", quantity: 1, unitAmount: 500}]
    })

# `create`

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

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

# `delete`

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

Deletes a bills by ID (async).

# `fetch_all`

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

Fetches all bills across all pages concurrently.

# `get`

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

Fetches a single bills by ID.

# `get_attachments`

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

Lists attachments for a bill.

# `get_create_model`

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

Returns the push model for creating bills.

# `get_update_model`

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

Returns the push model for updating a bills record.

# `list`

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

Returns a paginated list of bills.

# `stream`

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

Returns a lazy `Stream` of all results.

# `update`

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

Updates an existing bills (async).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
