Skip to content

Interface for ΑΑΔΕ myDATA invoicing REST API. It handles all the boilerplate code for sending, cancelling and requesting invoices.

License

Notifications You must be signed in to change notification settings

firebed/aade-mydata

Repository files navigation

ΑΑΔΕ - AADE myDATA

Latest Version on Packagist Total Downloads GitHub Workflow Status PHP Version Require License

Support This Project

If you find this project useful, you can show your appreciation and support by giving it a ⭐. Your support motivates us to work harder and make even better and more useful tools!

Introduction

This package provides an expressive, fluent interface to ΑΑΔΕ myDATA invoicing REST API. It handles almost all the boilerplate code for sending, cancelling and requesting invoices.

Documentation

Requirements

In order to use this package, you will need first a aade id and a Subscription key. You can get these credentials by signing up to mydata rest api.

Version PHP myDATA Support
^v5.x 8.1 v1.0.10 Active
^v4.x 8.1 v1.0.8 Ended
^v3.x 8.1 v1.0.7 Ended
^v2.x 8.1 v1.0.5 Ended
^v1.x 8.0 v1.0.3 Ended

Installation

To install through Composer, run the following command:

composer require firebed/aade-mydata

Setup

Once you have the user id and the subscription key use the following code to set the environment and the credentials:

$env = "dev"; // For production use "prod"
$user_id = "your-user-id";
$subscription_key = "your-subscription-key";

MyDataRequest::setEnvironment($env);
MyDataRequest::setCredentials($user_id, $subscription_key);

For development, you may need to disable client verification if you are not using https:

MyDataRequest::verifyClient(false);

Send invoice example

use Firebed\AadeMyData\Http\SendInvoices;
use Firebed\AadeMyData\Models\Invoice;
use Firebed\AadeMyData\Exceptions\MyDataException;

// Prepare your invoices, for simplicity we will use an array of empty
// Invoice objects. You should populate these objects with your own data.
$invoices = [new Invoice(), new Invoice()];
$sender = new SendInvoices();

try {
    $responses = $sender->handle($invoices);
    
    $errors = [];
    foreach ($responses as $response) {
        if ($response->isSuccessful()) { 
            // This invoice was successfully sent to myDATA.     
            // Each response has an index value which corresponds
            // to the index (-1) of the $invoices array.
            
            $index = $response->getIndex();
            $uid = $response->getInvoiceUid();
            $mark = $response->getInvoiceMark();
            $cancelledByMark = $response->getCancellationMark();
            $qrUrl = $response->getQrUrl();
    
            // If you need to relate the response to your local invoice
            // $invoice = $invoices[$index - 1];    
    
            print_r(compact('index', 'uid', 'mark', 'cancelledByMark', 'qrUrl'));
        } else {
            // There were some errors for a specific invoice. See errors for details.
            foreach ($response->getErrors() as $error) {
                $errors[$response->getIndex() - 1][] = $error->getCode() . ': ' . $error->getMessage();
            }
        }
    }
} catch (MyDataException $e) {
    // There was a communication error. None of the invoices were sent.
    echo "Σφάλμα επικοινωνίας: " . $e->getMessage();
}

Available methods

Method Availability
Validate VAT Number
SendInvoices
CancelInvoice
RequestDocs
RequestTransmittedDocs
RequestMyIncome
RequestMyExpenses
RequestVatInfo
RequestE3Info
SendPaymentsMethod
SendIncomeClassification In progress
SendExpensesClassification In progress

Digital Client (Car rental, parking/wash, workshops)

Method Availability
SendClient In progress
UpdateClient In progress
RequestClients In progress
CancelClient In progress
ClientCorrelations In progress

Upgrade Guide

If you are upgrading from a previous version, please see upgrade guide

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Licence

AADE myDATA is licenced under the MIT License.

Copyright 2022 © Okan Giritli

About

Interface for ΑΑΔΕ myDATA invoicing REST API. It handles all the boilerplate code for sending, cancelling and requesting invoices.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages