Example: Adding a sales document
 
The examples demonstrates how to add a sales document.
 
Remark
This example doesn't contain any business logic (exception handling, access management checks,...), it is just meant to show how to add a (simple) sales document.
 
See Also
How to add a purchase document
How to add a financial document
How to add a sundry document
 
Examples
C++
 
#include "stdafx.h"
#include "CppClient.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#include <atlbase.h>
#include <ATLComTime.h>

#import "C:\Program Files\Exact C-Logic\Venice\Bin\ClSdk.dll"

using namespace std;
using namespace ClSdk;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    OleInitialize (NULL);

    try
    {
        // These are not 'real' pointers, but 'smart' pointers, looking as pointers but acting as objects, so do not use 'delete'!
        IVenicePtr  pVenice;
        IDossierPtr pDossier;
        IYearPtr    pYear;
        ISalesPtr   pSales;
        ICustmPtr   pCustm;
        eAccessMode eAM;

        // Create the Venice object interface
        pVenice.CreateInstance(__uuidof(ClSdk::Venice));

        // Is option 'Access Management' installed?
        eAM = pVenice->GetAccessMode ();

        // Logon into Venice, allowing user interface
        if (eAM == amSecure)
            pVenice->LogonSecure ("13.10_", "MyApplication", lngNld, true, "ClSdkUser", "ClSdkPassword");
        else
            pVenice->Logon ("13.10_", "MyApplication", lngNld, true, "SDK", "ClSdkUser", "Software engineer");

        // Create Dossier Context, use the default filing cabinet 'Data' and the dossier 'Exact C-Logic'
        pDossier = pVenice->CreateDossierContext("", "Exact C-Logic");

        // Create Year Context
        pYear = pDossier->CreateYearContext (2024);

        // ----------------------------------------------------------------------------------------------------
        //  This example creates a sales invoice document with analytical information. Adding Intrastat  
        //  details is also listed but commented out.
        // ---------------------------------------------------------------------------------------------------- 

        // Create context for sales documents
        pSales = pYear->CreateSales (true);

        // Create context for customers
        pCustm = pDossier->CreateCustm (false);

        // Prepare the creation of a new Sales document.
        pSales->PrepareDocument (paInsert);
        // Initialize with default values.
        pSales->Init ();

        // In order to obtain a valid sales document header, the following properties must be assigned a value:
        // Customer number, Document type (invoice by default), book, Book date, Document date, Total amount and Currency, at least one of the VAT bases and at least one of the VAT amounts.
        // This does not imply however that these properties need to be set in code, they can also be assigned via the standard values.
        // Note: A document number is not required. If it is set to 0, a new successive number for the given book will be assigned automatically.
        // Note: While those are the only properties that are required to be filled in, other properties may require a value for the document to pass the internal validation checks. 
        //       These are the same validation checks that are applied when manually entering a document in Venice.
        pSales->pCstNum = 214;
        pSales->pCstSubNum = 0;
        pSales->pDocType = slsInvoice;       // or slsCreditnote, slsTransfer
        pSales->pBook = "FAC";
        pSales->pDocNum = 0;                 // 0 = Automatically determine the document number
        pSales->pBookDate = COleDateTime (2024, 8, 23, 0, 0, 0).m_dt;
        pSales->pDocDate = COleDateTime (2024, 8, 14, 0, 0, 0).m_dt;
        pSales->pExpDate = COleDateTime (2024, 9, 14, 0, 0, 0).m_dt;
        pSales->pTotalDocC = 2710.40;        // Positive for sales invoices and transfers. Negative for creditnotes.
        pSales->pCurrency = "EUR";

        // Assign (at least) one of the VAT bases: this value is positive for sales invoices and transfers, negative for creditnotes.
        pSales->pBaseVat1DocC = 0.00;        // at 0% VAT
        pSales->pBaseVat2DocC = 0.00;        // at 6% VAT
        pSales->pBaseVat3DocC = 0.00;        // at 12% VAT
        pSales->pBaseVat4DocC = 2240.00;     // at 21% VAT
        pSales->pBaseVat5DocC = 0.00;        // currently unused in Belgium
        pSales->pBaseVat6DocC = 0.00;        // currently unused in Belgium
        pSales->pBaseCoPartDocC = 0.00;
        pSales->pBaseIcGoodsDocC = 0.00;
        pSales->pBaseIcAssmDistDocC = 0.00;
        pSales->pBaseIcServicesDocC = 0.00;
        pSales->pBaseExportDocC = 0.00;
        pSales->pBaseForeignVatDocC = 0.00;
        pSales->pBaseFinDiscountDocC = 0.00;
        pSales->pBaseNotSubmitDocC = 0.00;

        // Assign (at least) one of the VAT amounts: this value is positive for sales invoices and transfers, negative for creditnotes.
        pSales->pVatDueNormDocC = 470.40;
        pSales->pVatDedNormDocC = 0.00;

        // Manually entering a document in Venice provides a number of automatic assignments. These do not get applied when creating a document via the SDK.
        // The following code performs those assignments:
        if (pCustm->SeekByCstNum (smEqual, pSales->pCstNum, pSales->pCstSubNum))
        {
            pSales->pClass = pCustm->pClass;
            pSales->pStatCode = pCustm->pStat;
            if ((BYTE)pCustm->pStandardBase >= asbBase0 && (BYTE)pCustm->pStandardBase <= asbBase5)
                pSales->pVatCode = pCustm->pStandardBase;
            pSales->pFinDiscount = pCustm->pFinDiscount;
            pSales->pRepresentative = pCustm->pRepresentative;
            pSales->pReminder = pCustm->pReminders;
        }

        // Add your code here for assigning additional properties of the document header.
        // pSales->Xxx = yyy;

        // Create detail lines and analytical information for each detail line.
        pSales->InsertDetail (0, -2000.00, 0.00, 0.00, "701", "FLC209 Heating unit", "");
            // Analytical details for centre (only when desired and when the option 'Analytical' is installed) 
            pSales->InsertAnaDetail (0, 0, aetCent, -2000.00 * 60/100, 0.00, 60, 0.00, "Sales.NatalieR", "Merchandise", "", "");
            pSales->InsertAnaDetail (0, 1, aetCent, -2000.00 * 40/100, 0.00, 40, 0.00, "Sales.KarelM", "Merchandise", "", "");
            // Analytical details for unit
            pSales->InsertAnaDetail (0, 0, aetUnit, -2000.00 * 15/100, 0.00, 15, 0.00, "Admin", "Merchandise", "", "");
            pSales->InsertAnaDetail (0, 1, aetUnit, -2000.00 * 85/100, 0.00, 85, 0.00, "Production", "Merchandise", "", "");

        pSales->InsertDetail (1, -240.00, 0.00, 0.00, "702", "Installation and setup (3 hours)", "");
            // Analytical details for centre
            pSales->InsertAnaDetail (1, 0, aetCent, -240.00 * 100/100, 0.00, 100, 0.00, "Maint.PeterVH", "Services", "", "");
            // Analytical details for unit
            pSales->InsertAnaDetail (1, 0, aetUnit, -240.00 * 10/100, 0.00, 10, 0.00, "Admin", "Services", "", "");
            pSales->InsertAnaDetail (1, 1, aetUnit, -240.00 * 90/100, 0.00, 90, 0.00, "Maintenance", "Services", "", "");

        // If you have the option Intrastat, you can also add Intrastat details. In order to do this, there must be an IC relation between the company and the customer 
        // (= They must have enterprise numbers from differing countries in the European Community).
        //pSales->InsertItrDetail (0, 2500.00, 0.00, 0.00, spDispatch, ntrNormal_Bussiness, reFlanders, trRoad, dcFCA, "85203219", "FR", "US");
        //pSales->InsertItrDetail (1, 1300.00, 0.00, 0.00, spDispatch, ntrNormal_Bussiness, reFlanders, trRoad, dcFCA, "85203219", "FR", "CO");

        // Write (or cancel) the document
        pSales->WriteDocument (rmErrorReport);
        // If you do not use WriteDocument() because you do not want to save the document (maybe because of an error) you should call CancelDocument() instead.
    }

    catch (_com_error CE)
    {
        printf ("\nError while executing application.\nReason: %s\nSource: %s", (LPCSTR)CE.Description (), (LPCSTR)CE.Source ()); 
    }

    // All objects must be out of scope (or destroyed) before calling OleUninitialize ()!
    OleUninitialize ();
}
C#
 
