An open API service indexing awesome lists of open source software.

https://github.com/firebed/aade-mydata

Interface for ΑΑΔΕ myDATA invoicing REST API. It handles all the boilerplate code for sending, cancelling and requesting invoices.
https://github.com/firebed/aade-mydata

aade mydata php8 restapi

Last synced: 12 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# ΑΑΔΕ - AADE myDATA

[![Latest Version on Packagist](https://img.shields.io/packagist/v/firebed/aade-mydata.svg?style=flat-square)](https://packagist.org/packages/firebed/aade-mydata)
[![Total Downloads](https://poser.pugx.org/firebed/aade-mydata/downloads)](https://packagist.org/packages/firebed/aade-mydata)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/firebed/aade-mydata/php.yml)
[![PHP Version Require](https://poser.pugx.org/firebed/aade-mydata/require/php)](https://packagist.org/packages/firebed/aade-mydata)
[![License](https://poser.pugx.org/firebed/aade-mydata/license)](LICENSE.md)

## 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

- Official documentation is available 👉 [on our documentation site](https://docs.invoicemaker.gr/getting-started)
- myDATA webpage: [AADE myDATA](https://www.aade.gr/mydata)
- myDATA documentation (PDF): [AADE myDATA REST API v1.0.10](https://www.aade.gr/sites/default/files/2024-12/myDATA%20API%20Documentation%20v1%20.0.10_official_erp.pdf)

## 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.

- Development: [Sign up to mydata development api](https://mydata-dev-register.azurewebsites.net/)
- Production: [Sign up to mydata production api](https://www.aade.gr/mydata)
- guzzlehttp/guzzle >= 7.0

| 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:

```php
$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:

```php
MyDataRequest::verifyClient(false);
```

## Send invoice example

```php
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](http://docs.invoicemaker.gr/http/search-vat) | :white_check_mark: |
| [SendInvoices](http://docs.invoicemaker.gr/http/send-invoices) | :white_check_mark: |
| [CancelInvoice](http://docs.invoicemaker.gr/http/cancel-invoice) | :white_check_mark: |
| [RequestDocs](http://docs.invoicemaker.gr/http/request-docs) | :white_check_mark: |
| [RequestTransmittedDocs](http://docs.invoicemaker.gr/http/request-transmitted-docs) | :white_check_mark: |
| [RequestMyIncome](http://docs.invoicemaker.gr/http/request-my-income) | :white_check_mark: |
| [RequestMyExpenses](http://docs.invoicemaker.gr/http/request-my-expenses) | :white_check_mark: |
| [RequestVatInfo](http://docs.invoicemaker.gr/http/request-vat-info) | :white_check_mark: |
| [RequestE3Info](http://docs.invoicemaker.gr/http/request-e3-info) | :white_check_mark: |
| [SendPaymentsMethod](http://docs.invoicemaker.gr/http/send-payments-method) | :white_check_mark: |
| [SendIncomeClassification](http://docs.invoicemaker.gr/http/send-income-classification) | :white_check_mark: |
| [SendExpensesClassification](http://docs.invoicemaker.gr/http/send-expenses-classification) | :white_check_mark: |

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

| Method | Availability |
|-------------------------------------------------------------------------------|--------------|
| [SendClient](http://docs.invoicemaker.gr/http/dcl/SendClient) | In progress |
| [UpdateClient](http://docs.invoicemaker.gr/http/dcl/UpdateClient) | In progress |
| [RequestClients](http://docs.invoicemaker.gr/http/dcl/RequestClient) | In progress |
| [CancelClient](http://docs.invoicemaker.gr/http/dcl/CancelClient) | In progress |
| [ClientCorrelations](http://docs.invoicemaker.gr/http/dcl/ClientCorrelations) | In progress |

## Upgrade Guide

If you are upgrading from a previous version, please see [upgrade guide](docs/upgrade-guide.md)

## Testing

```shell
composer test
```

## Contributing

Please see [CONTRIBUTING](http://docs.invoicemaker.gr/contributing) for details.

## Licence

AADE myDATA is licenced under the [MIT License](LICENSE.md).

Copyright 2022 © Okan Giritli