Skip to content

Commit

Permalink
Merge pull request #26 from eclipxe13/version-2.9.0
Browse files Browse the repository at this point in the history
Add CCP 3.1 & maintenance (Version 2.9.0)
  • Loading branch information
eclipxe13 authored Jun 19, 2024
2 parents 7129dae + 95007e1 commit 1959bcc
Show file tree
Hide file tree
Showing 110 changed files with 9,371 additions and 5 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ on:

jobs:

composer-normalize:
name: Composer normalization
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none
tools: composer-normalize
env:
fail-fast: true
- name: Composer normalize
run: composer-normalize

phpcs:
name: Code Style (phpcs)
runs-on: "ubuntu-latest"
Expand Down
10 changes: 5 additions & 5 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.49.0" installed="3.49.0" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpcs" version="^3.8.1" installed="3.8.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.8.1" installed="3.8.1" location="./tools/phpcbf" copy="false"/>
<phar name="phpstan" version="^1.10.57" installed="1.10.57" location="./tools/phpstan" copy="false"/>
<phar name="composer-normalize" version="^2.42.0" installed="2.42.0" location="./tools/composer-normalize" copy="false"/>
<phar name="php-cs-fixer" version="^3.59.3" installed="3.59.3" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/>
<phar name="phpstan" version="^1.11.5" installed="1.11.5" location="./tools/phpstan" copy="false"/>
<phar name="composer-normalize" version="^2.43.0" installed="2.43.0" location="./tools/composer-normalize" copy="false"/>
</phive>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Read the file [*Catálogos SAT*](docs/Catalogos.md) for more information about t
- Catálogos de Complemento de Nóminas 1.2.
- Catálogos de Complemento de Carta Porte 2.0.
- Catálogos de Complemento de Carta Porte 3.0.
- Catálogos de Complemento de Carta Porte 3.1.
- Catálogos de Complemento de Recepción de Pagos 1.0.
- Catálagos de CFDI De Retenciones e Información de Pagos 2.0

Expand Down
14 changes: 14 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# phpcfdi/sat-catalogos-populate Changelog

## Version 2.9.0 2024-06-19

Add CCP (*Complemento de Carta Porte*) 3.1 catalogs.

- Add *Origin* as a constant source, saving the file as `CatalogosCartaPorte31.xls`.
- Add *Source importer* from `CatalogosCartaPorte31.xls`. It includes 32 catalogs.
- Importers create tables with prefix `ccp_31_*`.
- Update `docs/Catalogos.md` with CCP 3.1 catalogs.

Other updates:

- Add `composer-normalize` job to continuous integration process.
- Update development tools.

## Version 2.8.1 2024-02-09

CFDI 4.0 catalog `UsoCFDI` change a header from `Regímen Fiscal Receptor` to `Régimen Fiscal Receptor`.
Expand Down
17 changes: 17 additions & 0 deletions docs/Catalogos.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,23 @@ contiene duplicados.

Por lo anterior, solo existe un importador con múltiples inyectores.

## CCP 3.1 (Complemento Carta Porte 3.1) `ccp_31_*`

> - <http://omawww.sat.gob.mx/tramitesyservicios/Paginas/complemento_carta_porte.htm>
> - <http://omawww.sat.gob.mx/tramitesyservicios/Paginas/documentos/CatalogosCartaPorte31.xls>
Los catálogos de CCP 3.1 contienen información extendida que debe ser respetada para el correcto llenado
del complemento de carta porte versión 3.1.

Los catálogos están en un solo archivo de excel por lo que se usa la misma estrategia que en los catálogos de CFDI.

Algunos nombres de las hojas contienen espacios: `c_Estaciones`.

El catálogo `c_MaterialPeligroso` debería tener un índice único en `Clave material peligroso` pero ocurre que
contiene duplicados.

Por lo anterior, solo existe un importador con múltiples inyectores.

## RET 2.0 (CFDI De Retenciones e Información de Pagos) `ret_20_*`
> - <http://omawww.sat.gob.mx/tramitesyservicios/Paginas/CFDI_retenciones.htm>
Expand Down
4 changes: 4 additions & 0 deletions docs/Pruebas.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ estos archivos y correr los tests. De esta forma podremos notar un cambio import
- `tests/_files/rep/*.csv`: Archivos que salen de los catálogos de recibo electrónico de pagos
- `tests/_files/ccp20/*.csv`: Archivos que salen de los catálogos de carta porte 2.0
- `tests/_files/ccp30/*.csv`: Archivos que salen de los catálogos de carta porte 3.0
- `tests/_files/ccp31/*.csv`: Archivos que salen de los catálogos de carta porte 3.1

## Actualizar los archivos de pruebas

Expand Down Expand Up @@ -51,6 +52,7 @@ rm -rf tests/_files/rep
rm -rf tests/_files/cce
rm -rf tests/_files/ccp20
rm -rf tests/_files/ccp30
rm -rf tests/_files/ccp31