using System;
using ClSdk;

namespace Example
{
    class Example
    {
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                eAccessMode eAM;

                // Create the Venice object
                Venice oVenice = new Venice();

                // Is option 'Access Management' installed?
                eAM = oVenice.GetAccessMode ();

                // Logon into Venice, allowing user interface
                if (eAM == eAccessMode.amSecure)
                    oVenice.LogonSecure ("13.10_", "MyApplication", eLanguage.lngNld, true, "ClSdkUser", "ClSdkPassword");
                else
                    oVenice.Logon ("13.10_", "MyApplication", eLanguage.lngNld, true, "SDK", "ClSdkUser", "Software engineer");

                // Create Dossier Context, use the default filing cabinet 'Data' and the dossier 'Exact C-Logic'
                Dossier oDossier = oVenice.CreateDossierContext ("", "Exact C-Logic");

                // Create Year Context
                Year oYear = oDossier.CreateYearContext (0);

                // ----------------------------------------------------------------------------------------------------
                //  This example creates a sales invoice document with analytical information. Adding Intrastat  
                //  details is also listed but commented out.
                // ----------------------------------------------------------------------------------------------------

                // Create context for sales documents
                Sales oSales = oYear.CreateSales (true);

                // Create context for customers
                Custm oCustm = oDossier.CreateCustm (false);

