ForceEN16931Guideline
Methode (Function) · gibt Boolean zurück
ForceEN16931Guideline ist eine Methode der Klasse Aloaha_ZUGFeRD.XML im Aloaha ZUGFeRD SDK. Sie betrifft BT-24 (Spezifikationskennung), BT-23 (Geschäftsprozesstyp).
Beschreibung (Originaltext der englischen SDK-Dokumentation): Writes EN 16931 or XRechnung 3.0 as specification identifier (BT-24) although the invoice uses fields that switched the profile to Factur-X EXTENDED. For receivers that accept only EN 16931 or XRechnung. Call it after all other calls and right before SaveXML. The EXTENDED fields stay in the XML.
Rückgabe: True if the mode was applied; False for an unknown mode (see Last_Error)
Hinweis: The setting stays on the object until Mode 0 is called or a CSV import resets it. Calls that use EXTENDED fields switch isKOSIT off: for an XRechnung set isKOSIT = True again before the call or use Mode 2. If the invoice contains EXTENDED fields, LastWarning reports that validators based on the KoSIT rules show warnings for them and that validators using the Factur-X EN 16931 schema reject the file. For a file without EXTENDED fields set ZUGFeRD_Profile to EN 16931 before SaveXML instead: the EXTENDED-only fields are then left out.
Deklaration
Public Function ForceEN16931Guideline(Optional ByVal Mode As Integer = -1) As Boolean
Parameter
| Name | Typ | Pflicht | Beschreibung |
|---|---|---|---|
Mode | Integer | optional (Standard: -1) | -1 (default) = follow isKOSIT (True = XRechnung 3.0, False = EN 16931); 1 = EN 16931; 2 = XRechnung 3.0 (also sets isKOSIT and, if empty, the business process BT-23); 0 = switch the forcing off again |
Aufruf (VB.NET)
Dim alo As New Aloaha_ZUGFeRD.XML(Aloaha_ZUGFeRD.iXML.ZUGFeRDProfile.comfort, False, "IHR-LIZENZSCHLUESSEL")
If Not alo.ForceEN16931Guideline() Then
Console.WriteLine("Fehler: " & alo.Last_Error)
End If
Aufruf (C#)
var zfStandard = Aloaha_ZUGFeRD.iXML.ZUGFeRDVersion.xInvoice; // Optional ByRef im Konstruktor: in C# mit ref übergeben
var alo = new Aloaha_ZUGFeRD.XML(Aloaha_ZUGFeRD.iXML.ZUGFeRDProfile.comfort, false, "IHR-LIZENZSCHLUESSEL", ref zfStandard);
if (!alo.ForceEN16931Guideline())
{
Console.WriteLine("Fehler: " + alo.Last_Error);
}
Vollständiges Beispiel (VB.NET)
' VB.NET (Verweis auf Aloaha_ZUGFeRD.dll)
' Der Empfänger nimmt nur EN 16931 an, die Rechnung enthält aber Felder aus Factur-X EXTENDED
Module KopfErzwingen
Sub Main()
Dim key As String = "IHR-LIZENZSCHLUESSEL"
Dim alo As New Aloaha_ZUGFeRD.XML(Aloaha_ZUGFeRD.iXML.ZUGFeRDProfile.comfort, False, key)
' ... Rechnung aufbauen: CreateInvoice, WriteSeller, Käufer, Positionen, AddTradeTax, WriteTotals ...
' ... dabei Aufrufe, die die Rechnung auf EXTENDED umstellen (z. B. WriteItemTradeTax mit Befreiungsgrund) ...
' Direkt vor dem Speichern: 1 = EN 16931, 2 = XRechnung 3.0, -1 = wie isKOSIT, 0 = aus
If Not alo.ForceEN16931Guideline(1) Then
Console.WriteLine("Fehler: " & alo.Last_Error)
Return
End If
If alo.SaveXML("C:\Temp\RE-1001.xml", key) Then
If alo.LastWarning <> "" Then Console.WriteLine("Hinweis: " & alo.LastWarning)
Else
Console.WriteLine("Fehler: " & alo.Last_Error)
End If
End Sub
End ModuleVollständiges Beispiel (C#)
// C# (Verweis auf Aloaha_ZUGFeRD.dll)
// Der Empfänger nimmt nur EN 16931 an, die Rechnung enthält aber Felder aus Factur-X EXTENDED
using System;
class KopfErzwingen
{
static void Main()
{
string key = "IHR-LIZENZSCHLUESSEL";
var standard = Aloaha_ZUGFeRD.iXML.ZUGFeRDVersion.xInvoice; // Optional ByRef: in C# mit ref
var alo = new Aloaha_ZUGFeRD.XML(Aloaha_ZUGFeRD.iXML.ZUGFeRDProfile.comfort, false, key, ref standard);
// ... Rechnung aufbauen, auch mit EXTENDED-Feldern ...
// Direkt vor dem Speichern: 1 = EN 16931, 2 = XRechnung 3.0, -1 = wie isKOSIT, 0 = aus
if (!alo.ForceEN16931Guideline(1))
{
Console.WriteLine("Fehler: " + alo.Last_Error);
return;
}
if (alo.SaveXML(@"C:\Temp\RE-1001.xml", key, ref standard))
{
if (alo.LastWarning != "") Console.WriteLine("Hinweis: " + alo.LastWarning);
}
else
{
Console.WriteLine("Fehler: " + alo.Last_Error);
}
}
}Worauf es bei ForceEN16931Guideline ankommt:
- Rufen Sie die Funktion direkt vor SaveXML auf, also nach allen Aufrufen, die die Rechnung auf EXTENDED umstellen.
- Geändert wird nur die Kennung im Kopf (BT-24). Die EXTENDED-Felder bleiben im XML.
- Ob der Empfänger die Datei annimmt, hängt von seinem Prüfprogramm ab: Der KoSIT-Validator nimmt sie mit Warnungen an, Mustang lehnt sie ab, weil das Schema für EN 16931 die zusätzlichen Elemente nicht kennt. Testen Sie vorher beim Empfänger.
- Braucht der Empfänger die EXTENDED-Angaben nicht, setzen Sie stattdessen
ZUGFeRD_Profile = 1direkt vor SaveXML: Dann lässt das SDK diese Felder weg, und die Rechnung ist ohne Warnungen gültig. - Ein unbekannter Mode liefert
Falsemit Meldung inLast_Error;LastWarningbeschreibt die Folgen.
Ausführlich: Mein Kunde verlangt EN 16931, die Rechnung braucht aber EXTENDED-Felder. Verfügbar ab Version 11.0.0.18.