Skip to content

Commit 31f9257

Browse files
authored
Merge pull request #128 from eclipxe13/version-3.0.1
Write TasaOCuotaP only when TipoFactorP is not Exento (version 3.0.1) Add S A P I DE CV to RegimenCapitalRemover
2 parents c05e25c + 4071a67 commit 31f9257

File tree

7 files changed

+78
-6
lines changed

7 files changed

+78
-6
lines changed

.phive/phars.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="php-cs-fixer" version="^3.72.0" installed="3.72.0" location="./tools/php-cs-fixer" copy="false"/>
4-
<phar name="phpcs" version="^3.12.0" installed="3.12.0" location="./tools/phpcs" copy="false"/>
5-
<phar name="phpcbf" version="^3.12.0" installed="3.12.0" location="./tools/phpcbf" copy="false"/>
6-
<phar name="phpstan" version="^2.1.8" installed="2.1.8" location="./tools/phpstan" copy="false"/>
3+
<phar name="php-cs-fixer" version="^3.75.0" installed="3.75.0" location="./tools/php-cs-fixer" copy="false"/>
4+
<phar name="phpcs" version="^3.12.2" installed="3.12.2" location="./tools/phpcs" copy="false"/>
5+
<phar name="phpcbf" version="^3.12.2" installed="3.12.2" location="./tools/phpcbf" copy="false"/>
6+
<phar name="phpstan" version="^2.1.14" installed="2.1.14" location="./tools/phpstan" copy="false"/>
77
</phive>

docs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
- Fix/improve `ElementsMaker` standard.
88
- Remove code to build CFDI 3.3.
99

10+
## Version 3.0.1 2025-05-01
11+
12+
Add `S A P I DE CV` to `RegimenCapitalRemover`.
13+
This should be an error from SAT when creates the certificate 00001000000710061506, but we have deal with it.
14+
15+
Fix a bug when write *Pagos* taxes summary.
16+
It was writing `TasaOCuotaP` when `TipoFactorP` is `Exento`.
17+
It now does not write that attribute as in `ImporteP`.
18+
Thanks `@jiagbrody` (discord) for noticing this issue.
19+
1020
## Version 3.0.0 2025-03-18
1121

1222
This is a major release primary for compatibility to PHP 8.4.

phpcs.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
1919
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
2020
<rule ref="Generic.Formatting.SpaceAfterNot"/>
21-
<rule ref="Generic.Functions.CallTimePassByReference"/>
2221
<rule ref="Generic.NamingConventions.ConstructorName"/>
2322
<rule ref="Generic.PHP.DeprecatedFunctions"/>
2423
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>

src/CfdiUtils/SumasPagos20/PagosWriter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function writePago(ElementPago $pagoElement, Pago $pagoData): void
9090
$trasladosElement->addTrasladoP([
9191
'ImpuestoP' => $traslado->getImpuesto(),
9292
'TipoFactorP' => $traslado->getTipoFactor(),
93-
'TasaOCuotaP' => $traslado->getTasaCuota(),
93+
'TasaOCuotaP' => ('Exento' === $traslado->getTipoFactor()) ? null : $traslado->getTasaCuota(),
9494
'BaseP' => $traslado->getBase(),
9595
'ImporteP' => ('Exento' === $traslado->getTipoFactor()) ? null : $traslado->getImporte(),
9696
]);

src/CfdiUtils/Utils/RegimenCapitalRemover.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ final class RegimenCapitalRemover
104104
'SAB DE CV',
105105
'SAB',
106106
'SAPI DE CV',
107+
'S A P I DE CV',
107108
'SAPI DE CV,SOFOM,ENR',
108109
'SAPI',
109110
'SAS DE CV',
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CfdiUtilsTests\SumasPagos20;
6+
7+
use CfdiUtils\Elements\Pagos20\Pagos as ElementPagos20;
8+
use CfdiUtils\SumasPagos20\Calculator;
9+
use CfdiUtils\SumasPagos20\PagosWriter;
10+
use CfdiUtilsTests\TestCase;
11+
12+
final class PagosWriterTest extends TestCase
13+
{
14+
public function testWritePagoWithOnlyOneExento(): void
15+
{
16+
$pagos = new ElementPagos20();
17+
18+
$pago = $pagos->addPago([
19+
'FechaPago' => '2025-06-24',
20+
'FormaDePagoP' => '03',
21+
'MonedaP' => 'MXN',
22+
'TipoCambioP' => '1',
23+
'Monto' => '10.00',
24+
]);
25+
26+
$pago->addDoctoRelacionado([
27+
'IdDocumento' => '00000000-1111-2222-3333-00000000000A',
28+
'MonedaDR' => 'MXN',
29+
'EquivalenciaDR' => '1',
30+
'NumParcialidad' => '1',
31+
'ImpSaldoAnt' => '4500.00',
32+
'ImpPagado' => '10.00',
33+
'ImpSaldoInsoluto' => '4490.00',
34+
'ObjetoImpDR' => '02',
35+
])->getImpuestosDR()->getTrasladosDR()->addTrasladoDR([
36+
'BaseDR' => '10.00',
37+
'ImpuestoDR' => '002',
38+
'TipoFactorDR' => 'Exento',
39+
]);
40+
41+
$calculator = new Calculator(2);
42+
$result = $calculator->calculate($pagos);
43+
44+
$writer = new PagosWriter($pagos);
45+
$writer->writePago($pago, $result->getPago(0));
46+
47+
$traslado = $pagos->searchNode('pago20:Pago', 'pago20:ImpuestosP', 'pago20:TrasladosP', 'pago20:TrasladoP');
48+
$this->assertFalse(isset($traslado['TasaOCuotaP']));
49+
$this->assertFalse(isset($traslado['ImporteP']));
50+
$this->assertSame('002', $traslado['ImpuestoP']);
51+
$this->assertSame('10.00', $traslado['BaseP']);
52+
}
53+
}

tests/CfdiUtilsTests/Utils/RegimenCapitalRemoverTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,13 @@ public function testRemoveOnlyOneEntry(): void
3838
$remover = RegimenCapitalRemover::createDefault();
3939
$this->assertSame($expected, $remover->remove($fullname));
4040
}
41+
42+
public function testRemoveSapiDeCv(): void
43+
{
44+
// There are CSD (like 00001000000710061506) with "EMPRESA S A P I DE CV"
45+
$fullname = 'EMPRESA S A P I DE CV';
46+
$expected = 'EMPRESA';
47+
$remover = RegimenCapitalRemover::createDefault();
48+
$this->assertSame($expected, $remover->remove($fullname));
49+
}
4150
}

0 commit comments

Comments
 (0)