diff --git a/packages/xml/src/Xml/Templates/invoice2.1.xml.twig b/packages/xml/src/Xml/Templates/invoice2.1.xml.twig index 72c66b74..ef91f768 100644 --- a/packages/xml/src/Xml/Templates/invoice2.1.xml.twig +++ b/packages/xml/src/Xml/Templates/invoice2.1.xml.twig @@ -324,7 +324,7 @@ {% if doc.mtoOperInafectas is not null %} {{ doc.mtoOperInafectas|n_format }} - 0 + 0.00 9998 @@ -337,7 +337,7 @@ {% if doc.mtoOperExoneradas is not null %} {{ doc.mtoOperExoneradas|n_format }} - 0 + 0.00 9997 @@ -363,7 +363,7 @@ {% if doc.mtoOperExportacion is not null %} {{ doc.mtoOperExportacion|n_format }} - 0 + 0.00 9995 diff --git a/packages/xml/src/Xml/Templates/notacr2.1.xml.twig b/packages/xml/src/Xml/Templates/notacr2.1.xml.twig index 7492a54f..53db4dba 100644 --- a/packages/xml/src/Xml/Templates/notacr2.1.xml.twig +++ b/packages/xml/src/Xml/Templates/notacr2.1.xml.twig @@ -189,7 +189,7 @@ {% if doc.mtoOperInafectas %} {{ doc.mtoOperInafectas|n_format }} - 0 + 0.00 9998 @@ -202,7 +202,7 @@ {% if doc.mtoOperExoneradas %} {{ doc.mtoOperExoneradas|n_format }} - 0 + 0.00 9997 @@ -228,7 +228,7 @@ {% if doc.mtoOperExportacion %} {{ doc.mtoOperExportacion|n_format }} - 0 + 0.00 9995 diff --git a/packages/xml/src/Xml/Templates/notadb2.1.xml.twig b/packages/xml/src/Xml/Templates/notadb2.1.xml.twig index ae0eb113..ee39389e 100644 --- a/packages/xml/src/Xml/Templates/notadb2.1.xml.twig +++ b/packages/xml/src/Xml/Templates/notadb2.1.xml.twig @@ -170,7 +170,7 @@ {% if doc.mtoOperInafectas %} {{ doc.mtoOperInafectas|n_format }} - 0 + 0.00 9998 @@ -183,7 +183,7 @@ {% if doc.mtoOperExoneradas %} {{ doc.mtoOperExoneradas|n_format }} - 0 + 0.00 9997 @@ -209,7 +209,7 @@ {% if doc.mtoOperExportacion %} {{ doc.mtoOperExportacion|n_format }} - 0 + 0.00 9995 diff --git a/packages/xml/tests/Xml/Builder/FeBuilderTrait.php b/packages/xml/tests/Xml/Builder/FeBuilderTrait.php index 11d6557f..0bf81c71 100644 --- a/packages/xml/tests/Xml/Builder/FeBuilderTrait.php +++ b/packages/xml/tests/Xml/Builder/FeBuilderTrait.php @@ -59,4 +59,26 @@ private function build(DocumentInterface $document): ?string return $generator->build($document); } + + /** + * Verifica que el TaxAmount de los tributos sin monto (EXP, EXO, INA) tenga formato n(12,2). + * + * @param string $xml + * @param int $expectedCount + */ + private function assertZeroTaxAmountFormat(string $xml, int $expectedCount): void + { + $doc = new \DOMDocument(); + $doc->loadXML($xml); + $xpath = new \DOMXPath($doc); + $xpath->registerNamespace('cac', 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2'); + $xpath->registerNamespace('cbc', 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'); + + $nodes = $xpath->query('/*/cac:TaxTotal/cac:TaxSubtotal[cac:TaxCategory/cac:TaxScheme/cbc:ID[.="9995" or .="9997" or .="9998"]]/cbc:TaxAmount'); + + $this->assertSame($expectedCount, $nodes->length); + foreach ($nodes as $node) { + $this->assertSame('0.00', $node->nodeValue); + } + } } diff --git a/packages/xml/tests/Xml/Builder/v21/FeInvoiceBuilderTest.php b/packages/xml/tests/Xml/Builder/v21/FeInvoiceBuilderTest.php index 96e22a7a..0afc1afc 100644 --- a/packages/xml/tests/Xml/Builder/v21/FeInvoiceBuilderTest.php +++ b/packages/xml/tests/Xml/Builder/v21/FeInvoiceBuilderTest.php @@ -36,6 +36,7 @@ public function testGenerate() // file_put_contents('x.xml', $xml); $this->assertNotEmpty($xml); $this->assertSchema($xml); + $this->assertZeroTaxAmountFormat($xml, 3); } /** diff --git a/packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php b/packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php index 10b5579d..95de118d 100644 --- a/packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php +++ b/packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php @@ -29,13 +29,16 @@ public function testCreateXmlCreditNote() { /**@var $note Note*/ $note = $this->createDocument(NoteStore::class); - $note->setUblVersion('2.1'); + $note->setUblVersion('2.1') + ->setMtoOperExoneradas(100) + ->setMtoOperInafectas(50); $xml = $this->build($note); // file_put_contents('notecr.xml', $xml); $this->assertNotEmpty($xml); $this->assertSchema($xml); + $this->assertZeroTaxAmountFormat($xml, 2); } public function testCreateXmlDebitNote() @@ -43,12 +46,15 @@ public function testCreateXmlDebitNote() /**@var $note Note*/ $note = $this->createDocument(NoteStore::class); $note->setTipoDoc('08'); - $note->setUblVersion('2.1'); + $note->setUblVersion('2.1') + ->setMtoOperExoneradas(100) + ->setMtoOperInafectas(50); $xml = $this->build($note); // file_put_contents('notedb.xml', $xml); $this->assertNotEmpty($xml); $this->assertSchema($xml); + $this->assertZeroTaxAmountFormat($xml, 2); } } \ No newline at end of file