Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be Factur-x ready #3443

Open
williamdes opened this issue Apr 19, 2024 · 1 comment
Open

Be Factur-x ready #3443

williamdes opened this issue Apr 19, 2024 · 1 comment
Milestone

Comments

@williamdes
Copy link
Contributor

williamdes commented Apr 19, 2024

What is Factur-x ?

related tools:

Related issue on TCPDF: tecnickcom/TCPDF#578 (no progress)

cc @Starfox64
Using the work from #3269 for PDF/A
Currently this are the errors I have to solve (https://services.fnfe-mpe.org):
Vera PDF only reports: Specification: ISO 19005-3:2012, Clause: 6.2.11.4.1, Test number: 1


Spec. ISO_19005_3 clause 6.2.11.4 test 1
PDF/A-3 error
The font programs for all fonts used for rendering within a conforming file shall be embedded within that file, as defined in ISO 32000-1:2008, 9.9.
Level: CosDocument
Context:
root/document[0]/pages[0](6 0 obj PDPage)/contentStream[0](7 0 obj PDContentStream)/operators[818]/font[0](Helvetica-Bold)
root/document[0]/pages[0](6 0 obj PDPage)/contentStream[0](7 0 obj PDContentStream)/operators[853]/font[0](Helvetica)
Missing /Names/EmbeddedFiles in PDF Catalog
PDF/A-3 error
Required tag 'DocumentType' missing
XMP error
Missing tag /x:xmpmeta/rdf:RDF/rdf:Description/fx:DocumentType in XMP Metadata (can also be set via an attribute 'DocumentType' of the tag '/x:xmpmeta/rdf:RDF/rdf:Description')
Required tag 'DocumentFileName' missing
XMP error
Missing tag /x:xmpmeta/rdf:RDF/rdf:Description/fx:DocumentFileName in XMP Metadata (can also be set via an attribute 'DocumentFileName' of the tag '/x:xmpmeta/rdf:RDF/rdf:Description')
Required tag 'Version' missing
XMP error
Missing tag /x:xmpmeta/rdf:RDF/rdf:Description/fx:Version in XMP Metadata (can also be set via an attribute 'Version' of the tag '/x:xmpmeta/rdf:RDF/rdf:Description')
Required tag 'ConformanceLevel' missing
XMP error
Missing tag /x:xmpmeta/rdf:RDF/rdf:Description/fx:ConformanceLevel in XMP Metadata (can also be set via an attribute 'ConformanceLevel' of the tag '/x:xmpmeta/rdf:RDF/rdf:Description')
@williamdes
Copy link
Contributor Author

I managed to embed a Factur-x xml file
The compliance is not great but that's a start

Using https://github.com/easybill/zugferd-php

        $result = DocumentGeneratorService::generate($command);
        $pdf = InvoiceServiceImpl::htmlToPDF($result);
        $canvas = $pdf->getCanvas();

        $facturXFile = '';
        if ($canvas instanceof CPDF) {

            $doc = new CrossIndustryInvoice();
            $ctx = $doc->exchangedDocumentContext = new ExchangedDocumentContext();
            $ctx->documentContextParameter = DocumentContextParameter::create('urn:factur-x.eu:1p0:minimum');

            $echDoc = $doc->exchangedDocument = new ExchangedDocument();
            $echDoc->id = 'F-0000001';// TODO: change me
            // See: https://communaute.chorus-pro.gouv.fr/wp-content/uploads/2017/07/Specifications_Externes_Annexe_EDI_V4.22.pdf
            // See: https://www.billygen.fr/publications/comprendre-factur-x-part2/
            // 380 : Facture commerciale
            // 381 : Avoir (note de crédit)
            // 384 : Facture rectificative
            // 389 : Facture d'autofacturation (créée par l'acheteur pour le compte du fournisseur). Code non accepté pour ChorusPro
            // 261 : Avoir d'autofacturation. Code non accepté pour Chorus Pro
            // 386 : Facture d'acompte
            // 751 : Informations de facture pour comptabilisation : code exigé en Allemagne pour satisfaire ses contraintes réglementaires. Code non accepté pour Chorus Pro.

            $echDoc->typeCode = '380';// TODO: change me
            $echDoc->languageId = ['FR'];// TODO: change me
            $echDoc->issueDateTime = new DateTime('now');// TODO: change me


            $xml = Builder::create()->transform($doc);

            $facturXFile = tempnam(sys_get_temp_dir(), 'factur-x');
            file_put_contents($facturXFile, $xml);

            $canvas->get_cpdf()->addEmbeddedFile(
                filepath: $facturXFile,
                embeddedFilename: 'factur-x.xml',
                description: 'Factur-X XML file'
            );
        }

        $output = $pdf->output();
        unlink($facturXFile);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants