Invalid reason code for a charge without a list identifier

Error FX-SCH-A-000604 Factur-X

Value of 'ram:ReasonCode[not (@listID)]' is not allowed.

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

When ram:ReasonCode has no @listID attribute, its value must be empty or included in the designated code list. The current value does not meet this condition.

What the rule means

ram:ReasonCode assigns a standardized code to the reason for the charge. Without @listID, the value is checked against the code list designated for this rule.

Please use an allowed reason code for the charge

The reason code for the charge, which has no list identifier, is not in the designated code list. You can change the value or leave it empty.

What to do
  1. Find the charge in ram:SpecifiedTradeAllowanceCharge whose udt:Indicator is true.
  2. Check ram:ReasonCode, which must not have a @listID attribute.
  3. Use a value from the designated code list or leave ram:ReasonCode empty.
  4. Generate the invoice again and validate it again.
What it looks like
✗ Triggers the message
<ram:SpecifiedTradeAllowanceCharge>
  <ram:ChargeIndicator>
    <udt:Indicator>true</udt:Indicator>
  </ram:ChargeIndicator>
  <ram:ReasonCode>INVALID-CODE</ram:ReasonCode>
</ram:SpecifiedTradeAllowanceCharge>
✓ Correct
<ram:SpecifiedTradeAllowanceCharge>
  <ram:ChargeIndicator>
    <udt:Indicator>true</udt:Indicator>
  </ram:ChargeIndicator>
  <ram:ReasonCode/>
</ram:SpecifiedTradeAllowanceCharge>
Technical details

The test applies to charges with udt:Indicator equal to true and ram:ReasonCode without @listID. It accepts an empty value or a value from code list cl with ID 30.

Where the rule applies

The rule applies to ram:ReasonCode of a document-level charge in ram:SpecifiedTradeAllowanceCharge when ram:ReasonCode has no @listID attribute.

Context (rule/@context)
/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator="true"]/ ram:ReasonCode[not (@listID)]
Test expression (assert/@test)
string-length($codeValue30)=0 or document('FACTUR-X_EN16931_codedb.xml')/codedb/cl[@id=30]/enumeration[@value=$codeValue30]