Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pagos 2.0 calculator & parciales construcción 1.0 elements (version 2.24.0) #110

Merged
merged 29 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
21838c0
Fix link syntax
eclipxe13 Jun 14, 2023
d06b46d
Fix precfdi term to *Pre-CFDI*
eclipxe13 Jun 14, 2023
4e78b10
Update markdownlint-cli tool
eclipxe13 Jun 14, 2023
c2a4dc0
Merge branch 'development'
eclipxe13 Jun 14, 2023
b84a381
Add complement Servicios parciales de construcción 1.0
eclipxe13 Jun 14, 2023
1b4264a
Merge branch 'parcialescontruccion10' into development
eclipxe13 Jun 14, 2023
8c61af6
Add bcmath extension as a suggestion and development
eclipxe13 Jun 14, 2023
ebf3163
Add Pagos 2.0 Calculator
eclipxe13 Jun 14, 2023
45fcdd2
Add Pagos 2.0 Writer (writes calculations)
eclipxe13 Jun 14, 2023
6e66d14
Add 8 cases from well known pagos values to test calculations
eclipxe13 Jun 14, 2023
50e5876
Add documentation for Pagos 2.0 calculator and writer
eclipxe13 Jun 14, 2023
c91691c
Merge branch 'pagos/calculator' into development
eclipxe13 Jun 14, 2023
95bf0ba
Fix PHP 7.3 compatibility (1st try)
eclipxe13 Jun 14, 2023
71a1602
Refactor CfdiUtils\SumasPagos20\Impuestos
eclipxe13 Jun 14, 2023
2931dc6
Remove assets folder from GitHub code language detection
eclipxe13 Jun 14, 2023
7517676
Fix typo on classes and namespace
eclipxe13 Jun 14, 2023
405f49d
Se agrega maker y especificacioes
Feb 20, 2023
3d6fc8e
Remove duplicated (and incorrect) spec file
eclipxe13 Jun 14, 2023
23acf51
Fix elements ConsumoDeCombustibles11
eclipxe13 Jun 14, 2023
fa0ca5e
Review Donatarias11
eclipxe13 Jun 15, 2023
7d30570
Fix IEDU 1.0
eclipxe13 Jun 15, 2023
4008f79
Fix INE 1.1
eclipxe13 Jun 15, 2023
6ccb6f3
Review Leyendas Fiscales 1.0
eclipxe13 Jun 15, 2023
212e4c3
Fix Notarios Públicos 1.0
eclipxe13 Jun 15, 2023
cfef601
Remove script, use instructions in README
eclipxe13 Jun 15, 2023
936315a
Merge branch 'blake-master' into development
eclipxe13 Jun 15, 2023
d8c3780
Documentation review
eclipxe13 Jun 15, 2023
f5a46da
Move soap extension requirement to suggest
eclipxe13 Jun 15, 2023
85f3a14
Reduce wait for code coverage from 10 mins to 2 minutes.
eclipxe13 Jun 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore

