Coder Social home page Coder Social logo

fattureincloud / fattureincloud-php-sdk Goto Github PK

View Code? Open in Web Editor NEW
26.0 6.0 7.0 2.07 MB

Fatture in Cloud SDK (Software Development Kit) for PHP

Home Page: https://www.fattureincloud.it

License: MIT License

JavaScript 0.01% PHP 99.99%
php php-library fattureincloud fatture-in-cloud guzzlehttp guzzle sdk rest-api fatturazione-elettronica fatturazione

fattureincloud-php-sdk's People

Contributors

barcigabri avatar emajo avatar fattureincloud-bot avatar valmoz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fattureincloud-php-sdk's Issues

`listPaymentMethods()` doesn't return `PaymentMethodDetails`

Describe the bug
When calling InfoApi::listPaymentMethods() the expected payload should carry a filled details key (when such object is populated).
It returns a details => null instead:

$infoApi->listPaymentMethods($companyId)->getData(); // Returns FattureInCloud\Model\PaymentMethod[]

When plucking out a PaymentMethod which has details set in company settings (on the web interface):

[
  "id" => 2047125,
  "name" => "Test",
  "is_default" => false,
  "default_payment_account" => null,
  "details" => null, // <-------------- This should not be `null` as it's filled correctly in the web interface
  "bank_iban" => null,
  "bank_name" => null,
  "bank_beneficiary" => null,
  "ei_payment_method" => null,
]

Env info
Please, provide us with the following details:

  • PHP: 8.1
  • PHP SDK version: latest as of the date the isse has been opened

To Reproduce
Please, share with us (if applicable):
Follow what's in Describe the bug section.

not working after install via composer

Describe the bug
I install the package via composer and not work!
How i can add in my code the library (to replace require_once(DIR . '/vendor/autoload.php'); )?
Must be have this line use FattureIncloud/xxxxxx

Get Subscription Account Info

Is there an API Call which we can get informations about user active subscription?

  • Subscription Plan name
  • Subscription expire date
  • Subscription annual documents number

PHP Docs: Wrong reference for `EmailSchedule` `sender_id` param

Describe the bug
Documentation for the PHP-SDK has a typo in the array given as the argument for EmailSchedule class:
Ref: https://developers.fattureincloud.it/docs/guides/invoice-creation/#-send-the-document (make sure to pick PHP as the SDK).

$email = new EmailSchedule(
    [
        "senderId" => 0,
        "recipient_email" => "[email protected]",
        "subject" => "Nostra fattura nr. 54321",
        "body" => "Gentile xxxxx,<br>per visualizzare la nostra&nbsp;<b>fattura nr. 54321&nbsp;</b>o per scaricarne una copia in versione&nbsp;PDF prema sul bottone sottostante.<br><br>{{allegati}}<br><br>Cordiali saluti,<br><b>Ino S.p.A</b>",
        "include" =>
            [
                "document" => true,
                "delivery_note" => false,
                "attachment" => false,
                "accompanying_invoice" => false
            ],
        "attach_pdf" => false,
        "send_copy" => false
    ]
);

"senderId" => 0, should in fact be sender_id instead.

If you try to run the code that's given in docs, the API will return a 422 error:

