# XV-RO-12

Source: https://xmlvalid.com/rules/XV-RO-12

> CUI cumparator incorect. #The buyer's tax code (CUI) fails ANAF's check: at most ten digits, no leading zero, and a valid check digit.

- Level: error
- Rule sets: RO e-Factura tax code checks ANAF validator 1.3.0
- Context: `/ubl:Invoice | /cn:CreditNote`
- Test: `$buyer != 'cui'`

## Why it fails

- The buyer's CUI has a typo, so its last digit (the check digit, key 753217532) does not match.
- The code has a leading zero, more than ten digits, spaces inside or another prefix than RO (`RO 123`, `R0123`).
- The code ANAF's validator reads is not the one you meant: it takes `cac:PartyTaxScheme/cbc:CompanyID` first, and `cac:PartyLegalEntity/cbc:CompanyID` only when that is missing or not a Romanian code.

## How to fix it

- Copy the buyer's CUI from the ANAF register, as `RO` followed by the digits for a VAT payer, or the digits alone. This is our check, written after ANAF's validator, not one of the published rules.

Validate a document against these rules: https://xmlvalid.com/validate
