Skip to content

Commit

Permalink
Version 2.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipxe13 committed Aug 28, 2020
2 parents dbb7af4 + ca6da05 commit afc37dd
Show file tree
Hide file tree
Showing 42 changed files with 1,759 additions and 9 deletions.
9 changes: 9 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
- Change visibility of `CfdiUtils\Cleaner\Cleaner#removeIncompleteSchemaLocation()` to private.


## Version 2.13.0 2020-08-28

- Add helper elements for *Complemento de Nómina 1.2 revisión B*.
- Root element is `CfdiUtils\Elements\Nomina12\Nomina`.
- Add test with 100% coverage on the namespace.
- Add documentation.
- **Important** It does not contain any validators but standard `XSD`.


## Version 2.12.11 2020-08-16

- Fix TimbreFiscalDigital XSLT URL locations, updated from SAT documentation.
Expand Down
170 changes: 170 additions & 0 deletions docs/crear/complemento-nomina12b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Complemento de Nómina 1.2 revisión B

El espacio de nombres de `CfdiUtils\Elements\Nomina12` permite trabajar en forma más fácil con los nodos
con nombres y acciones específicas para implementar el Complemento de Nómina versión 1.2 revisión B
vigente a partir del 01 de enero del 2020.

La documentación del complemento la puedes encontrar en el sitio oficial del SAT:

- Recibo de nómina <https://www.sat.gob.mx/consultas/97722/comprobante-de-nomina>
y <http://omawww.sat.gob.mx/tramitesyservicios/Paginas/complemento_nomina.htm>.
- Estándar técnico <http://omawww.sat.gob.mx/tramitesyservicios/Paginas/documentos/Nomina111219.pdf>.
- Catálogos <http://www.sat.gob.mx/sitio_internet/cfd/catalogos/Nomina/catNomina.xsd>.

Según la documentación técnica el XML **debe cumplir** con la siguiente especificación:

- Prefijo de namespace: `nomina12`.
- Namespace: `http://www.sat.gob.mx/nomina12`.
- Archivo XSD: `http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina12.xsd`.

## Gerarquía de nodos

En la liguiente lista se puede ver la gerarquía, el orden y el número de apariciones mínimas y máximas de los nodos
en el Complemento de Nómina versión 1.2 revisión B.

```text
[0,1] Nomina
[0,1] Emisor
[0,1] EntidadSNCF
[1,1] Receptor
[0,N] SubContratacion
[0,1] Percepciones
[0,N] Percepcion
[0,1] AccionesOTitulos
[0,N] HorasExtra
[0,1] JubilacionPensionRetiro
[0,1] SeparacionIndemnizacion
[0,1] Deducciones
[0,N] Deduccion
[0,1] OtrosPagos
[0,N] OtroPago
[0,1] SubsidioAlEmpleo
[0,1] CompensacionSaldosAFavor
[0,1] Incapacidades
[0,N] Incapacidad
```

## Nodos por número máximo de apariciones

Hay dos tipos de nodos según el número máximo de apariciones, el primer tipo es de los que admiten máximo una aparición
como `[0,1] Percepciones`, en el segundo tipo se admiten múltiples apariciones como `[0,N] Percepcion`. Ejemplificando:

```xml
<nomina12:Nomina>
<nomina12:Percepciones> <!-- solo puede aparecer 1 vez -->
<nomina12:Percepcion/> <!-- aparece múltiples veces -->
<nomina12:Percepcion/>
</nomina12:Percepciones>
</nomina12:Nomina>
```

## Métodos para agregar nodos

Los métodos de ayuda para nodos de máximo una sola aparición tienen la forma `getElemento(): Elemento`
y `addElemento(array $attributes): Elemento`. En donde `Elemento` se sustituye por el nombre del nodo.
En este caso, `addElemento` siempre trabaja con el elemento que previamente exista.

Los métodos de ayuda para nodos de múltiples apariciones tienen la forma `addElemento(array $attributes): Elemento`
y `multiElemento(array $attributes): self`. En donde `Elemento` se sustituye por el nombre del nodo y `self` es el
elemento que contiene el componente.
En este caso, `addElemento` siempre agrega un nuevo elemento.

```php
<?php
$nomina = new \CfdiUtils\Elements\Nomina12\Nomina();

// acceso por prefijo get (Emisor es de 1 aparición)
$emisor = $nomina->getEmisor();
$emisor['Curp'] = '...';

// agregar con prefijo add (Receptor es de 1 aparición)
$receptor = $nomina->addReceptor(['NumEmpleado' => 'JFIK000045']);

// agregar con prefijo add (Subcontratacion es de múltiples)
$receptor->addSubContratacion(['RfcLabora' => 'AAAA010101AAA', 'PorcentajeTiempo' => '50']); // devuelve SubContratacion
$receptor->addSubContratacion(['RfcLabora' => 'XXXX010101XXX', 'PorcentajeTiempo' => '60']); // devuelve SubContratacion

// agregar con prefijo multi (Subcontratacion es de múltiples)
$receptor->multiSubContratacion(
['RfcLabora' => 'AAAA010101AAA', 'PorcentajeTiempo' => '50'],
['RfcLabora' => 'XXXX010101XXX', 'PorcentajeTiempo' => '60']
); // devuelve Receptor (exactamente $receptor)
```

### Métodos de ayuda de los elementos

#### Elemento `Nomina`

- `Nomina::getEmisor(): Emisor`.
- `Nomina::addEmisor(array $attributes): Emisor`.
- `Nomina::getReceptor(): Receptor`.
- `Nomina::addReceptor(array $attributes): Receptor`.
- `Nomina::getPercepciones(): Percepciones`.
- `Nomina::addPercepciones(array $attributes): Percepciones`.
- `Nomina::getDeducciones(): Deducciones`.
- `Nomina::addDeducciones(array $attributes): Deducciones`.
- `Nomina::getOtrosPagos(): OtrosPagos`.
- `Nomina::addOtrosPagos(array $attributes): OtrosPagos`.
- `Nomina::getIncapacidades(): Incapacidades`.
- `Nomina::addIncapacidades(array $attributes): Incapacidades`.

#### Elemento `Emisor`

- `Emisor::getEntidadSNCF(): EntidadSNCF`.
- `Emisor::addEntidadSNCF(array $attributes): EntidadSNCF`.

#### Elemento `Receptor`

- `Receptor::addSubContratacion(array $attributes): SubContratacion`.
- `Receptor::multiSubContratacion(array $attributes, array $attributes, ...): Receptor`.

#### Elemento `Percepciones`

- `Percepciones::addPercepcion(array $attributes): Percepcion`.
- `Percepciones::multiPercepcion(array $attributes, array $attributes, ...): Percepcion`.
- `Percepciones::getJubilacionPensionRetiro(): JubilacionPensionRetiro`.
- `Percepciones::addJubilacionPensionRetiro(array $attributes): JubilacionPensionRetiro`.
- `Percepciones::getSeparacionIndemnizacion(): SeparacionIndemnizacion`.
- `Percepciones::addSeparacionIndemnizacion(array $attributes): SeparacionIndemnizacion`.

#### Elemento `Percepcion`

- `Percepcion::getAccionesOTitulos(): AccionesOTitulos`.
- `Percepcion::addAccionesOTitulos(array $attributes): AccionesOTitulos`.
- `Percepcion::addHorasExtra(array $attributes): HorasExtra`.
- `Percepcion::multiHorasExtra(array $attributes, array $attributes, ...): HorasExtra`.

#### Elemento `Deducciones`

- `Deducciones::addDeduccion(array $attributes): Deduccion`.
- `Deducciones::multiDeduccion(array $attributes, array $attributes, ...): Deducciones`.

#### Elemento `OtrosPagos`

- `OtrosPagos::addOtroPago(array $attributes): OtroPago`.
- `OtrosPagos::multiOtroPago(array $attributes, array $attributes, ...): OtrosPagos`.


#### Elemento `Incapacidades`

- `Incapacidades::addIncapacidad(array $attributes): addIncapacidad`.
- `Incapacidades::multiaddIncapacidad(array $attributes, array $attributes, ...): Incapacidades`.

### Agregar el complemento de nómina al comprobante

Cuando se tiene un comprobante, se puede utilizar el método `Comprobante::addComplemento()` para insertar
el elemento `Nomina` al comprobante.

```php
<?php
// clase de ayuda de creación del CFDI 3.3
$creator = new \CfdiUtils\CfdiCreator33();
// acceso al elemento Comprobante (el nodo principal del CFDI)
$comprobante = $creator->comprobante();

$nomina = new \CfdiUtils\Elements\Nomina12\Nomina();
// ... llenar la información de $nomina

// agregar $nomina como complemento del $comprobante
$comprobante->addComplemento($nomina);
```
18 changes: 9 additions & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ es una librería de PHP para leer, validar y crear CFDI 3.3.
Mira el archivo [README][] para información rápida (en inglés).

!!! note ""
Este proyecto se migrará eventualmente a `phpcfdi/cfdiutils`, aun no hay fecha planeada.
Este proyecto se migrará eventualmente a `phpcfdi/cfdiutils`, aún no hay fecha planeada.

La motivación de crear esta librería es contar con una herramienta flexible, rápida y
confiable para trabajar con CFDI. Se pretende que sea utilizada por la comunidad de PHP
Expand Down Expand Up @@ -57,7 +57,8 @@ Solo hay validadores para CFDI 3.3.
Solo hay métodos específicos para CFDI 3.3.

- [Crear un CFDI 3.3](crear/crear-cfdi.md)
- [Elementos de CFDI](crear/elements-cfdi33.md)
- [Elementos de CFDI 3.3](crear/elements-cfdi33.md)
- [Elementos de Nómina 1.2 revisión B](crear/complemento-nomina12b.md)
- [Agregar complementos](crear/complementos-aun-no-implementados.md)
- [CFDI Retenciones](crear/cfdi-de-retenciones-e-informacion-de-pagos.md)

Expand Down Expand Up @@ -102,12 +103,11 @@ Solo hay métodos específicos para CFDI 3.3.

## Copyright and License

