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
230 stars 124 forks source link

MustangValidator treats Peppol rules validation failures as error instead of warning #546

Open melo0187 opened 1 week ago

melo0187 commented 1 week ago

I have a CII invoice (Profile: EN16931 XRechnung (CII)) that passed Kosit validation, but fails Mustang validation.

The root cause is that Mustang treats the failure to comply with Peppol rules as error, while the severity for these rules is downgraded to warning in the CII Syntax. I base this on what the XRechnung specification says:

Die Peppol-Regeln wurden originär auf die Syntax UBL angepasst. Eine offizielle Veröffentlichung für CII seitens Peppol existiert bislang nicht. Daher wurden die Regeln mit der Veröffentlichung von XRechnung 3.0.0 für CII angepasst. Für eine Übergangszeit wird das Severity-Level "error"/"fatal" in der Syntax CII zunächst auf "warning" abgeschwächt.

So I believe it would be wrong to reject such invoice based on Mustang failing to validate it.

Mustang should treat Peppol rule violations in CII XRechnung compliant invoices as warning, as Kosit validator does.

Example Invoice:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rsm:CrossIndustryInvoice xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100">
    <rsm:ExchangedDocumentContext>
        <ram:BusinessProcessSpecifiedDocumentContextParameter>
            <ram:ID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</ram:ID>
        </ram:BusinessProcessSpecifiedDocumentContextParameter>
        <ram:GuidelineSpecifiedDocumentContextParameter>
            <ram:ID>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</ram:ID>
        </ram:GuidelineSpecifiedDocumentContextParameter>
    </rsm:ExchangedDocumentContext>
    <rsm:ExchangedDocument>
        <ram:ID>RE0021</ram:ID>
        <ram:TypeCode>380</ram:TypeCode>
        <ram:IssueDateTime>
            <udt:DateTimeString format="102">20241002</udt:DateTimeString>
        </ram:IssueDateTime>
        <ram:IncludedNote>
            <ram:Content>Rechnung</ram:Content>
            <ram:SubjectCode>AFM</ram:SubjectCode>
        </ram:IncludedNote>
        <ram:IncludedNote>
            <ram:Content>Unsere Lieferungen/Leistungen stellen wir Ihnen wie folgt in Rechnung.</ram:Content>
            <ram:SubjectCode>AAI</ram:SubjectCode>
        </ram:IncludedNote>
        <ram:IncludedNote>
            <ram:Content>Vielen Dank für die gute Zusammenarbeit.</ram:Content>
            <ram:SubjectCode>SUR</ram:SubjectCode>
        </ram:IncludedNote>
    </rsm:ExchangedDocument>
    <rsm:SupplyChainTradeTransaction>
        <ram:IncludedSupplyChainTradeLineItem>
            <ram:AssociatedDocumentLineDocument>
                <ram:LineID>1</ram:LineID>
            </ram:AssociatedDocumentLineDocument>
            <ram:SpecifiedTradeProduct>
                <ram:Name>1</ram:Name>
            </ram:SpecifiedTradeProduct>
            <ram:SpecifiedLineTradeAgreement>
                <ram:NetPriceProductTradePrice>
                    <ram:ChargeAmount>140.0000</ram:ChargeAmount>
                    <ram:BasisQuantity unitCode="H87">1.0000</ram:BasisQuantity>
                </ram:NetPriceProductTradePrice>
            </ram:SpecifiedLineTradeAgreement>
            <ram:SpecifiedLineTradeDelivery>
                <ram:BilledQuantity unitCode="H87">1.0000</ram:BilledQuantity>
            </ram:SpecifiedLineTradeDelivery>
            <ram:SpecifiedLineTradeSettlement>
                <ram:ApplicableTradeTax>
                    <ram:TypeCode>VAT</ram:TypeCode>
                    <ram:CategoryCode>S</ram:CategoryCode>
                    <ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
                </ram:ApplicableTradeTax>
                <ram:SpecifiedTradeSettlementLineMonetarySummation>
                    <ram:LineTotalAmount>140.00</ram:LineTotalAmount>
                </ram:SpecifiedTradeSettlementLineMonetarySummation>
            </ram:SpecifiedLineTradeSettlement>
        </ram:IncludedSupplyChainTradeLineItem>
        <ram:ApplicableHeaderTradeAgreement>
            <ram:BuyerReference>992-90009-96</ram:BuyerReference>
            <ram:SellerTradeParty>
                <ram:ID>231132</ram:ID>
                <ram:Name>Max Muster</ram:Name>
                <ram:DefinedTradeContact>
                    <ram:PersonName>Max Muster</ram:PersonName>
                    <ram:TelephoneUniversalCommunication>
                        <ram:CompleteNumber>0192435345</ram:CompleteNumber>
                    </ram:TelephoneUniversalCommunication>
                    <ram:EmailURIUniversalCommunication>
                        <ram:URIID>muster@example.com</ram:URIID>
                    </ram:EmailURIUniversalCommunication>
                </ram:DefinedTradeContact>
                <ram:PostalTradeAddress>
                    <ram:PostcodeCode>12345</ram:PostcodeCode>
                    <ram:LineOne>Straße</ram:LineOne>
                    <ram:CityName>Stadt</ram:CityName>
                    <ram:CountryID>DE</ram:CountryID>
                </ram:PostalTradeAddress>
                <ram:URIUniversalCommunication>
                    <ram:URIID schemeID="EM">muster@example.com</ram:URIID>
                </ram:URIUniversalCommunication>
                <ram:SpecifiedTaxRegistration>
                    <ram:ID schemeID="FC">DE99999/99999</ram:ID>
                </ram:SpecifiedTaxRegistration>
                <ram:SpecifiedTaxRegistration>
                    <ram:ID schemeID="VA">DE325845615</ram:ID>
                </ram:SpecifiedTaxRegistration>
            </ram:SellerTradeParty>
            <ram:BuyerTradeParty>
                <ram:Name>KUnde</ram:Name>
                <ram:PostalTradeAddress>
                    <ram:PostcodeCode>12345</ram:PostcodeCode>
                    <ram:LineOne>Straße</ram:LineOne>
                    <ram:CityName>Stadt</ram:CityName>
                    <ram:CountryID>DE</ram:CountryID>
                </ram:PostalTradeAddress>
            </ram:BuyerTradeParty>
        </ram:ApplicableHeaderTradeAgreement>
        <ram:ApplicableHeaderTradeDelivery>
            <ram:ActualDeliverySupplyChainEvent>
                <ram:OccurrenceDateTime>
                    <udt:DateTimeString format="102">20241002</udt:DateTimeString>
                </ram:OccurrenceDateTime>
            </ram:ActualDeliverySupplyChainEvent>
        </ram:ApplicableHeaderTradeDelivery>
        <ram:ApplicableHeaderTradeSettlement>
            <ram:PaymentReference>RE0021</ram:PaymentReference>
            <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
            <ram:SpecifiedTradeSettlementPaymentMeans>
                <ram:TypeCode>1</ram:TypeCode>
                <ram:Information>Überweisung</ram:Information>
                <ram:PayeePartyCreditorFinancialAccount>
                    <ram:IBANID>DE50110101002129646573</ram:IBANID>
                    <ram:AccountName>Max Muster</ram:AccountName>
                </ram:PayeePartyCreditorFinancialAccount>
                <ram:PayeeSpecifiedCreditorFinancialInstitution>
                    <ram:BICID>BEVODEBBXXX</ram:BICID>
                </ram:PayeeSpecifiedCreditorFinancialInstitution>
            </ram:SpecifiedTradeSettlementPaymentMeans>
            <ram:ApplicableTradeTax>
                <ram:CalculatedAmount>26.60</ram:CalculatedAmount>
                <ram:TypeCode>VAT</ram:TypeCode>
                <ram:BasisAmount>140.00</ram:BasisAmount>
                <ram:CategoryCode>S</ram:CategoryCode>
                <ram:RateApplicablePercent>19.00</ram:RateApplicablePercent>
            </ram:ApplicableTradeTax>
            <ram:SpecifiedTradePaymentTerms>
                <ram:Description>Zahlbar sofort, rein netto</ram:Description>
                <ram:DueDateDateTime>
                    <udt:DateTimeString format="102">20241002</udt:DateTimeString>
                </ram:DueDateDateTime>
            </ram:SpecifiedTradePaymentTerms>
            <ram:SpecifiedTradeSettlementHeaderMonetarySummation>
                <ram:LineTotalAmount>140.00</ram:LineTotalAmount>
                <ram:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>
                <ram:AllowanceTotalAmount>0.00</ram:AllowanceTotalAmount>
                <ram:TaxBasisTotalAmount>140.00</ram:TaxBasisTotalAmount>
                <ram:TaxTotalAmount currencyID="EUR">26.60</ram:TaxTotalAmount>
                <ram:GrandTotalAmount>166.60</ram:GrandTotalAmount>
                <ram:TotalPrepaidAmount>0.00</ram:TotalPrepaidAmount>
                <ram:DuePayableAmount>166.60</ram:DuePayableAmount>
            </ram:SpecifiedTradeSettlementHeaderMonetarySummation>
        </ram:ApplicableHeaderTradeSettlement>
    </rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>
jstaerk commented 1 week ago

I believe I just fixed that in #532, could you check with the current master? (and yes, that originates in your original proposal :-))

melo0187 commented 1 week ago

@jstaerk that is great news!

I can confirm that it was working with master (specifically e8a1997) by adding a test. The test failed with tagged version 2.14.2 and passed if based on e8a1997. (However, HEAD on master is now at d8ba834, which has compile errors)

Can you share an estimation when a new mustang version will ship with this fix?

Thank you in advance for your support!