Skip to content

datomatic/laravel-fatture-in-cloud

Repository files navigation

Laravel-Fatture-in-Cloud-DarkLaravel-Fatture-in-Cloud-Light

Laravel wrapper for Fatture in Cloud API v2

Latest Version on Packagist GitHub Code Style Action Status Total Downloads


This Laravel wrapper allows you to integrate Fatture in Cloud using Api v2.

Requirements

  • Laravel >= 8.37
  • PHP >= 8.1
  • ext-json

Installation

You can install the package via composer:

composer require datomatic/laravel-fatture-in-cloud

Optionally, you can publish the config file with:

php artisan vendor:publish --provider="Datomatic\FattureInCloud\FattureInCloudServiceProvider" --tag="fatture-in-cloud-config"

This is the contents of the published config file:

return [
    'access_token'  => env('FATTURE_IN_CLOUD_ACCESS_TOKEN'),
    'company_id'  => env('FATTURE_IN_CLOUD_COMPANY_ID'),
    'endpoint' => env('FATTURE_IN_CLOUD_ENDPOINT','https://api-v2.fattureincloud.it/'),
];

PS: to obtain company_id please see this article.

Usage

Get FattureInCloud class from service container or using FattureInCloud Facade.

use Datomatic\FattureInCloud\Facades\FattureInCloud;
//Facade
FattureInCloud::invoices()->...

use Datomatic\FattureInCloud\FattureInCloud;

//Automatic Injection
public function __construct(FattureInCloud $fic){}

//Resolve
$fic = App::make(FattureInCloud::class);
$fic = app(Datomatic\FattureInCloud\FattureInCloud::class);

Use the Fatture In Cloud utilities classes

$fic->clients()->create([... user array...]);

Please see the functionalities and the array to pass on Official Documentation.

The resources covered are:

  • user()
  • info()
  • products()
  • clients()
  • suppliers()
  • invoices()
  • quotes()
  • proformas()
  • receipts()
  • deliveryNotes()
  • creditNotes()
  • orders()
  • selfOwnInvoices()
  • selfSupplierInvoices()
  • invoices()
  • work_reports()
  • supplierOrders()
  • expenses()
  • passiveCreditNotes()
  • passiveDeliveryNotes()
  • paymentAccounts()
  • paymentMethods()

Each resource has the same methods available:

  • all(array $data = [])
  • create(array $data)
  • edit(int $id, array $data)
  • delete(int $id, array $data = [])
  • getById(int $id, array $data = [])

The methods will return an array with the response from Fatture in Cloud API (except for the delete method that may return null).

For example, to fetch all clients (according to Official Documentation) you should call:

$fic->clients()->all(['fieldset' => 'detailed'])

Enums

To improve the use of api usage is included a comfortable list of utilities enums:

  • DocumentStatus
  • EntityType
  • IssuedDocumentType
  • ReceivedDocumentType
  • PaymentStatus

Utilities

The Fatture in CLoud API accept only a fullname on country field 🤦‍♂️ so i add a Datomatic\FattureInCloud\Utilities\CountryConverter utility class with fromAlpha2 and fromName methods.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Laravel wrapper for Fatture in Cloud API v2

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages