-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from eclipxe13/catalogs-cfdi_40
Catalogs CFDI 4.0
- Loading branch information
Showing
86 changed files
with
7,327 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpCfdi\SatCatalogosPopulate\Importers\Cfdi40\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\InjectorInterface; | ||
use PhpCfdi\SatCatalogosPopulate\Utils\CsvFile; | ||
use RuntimeException; | ||
|
||
use function PhpCfdi\SatCatalogosPopulate\Utils\array_rtrim; | ||
|
||
class Aduanas extends AbstractCsvInjector implements InjectorInterface | ||
{ | ||
public function checkHeaders(CsvFile $csv): void | ||
{ | ||
$csv->move(3); | ||
$expected = ['c_Aduana', 'Descripción', 'Fecha inicio de vigencia', 'Fecha fin de vigencia']; | ||
$headers = array_rtrim($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('cfdi_40_aduanas', new DataFields([ | ||
new PaddingDataField('id', '0', 2), | ||
new TextDataField('texto'), | ||
new DateDataField('vigencia_desde'), | ||
new DateDataField('vigencia_hasta'), | ||
])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpCfdi\SatCatalogosPopulate\Importers\Cfdi40\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\InjectorInterface; | ||
use PhpCfdi\SatCatalogosPopulate\Utils\CsvFile; | ||
use RuntimeException; | ||
|
||
use function PhpCfdi\SatCatalogosPopulate\Utils\array_rtrim; | ||
|
||
class ClavesUnidades extends AbstractCsvInjector implements InjectorInterface | ||
{ | ||
public function checkHeaders(CsvFile $csv): void | ||
{ | ||
$csv->move(3); | ||
$expected = [ | ||
'c_ClaveUnidad', | ||
'Nombre', | ||
'Descripción', | ||
'Nota', | ||
'Fecha de inicio de vigencia', | ||
'Fecha de fin de vigencia', | ||
'Símbolo', | ||
]; | ||
$headers = array_rtrim($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('cfdi_40_claves_unidades', new DataFields([ | ||
new PaddingDataField('id', '0', 2), | ||
new TextDataField('texto'), | ||
new TextDataField('descripcion'), | ||
new TextDataField('notas'), | ||
new DateDataField('vigencia_desde'), | ||
new DateDataField('vigencia_hasta'), | ||
new TextDataField('simbolo'), | ||
])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpCfdi\SatCatalogosPopulate\Importers\Cfdi40\Injectors; | ||
|
||
use Generator; | ||
use PhpCfdi\SatCatalogosPopulate\AbstractCsvInjector; | ||
use PhpCfdi\SatCatalogosPopulate\Database\BoolDataField; | ||
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 CodigosPostales extends AbstractCsvInjector | ||
{ | ||
public function checkHeaders(CsvFile $csv): void | ||
{ | ||
$csv->move(3); | ||
$expectedLines = [ | ||
[ | ||
'c_CodigoPostal', | ||
'c_Estado', | ||
'c_Municipio', | ||
'c_Localidad', | ||
'Estímulo Franja Fronteriza', | ||
'Fecha inicio de vigencia', | ||
'Fecha fin de vigencia', | ||
'Referencias del Huso Horario', | ||
], | ||
[ | ||
'', | ||
'', | ||
'', | ||
'', | ||
'', | ||
'', | ||
'', | ||
'Descripción del Huso Horario', | ||
'Mes_Inicio_Horario_Verano', | ||
'Día_Inicio_Horario_Verano', | ||
'Día_Inicio_Horario_Verano', | ||
'Diferencia_Horaria_Verano', | ||
'Mes_Inicio_Horario_Invierno', | ||
'Día_Inicio_Horario_Invierno', | ||
'Día_Inicio_Horario_Invierno', | ||
'Diferencia_Horaria_Invierno', | ||
], | ||
]; | ||
foreach ($expectedLines as $line => $expected) { | ||
$line = $line + 1; | ||
$headers = array_map(fn ($line): string => trim((string) $line), $csv->readLine()); | ||
if ($expected !== $headers) { | ||
throw new RuntimeException("The headers did not match on file {$this->sourceFile()} line {$line}"); | ||
} | ||
$csv->next(); | ||
} | ||
} | ||
|
||
public function dataTable(): DataTable | ||
{ | ||
return new DataTable('cfdi_40_codigos_postales', new DataFields([ | ||
new TextDataField('id'), | ||
new TextDataField('estado'), | ||
new TextDataField('municipio'), | ||
new TextDataField('localidad'), | ||
new BoolDataField('estimulo_frontera', ['1']), | ||
new DateDataField('vigencia_desde'), | ||
new DateDataField('vigencia_hasta'), | ||
new TextDataField('huso_descripcion'), | ||
new TextDataField('huso_verano_mes_inicio'), | ||
new TextDataField('huso_verano_dia_inicio'), | ||
new TextDataField('huso_verano_hora_inicio'), | ||
new TextDataField('huso_verano_diferencia'), | ||
new TextDataField('huso_invierno_mes_inicio'), | ||
new TextDataField('huso_invierno_dia_inicio'), | ||
new TextDataField('huso_invierno_hora_inicio'), | ||
new TextDataField('huso_invierno_diferencia'), | ||
])); | ||
} | ||
|
||
/** @inheritdoc */ | ||
protected function readLinesFromCsv(CsvFile $csv): Generator | ||
{ | ||
foreach ($csv->readLines() as $line) { | ||
if ('00000' === $line[0]) { | ||
continue; | ||
} | ||
|
||
yield $line; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpCfdi\SatCatalogosPopulate\Importers\Cfdi40\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('cfdi_40_colonias', new DataFields([ | ||
new PaddingDataField('colonia', '0', 4), | ||
new PaddingDataField('codigo_postal', '0', 5), | ||
new TextDataField('texto'), | ||
]), ['colonia', 'codigo_postal']); | ||
} | ||
} |
Oops, something went wrong.