# BR-22: Add the invoiced or credited quantity to every line

Each line needs a quantity element, `cbc:InvoicedQuantity` or `cbc:CreditedQuantity`. Without it the unit code check and the line calculation fail too.

- Layer: EN 16931
- Severity: fatal (the document is invalid)
- Topics: Lines and prices, Core fields
- Official definition: https://docs.peppol.eu/poacc/billing/3.0/rules/ubl-tc434/BR-22/
- Explanation last updated: 2026-09-24

## The short answer

`BR-22` fails when a line has no quantity element: no `cbc:InvoicedQuantity` inside a `cac:InvoiceLine`, or no `cbc:CreditedQuantity` inside a `cac:CreditNoteLine`. Add the number of units the line charges or credits, with its `unitCode`, before `cbc:LineExtensionAmount`.

Expect two more findings on the same line until the quantity is back. The unit code is an attribute of the quantity element, so `BR-23` fails with it, and the Peppol line calculation carries on with a quantity of 1 in place of the missing one.

## What the rule checks

For every `cac:InvoiceLine` or `cac:CreditNoteLine`, the rule looks for a direct child named `cbc:InvoicedQuantity` or `cbc:CreditedQuantity` and passes if either exists. It does not read the number.

Only absence is caught here. An empty quantity element is refused by the XSD layer, which expects a number, so the business rules never run on it. A quantity of 0 passes this rule; on the recorded line it was reported by `PEPPOL-EN16931-R120` instead, because 0 x 12.5 is not 25.00.

The rule itself accepts either element name in either document type, but the schema does not. When tried, a `cbc:InvoicedQuantity` inside a `cac:CreditNoteLine` failed at the XSD layer.

A missing quantity always brings `BR-23`. Whether `PEPPOL-EN16931-R120` joins them depends on the price, because that rule counts the missing quantity as 1. When tried with the price raised to 25, so that 1 x 25 matched the line amount of 25.00, only `BR-22` and `BR-23` were reported.

| Term | Meaning | UBL element |
|---|---|---|
| BT-129 | Invoiced quantity | `cac:InvoiceLine/cbc:InvoicedQuantity (cac:CreditNoteLine/cbc:CreditedQuantity in a credit note)` |
| BT-130 | Invoiced quantity unit of measure code | `cac:InvoiceLine/cbc:InvoicedQuantity/@unitCode (cac:CreditNoteLine/cbc:CreditedQuantity/@unitCode in a credit note)` |

## How an integration ends up here

Possible causes, from the shape of the rule rather than from measured usage:

- Service or fixed-fee lines have an amount but no quantity in the source system, and the mapping skips the element when the field is null.
- The quantity is held on a delivery or order line that is not joined when the invoice line is built.
- Credit notes are built from the invoice mapping, and the step that should rename `cbc:InvoicedQuantity` to `cbc:CreditedQuantity` drops the element instead.
- A template writes the quantity only for stock items, and a manual or free-text line falls through without one.

## How to fix it

1. Find the line from the finding location.
2. Take the quantity from the source line: the number of units supplied, or the number being credited. A fee or service charged once has a quantity of 1 in a suitable unit such as `C62`; send that rather than leaving the quantity out.
3. Write it as `cbc:InvoicedQuantity` in an invoice or `cbc:CreditedQuantity` in a credit note, with the UN/ECE unit code in `unitCode`, immediately before `cbc:LineExtensionAmount`.
4. Recalculate the line: quantity x (net price / base quantity), plus line charges and minus line allowances, must come back to the line net amount within 0.02, which `PEPPOL-EN16931-R120` checks. If it does not, one of those values is wrong in the source.

## Before and after

These are fragments, not complete documents. The complete synthetic documents they come from are linked below.

Fragment of the failing invoice: the line has a net amount and a price but no quantity

```xml
<cac:InvoiceLine>
  <cbc:ID>1</cbc:ID>
  <cbc:LineExtensionAmount currencyID="GBP">25.00</cbc:LineExtensionAmount>
  <!-- item omitted from this fragment -->
  <cac:Price>
    <cbc:PriceAmount currencyID="GBP">12.5</cbc:PriceAmount>
    <cbc:BaseQuantity unitCode="C62">1</cbc:BaseQuantity>
  </cac:Price>
</cac:InvoiceLine>
```

