Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions packages/xml/src/Xml/Templates/invoice2.1.xml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
{% if doc.mtoOperInafectas is not null %}
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.mtoOperInafectas|n_format }}</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0</cbc:TaxAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0.00</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>9998</cbc:ID>
Expand All @@ -337,7 +337,7 @@
{% if doc.mtoOperExoneradas is not null %}
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.mtoOperExoneradas|n_format }}</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0</cbc:TaxAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0.00</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>9997</cbc:ID>
Expand All @@ -363,7 +363,7 @@
{% if doc.mtoOperExportacion is not null %}
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.mtoOperExportacion|n_format }}</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0</cbc:TaxAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0.00</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>9995</cbc:ID>
Expand Down
6 changes: 3 additions & 3 deletions packages/xml/src/Xml/Templates/notacr2.1.xml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
{% if doc.mtoOperInafectas %}
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.mtoOperInafectas|n_format }}</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0</cbc:TaxAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0.00</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>9998</cbc:ID>
Expand All @@ -202,7 +202,7 @@
{% if doc.mtoOperExoneradas %}
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.mtoOperExoneradas|n_format }}</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0</cbc:TaxAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0.00</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>9997</cbc:ID>
Expand All @@ -228,7 +228,7 @@
{% if doc.mtoOperExportacion %}
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.mtoOperExportacion|n_format }}</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0</cbc:TaxAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0.00</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>9995</cbc:ID>
Expand Down
6 changes: 3 additions & 3 deletions packages/xml/src/Xml/Templates/notadb2.1.xml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
{% if doc.mtoOperInafectas %}
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.mtoOperInafectas|n_format }}</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0</cbc:TaxAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0.00</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>9998</cbc:ID>
Expand All @@ -183,7 +183,7 @@
{% if doc.mtoOperExoneradas %}
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.mtoOperExoneradas|n_format }}</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0</cbc:TaxAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0.00</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>9997</cbc:ID>
Expand All @@ -209,7 +209,7 @@
{% if doc.mtoOperExportacion %}
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.mtoOperExportacion|n_format }}</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0</cbc:TaxAmount>
<cbc:TaxAmount currencyID="{{ doc.tipoMoneda }}">0.00</cbc:TaxAmount>
<cac:TaxCategory>
<cac:TaxScheme>
<cbc:ID>9995</cbc:ID>
Expand Down
22 changes: 22 additions & 0 deletions packages/xml/tests/Xml/Builder/FeBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function testGenerate()
// file_put_contents('x.xml', $xml);
$this->assertNotEmpty($xml);
$this->assertSchema($xml);
$this->assertZeroTaxAmountFormat($xml, 3);
}

/**
Expand Down
10 changes: 8 additions & 2 deletions packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,32 @@ 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()
{
/**@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);
}
}