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

# Totals and rounding

> How Cufea calculates and returns totals, taxes and the QR.

Cufea calculates the totals: you send quantities, unit prices before tax and tax rates, never
an amount. Each line's amount and each tax are rounded to 2 decimals (half to even, Anexo
§5.2.1), and the invoice totals are the sums of those rounded amounts.

Every invoice and note response (create, get, send, refresh, the lists and `GET /v1/documents`) carries
the calculated amounts as JSON, read from the signed XML, so they are exactly what the DIAN
receives. Amounts are decimal strings with 2 decimals.

| Field | What it holds | XML source |
| - | - | - |
| `totals.line_extension` | Sum of the line net amounts, after line discounts | `LineExtensionAmount` |
| `totals.tax_exclusive` | Sum of the net amounts of the lines that carry a tax | `TaxExclusiveAmount` |
| `totals.tax_inclusive` | `line_extension` plus the taxes | `TaxInclusiveAmount` |
| `totals.allowance_total`, `totals.charge_total` | Document-level discounts and charges (`0.00`: Cufea has none) | `AllowanceTotalAmount`, `ChargeTotalAmount` |
| `totals.payable` | The amount to pay | `PayableAmount` |
| `totals.rounding` | Rounding of the payable amount (`0.00`: Cufea sends none) | `PayableRoundingAmount` |
| `taxes[]` | One entry per tax code and percent: `scheme`, `name`, `percent`, `taxable_amount`, `tax_amount` | document `TaxTotal/TaxSubtotal` |
| `withholdings[]` | The same per withholding; empty on notes | `WithholdingTaxTotal/TaxSubtotal` |
| `lines[]` | `gross_amount` (quantity x price), `discount_rate`, `discount_amount`, `net_amount` and the line `taxes` | `InvoiceLine` (or the note line) |
| `qr.content` | The value to encode in the printed QR: the DIAN lookup URL with the CUFE or CUDE | `sts:QRCode` |
| `qr.url` | The same URL once `state` is `accepted`; null before | — |

* Exempt IVA is a `taxes` entry at `percent` `0.00`. Lines without IVA (sent with
  `is_excluded`, or without IVA at all) have `is_excluded: true`, and `taxes` ends with one
  IVA entry with `is_excluded: true`, `percent: null`, their summed net amount as
  `taxable_amount` and `0.00` as `tax_amount`: the XML informs no IVA for them.
* The debit note totals come from `RequestedMonetaryTotal`, with the same fields.
* Compared with Factus `data.totals`, `data.taxes` and `data.items`, the names follow the UBL
  element each value comes from, so you can check any amount against the XML.

A shelf price that already includes the tax can therefore differ from the invoice total by a
few cents. A price of 190,000 with 19% IVA is a unit price of 159,663.87, whose IVA is
30,336.14, for a total of **190,000.01**. Cufea takes no tax-included price and no expected
total: invoice the total Cufea calculated, and record the difference against the shelf price
as rounding in your own books.


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