ZUGFeRD / mustangproject

Open Source Java e-Invoicing library, validator and tool (Factur-X/ZUGFeRD, UNCEFACT/CII XRechnung)
http://www.mustangproject.org
Apache License 2.0
168 stars 99 forks source link

X-Rechnung direct-debit missing mandatory field BT-90 #370

Open asdf00000 opened 2 months ago

asdf00000 commented 2 months ago

For X-Rechnung with payment method direct debit, the now mandatory field BT-90 CreditorReferenceID is missing. The current Validator rejects files without that field. This is how it should look like:

<ram:ApplicableHeaderTradeSettlement>             
    <ram:CreditorReferenceID>[Bank assigned creditor identifier]</ram:CreditorReferenceID>
    <ram:PaymentReference>12345</ram:PaymentReference>
    <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
    <ram:SpecifiedTradeSettlementPaymentMeans>
        <ram:TypeCode>59</ram:TypeCode>
        ...

The problem is, that the field must be inside the ApplicableHeaderTradeSettlement-block, not inside the direct-debit-specific SpecifiedTradeSettlementPaymentMeans-block. So just adding the field into IZUGFeRDTradeSettlementDebit won't suffice as it is needed in the higher level xml-block. As a consequence, including the field might require rearranging the code that creates the ApplicableHeaderTradeSettlement-block.

Is anyone already working on it?

jstaerk commented 1 month ago

If your issue is a question if a mustang generated file is valid(?) please include either the complete source code and/or the complete output so that I can have a look and run it through a validator.

asdf00000 commented 1 month ago

No, it's not a question, just a notice. I have researched the issue before I opened the ticket.

I tested it with KOSIT Version 3.0.1_2023-09-22 and Mustang-Validator 2.10.0. Every X-Rechnung created with Mustang 2.10.0 with payment type direct-debit is rejected by KOSIT-Validator and Mustang-Validator because the CreditorReferenceID-field is not implemented. The field used to be optional in earlier versions of X-Rechnung, but is now mandatory for payment type direct-debit. As I mentioned above, the following line must be adeed so that the X-Rechnung passes the validation.

<ram:CreditorReferenceID>[Bank assigned creditor identifier]</ram:CreditorReferenceID>

I thought about implementing it myself and submitting a pull request, but your current code structure is not suitable for that without major changes.

So I fixed it locally for myself for now by post-processing the XML-string and injecting the missing line.

sebastianschmitz1510 commented 1 month ago

Last week I had the same issue with a "xRechnung" with a missing "CreditorReferenceID" (BT-90). By manually adding the "CreditorReferenceID" as the first element in "ApplicableHeaderTradeSettlement", the validator declared the X-invoice as valid. I use mustang-validator and mustang-library in version 2.10.0.