2017 © Pedro PelĂĄez
 

library fec-bundle

Generates FEC files (french accounting)

image

a5sys/fec-bundle

Generates FEC files (french accounting)

  • Monday, February 13, 2017
  • by arnaudgoulpeau
  • Repository
  • 3 Watchers
  • 1 Stars
  • 466 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 11 % Grown

The README.md

FecBundle

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)

  • flat file CSV with tab separator
  • flat file CSV with pipe separator (|)
  • flat file with fixed width columns
  • XML file following XSD spec

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)

  • BIC / IS : industrial and commercial profits / company tax
  • BNC/BA Droit commercial : non commercial and agricultural profits in trade law

21 columns :, (*7)

  • BA trĂ©sorerie : agricultural profits treasury

22 columns :, (*8)

  • BNC trĂ©sorerie : non commercial profits treasury

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)

Installation

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(),

configure

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)

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., (*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"
  • Argument 1
    • the fec.defaultTempDir parameter should not be modified here, prefer modify the parameter in config.yml

The 3 last arguments are the services you should carefuly choose to generate the right FEC file:, (*19)

  • Argument 2
    • In the example : "@fec.dumper.csv.tab.txt"
    • The following are currently provided:
      • "@fec.dumper.csv.tab.txt"
        • CSV file with tab separator and .txt extension
      • "@fec.dumper.csv.pipe.txt"
        • CSV file with | separator and .txt extension
  • Argument 3
    • In the example "@fec.normalizer.bic.is"
    • The following are currently provided:
      • "@fec.normalizer.bic.is"
        • Use input objects of type
          • EcritureBICIS
          • an instance of AbstractEcritureComptable
          • an instance of EcritureComptableInterface.
        • For accounting entries with 18 columns
      • "@fec.normalizer.bnc.ba.dc"
        • Use input objects of type
          • EcritureBNCBADroitCommercial
          • an instance of AbstractEcritureComptable
          • an instance of EcritureComptableInterface.
        • For accounting entries with 18 columns
      • "@fec.normalizer.ba.tresorerie"
        • Use input objects of type
          • EcritureBATresorerie
          • an instance of EcritureBATresorerieInterface
        • For accounting entries with 21 columns
      • "@fec.normalizer.bnc.tresorerie"
        • Use input objects of type
          • EcritureBNCTresorerie
          • an instance of EcritureBNCTresorerieInterface
        • For accounting entries with 22 columns
  • Argument 4
    • In the example "@fec.computer.debitcredit"
    • The following are currently provided:
      • "@fec.computer.debitcredit"
        • To produce the fields Debit and Credit, amount in one of the two
      • "@fec.computer.montantsens.alpha"
        • To produce the fields Montant and Sens
        • With D and C into Sens
      • "@fec.computer.montantsens.num"
        • To produce the fields Montant and Sens
        • With +1 for debit and -1 for credit into Sens

Use

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)

  • JournalCode
  • JournalLib
  • EcritureNum
  • EcritureDate
  • CompteNum
  • CompteLib
  • PieceRef
  • PieceDate
  • EcritureLib
  • ValidDate

EcritureBATresorerie, EcritureBNCTresorerie, and interfaces EcritureBATresorerieInterface, EcritureBNCTresorerieInterface, must provide a value for those additionnal fields, (*28)

  • DateRglt
  • ModeRglt

Change file extension

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)

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., (*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)

  • Argument 1
    • In the example : "@fec.dumper.csv.tab.txt"
    • The following are currently provided:
      • "@fec.reader.csv.tab"
        • CSV file with tab separator
      • "@fec.dumper.csv.pipe"
        • CSV file with | separator
  • Argument 2
    • In the example "@fec.normalizer.standard"
    • The following are currently provided:
      • "@fec.normalizer.bic.is"
        • Produce objects of type
          • EcritureBICIS
        • For accounting entries with 18 columns
      • "@fec.normalizer.bnc.ba.dc"
        • Produce objects of type
          • EcritureBNCBADroitCommercial
        • For accounting entries with 18 columns
      • "@fec.normalizer.ba.tresorerie"
        • Produce objects of type
          • EcritureBATresorerie
        • For accounting entries with 21 columns
      • "@fec.normalizer.bnc.tresorerie"
        • Produce objects of type
          • EcritureBNCTresorerie
        • For accounting entries with 22 columns
  • Argument 3
    • In the example "@fec.computer.debitcredit"
    • The following are currently provided:
      • "@fec.computer.debitcredit"
        • To produce the fields Debit and Credit, amount in one of the two
      • "@fec.computer.montantsens.alpha"
        • To produce the fields Montant and Sens
        • With D and C into Sens
      • "@fec.computer.montantsens.num"
        • To produce the fields Montant and Sens
        • With +1 for debit and -1 for credit into Sens

Use

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)

References

https://www.legifrance.gouv.fr/affichTexte.do?cidTexte=JORFTEXT000027788276&dateTexte=&categorieLien=id, (*43)

The Versions

13/02 2017

dev-master

9999999-dev

Generates FEC files (french accounting)

  Sources   Download

The Requires

 

13/02 2017

V2.0.2

2.0.2.0

Generates FEC files (french accounting)

  Sources   Download

The Requires

 

31/01 2017

V2.0.1

2.0.1.0

Generates FEC files (french accounting)

  Sources   Download

The Requires

 

16/12 2016

V2.0.0

2.0.0.0

Generates FEC files (french accounting)

  Sources   Download

The Requires

 

25/11 2016

V1.0.0

1.0.0.0

Generates FEC files (french accounting)

  Sources   Download

The Requires