Skip to content

Commit

Permalink
Add new data structure, update API to version 5, add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
itrack committed Feb 11, 2021
1 parent 5502aa5 commit 6503b7c
Show file tree
Hide file tree
Showing 20 changed files with 687 additions and 317 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
Expand Down
72 changes: 50 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Librarie PHP pentru verificarea gratuita a contribuabililor care sunt inregistra

Date care pot fi obtinute:
- Denumire/Adresa companie
- Numar Registrul Comertului
- Numar de telefon
- Platitor/Neplatitor TVA
- Platitor TVA la incasare
- ~~Platitor Split TVA~~ **OUG 23/2017 privind plata defalcată a TVA a fost abrogata incepand cu 1 februarie 2020**
Expand Down Expand Up @@ -35,63 +37,89 @@ $anaf = new \Itrack\Anaf\Client();
### Pentru a verifica doar un CUI foloseste metoda

```php
$cui = "123456";
$cif = "123456";
$dataVerificare = "YYYY-MM-DD";
$anaf->addCui($cui, $dataVerificare);
$anaf->addCif($cif, $dataVerificare);
```


#### Conform exemplului de mai jos:

```php
$cui = "123456";
$cif = "123456";
$dataVerificare = "2019-05-20";
$anaf->addCui($cui, $dataVerificare);
$raspuns = $anaf->getOneResult();
$anaf->addCif($cif, $dataVerificare);
$company = $anaf->first();

// Metode disponibile
echo $company->getName();
echo $company->getCIF();
echo $company->getRegCom();
echo $company->getPhone();

echo $company->getFullAddress();
echo $company->getAddress()->getCounty();
echo $company->getAddress()->getCounty();
echo $company->getAddress()->getStreet();
echo $company->getAddress()->getStreetNumber();
echo $company->getAddress()->getOthers();

echo $company->getTVA()->hasTVA();
echo $company->getTVA()->getTVAEnrollDate();
echo $company->getTVA()->getTVAEndDate();

echo $company->getTVA()->hasTVACollection();
echo $company->getTVA()->getTVACollectionEnrollDate();
echo $company->getTVA()->getTVACollectionEndDate();

echo $company->getTVA()->hasTVASplit();
echo $company->getTVA()->getTVASplitEnrollDate();
echo $company->getTVA()->getTVASplitEndDate();
echo $company->getTVA()->getTVASplitIBAN();

echo $company->getReactivationDate();
echo $company->getInactivationDate();
echo $company->getDeletionDate();
echo $company->isActive();
```

### Pentru a verifica mai multe CUI-uri in acelasi timp foloseste urmeaza exemplul de mai jos:

```php
$anaf->addCui("123456", "2019-05-20");
$anaf->addCui("RO654321"); // Daca data nu este setata, valoarea default va fi data de azi
$raspuns = $anaf->getResults();
$anaf->addCif("123456", "2019-05-20");
$anaf->addCif("RO654321"); // Daca data nu este setata, valoarea default va fi data de azi
$raspuns = $anaf->get();

// SAU

$cuis = [
$cifs = [
"123456",
"RO6543221"
];
$anaf->addCui($cuis, "2019-05-20");
$raspuns = $anaf->getResults();
$anaf->addCif($cuis, "2019-05-20");
$raspuns = $anaf->get();
```

# Exemplu raspuns
![Raspuns ANAF](https://github.com/itrack/anaf/blob/master/response.PNG?raw=true)


# Limite
Poti solicita raspuns pentru maxim 500 de CUI-uri simultan cu o rata de 1 request / secunda.

# Requirements
* PHP >= 5.5
* PHP >= 7.1
* Ext-Curl
* Ext-Json
* Ext-Mbstring

# Tratarea exceptiilor
Din versiunea 2.0.0 am adaugat exceptii pentru tratarea erorilor, pentru a nu afecta mediile de productie te rog sa tratezi aceste exceptii prin try -> catch

Exceptii:
# Exceptii:

* Itrack\Anaf\Exceptions\LimitExceeded - Ai depasit limita de 500 de CUI-uri / request;
* Itrack\Anaf\Exceptions\ResponseFailed - Raspunsul primit de la ANAF nu este in format JSON, exceptia returneaza body-ul raspunsului pentru a fi verificat manual;
* Itrack\Anaf\Exceptions\RequestFailed - Raspunsul primit de la ANAF nu are status de succes, verifica manual raspunsul primit in exceptie.

# Upgrade de la 2 la 3
Versiunea 2 nu este compatibila cu versiunea 3, daca aveti o implementare vechie, trebuie refacuta pentru a fi compatibila.

# Contribuitori
[![Contribuitori](https://contributors-img.firebaseapp.com/image?repo=itrack/anaf)](https://github.com/itrack/anaf/graphs/contributors)

# Linkuri utile
https://blog.turma.ro/api-anaf/ <br>
https://webservicesp.anaf.ro/PlatitorTvaRest/api/v4/
https://webservicesp.anaf.ro/PlatitorTvaRest/api/v5/
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
{
"name": "itrack/anaf",
"type": "library",
"version": "2.0.1",
"version": "3.0.0",
"description": "API ANAF pentru verificarea contribuabililor care sunt inregistrati conform art. 316 din Codul Fiscal",
"authors": [{
"name": "Alex Stoica",
"email": "0x01.alex+github@gmail.com"
}],
"keywords": [
"api anaf",
"verificare tva",
"inregistrat tva",
"api anaf",
"webservie anaf"
"webservie anaf",
"date firma",
"mfinante"
],
"license": [
"MIT"
],
"require": {
"php": ">=5.5",
"php": ">=7.1",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^8.5"
"phpunit/phpunit": "^7.5.20 || ^9.5.2"
},
"autoload": {
"psr-4": {
Expand Down
70 changes: 0 additions & 70 deletions example.php

This file was deleted.

21 changes: 21 additions & 0 deletions examples/getMoreCIFs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
require_once(__DIR__ . "/../vendor/autoload.php");

// Get data about more CIF
$anaf = new \Itrack\Anaf\Client();
$anaf->addCif("14080700");
$anaf->addCif("RO16826034");
$companies = $anaf->get();

foreach ($companies as $company) {
echo $company->getName();
echo $company->getCIF();
echo $company->getRegCom();
echo $company->getPhone();
echo $company->getAddress()->getCounty();
echo $company->getAddress()->getCounty();
echo $company->getAddress()->getStreet();
echo $company->getAddress()->getStreetNumber();

// ... etc
}
18 changes: 18 additions & 0 deletions examples/getOneCIF.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
require_once(__DIR__ . "/../vendor/autoload.php");

// Get data about more CIF
$anaf = new \Itrack\Anaf\Client();
$anaf->addCif("14080700");
$company = $anaf->first();

echo $company->getName();
echo $company->getCIF();
echo $company->getRegCom();
echo $company->getPhone();
echo $company->getAddress()->getCounty();
echo $company->getAddress()->getCounty();
echo $company->getAddress()->getStreet();
echo $company->getAddress()->getStreetNumber();

// ... etc
34 changes: 16 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Anaf Tests Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="API Anaf Tests Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
Binary file removed response.PNG
Binary file not shown.
Loading

0 comments on commit 6503b7c

Please sign in to comment.