Skip to content

Pacote de leitura de arquivos de ponto no padrão do brasil. AFD, AFDT e ACJEF

License

Notifications You must be signed in to change notification settings

convenia/afd-reader

Repository files navigation

logo


Pacote para leitura de Arquivo Fonte de Dados (AFD). Especificação do MTE referente a portaria 1.510/2009.


Latest Stable Version Build Status Total Downloads License

Arquivos suportados

  • Arquivo-Fonte de Dados - AFD
  • Arquivo-Fonte de Dados Tratado - AFDT
  • Arquivo de Controle de Jornada para Efeitos Fiscais - ACJEF

Métodos

  • getByUser()
  • getAll()

Utilização

O AfdReader pode ser instanciado informando apenas o caminho do arquivo, neste caso ele tentará descobrir o tipo:

use Convenia\AfdReader\AfdReader;
...
 
$afdReader = new AfdReader('afdt_test.txt');

Informando o tipo do arquivo:

use Convenia\AfdReader\AfdReader;
...

$afdReader = new AfdReader('afdt_test.txt', 'Afdt');

Obter informações agrupadas por NIS/PIS:

$afdReader->getByUser();
Array
(
    [62915959739] => Array
        (
            [20052015] => Array
                (
                    [01] => Array
                        (
                            [0] => Array
                                (
                                    [sequency] => 000000002
                                    [dateTime] => DateTime Object
                                        (
                                            [date] => 2015-05-20 09:00:00.000000
                                            [timezone_type] => 3
                                            [timezone] => America/Sao_Paulo
                                        )

                                    [reason] => 

                                    [direction] => Entrada
                                    [type] => Original
                                )

                            [1] => Array
                                (
                                    [sequency] => 000000003
                                    [dateTime] => DateTime Object
                                        (
                                            [date] => 2015-05-20 12:04:00.000000
                                            [timezone_type] => 3
                                            [timezone] => America/Sao_Paulo
                                        )

                                    [reason] => 

                                    [direction] => Saída
                                    [type] => Original
                                )

                        )

                    [02] => Array
                        (
                            [0] => Array
                                (
                                    [sequency] => 000000004
                                    [dateTime] => DateTime Object
                                        (
                                            [date] => 2015-05-20 13:14:00.000000
                                            [timezone_type] => 3
                                            [timezone] => America/Sao_Paulo
                                        )

                                    [reason] => 

                                    [direction] => Entrada
                                    [type] => Original
                                )

                            [1] => Array
                                (
                                    [sequency] => 000000005
                                    [dateTime] => DateTime Object
                                        (
                                            [date] => 2015-05-20 18:07:00.000000
                                            [timezone_type] => 3
                                            [timezone] => America/Sao_Paulo
                                        )

                                    [reason] => 

                                    [direction] => Saída
                                    [type] => Original
                                )

                        )

                )

        )

)

Obter as ocorrências de um NIS/PIS:

$afdReader->getByUser(62915959739);

Obter as ocorrências de um NIS/PIS no período especificado:

$afdReader->getByUser(62915959739, ['from' => '2015-05-20', 'to' => '2015-05-20']);

Obter as informações de todos os registros:

$afdReader->getAll();
Array
(
    [header] => Array
        (
            [sequency] => 000000001
            [type] => 1
            [entityType] => CNPJ
            [entityNumber] => 32041763000177
            [cei] => 000000000000
            [name] => NOME DA EMPRESA - LTDA ME
            [startDate] => 20052015
            [endDate] => 20092015
            [generationDate] => DateTime Object
                (
                    [date] => 2015-09-21 09:57:59.000000
                    [timezone_type] => 3
                    [timezone] => America/Sao_Paulo
                )

            [generationTime] => Array
                (
                    [hour] => 10
                    [minute] => 43
                )

        )

    [trailer] => Array
        (
            [sequency] => 000011305
            [type] => 9
        )

    [detail] => Array
        (
            [62915959739] => Array
                (
                    [20052015] => Array
                        (
                            [01] => Array
                                (
                                    [0] => Array
                                        (
                                            [sequency] => 000000002
                                            [dateTime] => DateTime Object
                                                (
                                                    [date] => 2015-05-20 09:00:00.000000
                                                    [timezone_type] => 3
                                                    [timezone] => America/Sao_Paulo
                                                )

                                            [reason] => 

                                            [direction] => Entrada
                                            [type] => Original
                                        )

                                    [1] => Array
                                        (
                                            [sequency] => 000000003
                                            [dateTime] => DateTime Object
                                                (
                                                    [date] => 2015-05-20 12:04:00.000000
                                                    [timezone_type] => 3
                                                    [timezone] => America/Sao_Paulo
                                                )

                                            [reason] => 

                                            [direction] => Saída
                                            [type] => Original
                                        )

                                )

                            [02] => Array
                                (
                                    [0] => Array
                                        (
                                            [sequency] => 000000004
                                            [dateTime] => DateTime Object
                                                (
                                                    [date] => 2015-05-20 13:14:00.000000
                                                    [timezone_type] => 3
                                                    [timezone] => America/Sao_Paulo
                                                )

                                            [reason] => 

                                            [direction] => Entrada
                                            [type] => Original
                                        )

                                    [1] => Array
                                        (
                                            [sequency] => 000000005
                                            [dateTime] => DateTime Object
                                                (
                                                    [date] => 2015-05-20 18:07:00.000000
                                                    [timezone_type] => 3
                                                    [timezone] => America/Sao_Paulo
                                                )

                                            [reason] => 

                                            [direction] => Saída
                                            [type] => Original
                                        )

                                )

                        )
                )

        )

)