mkdir -p tests/_files/sources
mkdir -p tests/_files/cfdi
Expand All @@ -60,6 +62,7 @@ mkdir -p tests/_files/rep
mkdir -p tests/_files/cce
mkdir -p tests/_files/ccp20
mkdir -p tests/_files/ccp30
mkdir -p tests/_files/ccp31

cp build/temp/*.xls tests/_files/sources

Expand All @@ -79,6 +82,7 @@ php tests/convert-xls-to-csv-folder.php tests/_files/sources/c_TipoOperacion.xls
php tests/convert-xls-to-csv-folder.php tests/_files/sources/c_UnidadAduana.xls tests/_files/cce
php tests/convert-xls-to-csv-folder.php tests/_files/sources/CatalogosCartaPorte20.xls tests/_files/ccp20
php tests/convert-xls-to-csv-folder.php tests/_files/sources/CatalogosCartaPorte30.xls tests/_files/ccp30
php tests/convert-xls-to-csv-folder.php tests/_files/sources/CatalogosCartaPorte31.xls tests/_files/ccp31
php tests/convert-xls-to-csv-folder.php tests/_files/sources/c_ClavePedimento20.xls tests/_files/cce20
php tests/convert-xls-to-csv-folder.php tests/_files/sources/c_Colonia20.xls tests/_files/cce20
php tests/convert-xls-to-csv-folder.php tests/_files/sources/C_Estado20.xls tests/_files/cce20
Expand Down
1 change: 1 addition & 0 deletions src/Commands/DumpOrigins.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function run(): int
new ConstantOrigin('REP', "{$common}/catPagos.xls"),
new ConstantOrigin('CCP 2.0 - Carta Porte 2.0', "{$common}/CatalogosCartaPorte20.xls"),
new ConstantOrigin('CCP 3.0 - Carta Porte 3.0', "{$common}/CatalogosCartaPorte30.xls"),
new ConstantOrigin('CCP 3.1 - Carta Porte 3.1', "{$common}/CatalogosCartaPorte31.xls"),
]);

echo (new OriginsIO())->originsToString($origins) . PHP_EOL;
Expand Down
41 changes: 41 additions & 0 deletions src/Importers/Ccp31/Injectors/AutorizacionesNaviero.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace PhpCfdi\SatCatalogosPopulate\Importers\Ccp31\Injectors;

use PhpCfdi\SatCatalogosPopulate\AbstractCsvInjector;
use PhpCfdi\SatCatalogosPopulate\Database\DataFields;
use PhpCfdi\SatCatalogosPopulate\Database\DataTable;
use PhpCfdi\SatCatalogosPopulate\Database\DateDataField;
use PhpCfdi\SatCatalogosPopulate\Database\TextDataField;
use PhpCfdi\SatCatalogosPopulate\Utils\CsvFile;
use RuntimeException;

class AutorizacionesNaviero extends AbstractCsvInjector
{
public function checkHeaders(CsvFile $csv): void
{
$csv->move(3);
$expected = [
'Número de autorización',
'Inicio de vigencia',
'Fin de vigencia',
];
$headers = $csv->readLine();
if ($expected !== $headers) {
throw new RuntimeException("The headers did not match on file {$this->sourceFile()}");
}

$csv->next();
}

public function dataTable(): DataTable
{
return new DataTable('ccp_31_autorizaciones_naviero', new DataFields([
new TextDataField('id'),
new DateDataField('vigencia_desde'),
new DateDataField('vigencia_hasta'),
]));
}
}
52 changes: 52 additions & 0 deletions src/Importers/Ccp31/Injectors/ClavesUnidades.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace PhpCfdi\SatCatalogosPopulate\Importers\Ccp31\Injectors;

use PhpCfdi\SatCatalogosPopulate\AbstractCsvInjector;
use PhpCfdi\SatCatalogosPopulate\Database\DataFields;
use PhpCfdi\SatCatalogosPopulate\Database\DataTable;
use PhpCfdi\SatCatalogosPopulate\Database\DateDataField;
use PhpCfdi\SatCatalogosPopulate\Database\TextDataField;
use PhpCfdi\SatCatalogosPopulate\Utils\CsvFile;
use RuntimeException;

class ClavesUnidades extends AbstractCsvInjector
{
public function checkHeaders(CsvFile $csv): void
{
$csv->move(3);
$expected = [
'Clave unidad',
'Nombre',
'Descripción',
'Nota',
'Fecha de inicio de vigencia',
'Fecha de fin de vigencia',
'Símbolo',
'Bandera',
];
$headers = $csv->readLine();

if ($expected !== $headers) {
throw new RuntimeException("The headers did not match on file {$this->sourceFile()}");
}

$csv->next();
}

public function dataTable(): DataTable
{
return new DataTable('ccp_31_claves_unidades', new DataFields([
new TextDataField('id'),
new TextDataField('texto'),
new TextDataField('descripcion'),
new TextDataField('nota'),
new DateDataField('vigencia_desde'),
new DateDataField('vigencia_hasta'),
new TextDataField('simbolo'),
new TextDataField('bandera'),
]));
}
}
48 changes: 48 additions & 0 deletions src/Importers/Ccp31/Injectors/CodigosTransporteAereo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace PhpCfdi\SatCatalogosPopulate\Importers\Ccp31\Injectors;

use PhpCfdi\SatCatalogosPopulate\AbstractCsvInjector;
use PhpCfdi\SatCatalogosPopulate\Database\DataFields;
use PhpCfdi\SatCatalogosPopulate\Database\DataTable;
use PhpCfdi\SatCatalogosPopulate\Database\DateDataField;
use PhpCfdi\SatCatalogosPopulate\Database\TextDataField;
use PhpCfdi\SatCatalogosPopulate\Utils\CsvFile;
use RuntimeException;

class CodigosTransporteAereo extends AbstractCsvInjector
{
public function checkHeaders(CsvFile $csv): void
{
$csv->move(3);
$expected = [
'Clave identificación',
'Nacionalidad',
'Nombre de la aerolínea',
'Designador OACI',
'Fecha de inicio de vigencia',
'Fecha de fin de vigencia',
];
$headers = $csv->readLine();

if ($expected !== $headers) {
throw new RuntimeException("The headers did not match on file {$this->sourceFile()}");
}

$csv->next();
}

public function dataTable(): DataTable
{
return new DataTable('ccp_31_codigos_transporte_aereo', new DataFields([
new TextDataField('id'),
new TextDataField('nacionalidad'),
new TextDataField('texto'),
new TextDataField('designador_oaci'),
new DateDataField('vigencia_desde'),
new DateDataField('vigencia_hasta'),
]));
}
}
38 changes: 38 additions & 0 deletions src/Importers/Ccp31/Injectors/Colonias.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace PhpCfdi\SatCatalogosPopulate\Importers\Ccp31\Injectors;

use PhpCfdi\SatCatalogosPopulate\AbstractCsvInjector;
use PhpCfdi\SatCatalogosPopulate\Database\DataFields;
use PhpCfdi\SatCatalogosPopulate\Database\DataTable;
use PhpCfdi\SatCatalogosPopulate\Database\PaddingDataField;
use PhpCfdi\SatCatalogosPopulate\Database\TextDataField;
use PhpCfdi\SatCatalogosPopulate\Utils\CsvFile;
use RuntimeException;

class Colonias extends AbstractCsvInjector
{
public function checkHeaders(CsvFile $csv): void
{
$csv->move(3);
$expected = ['c_Colonia', 'c_CodigoPostal', 'Nombre del asentamiento'];
$headers = $csv->readLine();

if ($expected !== $headers) {
throw new RuntimeException("The headers did not match on file {$this->sourceFile()}");
}

$csv->next();
}

public function dataTable(): DataTable
{
return new DataTable('ccp_31_colonias', new DataFields([
new PaddingDataField('colonia', '0', 4),
new PaddingDataField('codigo_postal', '0', 5),
new TextDataField('texto'),
]), ['colonia', 'codigo_postal']);
}
}
46 changes: 46 additions & 0 deletions src/Importers/Ccp31/Injectors/CondicionesEspeciales.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace PhpCfdi\SatCatalogosPopulate\Importers\Ccp31\Injectors;

use PhpCfdi\SatCatalogosPopulate\AbstractCsvInjector;
use PhpCfdi\SatCatalogosPopulate\Database\DataFields;
use PhpCfdi\SatCatalogosPopulate\Database\DataTable;
use PhpCfdi\SatCatalogosPopulate\Database\DateDataField;
use PhpCfdi\SatCatalogosPopulate\Database\PaddingDataField;
use PhpCfdi\SatCatalogosPopulate\Database\TextDataField;
use PhpCfdi\SatCatalogosPopulate\Database\ToBeDefinedDataField;
use PhpCfdi\SatCatalogosPopulate\Utils\CsvFile;
use RuntimeException;

class CondicionesEspeciales extends AbstractCsvInjector
{
public function checkHeaders(CsvFile $csv): void
{
$csv->move(3);
$expected = [
'Clave',
'Descripción',
'Fecha inicio de vigencia',
'Fecha fin de vigencia',
];
$headers = $csv->readLine();

if ($expected !== $headers) {
throw new RuntimeException("The headers did not match on file {$this->sourceFile()}");
}

$csv->next();
}

public function dataTable(): DataTable
{
return new DataTable('ccp_31_condiciones_especiales', new DataFields([
new PaddingDataField('id', '0', 2),
new TextDataField('texto'),
new ToBeDefinedDataField(new DateDataField('vigencia_desde')),
new DateDataField('vigencia_hasta'),
]));
}
}
Loading

0 comments on commit 1959bcc

Please sign in to comment.