# Do not count these files on github code language
/tests/assets/** linguist-detectable=false
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: soap, intl, xsl, fileinfo
extensions: soap, intl, xsl, fileinfo, bcmath
coverage: none
tools: composer:v2, phpstan
env:
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: soap, intl, xsl, fileinfo
extensions: soap, intl, xsl, fileinfo, bcmath
coverage: xdebug
tools: composer:v2
env:
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: soap, intl, xsl, fileinfo
extensions: soap, intl, xsl, fileinfo, bcmath
coverage: none
tools: composer:v2
env:
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ build:

tools:
external_code_coverage:
timeout: 600 # default is 300 seconds
timeout: 120 # default is 300 seconds
4 changes: 2 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at eclipxe13@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
reported by contacting the project team at [eclipxe13@gmail.com](mailto:eclipxe13@gmail.com).
All complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@ CFDI y herramientas del SAT. Y próximamente el lugar donde publicaremos la vers

## Main features

- Create CFDI version 3.3 & 4.0 based on a friendly extendable non-xml objects (`nodes`).
- Create CFDI version 3.3 & 4.0 based on a friendly extendable non XML objects (`nodes`).
- Read CFDI version 3.2, 3.3 & 4.0.
- Validate CFDI version 3.3 & 4.0 against schemas, cfdi signature (`Sello`) and custom rules.
- Validate CFDI version 3.3 & 4.0 against schemas, CFDI signature (`Sello`) and custom rules.
- Validate that the Timbre Fiscal Digital signature match with the CFDI 3.3 & CFDI 4.0,
if not then the document has been modified after signature.
- Validates the "Complemento de recepción de pagos".
- Helper objects to deal with:
- `Cadena de origen` generation.
- Extract information from CER files or `Certificado` attribute.
- Calculate `Comprobante` sums based on the list of `Conceptos`.
- Retrieve the CFDI version information.
- Keep a local copy of the tree of XSD and XSLT file dependencies from SAT.
- Keep a local copy of certificates to avoid downloads them each time.
- Check the SAT WebService to get the status of a CFDI (*Estado*, *EsCancelable* and *EstatusCancelacion*) without WSDL.
- Check the SAT WebService to get the status of a CFDI (*`Estado`*, *`EsCancelable`*, *`EstatusCancelacion`* and *`EFOS`*) without WSDL.


## Installation
Expand Down Expand Up @@ -78,6 +77,7 @@ See <https://www.php.net/supported-versions.php> for more details.
| 2.12.7 | 7.0, 7.1, 7.2, 7.3, 7.4 | 2019-12-04 |
| 2.15.0 | 7.3, 7.4, 8.0 | 2021-03-17 |
| 2.20.1 | 7.3, 7.4, 8.0, 8.1 | 2022-03-08 |
| 2.23.5 | 7.3, 7.4, 8.0, 8.1, 8.2 | 2023-05-26 |

## Contributing

Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@
"ext-simplexml": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-soap": "*",
"ext-iconv": "*",
"ext-json": "*",
"symfony/process": "^3.4|^4.2|^5.0|^6.0",
"eclipxe/xmlresourceretriever": "^1.3.0",
"eclipxe/xmlschemavalidator": "^3.0.2"
},
"suggest": {
"ext-bcmath": "Allows calculate totals and taxes on Pagos 2.0",
"ext-soap": "Allows consume the CFDI Status SAT Web Service",
"genkgo/xsl": "Allows usage of Genkgo/Xsl transformations"
},
"require-dev": {
"ext-bcmath": "*",
"ext-soap": "*",
"genkgo/xsl": "^1.0.8",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"php-namespace": "CfdiUtils\\Elements\\ConsumoDeCombustibles11",
"prefix": "consumodecombustibles11",
"xml-namespace": "http://www.sat.gob.mx/ConsumoDeCombustibles11",
"xml-schemalocation": "http://www.sat.gob.mx/sitio_internet/cfd/consumodecombustibles/consumodeCombustibles11.xsd",
"version-attribute": "version",
"version-value": "1.1",
"root-element": "ConsumoDeCombustibles",
"structure": {
"Conceptos": {
"ConceptoConsumoDeCombustibles": {
"multiple": true,
"Determinados": {
"Determinado": {
"multiple": true
}
}
}
}
}
}
11 changes: 11 additions & 0 deletions development/ElementsMaker/specifications/Donatarias11.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"php-namespace": "CfdiUtils\\Elements\\Donatarias11",
"prefix": "donat",
"xml-namespace": "http://www.sat.gob.mx/donat",
"xml-schemalocation": "http://www.sat.gob.mx/sitio_internet/cfd/donat/donat11.xsd",
"version-attribute": "version",
"version-value": "1.1",
"root-element": "Donatarias",
"structure": {
}
}
11 changes: 11 additions & 0 deletions development/ElementsMaker/specifications/Iedu10.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"php-namespace": "CfdiUtils\\Elements\\Iedu10",
"prefix": "iedu",
"xml-namespace": "http://www.sat.gob.mx/iedu",
"xml-schemalocation": "http://www.sat.gob.mx/sitio_internet/cfd/iedu/iedu.xsd",
"version-attribute": "version",
"version-value": "1.0",
"root-element": "instEducativas",
"structure": {
}
}
11 changes: 11 additions & 0 deletions development/ElementsMaker/specifications/Ine11.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"php-namespace": "CfdiUtils\\Elements\\Ine11",
"prefix": "ine",
"xml-namespace": "http://www.sat.gob.mx/ine",
"xml-schemalocation": "http://www.sat.gob.mx/sitio_internet/cfd/ine/ine11.xsd",
"version-attribute": "Version",
"version-value": "1.1",
"root-element": "INE",
"structure": {
}
}
14 changes: 14 additions & 0 deletions development/ElementsMaker/specifications/LeyendasFiscales10.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"php-namespace": "CfdiUtils\\Elements\\LeyendasFiscales10",
"prefix": "leyendasFisc",
"xml-namespace": "http://www.sat.gob.mx/leyendasFiscales",
"xml-schemalocation": "http://www.sat.gob.mx/sitio_internet/cfd/leyendasFiscales/leyendasFisc.xsd",
"version-attribute": "version",
"version-value": "1.0",
"root-element": "LeyendasFiscales",
"structure": {
"Leyenda": {
"multiple": true
}
}
}
34 changes: 34 additions & 0 deletions development/ElementsMaker/specifications/NotariosPublicos10.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"php-namespace": "CfdiUtils\\Elements\\NotariosPublicos10",
"prefix": "notariospublicos",
"xml-namespace": "http://www.sat.gob.mx/notariospublicos",
"xml-schemalocation": "http://www.sat.gob.mx/sitio_internet/cfd/notariospublicos/notariospublicos.xsd",
"version-attribute": "Version",
"version-value": "1.0",
"root-element": "NotariosPublicos",
"structure": {
"DescInmuebles": {
"DescInmueble": {
"multiple": true
}
},
"DatosOperacion": {},
"DatosNotario": {},
"DatosEnajenante": {
"DatosUnEnajenante": {},
"DatosEnajenantesCopSC": {
"DatosEnajenanteCopSC": {
"multiple": true
}
}
},
"DatosAdquiriente": {
"DatosUnAdquiriente": {},
"DatosAdquirientesCopSC": {
"DatosAdquirienteCopSC": {
"multiple": true
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"php-namespace": "CfdiUtils\\Elements\\ParcialesConstruccion10",
"prefix": "servicioparcial",
"xml-namespace": "http://www.sat.gob.mx/servicioparcialconstruccion",
"xml-schemalocation": "http://www.sat.gob.mx/sitio_internet/cfd/servicioparcialconstruccion/servicioparcialconstruccion.xsd",
"version-attribute": "Version",
"version-value": "1.0",
"root-element": "parcialesconstruccion",
"structure": {
"Inmueble": {}
}
}
29 changes: 29 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,35 @@
- Merge methods from `\CfdiUtils\Nodes\NodeHasValueInterface` into `\CfdiUtils\Nodes\NodeInterface`.
- Remove deprecated constant `CfdiUtils\Retenciones\Retenciones::RET_NAMESPACE`.

## Version 2.24.0 2023-06-14

Add a calculator and writer for complement *Pagos 2.0*.

This tool takes a *Pre-CFDI* elements to write `Pagos\Totales`, `Pagos\Pago[]\ImpuestosP`
and (if not found) `Pagos\Pago[]@Monto`. This feature is also documented.

Make SOAP extension requirement optional.

- Add element helpers for complement *Servicios parciales de construcción 1.0*.
- Add element helpers for complement *Consumo de combustibles 1.1*.
- Add element helpers for complement *Donatarias 1.1*.
- Add element helpers for complement *Instituciones educativas privadas 1.0*.
- Add element helpers for complement *INE 1.1*.
- Add element helpers for complement *Leyendas Fiscales 1.0*.
- Add element helpers for complement *Notarios Públicos 1.0*.

Thanks `@BlakePro` for the initial work on these improvements.

Changes on development environment and documentation:

- Move CFDI creation from 3.3 to 4.0.
- Review all files and fix almost all typos and phrasing errors, thanks PhpStorm.
- Add usage of phpcfdi/credentials.
- Add support for PHP 8.2 on README.md
- Remove GitHub code language detection on `tests/assets/`.
- Update `markdownlint-cli` tool.
- Fix issues found by `markdownlint-cli`.

## Version 2.23.5 2023-05-25

- Fix `SELLO04` false positives on CFDI 4.0.
Expand Down
6 changes: 3 additions & 3 deletions docs/componentes/cadena-de-origen.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ $location = $resolver->resolveCadenaOrigenLocation('3.3');

// fabricar la cadena de origen
$builder = new DOMBuilder();
$cadenaorigen = $builder->build($xmlContent, $location);
$cadenaOrigen = $builder->build($xmlContent, $location);
```

Sin embargo, en la práctica es poco probable que desees generar la cadena de origen.
Básicamente porque si estás creando un CFDI esta será generada automáticamente.
Básicamente, porque si estás creando un CFDI esta será generada automáticamente.
Si estás leyendo o validando también será generada automáticamente por los validadores.


Expand Down Expand Up @@ -137,7 +137,7 @@ $tfdXmlString = \CfdiUtils\Nodes\XmlNodeUtils::nodeToXmlString($tfd);
## PHP y XSLT versión 2

Es importante notar que hasta el momento (enero/2019) no es posible en PHP
procesar XSLT versión 2.0. Sin embargo el procesador que sí tiene PHP genera
procesar XSLT versión 2.0. Sin embargo, el procesador que sí tiene PHP genera
las cadenas de origen a pesar de la versión.
Esto no garantiza que si el SAT modifica los archivos XSLT utilizando
características incompatibles se producirá el resultado correcto.
Expand Down
4 changes: 2 additions & 2 deletions docs/componentes/certificado.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Una vez cargado el certificado permite obtener los siguientes datos utilizando *
- Llave pública
- Nombre del archivo cargado

Adicionalmente cuenta con los métodos:
Adicionalmente, cuenta con los métodos:

- Permite verificar si una llave privada corresponde a este certificado:

Expand Down Expand Up @@ -64,7 +64,7 @@ var_dump($certificate->getRfc()); // algo como COSC8001137NA

## Números de serie del certificado

En el número de serie requerido en los CFDI se utiliza una representación ASCII y no hexadecimal, sin embargo
En el número de serie requerido en los CFDI se utiliza una representación ASCII y no hexadecimal, sin embargo,
en algunas ocasiones se podría necesitar el número en formato hexadecimal de dos dígitos o la representación decimal.

El objeto `Certificado` contiene internamente un objeto de tipo `SerialNumber` que del que se puede obtener **una copia**
Expand Down
19 changes: 10 additions & 9 deletions docs/componentes/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ entonces `Comprobante::addEmisor(['RegimenFiscal' => '601'])` tiene este comport

- Se obtiene el elemento `Emisor`, si no existe se crea uno vacío.
- Se escriben los atributos pasados al elemento obtenido.
- Se devuelve el elemento.
- Se devuelve el elemento creado `Emisor`.

Por el contrario, como puede haber varios Cfdi Relacionados, entonces
`CfdiRelacionados::addCfdiRelacionado(['UUID' => $uuid])` tiene este comportamiento:
Por el contrario, como puede haber varios conceptos, entonces
`Conceptos::addConcepto([/* attributes */])` tiene este comportamiento:

- Se crea un elemento de tipo `CfdiRelacionado` con los atributos pasados.
- Se agrega el elemento recién creado a los hijos de `CfdiRelacionados`.
- Se devuelve el elemento creado.
- Se crea un elemento de tipo `Concepto` con los atributos pasados.
- Se agrega el elemento recién creado a los hijos de `Conceptos`.
- Se devuelve el elemento creado `Concepto`.

Existe un caso donde lo que se espera entregar como atributo al prefijo `add*` es en realidad un hijo.
Existe algunos casos donde, lo que se espera entregar como argumento al prefijo `add*`, es en realidad un hijo.
Esto sucede en `addComplemento` y `addAddenda`.


Expand All @@ -66,7 +66,8 @@ La nomenclatura con el prefijo `multi*` se escribe la forma `ElementoPadre::mult
y se espera crear múltiples una instancia de `ElementoHijo` con los atributos datos, agregarla a los hijos de `ElementoPadre`
y la instancia de `ElementoPadre` creada.

