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

omsætningsstatistik

0

Hello

How to create statistic like, you can in the report tap:

Omsætningsstatistik

varer

created Dec 14, 2015 by bahn
0% Accept Rate
Q 10 A 10 C 5
i am trying with this:
<pre>
$InvoiceHandles = $client->Invoice_FindByDateInterval(array('first' => $date_start, 'last' =>  $date_end))->Invoice_FindByDateIntervalResult;
        $num_orders = count($InvoiceHandles->InvoiceHandle);
print_r($InvoiceHandles);
echo "<hr>";
foreach ($InvoiceHandles->InvoiceHandle as $i => $Invoice)
{
       
$invoiceHandle = $client->Invoice_FindByNumber(array('number' => $Invoice->Number))->Invoice_FindByNumberResult;
   
   
    $InvoiceLineHandle = $client->Invoice_GetLines(array('invoiceHandle'=>$invoiceHandle))->Invoice_GetLinesResult;

    if(is_array($InvoiceLineHandle->InvoiceLineHandle))
    {
        $InvoiceLinesDataObjects = $client->InvoiceLine_GetDataArray(array('entityHandles' => $InvoiceLineHandle))->InvoiceLine_GetDataArrayResult->InvoiceLineData;
    }
    else
    {
        $InvoiceLinesDataObjects[] = $client->InvoiceLine_GetDataArray(array('entityHandles' => $InvoiceLineHandle))->InvoiceLine_GetDataArrayResult->InvoiceLineData;
    }
    foreach ($InvoiceLinesDataObjects as $i => $InvoiceLineData)
    {
        if ($_GET['number'] == $InvoiceLineData->ProductHandle->Number && $InvoiceLineData->InvoiceHandle->Number == $Invoice->Number)
        {
        $antal_solgt = $InvoiceLineData->Quantity+$antal_solgt;
       
        }
        //echo   "fak nr: ".$InvoiceLineData->InvoiceHandle->Number." ". $InvoiceLineData->ProductHandle->Number." - ".$InvoiceLineData->Quantity."stk. a".$InvoiceLineData->TotalNetAmount."<p>";
       
    }
}   

    echo $_GET['number']. " er solgt ". $antal_solgt ." gange mellem ".$date_start." og " .$date_end;
</pre>
it toke aboute 10 min to go trough 5777 invoices
a found 183 times the number i was searching for,
There has got to be a better way

1 Answer

0

Hi bahn

What is slowest in your current method is likely the loop where you get the linehandles for each invoice.
You might want to look at InvoiceLine_FindByProductList instead if you're looking up one or more products at a time.. Over all you should probably go for subsets or at least get your data in increments.

 

answered Dec 15, 2015 by olej
Over all you should probably go for subsets or at least get your data in increments.
Can you give me a working php example

what i want i can best describe by a mysql query

SELECT SUM(quantity) FROM invoiceline WHERE 1 and Number = '1519-9001-52' AND date BETWEEN '20140101T00:00:00' AND 20151231T23:59:59 GROUP BY Number
Visma e-conomic A/S
...