diff --git a/packages/core/src/Core/Model/Sale/BaseSale.php b/packages/core/src/Core/Model/Sale/BaseSale.php index 17d3bc19..f8937cc1 100644 --- a/packages/core/src/Core/Model/Sale/BaseSale.php +++ b/packages/core/src/Core/Model/Sale/BaseSale.php @@ -60,6 +60,11 @@ class BaseSale implements DocumentInterface */ protected $tipoMoneda; + /** + * @var float + */ + protected $sumOtrosDescuentos; + /** * @var float */ @@ -351,6 +356,26 @@ public function setTipoMoneda(?string $tipoMoneda): self return $this; } + /** + * @return float + */ + public function getSumOtrosDescuentos(): ?float + { + return $this->sumOtrosDescuentos; + } + + /** + * @param float $sumOtrosDescuentos + * + * @return $this + */ + public function setSumOtrosDescuentos(?float $sumOtrosDescuentos): self + { + $this->sumOtrosDescuentos = $sumOtrosDescuentos; + + return $this; + } + /** * @return float */ diff --git a/packages/core/src/Core/Model/Sale/Invoice.php b/packages/core/src/Core/Model/Sale/Invoice.php index c6feb474..2ffced88 100644 --- a/packages/core/src/Core/Model/Sale/Invoice.php +++ b/packages/core/src/Core/Model/Sale/Invoice.php @@ -43,11 +43,6 @@ class Invoice extends BaseSale */ private $mtoDescuentos; - /** - * @var float - */ - private $sumOtrosDescuentos; - /** * @var Charge[] */ @@ -195,26 +190,6 @@ public function setMtoDescuentos(?float $mtoDescuentos): Invoice return $this; } - /** - * @return float - */ - public function getSumOtrosDescuentos(): ?float - { - return $this->sumOtrosDescuentos; - } - - /** - * @param float $sumOtrosDescuentos - * - * @return Invoice - */ - public function setSumOtrosDescuentos(?float $sumOtrosDescuentos): Invoice - { - $this->sumOtrosDescuentos = $sumOtrosDescuentos; - - return $this; - } - /** * @return Charge[] */ diff --git a/packages/xml/src/Xml/Templates/notacr2.1.xml.twig b/packages/xml/src/Xml/Templates/notacr2.1.xml.twig index 7492a54f..8e4a35d7 100644 --- a/packages/xml/src/Xml/Templates/notacr2.1.xml.twig +++ b/packages/xml/src/Xml/Templates/notacr2.1.xml.twig @@ -278,6 +278,9 @@ {% endif %} + {% if doc.sumOtrosDescuentos is not null %} + {{ doc.sumOtrosDescuentos|n_format }} + {% endif %} {% if doc.sumOtrosCargos is not null %} {{ doc.sumOtrosCargos|n_format }} {% endif %} diff --git a/packages/xml/src/Xml/Templates/notadb2.1.xml.twig b/packages/xml/src/Xml/Templates/notadb2.1.xml.twig index ae0eb113..37f2ff84 100644 --- a/packages/xml/src/Xml/Templates/notadb2.1.xml.twig +++ b/packages/xml/src/Xml/Templates/notadb2.1.xml.twig @@ -265,6 +265,9 @@ {% if doc.subTotal is not null %} {{ doc.subTotal|n_format }} {% endif %} + {% if doc.sumOtrosDescuentos is not null %} + {{ doc.sumOtrosDescuentos|n_format }} + {% endif %} {% if doc.sumOtrosCargos is not null %} {{ doc.sumOtrosCargos|n_format }} {% endif %} diff --git a/packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php b/packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php index 10b5579d..05c219db 100644 --- a/packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php +++ b/packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php @@ -51,4 +51,33 @@ public function testCreateXmlDebitNote() $this->assertNotEmpty($xml); $this->assertSchema($xml); } + + /** + * @dataProvider noteTypeProvider + */ + public function testCreateXmlNoteWithGlobalDiscount(string $tipoDoc) + { + /**@var $note Note*/ + $note = $this->createDocument(NoteStore::class); + $note->setTipoDoc($tipoDoc); + $note->setUblVersion('2.1'); + $note->setSumOtrosDescuentos(20.50); + + $xml = $this->build($note); + + $this->assertNotEmpty($xml); + $this->assertSchema($xml); + $this->assertStringContainsString( + '20.50', + $xml + ); + } + + public function noteTypeProvider(): array + { + return [ + 'credit note' => ['07'], + 'debit note' => ['08'], + ]; + } } \ No newline at end of file