Otra forma de decirlo: es como los métodos `add*` pero se le pueden mandar varios arreglos de atributos y se creará un elemento para cada parámetro enviado.
Otra forma de decirlo: es como los métodos `add*` pero se le pueden mandar varios arreglos de atributos y
se creará un elemento para cada parámetro enviado.

Por lo anterior, `CfdiRelacionados::multiCfdiRelacionado([ ['UUID' => $uuid1], ['UUID' => $uuid2] ])` agregará dos hijos
y devolverá la misma instancia del objeto llamado.
y devolverá la misma instancia del objeto `CfdiRelacionados` llamado.
29 changes: 14 additions & 15 deletions docs/componentes/estado-sat.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Se refiere a que si en el momento de la consulta el CFDI se puede cancelar.

- `No cancelable`: No se puede cancelar, tal vez ya hay documentos relacionados.
- `Cancelable sin aceptación`: Se puede cancelar de inmediato.
- `Cancelable con aceptación`: Se puede cancelar pero se va a tener que esperar respuesta.
- `Cancelable con aceptación`: Se puede cancelar, pero se va a tener que esperar respuesta.

### EstatusCancelacion (estado de cancelación)

Expand All @@ -106,26 +106,25 @@ Se refiere al estado de la cancelación solicitada previamente.

