API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Fastest way of receiving all open invoices

0
Hi

We need to generate a list of all open invoices on all debtors.

I have created this loop, that is working, but is Terrible slow. How can I do this faster?

'Container for the invoices:
Dim invoices As New Dictionary(Of Integer, Economic.Api.IInvoice)

 For Each deb As Economic.Api.IDebtor In Me.getDeptorGroup().GetDebtors()
            For Each inv As Economic.Api.IInvoice In deb.GetInvoices()
                If inv.Remainder  0 Then '=kun ikke lukkede!
                    If Not (invoices.ContainsKey(inv.Number)) Then
                        invoices.Add(inv.Number, inv)
                    End If
                End If
            Next
created Jul 16, 2012 by koldstar
0% Accept Rate
Q 6 A 2 C 0

1 Answer

0
You should collect data instances. Every time you ask: inv.Remainder  0 the API will make a round trip to the server = slow...

Try getting your invoice data instances for each debtor:
(in C#)

IDebtorGroup _group = // your debtor group
IDebtor Debtors = _groupGetDebtors();
                   
foreach (IDebtor debtor in Debtors)
{
    IInvoice _invoices = debtorGetInvoices();
    IInvoiceData _invoiceData = sessionInvoiceDataGetDataArray(_invoices);

    foreach (IInvoiceData _data in _invoiceData)
    {
        if (_dataRemainder != 0)
        {
            // Add to dictionary
        }
    }
}
answered Aug 16, 2012 by KiaerInnologic
Visma e-conomic A/S
...