# BR-DE-26

Source: https://xmlvalid.com/rules/BR-DE-26

> Wenn im Element "Invoice type code" (BT-3) der Code 384 (Corrected invoice) übergeben wird, soll PRECEDING INVOICE REFERENCE BG-3 mind. einmal vorhanden sein.

- Level: warning
- Rule sets: XRechnung 3.0 rules (UBL) 2.6.0
- Context: `/ubl:Invoice | /cn:CreditNote`
- Test: `((not(normalize-space(cbc:InvoiceTypeCode) = '384' or normalize-space(cbc:CreditNoteTypeCode) = '384') or (cac:BillingReference/cac:InvoiceDocumentReference)))`

> Wenn im Element Invoice type code (BT-3) der Code 384 (Corrected invoice) übergeben wird, soll PRECEDING INVOICE REFERENCE BG-3 mind. einmal vorhanden sein.

- Level: warning
- Rule sets: XRechnung 3.0 rules (CII) 2.6.0
- Context: `/rsm:CrossIndustryInvoice`
- Test: `not(normalize-space(rsm:ExchangedDocument/ram:TypeCode) = '384') or (rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceReferencedDocument)`

## Why it fails

- The invoice is marked as corrected (type code `384`) but does not say which invoice it corrects.

## How to fix it

- Add the number of the corrected invoice in `cac:BillingReference/cac:InvoiceDocumentReference/cbc:ID` (`ram:InvoiceReferencedDocument/ram:IssuerAssignedID` in CII), with its issue date if you have it.

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