Message

An Invoice that contains a Document level allowance (BG-20) where the Document level allowance VAT category code (BT-95) is "Not subject to VAT" shall not contain the Seller VAT identifier (BT-31), the Seller tax representative VAT identifier (BT-63) or the Buyer VAT identifier (BT-48).

Context
/ubl:Invoice | /cn:CreditNote
Test
(exists((/ubl:Invoice|/cn:CreditNote)/cac:AllowanceCharge[cbc:ChargeIndicator=false()]/cac:TaxCategory[normalize-space(cbc:ID) = 'O'][cac:TaxScheme/normalize-space(upper-case(cbc:ID))='VAT']) and (not(//cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme[cac:TaxScheme/(normalize-space(upper-case(cbc:ID)) = 'VAT')]/cbc:CompanyID) and not(//cac:TaxRepresentativeParty/cac:PartyTaxScheme[cac:TaxScheme/(normalize-space(upper-case(cbc:ID)) = 'VAT')]/cbc:CompanyID) and not(//cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme[cac:TaxScheme/(normalize-space(upper-case(cbc:ID)) = 'VAT')]/cbc:CompanyID))) or not(exists((/ubl:Invoice|/cn:CreditNote)/cac:AllowanceCharge[cbc:ChargeIndicator=false()]/cac:TaxCategory[normalize-space(cbc:ID) = 'O'][cac:TaxScheme/normalize-space(upper-case(cbc:ID))='VAT']))
Usage
/ ubl:Invoice / cac:AccountingSupplierParty / cac:Party / cac:PartyTaxScheme / cbc:CompanyID
/ ubl:Invoice / cac:AccountingCustomerParty / cac:Party / cac:PartyTaxScheme / cbc:CompanyID
/ ubl:Invoice / cac:TaxRepresentativeParty / cac:PartyTaxScheme / cbc:CompanyID
/ ubl:CreditNote / cac:AccountingSupplierParty / cac:Party / cac:PartyTaxScheme / cbc:CompanyID
/ ubl:CreditNote / cac:AccountingCustomerParty / cac:Party / cac:PartyTaxScheme / cbc:CompanyID
/ ubl:CreditNote / cac:TaxRepresentativeParty / cac:PartyTaxScheme / cbc:CompanyID