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

# Transaction Math

> Understand how transaction math works when sending transactions to Zamp.

# Overview

When calculating taxes or posting transactions to Zamp, take a look at this guide for how the math works for subtotals and totals.

<Tip>
  Zamp’s APIs accept up to the cent (second decimal place) for financial values. Otherwise, we will return a `Number must be a multiple of 0.01` error.
</Tip>

## Transaction-Level Subtotal

At the transaction-level, the `subTotal` is the cost of the items and any transaction-level or line-item discounts. The difference is, the discount at the transaction-level is still passed as a `discount` even though it is factored into the `subTotal`.

<Accordion title="Single Item Transaction with Transaction-level Discount">
  * I have a transaction for 2 of the same item.
    * They cost \$10 each.
  * There is a promotion running for \$10.00 off your cart. 
  * **The `subtotal` for this transaction is \$10.**

  $$
  (10.00 * 2) - 10.00 = subtotal (10.00)
  $$
</Accordion>

<Accordion title="Multiple Item Transaction with Transaction-level Discount">
  * I have a transaction where 3 different items are being sold.
    * Item A is \$10, and the customer ordered 1.
    * Item B is \$15, and the customer ordered 3.
    * Item C is \$20, and the customer ordered 2.
  * There is an additional 20% discount for the cart.
  * **The `subtotal` for this transactions is \$75.00**

  $$
  (10.00 * 1) + (15.00 * 3) + (20.00 * 2) - 20.00 = subtotal (75.00)
  $$
</Accordion>

<Accordion title="A Single Item Transaction with an Item-Discount">
  * I have a transaction for 3 of the same item.
    * The item costs \$10.00.
  * There is a "Buy Two Get One Free" promotion, so the discount is \$10.00.
    ```json theme={null}
    "id": "item1",
    "amount": 10,
    "quantity": 3,
    "discount": 10
    ```
  * **The** `subTotal `**for the transaction is still \$20.00, but there is no transaction-level discount value since it is factored in at the line-item.**

  $$
  (10.00 * 3 - 10.00) = subtotal (20.00)
  $$
</Accordion>

## Transaction Total

At the transaction-level, the `total` is the aggregate of the subtotal, any shipping and/or handling, and tax.

<Accordion title="A Single Item Transaction With Order-level Itemized Shipping and Handling, and Tax">
  * I have a sale with a single line item worth \$20.00.
    * It costs \$1.50 to ship.
    * It costs \$1.00 to handle.
    * It has \$2.00 of tax calculated.
  * **The** `total `**for this transaction is \$24.50.**

  $$
  20.00 + 1.50 + 1.00 + 2.00 - total (24.50)
  $$
</Accordion>

<Accordion title="A Multiple Item Transaction With an Aggregate Shipping and Handling, with Tax">
  * I have a sale with 3 line items.
    * Each cost \$10.00.
    * It costs \$5.00 to ship <u>AND</u> handle.
    * The tax calculated is \$3.00.
  * **The** `total `**for this transaction is \$38.00.**

  $$
  (10.00 * 3) + 5.00 + 3.00 = total (38.00)
  $$
</Accordion>