Fragment of the corrected invoice: a quantity of 2 in unit C62 before the line net amount

```xml
<cac:InvoiceLine>
  <cbc:ID>1</cbc:ID>
  <cbc:InvoicedQuantity unitCode="C62">2</cbc:InvoicedQuantity>
  <cbc:LineExtensionAmount currencyID="GBP">25.00</cbc:LineExtensionAmount>
  <!-- item omitted from this fragment -->
  <cac:Price>
    <cbc:PriceAmount currencyID="GBP">12.5</cbc:PriceAmount>
    <cbc:BaseQuantity unitCode="C62">1</cbc:BaseQuantity>
  </cac:Price>
</cac:InvoiceLine>
```

The corrected invoice has `<cbc:InvoicedQuantity unitCode="C62">2</cbc:InvoicedQuantity>` on line 1 and the failing one has no quantity there. Two other rules are reported against the same line. `BR-23` fails because the unit code it looks for is an attribute of the missing element. `PEPPOL-EN16931-R120` fails because it counts the missing quantity as 1, and 1 x 12.5 is 12.50, not the 25.00 the line states. Restoring the quantity of 2 clears all three.

### What the validator reported

- The failing invoice reports **BR-22**, [BR-23](https://ironfang.uk/docs/finance/rules/BR-23.md) and [PEPPOL-EN16931-R120](https://ironfang.uk/docs/finance/rules/PEPPOL-EN16931-R120.md). The corrected document passes every layer with no findings.
  - [Download the failing XML](https://ironfang.uk/finance/rule-examples/BR-22-invalid.xml)
  - [Download the corrected XML](https://ironfang.uk/finance/rule-examples/invoice-minimal.xml)

Recorded on phive 12.1.0 / phive-rules-peppol 4.5.6 / Saxon-HE 12.10, the engine behind the free validator, using synthetic data. A recorded result is regression evidence for these documents; it is not a certification.

## Where it applies

- In a UBL `Invoice` the element is `cbc:InvoicedQuantity` inside `cac:InvoiceLine`; in a `CreditNote` it is `cbc:CreditedQuantity` inside `cac:CreditNoteLine`. When tried on a credit note, removing the credited quantity reported the same three rules at `cac:CreditNoteLine[1]`.
- The quantity is optional in the UBL schema, which is why its absence gets past the XSD layer and is left to this rule.
- A quantity that is present but has no `unitCode` passes this rule and is reported by `BR-23` instead.

## Related rules

- [BR-23 requires the unit code on the quantity and is reported with this rule when the element is missing](https://ironfang.uk/docs/finance/rules/BR-23.md)
- [PEPPOL-EN16931-R120 recalculates the line from the quantity and reads a missing one as 1](https://ironfang.uk/docs/finance/rules/PEPPOL-EN16931-R120.md)
- [BR-CL-23 checks that the unit code on the quantity is a recognised code](https://ironfang.uk/docs/finance/rules/BR-CL-23.md)
- [BR-26 requires the item net price, the other input to the line calculation](https://ironfang.uk/docs/finance/rules/BR-26.md)

## Scope and source

Written for Peppol BIS Billing 3.0.21 (May 2026), EN 16931 1.3.16, as applied to UBL 2.1 Invoice and CreditNote documents. Other profiles, syntaxes and releases can define this identifier differently. Guidance version 2026-09-24.1: source checked 2026-09-24, explanation last updated 2026-09-24.

[The official definition of BR-22](https://docs.peppol.eu/poacc/billing/3.0/rules/ubl-tc434/BR-22/) carries the normative wording and test. This page is our explanation of it, not a copy.

Guidance does not change the engine verdict. Fixing this finding does not mean the document passes every layer, and validation does not certify legal or tax compliance or transmit a document over Peppol.

## Links

- [This rule as a web page](https://ironfang.uk/docs/finance/rules/BR-22)
- [Free Peppol invoice validator](https://ironfang.uk/tools/peppol-validator)
- [Rule index](https://ironfang.uk/docs/finance/rules.md)
- [Ironfang Finance API docs](https://ironfang.uk/docs/finance)
- The same rule is available to MCP clients as the tool `finance.rule.get` on https://mcp.ironfang.uk/mcp
