> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yondatax.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculation guide

> Build accurate requests and reconcile product, shipping, and tax totals.

`POST /v1/transactions` calculates tax for a sale. Send product amounts before tax, the applicable date, and the customer address used for the calculation.

## Money and quantities

All monetary fields use integer minor units. Apply the currency's scale before sending the request.

| Currency | Display amount | API amount |
| - | - | - |
| USD | \$10.00 | `1000` |
| JPY | ¥1,000 | `1000` |
| BHD | 1.000 BHD | `1000` |

Use JSON numbers greater than zero for `quantity`; fractional quantities are supported. Send `currency` as a supported three-letter code. Responses normalize the code to lowercase. Zero quantities and unsupported currency codes return HTTP 400 `invalid_input`.

## Discounts

Each line's `amount` is already discounted:

```text theme={null}
amount = quantity × unit_price − discount_amount
```

For two items priced at USD 10.00 each with a USD 2.00 discount, send:

```json theme={null}
{
  "number": 1,
  "quantity": 2,
  "unit_price": 1000,
  "discount_amount": 200,
  "amount": 1800
}
```

The API uses the supplied `amount` as the calculation base. It does not recompute it from quantity and unit price or subtract the discount again. `total_discount` reports the sum of product discounts; those discounts are already reflected in the totals.

## Product codes

Send each line's `product_code` as it appears in your product catalogue in the Yonda portal. Leading and trailing whitespace is ignored on both your code and the catalogue's, and so is case: `ABC-123`, `abc-123` and `Abc-123` find the same product. Each line is priced under:

1. the tax category your organization chose for that product, or
2. your organization's default category, when the product has no category, isn't in your catalogue, or the line has no `product_code`, or
3. general goods, when you have no default.

A product code never makes a calculation fail. Each response line reports the category it was priced under in `classification`, with `source` set to `product`, `default` or `general`. A line is also priced as general goods if your catalogue cannot be read in time, or if one of its categories cannot be priced; in that case every line in the request is priced as general goods. `classification` is null when no category applied, as when tax is not collected for the address. If your catalogue holds two products whose codes match alike, such as `abc-123` and `ABC-123`, neither is used, even for an exact match, and the line takes your default.

## Shipping

Include a `shipping` object to calculate tax on a delivery charge alongside the products:

```json theme={null}
{
  "cost": 200
}
```

Send the shipping cost before tax. Shipping uses the selected customer tax address. Omit shipping when there is no delivery charge. The response then has `shipping: null` and `total_shipping_tax: 0`.

## Reconcile the response

| Field | Includes |
| - | - |
| `subtotal` | Product and shipping values after discounts, before tax. |
| `total_tax` | Product tax plus shipping tax. |
| `total_shipping_tax` | Only shipping tax, already included in `total_tax`. |
| `amount_total` | All products, shipping, and tax. |

Treat absent shipping as zero when reconciling these totals:

```text theme={null}
amount_total = subtotal + total_tax
amount_total = sum(line_items[].total) + shipping.total
total_tax = sum(line_items[].tax_amount) + total_shipping_tax
```

The [quickstart](https://docs.yondatax.com/quickstart.md) example response uses minor units: `1307 = 1200 + 107`, `1307 = 1089 + 218`, and `107 = 89 + 18`.

> [!WARNING]
>
> Do not add `total_shipping_tax` to `total_tax` again. Do not subtract `total_discount` from the returned totals again.

Each product's `tax_details.jurisdictions` and the shipping `jurisdictions` describe the individual authorities. A rate of `8.75` means 8.75%. Jurisdiction taxable amounts can overlap when multiple authorities tax the same purchase; sum their `tax_due` values to reconcile tax, not their taxable bases.

## Customer address

Set `customer.address_source` to `billing` or `shipping` and provide the corresponding customer address. The selected address is echoed in `address_used_for_tax`. Include enough address detail for the jurisdiction.

Confirm geographic coverage and product treatment with Yonda during onboarding.

Use the [API reference](https://docs.yondatax.com/api-reference/transactions.md) for field constraints and [errors](https://docs.yondatax.com/errors.md) for rejected requests.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.