At most two VA tax registrations

Error FX-SCH-A-000386 Factur-X

Element variant 'ram:SpecifiedTaxRegistration[ram:ID/@schemeID="VA"]' may occur at maximum 2 times.

Mandatory rule: As long as it is violated, the invoice is invalid and will be rejected by validators.
What is wrong

The same ram:ManufacturerTradeParty contains more than two ram:SpecifiedTaxRegistration elements whose child ram:ID has a schemeID attribute with the value VA.

What the rule means

The rule limits the number of tax registrations using scheme VA within the manufacturer element to two. Additional registrations using this scheme exceed the permitted maximum.

Please limit the manufacturer’s VA tax registrations to two

More than two tax registrations with schemeID="VA" are specified for the manufacturer. Reduce these entries to no more than two.

What to do
  1. Locate ram:ManufacturerTradeParty for the product on the invoice line.
  2. Count the ram:SpecifiedTaxRegistration elements whose ram:ID has the attribute schemeID="VA".
  3. Keep no more than two of these elements.
  4. Generate the invoice again and validate it again.
What it looks like
✗ Triggers the message
<ram:ManufacturerTradeParty>
  <ram:SpecifiedTaxRegistration>
    <ram:ID schemeID="VA">A</ram:ID>
  </ram:SpecifiedTaxRegistration>
  <ram:SpecifiedTaxRegistration>
    <ram:ID schemeID="VA">B</ram:ID>
  </ram:SpecifiedTaxRegistration>
  <ram:SpecifiedTaxRegistration>
    <ram:ID schemeID="VA">C</ram:ID>
  </ram:SpecifiedTaxRegistration>
</ram:ManufacturerTradeParty>
✓ Correct
<ram:ManufacturerTradeParty>
  <ram:SpecifiedTaxRegistration>
    <ram:ID schemeID="VA">A</ram:ID>
  </ram:SpecifiedTaxRegistration>
  <ram:SpecifiedTaxRegistration>
    <ram:ID schemeID="VA">B</ram:ID>
  </ram:SpecifiedTaxRegistration>
</ram:ManufacturerTradeParty>
Technical details

The test counts ram:SpecifiedTaxRegistration elements within ram:ManufacturerTradeParty whose direct ram:ID has the value VA in @schemeID, and requires a count of no more than two.

Where the rule applies

This rule applies to ram:SpecifiedTaxRegistration within ram:ManufacturerTradeParty for a product on an invoice line.

Context (rule/@context)
/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ ram:SpecifiedTradeProduct/ram:ManufacturerTradeParty
Test expression (assert/@test)
count(ram:SpecifiedTaxRegistration[ram:ID/@schemeID="VA"])<=2