El WebService del SAT devuelve dos códigos que asumimos se refieren al emisor del CFDI:

- 200: No se enctró en el listado de EFOS.
- 200: No se encontró en el listado de EFOS.
- 100: Se encontró en el listado de EFOS.

Desconocemos si el código se refiere a si estaba listado en el momento de la emisión del CFDI,
al momento de ser reportado el CFDI al SAT o al momento de consulta.

## Estados mutuamente excluyentes

CodigoEstatus | Estado | EsCancelable | EstatusCancelacion | Explicación
------------- | ------------- | ------------------------- | ------------------------ | -----------------------------------------------------
N - ... | * | * | * | El SAT no sabe del CFDI con los datos ofrecidos
S - ... | Cancelado | * | Plazo vencido | Cancelado por plazo vencido
S - ... | Cancelado | * | Cancelado con aceptación | Cancelado con aceptación del receptor
S - ... | Cancelado | * | Cancelado sin aceptación | No fue requerido preguntarle al receptor y se canceló
S - ... | Vigente | No cancelable | * | No se puede cancelar
S - ... | Vigente | Cancelable sin aceptación | * | Se puede cancelar pero no se ha realizado solicitud
S - ... | Vigente | Cancelable con aceptación | (ninguno) | Se puede cancelar pero no se ha realizado solicitud
S - ... | Vigente | Cancelable con aceptación | En proceso | Se hizo la solicitud y se está en espera
S - ... | Vigente | Cancelable con aceptación | Solicitud rechazada | Se hizo la solicitud y fue rechazada

