public void ImportEinvoiceIntoBilling1()
{
    using (MercatorUi.Forms.Other.OtherClasses.PeppolBoxHelper peppolBoxHelper = new MercatorUi.Forms.Other.OtherClasses.PeppolBoxHelper())
    {
        if (peppolBoxHelper.DataTable == null)
        {
            MercatorUi.Globals.MercatorTasksToMain.Log("Fout bij de initialisatie van de PeppolBoxHelper: " + Api.LastError, isError: true);
            return;
        }

        var message = peppolBoxHelper.Messages.FirstOrDefault(m => m.IsInvoiceOrCreditNote); // voeg hier een logica toe om het te importeren bericht te selecteren
        if (message == null)
        {
            MercatorUi.Globals.MercatorTasksToMain.Log("Bericht niet gevonden", isError: true);
            return;
        }

        MercatorUi.Forms.Gescom.GescomClasses.ImportFromEinvoiceDescriptor importFromEinvoiceDescriptor = new MercatorUi.Forms.Gescom.GescomClasses.ImportFromEinvoiceDescriptor
        {
            Silent = true,
            Journal = "KladA", // importeer naar een kladaankoop
            ReplacementItemId = "ARTIMC6XS9" // als het artikel niet geïdentificeerd is, zal dit artikel gebruikt worden
        };
        using (MercatorUi.Engine.Gescom.BillingEngine billingEngine = message.ImportIntoBilling(importFromEinvoiceDescriptor, out string error))
        {
            if (error != null)
            {
                MercatorUi.Globals.MercatorTasksToMain.Log(error, isError: true);
                return;
            }
            billingEngine.PeppolBoxId = message.Id;


            // hier kunnen boekhoudkundige gegevens toegevoegd worden die uit de XML-inhoud komen, zoals de naam en het e-mailadres van de contactpersoon
            MercatorPeppol.ReceivedDoc.ParseContentRet parsedContent = message.ReceivedDoc.ParseContent(MercatorUi.Globals.Langue);
            billingEngine.PiedsVRecord.NOTE1 = parsedContent.XmlSelectNodes("cac:AccountingSupplierParty/cac:Party/cac:Contact/cbc:Name").FirstOrDefault()?.InnerText + " "
                + parsedContent.XmlSelectNodes("cac:AccountingSupplierParty/cac:Party/cac:Contact/cbc:ElectronicMail").FirstOrDefault()?.InnerText;

            // haal eventuele waarschuwingen op
            if (!string.IsNullOrEmpty(importFromEinvoiceDescriptor.Warning))
                billingEngine.PiedsVRecord.NOTE2 = importFromEinvoiceDescriptor.Warning;

            if (!billingEngine.Save())
            {
                MercatorUi.Globals.MercatorTasksToMain.Log("Fout bij het opslaan van het document: " + billingEngine.LastError, isError: true);
                return;
            }

            if (!message.RemoveFromListAndDb()) // verwijder het bericht uit de PeppolBox
            {
                MercatorUi.Globals.MercatorTasksToMain.Log("Fout bij het verwijderen van het bericht: " + Api.LastError, isError: true);
                return;
            }
            MercatorUi.Globals.MercatorTasksToMain.Log(string.Format("Import voltooid {0} {1} succesvol", billingEngine.Journal, billingEngine.Piece));
        }
    }
}