                // Prepare the creation of a new Sales document.
                oSales.PrepareDocument (ePrepareAction.paInsert);
                // Initialize with default values.
                oSales.Init ();

                // In order to obtain a valid sales document header, the following properties must be assigned a value:
                // Customer number, Document type (invoice by default), book, Book date, Document date, Total amount and Currency, at least one of the VAT bases and at least one of the VAT amounts.
                // This does not imply however that these properties need to be set in code, they can also be assigned via the standard values.
                // Note: A document number is not required. If it is set to 0, a new successive number for the given book will be assigned automatically.
                // Note: While those are the only properties that are required to be filled in, other properties may require a value for the document to pass the internal validation checks. 
                //       These are the same validation checks that are applied when manually entering a document in Venice.
                oSales.pCstNum = 214;
                oSales.pCstSubNum = 0;
                oSales.pDocType = eSalesDocType.slsInvoice;           // or slsCreditnote, slsTransfer
                oSales.pBook = "FAC";
                oSales.pDocNum = 0;                     // 0 = Automatically determine the document number
                oSales.pBookDate = new DateTime (2024, 8, 23);
                oSales.pDocDate = new DateTime (2024, 8, 14);
                oSales.pExpDate = new DateTime (2024, 9, 14);
                oSales.pTotalDocC = 2710.40;            // Positive for sales invoices and transfers. Negative for creditnotes.
                oSales.pCurrency = "EUR";

                // Assign (at least) one of the VAT bases: this value is positive for sales invoices and transfers, negative for creditnotes.
                oSales.pBaseVat1DocC = 0.00;            // at 0% VAT
                oSales.pBaseVat2DocC = 0.00;            // at 6% VAT
                oSales.pBaseVat3DocC = 0.00;            // at 12% VAT
                oSales.pBaseVat4DocC = 2240.00;         // at 21% VAT
                oSales.pBaseVat5DocC = 0.00;            // currently unused in Belgium
                oSales.pBaseVat6DocC = 0.00;            // currently unused in Belgium
                oSales.pBaseCoPartDocC = 0.00;
                oSales.pBaseIcGoodsDocC = 0.00;
                oSales.pBaseIcAssmDistDocC = 0.00;
                oSales.pBaseIcServicesDocC = 0.00;
                oSales.pBaseExportDocC = 0.00;
                oSales.pBaseForeignVatDocC = 0.00;
                oSales.pBaseFinDiscountDocC = 0.00;
                oSales.pBaseNotSubmitDocC = 0.00;

                // Assign (at least) one of the VAT amounts: this value is positive for sales invoices and transfers, negative for creditnotes.
                oSales.pVatDueNormDocC = 470.40;
                oSales.pVatDedNormDocC = 0.00;

                // Manually entering a document in Venice provides a number of automatic assignments. These do not get applied when creating a document via the SDK.
                // The following code performs those assignments:
                if (oCustm.SeekByCstNum (eSeekMode.smEqual, (int)oSales.pCstNum, (int)oSales.pCstSubNum))
                {
                    oSales.pClass = oCustm.pClass;
                    oSales.pStatCode = oCustm.pStat;
                    if ((eAsalsBase)oCustm.pStandardBase >= eAsalsBase.asbBase0 && (eAsalsBase)oCustm.pStandardBase <= eAsalsBase.asbBase5)
                        oSales.pVatCode = oCustm.pStandardBase;
                    oSales.pFinDiscount = oCustm.pFinDiscount;
                    oSales.pRepresentative = oCustm.pRepresentative;
                    oSales.pReminder = oCustm.pReminders;
                }

