Hi Jacek,
when KsEF is according to the UBL/Peppol rules it will be very hard to create the xml yourself and also not the best way to do.
I propose you use the .net library ubllarsen (see
https://github.com/UblSharp/UblSharp)
It offers an object model to ubl and will create the xml for you using serialization. Included are also a lot of samples.
Understanding the ubl requirements is already complicated enough and it will help you to code while using syntax code completion.
small sample:
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
USING ublSharp
USING UblSharp.CommonAggregateComponents
USING UblSharp.CommonExtensionComponents
USING UblSharp.UnqualifiedDataTypes
USING UblSharp.XmlDigitalSignature
USING System.IO
USING System.Xml
USING System.Xml.Serialization
***
SELF:w_oUBLInvoice := ublSharp.InvoiceType{}
SELF:Create(oExternalInvoice, oCustomer, oSupplier, aInvoiceEntries)
self:SaveInvoiceXML(sFullName)
PROTECT METHOD SaveInvoiceXML(sFullName AS STRING) AS LONG PASCAL CLASS fExportUBLbase
LOCAL oSetting AS XmlWriterSettings
LOCAL oXMLWriter AS xmlWriter
LOCAL hResult AS LONG
TRY
oSetting := XmlWriterSettings{}
oSetting:Indent := TRUE
oSetting:IndentChars := space(4)
oSetting:NewLineOnAttributes := FALSE
oXmlWriter := xmlWriter:Create(sFullName, oSetting)
LOCAL oXMLSerializer AS System.Xml.Serialization.XmlSerializer
oXMLSerializer := System.Xml.Serialization.XmlSerializer{ SELF:w_oUBLInvoice:GetType() }
oXMLSerializer:Serialize(oXMLWriter, SELF:w_oUBLInvoice)
CATCH e AS exception
hresult := e:HResult
THROW
FINALLY
IF oXmlWriter != NULL
oXMLWriter:Close()
ENDIF
END TRY
RETURN hresult
HIDDEN METHOD Create(oExternalInvoice AS dInvoice, oCustomer AS dCustomer, oSupplier AS dCustomer, aInvoiceEntries AS ARRAY)
AS LONG PASCAL CLASS fExportUBLAccountancy
LOCAL hResult AS LONG
TRY
SELF:w_oUBLInvoice:UBLVersionID := "2.1"
SELF:w_oUBLInvoice:CustomizationID := "urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu
poacc:billing:3.0"
SELF:w_oUBLInvoice:ProfileID := "urn:fdc:peppol.eu
poacc:billing:01:1.0"
LOCAL sOrderNumber, sorderRef AS STRING
sOrderNumber := oExternalInvoice:BES_NUMMER
sOrderNumber := sOrderNumber:Trim()
sOrderRef := oExternalinvoice:REF_KLANT
sOrderRef := sOrderRef:Trim()
IF sOrderNumber:Length > 0
VAR oOrderReference := OrderReferenceType{}
oOrderReference:ID := SELF:CreateIdentifier(sOrderNumber)
oOrderReference:SalesOrderID := SELF:CreateIdentifier(sOrderNumber)
IF sOrderRef:Length > 0
oOrderReference:CustomerReference := sOrderRef
ENDIF
SELF:w_oublInvoice:OrderReference := oOrderReference
SELF:w_oUBLInvoice:BuyerReference := sOrderNumber
//Error message: A buyer reference or purchase order reference MUST be provided.
ENDIF
SELF:w_oUBLInvoice:ID := SELF:CreateIdentifier(oExternalInvoice:FAKT_NR:tostring() )
....
PROTECT METHOD CreateIdentifier(sID AS STRING) AS IdentifierType PASCAL CLASS fexportUBLbase
VAR oIdentifier := IdentifierType{}
oIdentifier:Value := sID:Trim()
RETURN oIdentifier
Regards,
Luc