[422] Client error: `POST https://api-v2.fattureincloud.it/c/REDACTED/issued_documents/REDACTED/email` resulted in a `422 Unprocessable Entity` response:
{"error":{"message":"Invalid request.","validation_result":{"data.sender_id":["The data.sender id field is required when (truncated...)

Custom template not listed

Describe the bug
With the command $fattureInCloud->info()->listTemplates() we can't see our custom template we created on Fatture in cloud web gui.

Env info
Please, provide us with the following details:

  • PHP version 8.0
  • PHP SDK version latest

To Reproduce
$fattureInCloud->info()->listTemplates()

Expected behavior
Show our custom templates

Modify Issued Document fails without emitting anything

Describe the bug
A call to $documentsApi->modifyIssuedDocument with malformed parameters fails silently without emitting warnings, errors, or throwing exceptions

Env info

  • PHP 7.2
  • SDK 2.0.16

To Reproduce

  • $result = $documentsApi->modifyIssuedDocument($this->company_id, $document_id, $request)->getData();, where the request is created with some invalid parameters (eg: adding/deleting/updating items without also updating the payment amount)

Expected behavior
An ApiException is thrown with, for instance,"Il totale dei pagamenti non corrisponde al totale da pagare." as a message.

Additional context
Also, it would be very convenient to have the fix_payments options also in the modifying requests.

Entity senza chiave primaria?

Salve, ho una domanda: come è possibile che ci siano alcune entity (associate a fatture) senza l'id. Qual è la chiave primaria su cui fare affidamento? Posso usare il name?
Grazie.

Error on fetchToken with oauth2

Describe the bug
Getting error when use OAuth2 fetchToken method.

Env info

  • PHP version: 7.4.27
  • PHP SDK version: 2.0.13

To Reproduce
Example code

$code = request()->code;
$redirectUri = "http://localhost:8000/api/grant";
$oauth = new OAuth2AuthorizationCodeManager("CLIENT_ID", "CLIENT_SECRET", $redirectUri);
$tokenObj = $oauth->fetchToken($code);
$accessToken = $tokenObj->getAccessToken();
$refreshToken = $tokenObj->getRefreshToken();
  • Error status and message
    Client error: POST https://api-v2.fattureincloud.it/oauth/token resulted in a 400 Bad Request response:
    {"error":"invalid_request","error_description":"The grant type field is required."}
    {"exception":"[object] (GuzzleHttp\Exception\ClientException(code: 400): Client error: POST https://api-v2.fattureincloud.it/oauth/token resulted in a 400 Bad Request response:
    {"error":"invalid_request","error_description":"The grant type field is required."}

Expected behavior
Working fetchToken.

Additional context
I think the problem is in the method fetchToken at line 176 of OAuth2AuthorizationCodeManager.php, where the $body not includes key 'json', like it is described on Vanilla documentation (https://developers.fattureincloud.it/docs/authentication/code-flow/vanilla-code#3%EF%B8%8F%E2%83%A3-obtain-the-access-token)

Creare una fattura da cliente esistente

Buongiorno

Purtroppo non trovo alcun riferimento su come creare una fattura con dati di un cliente esistente.

La vostra SDK prevede solo il setEntity per la creazione di nuovi clienti (se non sbaglio)

Nella vecchia versione c'era la funzione "autocompila_anagrafica" che non ritrovo qui

Incongrunenza tra tipo atteso e tipologia del parametro passato

\FattureInCloud\Model\IssuedDocument::setType si aspetta \FattureInCloud\Model\IssuedDocumentType|null:

    /**
     * Sets type
     *
     * @param \FattureInCloud\Model\IssuedDocumentType|null $type type
     *
     * @return self
     */
    public function setType($type)
    {
        $this->container['type'] = $type;

        return $this;
    }

Ma gli viene passata una string (vedi documentazione)

$invoice = new IssuedDocument;
$invoice->setType(IssuedDocumentType::INVOICE);

In quanto le costanti sono stringhe:

class IssuedDocumentType
{
    /**
     * Possible values of this enum
     */
    const INVOICE = 'invoice';

    const QUOTE = 'quote';

    const PROFORMA = 'proforma';

    const RECEIPT = 'receipt';

Missing permanent token and mismatch between examples and schemas in API reference docs

Describe the bug
The permanent_token field is present in the responses examples for creation, retrieval and modification of issued documents, but it is not present in the related docs schemes and SDK.

Previously (API v1), the id of the issued documents changes at each modification of the data requiring the use of the permanent token.

Now (API v2) the permanent token is no longer accessible, and even if the id remains the same, it makes it impossible to transition from API v1 to v2 without creating disruption to our customers.

Env info
Please, provide us with the following details:

  • PHP 7.3.32
  • PHP SDK 2.0.16

To Reproduce
Not applicable.

Expected behavior
The documentation should be aligned and the permanent_token should be accessible from the SDK, otherwise it becomes impossible to transition to v2 for non-finalized documents, or for documents for which a subsequent modification is made through the API.

I understand it's a major version transition, but I don't think you've overlooked that, so let me know if I've missed anything.

Errore di non autorizzazione 401 lista clienti

Describe the bug
Dal 9 di gennaio quando provo ad accedere alla lista clienti ottengo un errore "401 non autorizzato"

Env info

  • PHP 8.0.30
  • PHP SDK 2.0.24

To Reproduce
Eseguo una chiamata per avere la lista dei clienti ma ottengo un errore 401

$companies = $userInstance->listUserCompanies();
if (empty($companies->getData()->getCompanies())){
return;
}
$companyId = $companies->getData()->getCompanies()[0]->getId();

$cont_pagina = 1;
$listaClienti = [];

	do {
		try {
			$resClienti = $clientInstance->listClients($companyId, null, null, null, $cont_pagina, 100);
		} catch (Exception $e) {
return;
}

[401] Client error: GET https://api-v2.fattureincloud.it/c/944984/entities/clients?page=1&per_page=100 resulted in a 401 Unauthorized response:
{"error":"unauthorized","error_description":"The given user is not authorized to use this application."}

Mostro alcuni screenshot:
image

image

image

how use create_client_request

How i can send client data (as name, cf, phone) with CreateClientRequest ?

$apiInstance = new FattureInCloud\Api\ClientsApi(
// If you want use custom http client, pass your client which implements GuzzleHttp\ClientInterface.
// This is optional, GuzzleHttp\Client will be used as default.
new GuzzleHttp\Client(),
$config
);
$create_client_request = new \FattureInCloud\Model\CreateClientRequest; // \FattureInCloud\Model\CreateClientRequest | The client to create

try {
$result = $apiInstance->createClient($company_id, $create_client_request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ClientsApi->createClient: ', $e->getMessage(), PHP_EOL;
}

Invalid value 'manual_accepted' for 'ei_status'

Describe the bug
I valori di stato documento manual_accepted e (suppongo) manual_rejected non sono visti come validi

Env info
Php 7.4
sdk v2.0.13

To Reproduce
Nel recuperare l'elenco delle ultime fatture emesse:

$apiInstance = new IssuedDocumentsApi(new Client(), $this->config);
$all = $apiInstance->listIssuedDocuments($this->companyId, IssuedDocumentType::INVOICE, "id,ei_status,date", null, "-date", null, 10)->getData();

image

create issued document with vat model retreived from endpoint

Describe the bug
Invoice creation issue

To Reproduce
Get the vatType "GET /c/{company_id}/info/vat_types" with id 0 (for italy), then use the VatType object as it is to create an invoice.

Client error: POST https://api-v2.fattureincloud.it/c/9999999/issued_documents resulted in a 422 Unprocessable Entity response:
{"error":{"message":"Invalid request.","validation_result":{"data.items_list.0.vat.notes":["The data.items list.0.vat.no (truncated...)
{"exception":"[object] (FattureInCloud\ApiException(code: 422): [422] Client error: POST https://api-v2.fattureincloud.it/c/99999999/issued_documents resulted in a 422 Unprocessable Entity response:
{"error":{"message":"Invalid request.","validation_result":{"data.items_list.0.vat.notes":["The data.items list.0.vat.no (truncated...)
at /var/www/html/vendor/fattureincloud/fattureincloud-php-sdk/lib/Api/IssuedDocumentsApi.php:206)

Expected behavior
Invoice creation or an error message not truncated.

Return 500 on createClient

Describe the bug
return a 500 on entities/clients
{"error":{"message":"An unexpected error occurred. Contact support for more information."}}
Env info
Please, provide us with the following details:

  • PHP version 8.1
  • PHP SDK version 2.0.16

Expected behavior
Create a client on FIC or return an error not a 500

data.items_list.0.discount can't be null, discording with API Reference

Describe the bug
A clear and concise description of what the bug is.
POST https://api-v2.fattureincloud.it/c/company_id/issued_documents resulted in a 422 Unprocessable Entity response:
{"error":{"message":"Invalid request.","validation_result":{"data.items_list.0.discount":["The data.items list.0.discoun

From API Reference
discount: number┃null Discount percentual value.
But when is set to null we receive a 422

Env info

  • PHP version 8.0
  • PHP SDK version latest

To Reproduce
Create an invoice with discount null

Expected behavior
Creation of an invoice

Fatture - Campo 2.1.1.1 - TipoDocumento

Buongiorno a tutti,
all'interno di un'integrazione custom tra uno dei nostri SW e Fatture in Cloud abbiamo la necessità di specificare, nella chiamata di creazione di una fattura (POST /c/{company_id}/issued_documents), il campo 2.1.1.1 - TipoDocumento.

Tale campo è modificabile da interfaccia FiC nella sezione "Attributi avanzati" del blocco Fatturazione elettronica mentre all'interno del SDK o della documentazione API non riesco a trovare riferimenti al campo in questione.
Mi aspettavo di trovarlo nella classe FattureInCloud\Model\IssuedDocumentEiData ma vedo che non è presente.

Potreste indicarmi se tale campo è esposto nella rotta API oppure se ne è prevista la futura implementazione?

Grazie

Fatture - Implementazione sconto con importo fisso sulla singola riga di dettaglio

Buongiorno a tutti,
nella rappresentazione tabellare del tracciato Fattura PA, è indicato che, all'interno degli N elementi della sezione "2.2 DatiBeniServizi" per il blocco 2.2.1.10 ScontoMaggiorazione, è necessario specificare almeno uno tra gli elementi "2.2.1.10.2 Percentuale" o "2.2.1.10.3 Importo", fornendo quindi la possibilità di inserire uno sconto percentuale oppure uno sconto con importo fisso:

Se valorizzato, viene controllato che esista almeno uno dei due elementi 2.2.1.10.2 Percentuale e 2.2.1.10.3 Importo

All'interno dell'SDK, nella classe IssuedDocumentItemsListItem, il campo "discount" è unico e di fatto corrisponde al campo di sconto percentuale, non permettendo quindi di inserire uno sconto con importo fisso.

L'introduzione dello sconto con importo fisso sulla singola riga di dettaglio è prevista come futura implementazione?

Grazie

Implement `salva_anagrafica` and `autocompleta_anagrafica`

Currently Api v2 does not support the salva_anagrafica and autocompleta_anagrafica options on IssuedDocument endpoints to automatically save and fetch entity information, it would be very useful to implement it, as it makes transition from v1 to v2 much easier

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.