                // Add your code here for assigning additional properties of the document header.
                // oSales.Xxx = yyy;

                // Create detail lines and analytical information for each detail line.
                oSales.InsertDetail (0, -2000.00, 0.00, 0.00, "701", "FLC209 Heating unit", "");
                // Analytical details for centre (only when desired and when the option 'Analytical' is installed) 
                oSales.InsertAnaDetail (0, 0, eAnaEntType.aetCent, -2000.00 * 60/100, 0.00, 60, 0.00, "Sales.NatalieR", "Merchandise", "", "");
                oSales.InsertAnaDetail (0, 1, eAnaEntType.aetCent, -2000.00 * 40/100, 0.00, 40, 0.00, "Sales.KarelM", "Merchandise", "", "");
                // Analytical details for unit
                oSales.InsertAnaDetail (0, 0, eAnaEntType.aetUnit, -2000.00 * 15/100, 0.00, 15, 0.00, "Admin", "Merchandise", "", "");
                oSales.InsertAnaDetail (0, 1, eAnaEntType.aetUnit, -2000.00 * 85/100, 0.00, 85, 0.00, "Production", "Merchandise", "", "");

                oSales.InsertDetail (1, -240.00, 0.00, 0.00, "702", "Installation and setup (3 hours)", "");
                // Analytical details for centre
                oSales.InsertAnaDetail (1, 0, eAnaEntType.aetCent, -240.00 * 100/100, 0.00, 100, 0.00, "Maint.PeterVH", "Services", "", "");
                // Analytical details for unit
                oSales.InsertAnaDetail (1, 0, eAnaEntType.aetUnit, -240.00 * 10/100, 0.00, 10, 0.00, "Admin", "Services", "", "");
                oSales.InsertAnaDetail (1, 1, eAnaEntType.aetUnit, -240.00 * 90/100, 0.00, 90, 0.00, "Maintenance", "Services", "", "");

                // If you have the option Intrastat, you can also add Intrastat details. In order to do this, there must be an IC relation between the company and the customer 
                // (= They must have enterprise numbers from differing countries in the European Community).
                //oSales.InsertItrDetail (0, 2500.00, 0.00, 0.00, eStatProc.spDispatch, eNatTrans.ntrNormal_Bussiness, eRegion.reFlanders, eTransport.trRoad, eDelivCond.dcFCA, "85203219", "FR", "US");
                //oSales.InsertItrDetail (1, 1300.00, 0.00, 0.00, eStatProc.spDispatch, eNatTrans.ntrNormal_Bussiness, eRegion.reFlanders, eTransport.trRoad, eDelivCond.dcFCA, "85203219", "FR", "CO");

                // Write (or cancel) the document
                oSales.WriteDocument (eReportMode.rmErrorReport);
                // If you do not use WriteDocument() because you do not want to save the document (maybe because of an error) you should call CancelDocument() instead.
            }
            catch (Exception ex)
            {
                Console.WriteLine ("Error while executing application.\nReason:" + ex.Message + "\nSource: " + ex.Source);
            }
        }
    }
}
VBS
 
Const amMin = -1
Const amNormal = 0
Const amSecure = 1
Const amMax = 2

Const lngMin = 0
Const lngNld = 0
Const lngFra = 1
Const lngEngNld = 2
Const lngEngFra = 3
Const lngAuto = 4
Const lngMax = 5

Const paMin = 0
Const paInsert = 0
Const paDuplicate = 1
Const paUpdate = 2
Const paView = 3
Const paMax = 4

Const rmMin = 0
Const rmNoReport = 0
Const rmErrorReport = 1
Const rmFullReport = 2
Const rmMax = 3

Const smMin = 0
Const smFirst = 0
Const smLess = 1
Const smLessOrEqual = 2
Const smEqual = 3
Const smGreaterOrEqual = 4
Const smGreater = 5
Const smLast = 6
Const smMax = 7

Const slsMin = 0
Const slsInvoice = 0
Const slsCreditnote = 1
Const slsTransfer = 2
Const slsMax = 3

Const aetMin = 0
Const aetCent = 0
Const aetUnit = 1
Const aetMax = 2

Const ccMin = 0
Const ccNone = 0
Const ccConstituent = 1
Const ccBeneficiary = 2
Const ccMax = 3

Const spArrival = 19
Const spDispatch = 29