The `eclipxe/CfdiUtils` library is copyright © [Carlos C Soto](http://eclipxe.com.mx/) and
licensed for use under the MIT License (MIT). Please see [LICENSE][] for more information.
The `eclipxe/CfdiUtils` library is copyright © [Carlos C Soto](http://eclipxe.com.mx/)
and licensed for use under the MIT License (MIT). Please see [LICENSE][] for more information.

La librería `eclipxe/CfdiUtils` tiene copyright © [Carlos C Soto](http://eclipxe.com.mx/)
y se encuentra amparada por la Licencia MIT (MIT).
Consulte el archivo [LICENSE][] para más información.
y se encuentra amparada por la Licencia MIT (MIT). Consulte el archivo [LICENSE][] para más información.


[readme]: https://github.com/eclipxe13/CfdiUtils/blob/master/README.md
Expand All @@ -117,18 +117,18 @@ Consulte el archivo [LICENSE][] para más información.
[discord]: https://discord.gg/aFGYXvX
[release]: https://github.com/eclipxe13/CfdiUtils/releases
[license]: https://github.com/eclipxe13/CfdiUtils/blob/master/LICENSE
[build]: https://travis-ci.org/eclipxe13/CfdiUtils?branch=master
[build]: https://travis-ci.com/eclipxe13/CfdiUtils?branch=master
[appveyor]: https://ci.appveyor.com/project/eclipxe13/cfdiutils/branch/master
[quality]: https://scrutinizer-ci.com/g/eclipxe13/CfdiUtils/?branch=master
[coverage]: https://scrutinizer-ci.com/g/eclipxe13/CfdiUtils/code-structure/master/code-coverage/src/CfdiUtils/
[downloads]: https://packagist.org/packages/eclipxe/CfdiUtils

[badge-source]: http://img.shields.io/badge/source-eclipxe13/CfdiUtils-blue?logo=github&style=flat-square
[badge-source]: https://img.shields.io/badge/source-eclipxe13/CfdiUtils-blue?logo=github&style=flat-square
[badge-documentation]: https://img.shields.io/readthedocs/cfdiutils/stable?logo=read-the-docs&style=flat-square
[badge-discord]: https://img.shields.io/discord/459860554090283019?logo=discord&style=flat-square
[badge-release]: https://img.shields.io/github/release/eclipxe13/CfdiUtils?logo=git&style=flat-square
[badge-license]: https://img.shields.io/github/license/eclipxe13/CfdiUtils?logo=open-source-initiative&style=flat-square
[badge-build]: https://img.shields.io/travis/eclipxe13/CfdiUtils/master?logo=travis&style=flat-square
[badge-build]: https://img.shields.io/travis/com/eclipxe13/CfdiUtils/master?logo=travis&style=flat-square
[badge-appveyor]: https://img.shields.io/appveyor/ci/eclipxe13/cfdiutils/master?logo=appveyor&style=flat-square
[badge-quality]: https://img.shields.io/scrutinizer/g/eclipxe13/CfdiUtils/master?logo=scrutinizer-ci&style=flat-square
[badge-coverage]: https://img.shields.io/scrutinizer/coverage/g/eclipxe13/CfdiUtils/master?logo=scrutinizer-ci&style=flat-square
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ nav:
- "Creación":
- crear/crear-cfdi.md
- crear/elements-cfdi33.md
- crear/complemento-nomina12b.md
- crear/complementos-aun-no-implementados.md
- crear/cfdi-de-retenciones-e-informacion-de-pagos.md
- "Componentes":
Expand Down
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/Nomina12/AccionesOTitulos.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\Nomina12;

use CfdiUtils\Elements\Common\AbstractElement;

class AccionesOTitulos extends AbstractElement
{
public function getElementName(): string
{
return 'nomina12:AccionesOTitulos';
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/Nomina12/CompensacionSaldosAFavor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\Nomina12;

use CfdiUtils\Elements\Common\AbstractElement;

class CompensacionSaldosAFavor extends AbstractElement
{
public function getElementName(): string
{
return 'nomina12:CompensacionSaldosAFavor';
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/Nomina12/Deduccion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\Nomina12;

use CfdiUtils\Elements\Common\AbstractElement;

class Deduccion extends AbstractElement
{
public function getElementName(): string
{
return 'nomina12:Deduccion';
}
}
28 changes: 28 additions & 0 deletions src/CfdiUtils/Elements/Nomina12/Deducciones.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace CfdiUtils\Elements\Nomina12;

use CfdiUtils\Elements\Common\AbstractElement;

class Deducciones extends AbstractElement
{
public function getElementName(): string
{
return 'nomina12:Deducciones';
}

public function addDeduccion(array $attributes = []): Deduccion
{
$deduccion = new Deduccion($attributes);
$this->addChild($deduccion);
return $deduccion;
}

public function multiDeduccion(array ...$elementAttributes): self
{
foreach ($elementAttributes as $attributes) {
$this->addDeduccion($attributes);
}
return $this;
}
}
26 changes: 26 additions & 0 deletions src/CfdiUtils/Elements/Nomina12/Emisor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace CfdiUtils\Elements\Nomina12;

use CfdiUtils\Elements\Common\AbstractElement;

class Emisor extends AbstractElement
{
public function getElementName(): string
{
return 'nomina12:Emisor';
}

public function getEntidadSNCF(): EntidadSNCF
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->helperGetOrAdd(new EntidadSNCF());
}

public function addEntidadSNCF(array $attributes = []): EntidadSNCF
{
$entidadSncf = $this->getEntidadSNCF();
$entidadSncf->addAttributes($attributes);
return $entidadSncf;
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/Nomina12/EntidadSNCF.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\Nomina12;

use CfdiUtils\Elements\Common\AbstractElement;

class EntidadSNCF extends AbstractElement
{
public function getElementName(): string
{
return 'nomina12:EntidadSNCF';
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/Nomina12/HorasExtra.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\Nomina12;

use CfdiUtils\Elements\Common\AbstractElement;

class HorasExtra extends AbstractElement
{
public function getElementName(): string
{
return 'nomina12:HorasExtra';
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/Nomina12/Incapacidad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\Nomina12;

use CfdiUtils\Elements\Common\AbstractElement;

class Incapacidad extends AbstractElement
{
public function getElementName(): string
{
return 'nomina12:Incapacidad';
}
}

0 comments on commit afc37dd

Please sign in to comment.