Skip to content

Commit

Permalink
Beta Version (#1)
Browse files Browse the repository at this point in the history
* Licenza MIT

* Prova Formato (WIP)

* Wip con DTO

* Wip...

* Wip...

* Clean

* Fix

* Fix

* Fix

* Wip...

* Fix

* Wip...

* Traits

* Trait to Handler

* Wip

* Wip...

* Wip...

* Wip...

* Fix

* Wip...

* Fix

* Fix

* Fix

* Fix

* Fix

* Wip

* Wip...

* Wip...

* Fix

* Fix

* Wip...

* Wip...

* Wip...

* Wip...

* Wip...

* Fix

* Wip

* Wip...

* Wip...

* Wip...

* Wip...

* Wip...

* Fix

* Wip...

* Wip...

* Wip...

* Wip...

* Fix

* Fix

* Testing...

* Fix Pipeline

* Fix Pipeline

* Testing

* Testing...

* Test on Windows

* Less Pipeline

* Wip...

* Wip

* Wip...

* Test Suite

* Docs

* Pipeline...

* Fix Lint

* Fix

* CS Fixing...

* Fix styling changes

* Fix

* Fix styling changes

* Revert "Fix styling changes"

This reverts commit 7ca7cf4.

* Fix

* Revert "Fix styling changes"

This reverts commit 15e8428.

* Revert "CS Fixing..."

This reverts commit 8c16121.

* Wip

* Wip...

* Fix

* Wip...

* Test

* Fix

* Clean

* Fix

* Fix

* Fix

---------

Co-authored-by: apaxio <[email protected]>
  • Loading branch information
AP - Axio Studio and apaxio committed Nov 14, 2023
1 parent 7372bb7 commit d73d27c
Show file tree
Hide file tree
Showing 47 changed files with 1,741 additions and 3 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on: [push, pull_request]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.2, 8.1]
stability: [prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/phpunit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor
composer.lock
.phpunit.result.cache
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to `fattura-elettronica` will be documented in this file

## beta - Versione Beta (2023-11-14)

- Versione iniziale "beta" completa ma con funzionalità "base"
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

Contributions are welcome.

Please read and understand the contribution guide before creating an issue or pull request.

## Etiquette

This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.

Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.

It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.

## Viability

When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.

## Procedure

Before filing an issue:

- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

## Requirements

If the project maintainer has any additional requirements, you will find them listed here.

- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

**Happy coding**!
2 changes: 1 addition & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Axio Studio
Copyright (c) Axio Studio s.r.l.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
116 changes: 114 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,114 @@
# fattura-elettronica
Una libreria Laravel per la generazione dell'XML di una fattura elettronica
# Fattura Elettronica PHP

[![Latest Version on Packagist](https://img.shields.io/packagist/v/axiostudio/fattura-elettronica.svg?style=flat-square)](https://packagist.org/packages/axiostudio/fattura-elettronica)
[![Tests](https://github.com/axiostudio/fattura-elettronica/actions/workflows/tests.yml/badge.svg)](https://github.com/axiostudio/fattura-elettronica/actions/workflows/tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/axiostudio/fattura-elettronica.svg?style=flat-square)](https://packagist.org/packages/axiostudio/fattura-elettronica)

## Introduzione

Fattura Elettronica è un pacchetto PHP che consente di generare all'interno del proprio applicativo, fatture elettroniche in XML compatibili con le seguenti specifiche: https://www.agenziaentrate.gov.it/portale/web/guest/fatturazione-elettronica-e-dati-fatture-transfrontaliere-new

## Requisiti

- Composer 2
- PHP 8.1 o 8.2

## Installazione

Per installare il pacchetto eseguire:

```bash
composer require axiostudio/fattura-elettronica
```

## Utilizzo

Finita l'installazione, per utilizzare il pacchetto è necessario inizializzare la classe:

```php
$fattura = new \Axiostudio\FatturaElettronica\FatturaElettronica();
```

Successivamente bisogna passare i dati necessari al metodo "compose" che ci restituirà un array contente un parametro `fileName` che dichiara il nome del file XML generato e un parametro `fileContent` che contiene in formato string l'XML generato.

Per generare la fattura è necessario richiamare il metodo `compose()` passando al suo interno i dati necessari alla fattura che saranno parsati, computati e convertiti in formato XML secondo le specifiche.

Ricordiamo che il pacchetto è in fase BETA, le specifiche dei vari Model utilizzati saranno documentati nella versione 1.0. Di seguito un esempio di utilizzo:

```php
$fattura = new FatturaElettronica();

$datiTrasmissione = [
'12345678910',
'123'
];

$anagraficaPrestatore = [
'12345678910',
'Fornitore srl'
];

$sedePrestatore = [
'Via Verdi',
'00100',
'Roma',
'RM'
];

$anagraficaCommittente = [
'12345678911',
'Cliente srl'
];

$sedeCommittente = [
'Via Puccini',
'20100',
'Milano',
'MI'
];

$datiGeneraliDocumento = [
'123',
'2021-01-01',
'345.22'
];

$datiGenerali = [$datiGeneraliDocumento];

$dettaglioPagamento = ['345.22'];

$datiDatiPagamento = [$dettaglioPagamento];

$dettaglioLinee = [
['Articolo di riga 1', '100.50'],
['Articolo di riga 2', '100.50'],
['Articolo di riga 3', '100.00', '1', 'pz', '0.00', 'N2.1'],
];

$datiRiepilogo = [
['201.00', '22.00'],
['100.00', '0.00', 'N2.1'],
];

$datiXml = $fattura->compose(
$datiTrasmissione,
$anagraficaPrestatore,
$sedePrestatore,
$anagraficaCommittente,
$sedeCommittente,
$datiGenerali,
$datiDatiPagamento,
$dettaglioLinee,
$datiRiepilogo
);

var_dump($datiXml);
```

## Note

Questo pacchetto è in versione BETA, per supporto o bug utilizzare le Issue di Github, per collaborare invece è sufficente aprire un PR con le specifiche dell'integrazione eseguita.

## Credits

Questo pacchetto è stato creato ed è mantenuto da Axio Studio, per maggiori informazioni: https://axio.studio.
50 changes: 50 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "axiostudio/fattura-elettronica",
"description": "Pacchetto per la gestione della fatturazione elettronica in PHP.",
"keywords": [
"axiostudio",
"fattura-elettronica",
"xml",
"php",
"italia",
"package",
"fattura",
"PA",
"Laravel",
"Backend"
],
"homepage": "https://github.com/axiostudio/fattura-elettronica",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Axio Studio",
"email": "[email protected]"
}
],
"require": {
"php": "^8.1|^8.2",
"spatie/array-to-xml": "^3.2",
"symfony/validator": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
"Axiostudio\\FatturaElettronica\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Axiostudio\\FatturaElettronica\\Tests\\": "tests"
}
},
"scripts": {
"test": "vendor/bin/phpunit"

},
"config": {
"sort-packages": true
}
}
13 changes: 13 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Fattura Elettronica">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
11 changes: 11 additions & 0 deletions src/Abstracts/Model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Axiostudio\FatturaElettronica\Abstracts;

use Axiostudio\FatturaElettronica\Contracts\Model as ModelInterface;
use Axiostudio\FatturaElettronica\Handlers\Model as ModelHandler;

abstract class Model implements ModelInterface
{
use ModelHandler;
}
12 changes: 12 additions & 0 deletions src/Contracts/Model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Axiostudio\FatturaElettronica\Contracts;

use Symfony\Component\Validator\Mapping\ClassMetadata;

interface Model
{
public function __construct(...$args);

public static function loadValidatorMetadata(ClassMetadata $metadata): void;
}
Loading

0 comments on commit d73d27c

Please sign in to comment.