Skip to content
Closed
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
25 changes: 25 additions & 0 deletions packages/core/src/Core/Model/Sale/BaseSale.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class BaseSale implements DocumentInterface
*/
protected $tipoMoneda;

/**
* @var float
*/
protected $sumOtrosDescuentos;

/**
* @var float
*/
Expand Down Expand Up @@ -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
*/
Expand Down
25 changes: 0 additions & 25 deletions packages/core/src/Core/Model/Sale/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ class Invoice extends BaseSale
*/
private $mtoDescuentos;

/**
* @var float
*/
private $sumOtrosDescuentos;

/**
* @var Charge[]
*/
Expand Down Expand Up @@ -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[]
*/
Expand Down
3 changes: 3 additions & 0 deletions packages/xml/src/Xml/Templates/notacr2.1.xml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@
{% endif %}
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
{% if doc.sumOtrosDescuentos is not null %}
<cbc:AllowanceTotalAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.sumOtrosDescuentos|n_format }}</cbc:AllowanceTotalAmount>
{% endif %}
{% if doc.sumOtrosCargos is not null %}
<cbc:ChargeTotalAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.sumOtrosCargos|n_format }}</cbc:ChargeTotalAmount>
{% endif %}
Expand Down
3 changes: 3 additions & 0 deletions packages/xml/src/Xml/Templates/notadb2.1.xml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@
{% if doc.subTotal is not null %}
<cbc:TaxInclusiveAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.subTotal|n_format }}</cbc:TaxInclusiveAmount>
{% endif %}
{% if doc.sumOtrosDescuentos is not null %}
<cbc:AllowanceTotalAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.sumOtrosDescuentos|n_format }}</cbc:AllowanceTotalAmount>
{% endif %}
{% if doc.sumOtrosCargos is not null %}
<cbc:ChargeTotalAmount currencyID="{{ doc.tipoMoneda }}">{{ doc.sumOtrosCargos|n_format }}</cbc:ChargeTotalAmount>
{% endif %}
Expand Down
29 changes: 29 additions & 0 deletions packages/xml/tests/Xml/Builder/v21/FeNoteBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<cbc:AllowanceTotalAmount currencyID="PEN">20.50</cbc:AllowanceTotalAmount>',
$xml
);
}

public function noteTypeProvider(): array
{
return [
'credit note' => ['07'],
'debit note' => ['08'],
];
}
}