Const ntrMin = 1
Const ntrNormal = 1
Const ntrReturn = 2
Const ntrFree = 3
Const ntrPreProc = 4
Const ntrPostProc = 5
Const ntrRepair = 6
Const ntrDefence = 7
Const ntrBuilding = 8
Const ntrOther = 9
Const ntrNormal_Bussiness = 11
Const ntrNormal_Consumer = 12
Const ntrReturn_Goods = 21
Const ntrReturn_Replace = 22
Const ntrReturn_NonReturn = 23
Const ntrFree_Warehouse = 31
Const ntrFree_Trial = 32
Const ntrFree_Leasing = 33
Const ntrFree_Free = 34
Const ntrPreProc_Return = 41
Const ntrPreProc_NoReturn = 42
Const ntrPostProc_Return = 51
Const ntrPostProc_NoReturn = 52
Const ntrRepair_Repair = 60
Const ntrClearance_Release = 71
Const ntrClearance_OtherMember = 72
Const ntrBuilding_Building = 80
Const ntrOther_Other24Month = 91
Const ntrOther_Other = 99
Const ntrMax = 100

Const reMin = 1
Const reFlanders = 1
Const reWallonia = 2
Const reBrussels = 3
Const reMax = 4

Const trMin = 1
Const trSea = 1
Const trTrack = 2
Const trRoad = 3
Const trAir = 4
Const trPost = 5
Const trUnused = 6
Const trFixed = 7
Const trRiver = 8
Const trOwn = 9
Const trMax = 10

Const dcMin = 0
Const dcEXW = 0
Const dcFCA = 1
Const dcFAS = 2
Const dcFOB = 3
Const dcCFR = 4
Const dcCIF = 5
Const dcCPT = 6
Const dcCIP = 7
Const dcDAF = 8
Const dcDES = 9
Const dcDEQ = 10
Const dcDDU = 11
Const dcDDP = 12
Const dcXXX = 13
Const dcMax = 14

' Call main
Main

