condividendo/laravel-fatturapa

v0.2.0 2022-12-08 14:46 UTC

This package is auto-updated.

Last update: 2024-04-08 18:01:18 UTC


README

Latest Version MIT License

This package allows you to generate the XML of Italian eInvoice (aka FatturaPA).

Useful links:

Installation

composer require condividendo/laravel-fatturapa

Usage

$invoice = \Condividendo\FatturaPA\FatturaPA::build()
    ->senderId('IT', '01879020517')
    ->transmissionFormat(\Condividendo\FatturaPA\Enums\TransmissionFormat::FPR12())
    ->transmissionSequence('1')
    ->recipientCode('ABC1234')
    ->supplier(
        \Condividendo\FatturaPA\Entities\Supplier::make()
            ->companyName('Condividendo italia srl')
            ->vatNumber('IT12345640962')
            ->taxRegime(\Condividendo\FatturaPA\Enums\TaxRegime::RF01())
            ->address(
                \Condividendo\FatturaPA\Entities\Address::make()
                    ->addressLine('Via Italia, 123')
                    ->postalCode('12345')
                    ->city('Milano')
                    ->province('MI')
                    ->country('IT')
            )
    )
    ->customer(
        \Condividendo\FatturaPA\Entities\Customer::make()
            ->firstName('Mario')
            ->lastName('Rossi')
            ->fiscalCode('RSSMRA73L09Z103F')
            ->address(
                \Condividendo\FatturaPA\Entities\Address::make()
                    ->addressLine('Via Italia, 123')
                    ->postalCode('12345')
                    ->city('Milano')
                    ->province('MI')
                    ->country('IT')
            )
    )
    ->addBody(
        \Condividendo\FatturaPA\Entities\Body::make()
            ->type(\Condividendo\FatturaPA\Enums\Type::TD01())
            ->currency('EUR')
            ->number('1')
            ->items([
                \Condividendo\FatturaPA\Entities\Item::make()
                    ->number(1)
                    ->description('Product description')
                    ->price('10.00')
                    ->taxRate('0.22')
            ])
            ->summaryItems([
                \Condividendo\FatturaPA\Entities\SummaryItem::make()
                    ->taxableAmount('10.00')
                    ->taxRate('0.22')
            ])
    );
    
/** @var \SimpleXMLElement $xml */
$xml = $invoice->toXML();

// do whatever you want with $xml variable...

Changelog

Please see Changelog File for more information on what has changed recently.

Testing

composer test

License

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