firebed / aade-mydata

Interface for ΑΑΔΕ myDATA invoicing REST API. It handles all the boilerplate code for sending, cancelling and requesting invoices.
https://docs.invoicemaker.gr/getting-started
MIT License
50 stars 20 forks source link

Usage of $expensesClassifications = $requestedDoc->getExpensesClassifications(); #18

Closed imneckro closed 4 months ago

imneckro commented 4 months ago

Hello there. Could you please help me how to use

$expensesClassifications = $requestedDoc->getExpensesClassifications();

in the below example:

use Firebed\AadeMyData\Enums\InvoiceType;
use Firebed\AadeMyData\Exceptions\MyDataException;
use Firebed\AadeMyData\Http\RequestDocs;

MyDataRequest::init($user_id, $subscription_key, $env);
MyDataRequest::verifyClient(false);

    $invoices = [];
    $request = new RequestDocs();
    try {        
        $continuationToken = null;
        do {
            $response = $request->handle(
                dateFrom: $dateFrom,
                dateTo: $dateTo,
                nextPartitionKey: $continuationToken?->getNextPartitionKey(),
                nextRowKey: $continuationToken?->getNextRowKey()
            );
            $checkifempty = $response->getInvoices();
            if($checkifempty!=null && $checkifempty!="undefined"){
            $invoices = array_merge($invoices, $response->getInvoices()->all());
            }else{
                $invoices = $invoices;
            }
            $continuationToken = $response->getContinuationToken();
        } while ($continuationToken);
    } catch (MyDataException $e) {
           die($e->getMessage());
 }

foreach ($invoices as $invoice){
       //......do something
}

Thanks in advance

firebed commented 4 months ago

The $response variable you got back is actually a type of RequestedDoc. So you can do $response->getExpensesClassifications

imneckro commented 4 months ago

It returns empty result even though expensesclassifications exist for the specific period of time.

firebed commented 4 months ago

Can you confirm that the response xml contains such data? You can get the xml by $request->getResponseXml()

imneckro commented 4 months ago

No, response $xml from $request->getResponseXml() does not even contain child nodes for expsenses classification.

The $request->getResponseXml() though, doesnt accept ->handle(dateFrom: $dateFrom,dateTo: $dateTo) and as a result of that returns only a few results.

firebed commented 4 months ago

The xml returned from the $request->getResponseXml() is the xml directly from mydata and it is not altered in any way. If this xml doesn't contain expense classifications then probably you don't have any.