dev-master
9999999-devGenerates FEC files (french accounting)
The Requires
- php >=5.6
- symfony/symfony >=2.7
Generates FEC files (french accounting)
FecBundle allows generation of FEC files and reading data from FEC files., (*1)
FEC stands for "fichier d'écritures comptables" and is specific to french accounting., (*2)
FEC files are standardized. Theire are four formats that french accounting standard accept :, (*3)
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., (*4)
A FEC file, whatever its type, must have at least 18 fields by accounting line, but it can be 21 or 22 columns., (*5)
18 columns :, (*6)
21 columns :, (*7)
22 columns :, (*8)
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)., (*9)
Note : this bundle does not generate the associated textual description file., (*10)
Use composer, (*11)
php composer.phar require "a5sys/fec-bundle:dev-master"
or, (*12)
composer require "a5sys/fec-bundle:dev-master"
Declare bundle in AppKernel.php
:, (*13)
new A5sys\FecBundle\FecBundle(),
config.yml, (*14)
You can configure the default temp dir for the generation of FEC files:, (*15)
fec: defaultTempDir: /a/writable/path
if not set, the bundle will use the system temp dir., (*16)
To generate FEC files, declare a service, using the pre-configured class in the parameter fec.manager.class., (*17)
services.yml, (*18)
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:, (*19)
In a controller :, (*20)
$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 :, (*21)
Simply inject your "fec.manager.my" in an an other service of your., (*22)
Notes:, (*23)
The manager needs the siren and closing date to produce the right file name, as it is conventionned too., (*24)
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., (*25)
Input objects and mandatory fields, (*26)
EcritureBICIS, EcritureBNCBADroitCommercial, and more widely all EcritureComptableInterface, must have a value for those fields:, (*27)
EcritureBATresorerie, EcritureBNCTresorerie, and interfaces EcritureBATresorerieInterface, EcritureBNCTresorerieInterface, must provide a value for those additionnal fields, (*28)
services.yml, (*29)
declare an other service like this, to get a CSV file with pipe separator and ".fec" extension:, (*30)
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., (*31)
To read FEC files, declare a service, using the pre-configured class in the parameter fec.manager.class., (*32)
services.yml, (*33)
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:, (*34)
In a controller :, (*35)
/** * 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 :, (*36)
Simply inject your "fec.reader.my" in an an other service of your., (*37)
Validation, (*38)
When reading the CSV FEC file, a check is done on the well formed aspect of all the lines., (*39)
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., (*40)
Further details, see CsvReader class., (*41)
Then, when the ValueObject (EcritureXxx) is created, the validator checks it and may throw a FecValidationException if data does not respect the french specification., (*42)
https://www.legifrance.gouv.fr/affichTexte.do?cidTexte=JORFTEXT000027788276&dateTexte=&categorieLien=id, (*43)
Generates FEC files (french accounting)