# BR-FREXT-AF-01

Source: https://xmlvalid.com/rules/BR-FREXT-AF-01

> An Invoice that contains an Invoice line (BG-25) where the "Subtype of invoice line item" (EXT-FR-FE-163 / BT-X-8) has the value "DETAIL" or is not specified, a Document level allowance (BG-20) or a Document level charge or tax (BG-21) where the VAT category code (BT-151, BT-95 or BT-102) is “L” ("Canary Islands tax") shall contain in the VAT breakdown (BG-23) at least one VAT category code (BT-118) equal with “L” ("Canary Islands tax").

- Level: error
- Rule sets: EXTENDED-CTC-FR rules (UBL) 1.4.0.04
- Context: `/ubl:Invoice | /cn:CreditNote`
- Test: `(count(cac:AllowanceCharge/cac:TaxCategory[normalize-space(cbc:ID) = 'L']) + count((cac:InvoiceLine | cac:CreditNoteLine)[not(cac:BillingReference/cac:InvoiceDocumentReference/cbc:ID = $invoiceID) or (cac:BillingReference[cac:InvoiceDocumentReference/cbc:ID = $invoiceID]/cac:InvoiceDocumentReference/cbc:DocumentStatusCode = 'DETAIL')]/cac:Item/cac:ClassifiedTaxCategory[normalize-space(cbc:ID) = 'L']) + count(cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory[normalize-space(cbc:ID) = 'L']) = 0) or (count(cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory[normalize-space(cbc:ID) = 'L']) >= 1 and (exists(cac:AllowanceCharge/cac:TaxCategory[normalize-space(cbc:ID) = 'L']) or exists((cac:InvoiceLine | cac:CreditNoteLine)[not(cac:BillingReference/cac:InvoiceDocumentReference/cbc:ID = $invoiceID) or (cac:BillingReference[cac:InvoiceDocumentReference/cbc:ID = $invoiceID]/cac:InvoiceDocumentReference/cbc:DocumentStatusCode = 'DETAIL')]/cac:Item/cac:ClassifiedTaxCategory[normalize-space(cbc:ID) = 'L'])))`

> An Invoice that contains an Invoice line (BG-25) where the "Subtype of invoice line item" (BT-X-8) has the value "DETAIL" or is not specified, a Document level allowance (BG-20) or a Document level charge or tax (BG-21) where the VAT category code (BT-151, BT-95 or BT-102) is “L” ("Canary Islands tax") shall contain in the VAT breakdown (BG-23) at least one VAT category code (BT-118) equal with “L” ("Canary Islands tax").

- Level: error
- Rule sets: EXTENDED-CTC-FR rules (CII) 1.4.0.04
- Context: `/rsm:CrossIndustryInvoice`
- Test: `(count(//ram:ApplicableHeaderTradeSettlement/ram:ApplicableTradeTax[ram:CategoryCode='L'])=0 and count(//ram:SpecifiedLineTradeSettlement[not(../ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode) or ../ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode = 'DETAIL']/ram:ApplicableTradeTax[ram:CategoryCode='L'])=0 and count(//ram:CategoryTradeTax[ram:CategoryCode='L'])=0) or ( count(//ram:ApplicableHeaderTradeSettlement/ram:ApplicableTradeTax[ram:CategoryCode='L'])>=1 and (exists(//ram:SpecifiedLineTradeSettlement[not(../ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode) or ../ram:AssociatedDocumentLineDocument/ram:LineStatusReasonCode = 'DETAIL']/ram:ApplicableTradeTax[ram:CategoryCode='L']) or exists(//ram:CategoryTradeTax[ram:CategoryCode='L'])))`

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