Download the PHP package a5sys/fec-bundle without Composer

On this page you can find all versions of the php package a5sys/fec-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fec-bundle

FecBundle

FecBundle allows generation of FEC files and reading data from FEC files.

FEC stands for "fichier d'écritures comptables" and is specific to french accounting.

FEC files are standardized. Theire are four formats that french accounting standard accept :

This bundle can currently produce and read the two first type : flat file CSV tab or pipe separator, but can be extended to plug an adapter of your own to produce the XML or flat fixed width column format.

A FEC file, whatever its type, must have at least 18 fields by accounting line, but it can be 21 or 22 columns.

18 columns :

21 columns :

22 columns :

All fields are standardized, even if Debit and Credit fields can be switched by Montant (amount) and Sens (direction, which can be D/C or +1/-1).

Note : this bundle does not generate the associated textual description file.

Installation

Use composer

php composer.phar require "a5sys/fec-bundle:dev-master"

or

composer require "a5sys/fec-bundle:dev-master"

Declare bundle in AppKernel.php :

new A5sys\FecBundle\FecBundle(),

configure

config.yml

You can configure the default temp dir for the generation of FEC files:

fec:
    defaultTempDir: /a/writable/path

if not set, the bundle will use the system temp dir.

Compose and use the FEC generator service

Compose

To generate FEC files, declare a service, using the pre-configured class in the parameter fec.manager.class.

services.yml

fec.manager.my:
    class: %fec.manager.class%
    arguments:
        - %fec.defaultTempDir%
        - "@fec.dumper.csv.tab.txt"
        - "@fec.normalizer.bic.is"
        - "@fec.computer.debitcredit"

The 3 last arguments are the services you should carefuly choose to generate the right FEC file:

Use

In a controller :

    $fecLines = array();
    foreach ($ecritureLignes as $ecritureLigne) {
        $fecLine = new \A5sys\FecBundle\ValueObject\EcritureBICIS();
        $fecLine
            ->setJournalCode($jCode)
            ->setJournalLib($jLib)
            ->setEcritureNum($eNum)
            ->setEcritureDate($eDate)
            ->setCompteNum($cNum)
            ->setCompteLib($cLib)
            ->setCompAuxNum($caNum)
            ->setCompAuxLib($caLib)
            ->setPieceRef($numeroPiece)
            ->setPieceDate($datePiece)
            ->setEcritureLib($eLib)
            ->setDebit($debit)
            ->setCredit($credit)
            ->setEcritureLet($eLet)
            ->setDateLet($dLet)
            ->setValidDate($dateValid)
            ->setMontantdevise($mDev)
            ->setIdevise($iDev)
        ;

        $fecLines[] = $fecLine;
    }

    $this->get('fec.manager.my')->generateFile($sirenNumber, $dateCloture, $fecLines)

In a service :

Simply inject your "fec.manager.my" in an an other service of your.

Notes:

The manager needs the siren and closing date to produce the right file name, as it is conventionned too.

All Input objects specify the Debit and Credit, and not the Montant and Sens, the output format, in the file, can be choosen, but not the input method.

Input objects and mandatory fields

EcritureBICIS, EcritureBNCBADroitCommercial, and more widely all EcritureComptableInterface, must have a value for those fields:

EcritureBATresorerie, EcritureBNCTresorerie, and interfaces EcritureBATresorerieInterface, EcritureBNCTresorerieInterface, must provide a value for those additionnal fields

Change file extension

services.yml

declare an other service like this, to get a CSV file with pipe separator and ".fec" extension:

fec.dumper.csv.pipe.fec:
    class: %fec.dumper.csv.class%
    arguments:
        - "|"
        - "fec"

Use now the "@fec.dumper.csv.pipe.fec" service in the fec.manager.my definition in services.yml.

Compose and use the FEC reader service

Compose

To read FEC files, declare a service, using the pre-configured class in the parameter fec.manager.class.

services.yml

fec.reader.my:
    class: %fec.reader.class%
    arguments:
        - "@fec.dumper.csv.tab.txt"
        - "@fec.normalizer.standard"
        - "@fec.computer.debitcredit"

The 3 last arguments are the services you should carefuly choose to generate the right FEC file:

Use

In a controller :

/**
 * Import a FEC file
 *
 * @param Request $request
 * @return Response
 *
 * @Route("/import/fec", name="import_fec")
 */
public function importFecAction(Request $request)
{
    // get the uploaded file. With Symfony you directly get a UploadedFile which extends File
    $uploadedFile = $request->files->get('file');

    // Get the list of A5sys\FecBundle\ValueObject\EcritureBICIS by giving a File to the service you've just composed
    $ecrituresComptables = $this->get('fec.reader.expertim')->readFile($uploadedFile);

    ...
}

In a service :

Simply inject your "fec.reader.my" in an an other service of your.

Validation

When reading the CSV FEC file, a check is done on the well formed aspect of all the lines.

When the number of columns of a line is not the same as the number of headers, a FecException is thrown. If a Date field is not Ymd formatted, a FecException is thrown. If a numeric field is not numeric, a FecException is throw.

Further details, see CsvReader class.

Then, when the ValueObject (EcritureXxx) is created, the validator checks it and may throw a FecValidationException if data does not respect the french specification.

References

https://www.legifrance.gouv.fr/affichTexte.do?cidTexte=JORFTEXT000027788276&dateTexte=&categorieLien=id


All versions of fec-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
symfony/symfony Version >=2.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package a5sys/fec-bundle contains the following files

Loading the files please wait ....