-
Notifications
You must be signed in to change notification settings - Fork 50
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 #104 from eclipxe13/fix-exentos
Fix SumasConceptos with Exentos (version 2.23.3)
- Loading branch information
Showing
6 changed files
with
299 additions
and
43 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
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
111 changes: 111 additions & 0 deletions
111
tests/CfdiUtilsTests/CreateComprobanteWithOnlyExentosCaseTest.php
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,111 @@ | ||
<?php | ||
|
||
namespace CfdiUtilsTests; | ||
|
||
use CfdiUtils\CfdiCreator33; | ||
use CfdiUtils\CfdiCreator40; | ||
use CfdiUtils\Nodes\Node; | ||
use CfdiUtils\Nodes\XmlNodeUtils; | ||
|
||
final class CreateComprobanteWithOnlyExentosCaseTest extends TestCase | ||
{ | ||
public function testCreateCcomprobante33WithOnlyExentosWriteImpuestos(): void | ||
{ | ||
$creator = new CfdiCreator33([]); | ||
|
||
$comprobante = $creator->comprobante(); | ||
$comprobante->addConcepto([ | ||
'ClaveProdServ' => '01010101', | ||
'NoIdentificacion' => 'FOO', | ||
'Cantidad' => '1', | ||
'ClaveUnidad' => 'E48', | ||
'Descripcion' => 'HONORARIOS MEDICOS', | ||
'ValorUnitario' => '617.000000', | ||
'Importe' => '617.000000', | ||
'Descuento' => '144.271240', | ||
'ObjetoImp' => '02', | ||
])->addTraslado([ | ||
'Impuesto' => '002', | ||
'TipoFactor' => 'Exento', | ||
]); | ||
|
||
// test sumasConceptos | ||
|
||
$precision = 2; | ||
$sumasConceptos = $creator->buildSumasConceptos($precision); | ||
$this->assertTrue($sumasConceptos->hasExentos()); | ||
$this->assertFalse($sumasConceptos->hasTraslados()); | ||
$this->assertFalse($sumasConceptos->hasRetenciones()); | ||
|
||
$expectedExentos = [ | ||
'002:Exento:' => [ | ||
'TipoFactor' => 'Exento', | ||
'Impuesto' => '002', | ||
'Base' => 0, | ||
], | ||
]; | ||
|
||
$this->assertEquals($expectedExentos, $sumasConceptos->getExentos()); | ||
|
||
// test cfdi:Impuestos XML does not exists | ||
|
||
$creator->addSumasConceptos($sumasConceptos, $precision); | ||
|
||
$this->assertNull($comprobante->searchNode('cfdi:Impuestos')); | ||
} | ||
|
||
public function testCreateCcomprobante40WithOnlyExentosWriteImpuestos(): void | ||
{ | ||
$creator = new CfdiCreator40([]); | ||
|
||
$comprobante = $creator->comprobante(); | ||
$comprobante->addConcepto([ | ||
'ClaveProdServ' => '01010101', | ||
'NoIdentificacion' => 'FOO', | ||
'Cantidad' => '1', | ||
'ClaveUnidad' => 'E48', | ||
'Descripcion' => 'HONORARIOS MEDICOS', | ||
'ValorUnitario' => '617.000000', | ||
'Importe' => '617.000000', | ||
'Descuento' => '144.271240', | ||
'ObjetoImp' => '02', | ||
])->addTraslado([ | ||
'Base' => '472.728760', | ||
'Impuesto' => '002', | ||
'TipoFactor' => 'Exento', | ||
]); | ||
|
||
// test sumasConceptos | ||
|
||
$precision = 2; | ||
$sumasConceptos = $creator->buildSumasConceptos($precision); | ||
$this->assertTrue($sumasConceptos->hasExentos()); | ||
$this->assertFalse($sumasConceptos->hasTraslados()); | ||
$this->assertFalse($sumasConceptos->hasRetenciones()); | ||
|
||
$expectedExentos = [ | ||
'002:Exento:' => [ | ||
'TipoFactor' => 'Exento', | ||
'Impuesto' => '002', | ||
'Base' => 472.72876, | ||
], | ||
]; | ||
|
||
$this->assertEquals($expectedExentos, $sumasConceptos->getExentos()); | ||
|
||
// test cfdi:Impuestos XML | ||
|
||
$creator->addSumasConceptos($sumasConceptos, $precision); | ||
|
||
$expectedImpuestosNode = new Node('cfdi:Impuestos', [], [ | ||
new Node('cfdi:Traslados', [], [ | ||
new Node('cfdi:Traslado', ['TipoFactor' => 'Exento', 'Impuesto' => '002', 'Base' => '472.73']), | ||
]), | ||
]); | ||
|
||
$this->assertXmlStringEqualsXmlString( | ||
XmlNodeUtils::nodeToXmlString($expectedImpuestosNode), | ||
XmlNodeUtils::nodeToXmlString($comprobante->searchNode('cfdi:Impuestos')) | ||
); | ||
} | ||
} |
Oops, something went wrong.