Code Monkey home page Code Monkey logo

fatture-in-cloud-sdk's Introduction

Fazland - FattureInCloud SDK

Build Status

Unofficial PHP SDK for FattureInCloud.it

Requirements

  • php ^7.1
  • giggsey/libphonenumber-for-php ^8.10
  • php-http/discovery ^1.4
  • php-http/message" ^1.7
  • php-http/message-factory ^1.0
  • psr/cache-implementation ^1.0
  • psr/http-client-implementation ^1.0
  • psr/http-message-implementation ^1.0
  • psr/log ^1.0
  • moneyphp/money ^3.1

Installation

The suggested installation method is via composer:

$ composer require fazland/fatture-in-cloud-sdk

Using FattureInCloud SDK

Work in progress

Test

Run

$ vendor/bin/phpunit

Contributing

Contributions are welcome. Feel free to open a PR or file an issue here on GitHub!

License

FattureInCloud SDK is licensed under the MIT License - see the LICENSE file for details.

fatture-in-cloud-sdk's People

Contributors

alekitto avatar alxy avatar dlondero avatar giovannialbero1992 avatar massimilianobraglia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fatture-in-cloud-sdk's Issues

Some issues

While using this SDK, I found some issues:

  1. I used the GuzzleHttp client with the base_uri set to https://api.fattureincloud.it/v1/. Unfortuantely, in your code you preprend the API calls with a slash (e.g. here) making these absolute URLs. What that means is that the /v1 part is stripped from the URL resulting in an invalid call. This may be a different story with another client implementation - which one do you use?
  2. How can I update existing entities? The save and delete methods in your code assume that the $client variable is set. However, this is only the case after creating an object via the API. There is no chance to set the client variable, as it is private.

If I find something else, I will update this list. Anyhow, thanks for publishing this SDK :)

Rivalsa mancante

Salve, sarebbe interessante e utile avere il campo 'rivalsa' per poter impostare una percentuale di rivalsa inps nei documenti.

Roadmap

From the official documentation: https://api.fattureincloud.it/v1/documentation/dist
Here's the list of what is missing in this library.

Resources

Product

  • Product list
  • Product new/edit
  • Product delete
  • Product bulk insert

Document

  • Documents Info
  • Document email sending

Purchase

  • Purchase list
  • Purchase new/edit
  • Purchase delete

Fee

  • Fee list
  • Fee new/edit
  • Fee delete

Warehouse

  • Arrival list
  • Arrival detail

Email

  • Email archive list

Info

  • Misc data

Documentation

  • Everything

Tests

  • Everything ๐Ÿ˜„

API interface for Goods

Can you also add the API interface for Good entities? I was able to create my own API\Good class, but I think it makes sense to have this as well in the package.

The use case is the following: We manage customers and products in our custom CRM, but do the accounting stuff (invoices) directly on the fatture in cloud website.

Amount must be an integer(ish) value

Document::fromArray which is called after getting a document or creating a new one (returned value is a new objected created from response in order to have all computed values filled from FIC) is already multiplying * 100 all amounts to work with integers. This of course is great when working with amounts, also makes happy Money constructor.

Unfortunately FIC api response sends back floats with a precision of 4 digits. Multiplying by 100 does not give us an integer as expected but leaves us a float. Example we get 32.9644 in the response, we multiply new Money($item['prezzo_netto'] * 100, $this->currency), we have now 3296.44 which is passed to Money constructor.

There a Money\Number object is created in order to check if the amount passed is an integer or not and unfortunately in our case we still have a decimal part:

if (filter_var($amount, FILTER_VALIDATE_INT) === false) {
    $numberFromString = Number::fromString($amount);
    if (!$numberFromString->isInteger()) {
        throw new \InvalidArgumentException('Amount must be an integer(ish) value');
    }

    $amount = $numberFromString->getIntegerPart();
}

This affects only Document so far and a quick fix would be to round down amounts to a precision of 2 digits (keeping PHP_ROUND_HALF_UP mode) before multiplying by 100:

new Money(round($item['prezzo_netto'], 2) * 100, $this->currency)

EDIT:
However this approach would work for most cases (currencies with subunits down to cents) it wouldn't work for other cases like JPY, ISK (just to mention two) without cents or TND which goes down to milim (1/1000).

Knowing that it would be good to get the subunit for a currency in order to know how to round it and how to multiply it to get an integer. Below example:

$eur = new Currency('EUR');
$subUnit = (new ISOCurrencies())->subunitFor($eur);
$amount = new Money(round($item['prezzo_netto'], $subUnit) * (10 ** $subUnit), $this->currency)

This would cover all currencies! @alekitto what do you think?

Add cs lint to pipeline

Cs check should run on every commit/PR.

GitHub actions should be used to run the linter while travis executes the tests.

Roadmap

@alekitto Are you planning to add support for all the other end points of the API? Thinking to products, purchases, mail, info, etc... Maybe you could open some issues where to discuss that and then someone could pick up, I could help with that.

Add `giacenza_iniziale` to Good

I am afraid that this is another inconsistency in the API, but I just realized the Good class does not contain the giacenza_iniziale attribute, which is documented here.

On the other hand, it does contain another attribute quantita, which I expect is used in the invoice context (which we do not use). Do you see any issue adding the initial stock attribute to the model class?

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.