sub Main
    Dim oVenice
    Dim oDossier
    Dim oYear

    ' Create Venice object
    Set oVenice = CreateObject("Clsdk.Venice")

    ' Dummy code to activate Intellisense
    If False Then
        Set oDossier = CreateObject("ClSdk.Dossier")
        Set oYear = CreateObject("ClSdk.Year")
        Set oSales = CreateObject("ClSdk.Sales")
        Set oCustm = CreateObject("ClSdk.Custm")
    End If

    ' Login
    If oVenice.GetAccessMode() = amSecure Then
        Call oVenice.LogonSecure("13.10_", "MyApplication", lngNld, true, "ClSdkUser", "ClSdkPassword")
    Else
        Call oVenice.Logon("13.10_", "MyApplication", lngNld, true, "SDK", "ClSdkUser", "Software engineer")
    End If

    ' Create Dossier Context, using the default filing cabinet 'Data' and the dossier 'Exact C-Logic'
    Set oDossier = oVenice.CreateDossierContext("", "Exact C-Logic")

    ' Create Year Context
    Set oYear = oDossier.CreateYearContext(2024)

    '----------------------------------------------------------------------------------------------------
    ' This example creates a sales invoice document with analytical information. Adding Intrastat 
    ' details is also listed but commented out.
    '----------------------------------------------------------------------------------------------------

    ' Create context for sales documents
    Set oSales = oYear.CreateSales(true)

    ' Create context for customers
    Set oCustm = oDossier.CreateCustm(false)

    ' Prepare the creation of a new Sales document.
    Call oSales.PrepareDocument(paInsert)
    ' Initialize with default values.
    Call oSales.Init()

    ' In order to obtain a valid sales document header, the following properties must be assigned a value:
    ' Customer number, Document type (invoice by default), book, Book date, Document date, Total amount and Currency, at least one of the VAT bases and at least one of the VAT amounts.
    ' This does not imply however that these properties need to be set in code, they can also be assigned via the standard values.
    ' Note: A document number is not required. If it is set to 0, a new successive number for the given book will be assigned automatically.
    ' Note: While those are the only properties that are required to be filled in, other properties may require a value for the document to pass the internal validation checks. 
    '       These are the same validation checks that are applied when manually entering a document in Venice.
    oSales.pCstNum = 214
    oSales.pCstSubNum = 0
    oSales.pDocType = slsInvoice ' or slsCreditnote, slsTransfer
    oSales.pBook = "FAC"
    oSales.pDocNum = 0 ' 0 = Automatically determine the document number
    oSales.pBookDate = #8/23/2024# 
    oSales.pDocDate = #8/14/2024# 
    oSales.pExpDate = #9/14/2024#
    oSales.pTotalDocC = 2710.40 ' Positive for sales invoices and transfers. Negative for creditnotes.
    oSales.pCurrency = "EUR"

    ' Assign (at least) one of the VAT bases: this value is positive for sales invoices and transfers, negative for creditnotes.
    oSales.pBaseVat1DocC = 0        ' at 0% VAT
    oSales.pBaseVat2DocC = 0        ' at 6% VAT
    oSales.pBaseVat3DocC = 0        ' at 12% VAT
    oSales.pBaseVat4DocC = 2240.00  ' at 21% VAT
    oSales.pBaseVat5DocC = 0        ' currently unused in Belgium
    oSales.pBaseVat6DocC = 0        ' currently unused in Belgium
    oSales.pBaseCoPartDocC = 0
    oSales.pBaseIcGoodsDocC = 0
    oSales.pBaseIcAssmDistDocC = 0
    oSales.pBaseIcServicesDocC = 0
    oSales.pBaseExportDocC = 0
    oSales.pBaseForeignVatDocC = 0
    oSales.pBaseFinDiscountDocC = 0
    oSales.pBaseNotSubmitDocC = 0

    ' Assign (at least) one of the VAT amounts: this value is negative for sales invoices and transfers, positive for creditnotes.
    oSales.pVatDueNormDocC = 470.40
    oSales.pVatDedNormDocC = 0

    ' Manually entering a document in Venice provides a number of automatic assignments. These do not get applied when creating a document via the SDK.
    ' The following code performs those assignments:
    If oCustm.SeekByCstNum(smEqual, oSales.pCstNum, oSales.pCstSubNum) Then
        oSales.pClass = oCustm.pClass
        oSales.pStatCode = oCustm.pStat
        If oCustm.pStandardBase >= asbBase0 And oCustm.pStandardBase <= asbBase5 Then
            oSales.pVatCode = oCustm.pStandardBase
        End If
        oSales.pFinDiscount = oCustm.pFinDiscount
        oSales.pRepresentative = oCustm.pRepresentative
        oSales.pReminder = oCustm.pReminders
    End If

    ' Add your code here for assigning additional properties of the document header.
    ' oSales.Xxx = yyy

    ' Create detail lines and analytical information for each detail line.
    Call oSales.InsertDetail(0, -2000.00, 0.00, 0.00, "701", "FLC209 Heating unit", "")
        ' Analytical details for centre (only when desired and when the option 'Analytical' is installed) 
        Call oSales.InsertAnaDetail(0, 0, aetCent, -2000.00 * 60/100, 0.0, 60, 0.0, "Sales.NatalieR", "Merchandise", "", "")
        Call oSales.InsertAnaDetail(0, 1, aetCent, -2000.00 * 40/100, 0.0, 40, 0.0, "Sales.KarelM", "Merchandise", "", "")
        ' Analytical details for unit
        Call oSales.InsertAnaDetail(0, 0, aetUnit, -2000.00 * 15/100, 0.0, 15, 0.0, "Admin", "Merchandise", "", "")
        Call oSales.InsertAnaDetail(0, 1, aetUnit, -2000.00 * 85/100, 0.0, 85, 0.0, "Production", "Merchandise", "", "")

    Call oSales.InsertDetail(1, -240.00, 0.00, 0.00, "702", "Installation and setup (3 hours)", "")
        ' Analytical details for centre
        Call oSales.InsertAnaDetail(1, 0, aetCent, -240.00 * 100/100, 0.0, 100, 0.0, "Maint.PeterVH", "Services", "", "")
        ' Analytical details for unit
        Call oSales.InsertAnaDetail(1, 0, aetUnit, -240.00 * 10/100, 0.0, 10, 0.0, "Admin", "Services", "", "")
        Call oSales.InsertAnaDetail(1, 1, aetUnit, -240.00 * 90/100, 0.0, 90, 0.0, "Maintenance", "Services", "", "")

    ' If you have the option Intrastat, you can also add Intrastat details. In order to do this, there must be an IC relation between the company and the client 
    ' (= They must have enterprise numbers from differing countries in the European Community).
    'Call oSales.InsertItrDetail(0, 2500.00, 0.0, 0.0, eStatProc.spDispatch, eNatTrans.ntrNormal_Bussiness, eRegion.reFlanders, eTransport.trRoad, eDelivCond.dcFCAA, "85203219", "FR", "US")
    'Call oSales.InsertItrDetail(1, 1300.00, 0.0, 0.0, eStatProc.spDispatch, eNatTrans.ntrNormal_Bussiness, eRegion.reFlanders, eTransport.trRoad, eDelivCond.dcFCAA, "85203219", "FR", "CO")

    ' Write (or cancel) the document
    Call oSales.WriteDocument(rmErrorReport)
    ' If you do not use WriteDocument() because you do not want to save the document (maybe because of an error) you should call CancelDocument() instead.

    ' Error
    MsgBox("Finished!")
