Also called BT-151, VAT category, tax category code
A VAT category code says how a line is treated for VAT: standard rated, zero rated, exempt, reverse charge, intra-community, export or outside scope. Each code brings its own conditions, and 96 of the 223 EN 16931 rules exist to check them.
S is standard rated, the ordinary case with a positive rate. Z is zero rated, where VAT applies at 0%. E is exempt, where VAT does not apply and a reason is required. AE is reverse charge, where the buyer accounts for the VAT. K is intra-community supply within the EU. G is export outside the EU. O is outside the scope of VAT entirely.
The distinction people most often get wrong is Z against E. Zero rated is taxable at 0%, exempt is not taxable. They look the same on the invoice and behave differently in a VAT return.
Choosing a code is a claim, and each claim brings obligations. E, AE, K and G all require an exemption reason. AE, K, G and O require the rate to be zero. Several require the seller or buyer VAT identifier to be present.
This is why the VAT family is the largest in the standard. It is not checking arithmetic, it is checking that the story the invoice tells about itself is internally consistent.
Nearly every failure in this family comes from a VAT breakdown written by hand rather than derived by grouping the lines.
Build the breakdown from the lines: one entry per distinct combination of category and rate, with the taxable amount being the sum of that group. Most of these 96 rules stop firing at once.
Grouped by code, with the cause and the fix for each.