Venice
Sales::InsertAnaDetail
 
Inserts a new analytical detail for one accounting detail and analytical type.
 
void InsertAnaDetail (
    SHORT sAccIndex,
    SHORT sAnaIndex,
    enum eAnaEntType eAnaEntType,
    DOUBLE dAmountDocC,
    DOUBLE dQuantity,
    DOUBLE dPercentage,
    DOUBLE dValue1,
    BSTR bsAnaAccount,
    BSTR bsAnaKind,
    BSTR bsRemark,
    BSTR bsText1
)
 
Parameters
sAccIndex
[in] The index of the detail line where the analytical detail line belongs to, starting from 0.
sAnaIndex
[in] The index of the analytical detail line, starting from 0.
eAnaEntType
[in] A value of the 'eAnaEntType' enumeration.
dAmountDocC
[in] The amount (in document currency ) of the analytical detail.
dQuantity
[in] The quantity of the analytical detail.
dPercentage
[in] The percentage that has to be distributed for the analytical detail.
dValue1
[in] The free value of the analytical detail.
bsAnaAccount
[in] The analytical account of the analytical detail.
bsAnaKind
[in] The analytical kind of the analytical detail.
bsRemark
[in] The remark of the analytical detail.
bsText1
[in] The free text of the analytical detail.
 
Remarks
If a value is provided for the parameter dAmountDocC and no value is provided for the parameter dPercentage the percentages is automatically calculated by the SDK.
The parameter sAnaIndex can have the value -1 (sAccIndex must be a valid index!). In this case the new analytical detail is inserted after the existing analytical details.
If sIndex refers to an existing index, the new analytical detail is inserted at this index and all following analytical details are moved to the next index.
 
See Also
CreateSales
Handling accounting documents using the SDK
PrepareDocument
GetManualIndex
NeedAnaDistrib
GetDetail
WriteDocument
CancelDocument
 
Samples
 
C++
 
// Insert an analytical centre detail (after the other analytical details) for the first manual detail of the current document
short sManualIndex;
bool bWrite = false;

pSales->PrepareDocument (paUpdate);

sManualIndex = pSales->GetManualIndex ();

if (sManualIndex != -1 && pSales->NeedAnaDistrib (sManualIndex, aetCent))
{
    VARIANT vAmountDocC;

    if (pSales->GetDetail (sManualIndex, &vAmountDocC, NULL, NULL, NULL, NULL, NULL))
    {
        pSales->InsertAnaDetail (sManualIndex, -1, aetCent, 0.2*vAmountDocC.dblVal, 0.0, 20.0, 0.0, "CENT", "KIND", "Inserted via SDK", "");
        bWrite = true;
    }
}

if (bWrite)
    pSales->WriteDocument (rmFullReport);
else
    pSales->CancelDocument ();

C#
 
// Insert an analytical centre detail (after the other analytical details) for the first manual detail of the current document
short sManualIndex;
bool bWrite = false;

oSales.PrepareDocument (ePrepareAction.paUpdate);

sManualIndex = oSales.GetManualIndex ();

if (sManualIndex != -1 && oSales.NeedAnaDistrib (sManualIndex, eAnaEntType.aetCent))
{
    object oAmountDocC, oDummy;

    if (oSales.GetDetail (sManualIndex, out oAmountDocC, out oDummy, out oDummy, out oDummy, out oDummy, out oDummy))
    {
        oSales.InsertAnaDetail (sManualIndex, -1, eAnaEntType.aetCent, 0.2*((double)oAmountDocC), 0.0, 20.0, 0.0, "CENT", "KIND", "Inserted via SDK", "");
        bWrite = true;        
    }
}

if (bWrite)
    oSales.WriteDocument (eReportMode.rmFullReport);
else
    oSales.CancelDocument ();

VBS
 
' Insert an analytical centre detail (after the other analytical details) for the first manual detail of the current document
Dim sManualIndex
Dim bWrite

Call oSales.PrepareDocument(paUpdate)

sManualIndex = oSales.GetManualIndex()
bWrite = False

If sManualIndex <> -1 And oSales.NeedAnaDistrib(sManualIndex, aetCent) Then
    Dim oAmountDocC, oDummy

    If oSales.GetDetail(sManualIndex, oAmountDocC, oDummy, oDummy, oDummy, oDummy, oDummy) Then
        Call oSales.InsertAnaDetail(sManualIndex, -1, aetCent, oAmountDocC / 5, 0.0, 20.0, 0.0, "CENT", "KIND", "Inserted via SDK", "")
        bWrite = True
    End If
End If

If bWrite Then
    Call oSales.WriteDocument(rmFullReport)
Else
    Call oSales.CancelDocument()
End If

VB.NET
 
' Insert an analytical centre detail (after the other analytical details) for the first manual detail of the current document
Dim sManualIndex As Short
Dim bWrite As Boolean

oSales.PrepareDocument(ePrepareAction.paUpdate)

sManualIndex = oSales.GetManualIndex()
bWrite = False

If sManualIndex <> -1 And oSales.NeedAnaDistrib(sManualIndex, eAnaEntType.aetCent) Then
    Dim oAmountDocC, oDummy As Object

    If oSales.GetDetail(sManualIndex, oAmountDocC, oDummy, oDummy, oDummy, oDummy, oDummy) Then
        oSales.InsertAnaDetail(sManualIndex, -1, eAnaEntType.aetCent, oAmountDocC / 5, 0.0, 20.0, 0.0, "CENT", "KIND", "Inserted via SDK", "")
        bWrite = True
    End If
End If

If bWrite Then
    oSales.WriteDocument(eReportMode.rmFullReport)
Else
    oSales.CancelDocument()
End If