end sub
VB.NET
 
Imports ClSdk

Module Example

    Sub Main()
        Try

            Dim oVenice As Venice
            Dim oDossier As Dossier
            Dim oYear As Year
            Dim oSales As Sales
            Dim oCustm As Custm
            Dim eAM As eAccessMode

            ' Create the Venice object
            oVenice = New Venice

            ' Is option 'Access Management' installed?
            eAM = oVenice.GetAccessMode()

            ' Logon into Venice, allowing user interface
            If eAM = eAccessMode.amSecure Then
                oVenice.LogonSecure("13.10_", "MyApplication", eLanguage.lngNld, True, "ClSdkUser", "ClSdkPassword")
            Else
                oVenice.Logon("13.10_", "MyApplication", eLanguage.lngNld, True, "SDK", "ClSdkUser", "Software engineer")
            End If

            ' Create Dossier Context, use the default filing cabinet 'Data' and the dossier 'Exact C-Logic' 
            oDossier = oVenice.CreateDossierContext("", "Exact C-Logic")

            ' Create Year Context
            oYear = oDossier.CreateYearContext(2024)

            ' ----------------------------------------------------------------------------------------------------
            '  This example creates a sales invoice document with analytical information. Adding Intrastat  
            '  details is also listed but commented out.
            ' ----------------------------------------------------------------------------------------------------

            ' Create context for sales documents
            oSales = oYear.CreateSales(True)

            ' Create context for customers
            oCustm = oDossier.CreateCustm(False)

            ' Prepare the creation of a new Sales document.
            oSales.PrepareDocument(ePrepareAction.paInsert)
            ' Initialize with default values.
            oSales.Init()

            ' In order to obtain a valid sales document header, the following properties must be assigned a value:
            ' Customer number, Document type (invoice by default), book, Book date, Document date, Total amount and Currency, at least one of the VAT bases and at least one of the VAT amounts.
            ' This does not imply however that these properties need to be set in code, they can also be assigned via the standard values.
            ' Note: A document number is not required. If it is set to 0, a new successive number for the given book will be assigned automatically.
            ' Note: While those are the only properties that are required to be filled in, other properties may require a value for the document to pass the internal validation checks. 
            '       These are the same validation checks that are applied when manually entering a document in Venice.
            oSales.pCstNum = 214
            oSales.pCstSubNum = 0
            oSales.pDocType = eSalesDocType.slsInvoice           ' or slsCreditnote, slsTransfer
            oSales.pBook = "FAC"
            oSales.pDocNum = 0                     ' 0 = Automatically determine the document number
            oSales.pBookDate = New DateTime(2024, 8, 23)
            oSales.pDocDate = New DateTime(2024, 8, 14)
            oSales.pExpDate = New DateTime(2024, 9, 14)
            oSales.pTotalDocC = 27104.0 / 10.0 ' Positive for sales invoices and transfers. Negative for creditnotes.
            oSales.pCurrency = "EUR"

            ' Assign (at least) one of the VAT bases: this value is positive for sales invoices and transfers, negative for creditnotes.
            oSales.pBaseVat1DocC = 0.0             ' at 0% VAT
            oSales.pBaseVat2DocC = 0.0             ' at 6% VAT
            oSales.pBaseVat3DocC = 0.0             ' at 12% VAT
            oSales.pBaseVat4DocC = 2240.0          ' at 21% VAT
            oSales.pBaseVat5DocC = 0.0             ' currently unused in Belgium
            oSales.pBaseVat6DocC = 0.0             ' currently unused in Belgium
            oSales.pBaseCoPartDocC = 0.0
            oSales.pBaseIcGoodsDocC = 0.0
            oSales.pBaseIcAssmDistDocC = 0.0
            oSales.pBaseIcServicesDocC = 0.0
            oSales.pBaseExportDocC = 0.0
            oSales.pBaseForeignVatDocC = 0.0
            oSales.pBaseFinDiscountDocC = 0.0
            oSales.pBaseNotSubmitDocC = 0.0

            ' Assign (at least) one of the VAT amounts: this value is negative for sales invoices and transfers, positive for creditnotes.
            oSales.pVatDueNormDocC = 4704.0 / 10.0
            oSales.pVatDedNormDocC = 0.0

            ' Manually entering a document in Venice provides a number of automatic assignments. These do not get applied when creating a document via the SDK.
            ' The following code performs those assignments:
            If oCustm.SeekByCstNum(eSeekMode.smEqual, oSales.pCstNum, oSales.pCstSubNum) Then
                oSales.pClass = oCustm.pClass
                oSales.pStatCode = oCustm.pStat
                If oCustm.pStandardBase >= eAsalsBase.asbBase0 And oCustm.pStandardBase <= eAsalsBase.asbBase5 Then
                    oSales.pVatCode = oCustm.pStandardBase
                End If
                oSales.pFinDiscount = oCustm.pFinDiscount
                oSales.pRepresentative = oCustm.pRepresentative
                oSales.pReminder = oCustm.pReminders
            End If

            ' Add your code here for assigning additional properties of the document header.
            ' oSales.Xxx = yyy

            ' Create detail lines and analytical information for each detail line.
            oSales.InsertDetail(0, -2000.0, 0.0, 0.0, "701", "FLC209 Heating unit", "")
            ' Analytical details for centre (only when desired and when the option 'Analytical' is installed) 
            oSales.InsertAnaDetail(0, 0, eAnaEntType.aetCent, -2000.0 * 60 / 100, 0.0, 60, 0.0, "Sales.NatalieR", "Merchandise", "", "")
            oSales.InsertAnaDetail(0, 1, eAnaEntType.aetCent, -2000.0 * 40 / 100, 0.0, 40, 0.0, "Sales.KarelM", "Merchandise", "", "")
            ' Analytical details for unit
            oSales.InsertAnaDetail(0, 0, eAnaEntType.aetUnit, -2000.0 * 15 / 100, 0.0, 15, 0.0, "Admin", "Merchandise", "", "")
            oSales.InsertAnaDetail(0, 1, eAnaEntType.aetUnit, -2000.0 * 85 / 100, 0.0, 85, 0.0, "Production", "Merchandise", "", "")

            oSales.InsertDetail(1, -240.0, 0.0, 0.0, "702", "Installation and setup (3 hours)", "")
            ' Analytical details for centre
            oSales.InsertAnaDetail(1, 0, eAnaEntType.aetCent, -240.0 * 100 / 100, 0.0, 100, 0.0, "Maint.PeterVH", "Services", "", "")
            ' Analytical details for unit
            oSales.InsertAnaDetail(1, 0, eAnaEntType.aetUnit, -240.0 * 10 / 100, 0.0, 10, 0.0, "Admin", "Services", "", "")
            oSales.InsertAnaDetail(1, 1, eAnaEntType.aetUnit, -240.0 * 90 / 100, 0.0, 90, 0.0, "Maintenance", "Services", "", "")

            ' If you have the option Intrastat, you can also add Intrastat details. In order to do this, there must be an IC relation between the company and the customer 
            ' (= They must have enterprise numbers from differing countries in the European Community).
            'oSales.InsertItrDetail(0, 2500.00, 0.00, 0.00, eStatProc.spDispatch, eNatTrans.ntrNormal_Bussiness, eRegion.reFlanders, eTransport.trRoad, eDelivCond.dcFCA, "85203219", "FR", "US")
            'oSales.InsertItrDetail(1, 1300.00, 0.00, 0.00, eStatProc.spDispatch, eNatTrans.ntrNormal_Bussiness, eRegion.reFlanders, eTransport.trRoad, eDelivCond.dcFCA, "85203219", "FR", "CO")

            ' Write (or cancel) the document
            oSales.WriteDocument(eReportMode.rmErrorReport)
            ' If you do not use WriteDocument() because you do not want to save the document (maybe because of an error) you should call CancelDocument() instead.

        Catch ex As Exception
            Console.WriteLine("Error while executing application." + vbCrLf + "Reason:" + ex.Message + vbCrLf + "Source: " + ex.Source)
        End Try
    End Sub

End Module