| `CodigoEstatus` | `Estado` | `EsCancelable` | `EstatusCancelacion` | `Explicación` |
|-----------------|-----------|---------------------------|--------------------------|-------------------------------------------------------|
| N - ... | * | * | * | El SAT no sabe del CFDI con los datos ofrecidos |
| S - ... | Cancelado | * | Plazo vencido | Cancelado por plazo vencido |
| S - ... | Cancelado | * | Cancelado con aceptación | Cancelado con aceptación del receptor |
| S - ... | Cancelado | * | Cancelado sin aceptación | No fue requerido preguntarle al receptor y se canceló |
| S - ... | Vigente | No cancelable | * | No se puede cancelar |
| S - ... | Vigente | Cancelable sin aceptación | * | Se puede cancelar pero no se ha realizado solicitud |
| S - ... | Vigente | Cancelable con aceptación | (ninguno) | Se puede cancelar pero no se ha realizado solicitud |
| S - ... | Vigente | Cancelable con aceptación | En proceso | Se hizo la solicitud y se está en espera |
| S - ... | Vigente | Cancelable con aceptación | Solicitud rechazada | Se hizo la solicitud y fue rechazada |

## Ejemplo de uso a partir de un archivo

Expand Down Expand Up @@ -183,7 +182,7 @@ Hasta antes de la versión 2.10 se necesitaba un archivo WSDL,
a partir de 2.10 ya no se necesita y la llamada SOAP se hace correctamente.


## Posibles futuros cambios
## Futuros cambios

Usar alguna librería como <https://github.com/phpro/soap-client> o <https://github.com/meng-tian/async-soap-guzzle>
en lugar de la extensión SOAP de PHP.
Expand Down
Loading