# `LatticeStripe.Tax.Transaction`
[🔗](https://github.com/szTheory/lattice_stripe/blob/v2.2.2/lib/lattice_stripe/tax/transaction.ex#L1)

Record and reverse tax via Stripe's standalone Tax Transactions API.

## Lifecycle

Create a transaction from a live calculation ID with a globally unique
`reference`, inspect it via `retrieve/3` or `list_line_items/4`, and reverse
it with `create_reversal/3` when refunds or corrections require undoing
recorded tax.

## Operational constraints

Tax calculations expire after roughly **90 days** — create transactions from
a calculation before `expires_at`. The `reference` you pass to
`create_from_calculation/3` and `create_reversal/3` must be **globally
unique** across all tax transactions in your Stripe account (for example
`"order_#{order_id}"`).

## Relationship to other tax surfaces

This module is **not** `LatticeStripe.Invoice.AutomaticTax`. Automatic tax on
Invoices, Subscriptions, and Quotes is configured via nested `automatic_tax`
settings on those Billing resources. Use this Transactions API for custom
payment flows that calculate tax with `LatticeStripe.Tax.Calculation` first.
Filing, returns, and threshold monitoring are out of SDK scope.

## Usage

    reference = "order_#{order.id}"

    {:ok, txn} =
      LatticeStripe.Tax.Transaction.create_from_calculation(client, %{
        "calculation" => calc.id,
        "reference" => reference
      })

    {:ok, reversal} =
      LatticeStripe.Tax.Transaction.create_reversal(client, %{
        "mode" => "full",
        "original_transaction" => txn.id,
        "reference" => "#{reference}-rev"
      })

See [Standalone Tax API](guides/tax.md) for the canonical calculate → record → reverse workflow.

See [Stripe Tax Transactions](https://docs.stripe.com/api/tax/transactions).

# `t`

```elixir
@type t() :: %LatticeStripe.Tax.Transaction{
  created: integer() | nil,
  currency: String.t() | nil,
  customer: LatticeStripe.Customer.t() | String.t() | nil,
  customer_details: LatticeStripe.Tax.CustomerDetails.t() | nil,
  extra: map(),
  id: String.t() | nil,
  line_items: LatticeStripe.List.t() | nil,
  livemode: boolean() | nil,
  metadata: map() | nil,
  object: String.t(),
  posted_at: integer() | nil,
  reference: String.t() | nil,
  reversal: map() | String.t() | nil,
  shipping_cost: LatticeStripe.Tax.ShippingCost.t() | nil,
  tax_date: integer() | nil,
  type: String.t() | nil
}
```

# `create_from_calculation`

```elixir
@spec create_from_calculation(LatticeStripe.Client.t(), map(), keyword()) ::
  {:ok, t()} | {:error, LatticeStripe.Error.t()}
```

Creates a Tax Transaction from an existing Tax Calculation.

# `create_from_calculation!`

```elixir
@spec create_from_calculation!(LatticeStripe.Client.t(), map(), keyword()) :: t()
```

Like `create_from_calculation/3` but raises on failure.

# `create_reversal`

```elixir
@spec create_reversal(LatticeStripe.Client.t(), map(), keyword()) ::
  {:ok, t()} | {:error, LatticeStripe.Error.t()}
```

Creates a reversal Tax Transaction.

# `create_reversal!`

```elixir
@spec create_reversal!(LatticeStripe.Client.t(), map(), keyword()) :: t()
```

Like `create_reversal/3` but raises on failure.

# `from_map`

```elixir
@spec from_map(map() | nil) :: t() | nil
```

# `list_line_items`

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

Lists line items for a Tax Transaction.

# `list_line_items!`

```elixir
@spec list_line_items!(LatticeStripe.Client.t(), String.t(), map(), keyword()) ::
  LatticeStripe.Response.t()
```

Like `list_line_items/4` but raises on failure.

# `retrieve`

```elixir
@spec retrieve(LatticeStripe.Client.t(), String.t(), keyword()) ::
  {:ok, t()} | {:error, LatticeStripe.Error.t()}
```

Retrieves a Tax Transaction by ID.

# `retrieve!`

```elixir
@spec retrieve!(LatticeStripe.Client.t(), String.t(), keyword()) :: t()
```

Like `retrieve/3` but raises on failure.

---

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