From 0b60be1cc1cdbbf4a554a637ff37c0037196faa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20Moreno?= Date: Sun, 4 Dec 2022 10:34:31 +0100 Subject: [PATCH] Updated rounding unit tests - Updated InvoiceTotalsTest class - Added "peppol-rounding.xml" integration test sample > Related to #31 --- tests/Integration/IntegrationTest.php | 4 ++ tests/Integration/peppol-rounding.xml | 100 ++++++++++++++++++++++++++ tests/Models/InvoiceTotalsTest.php | 15 +++- 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 tests/Integration/peppol-rounding.xml diff --git a/tests/Integration/IntegrationTest.php b/tests/Integration/IntegrationTest.php index 38cd09c..68b9cc1 100644 --- a/tests/Integration/IntegrationTest.php +++ b/tests/Integration/IntegrationTest.php @@ -62,6 +62,10 @@ public function testCanRecreatePeppolAllowanceExample(): void { $this->importAndExportInvoice(__DIR__ . "/peppol-allowance.xml"); } + public function testCanRecreatePeppolRoundingExample(): void { + $this->importAndExportInvoice(__DIR__ . "/peppol-rounding.xml"); + } + public function testCanRecreateCiusRoTaxCurrencyCodeExample(): void { $this->importAndExportInvoice(__DIR__ . "/cius-ro-tax-currency-code.xml"); } diff --git a/tests/Integration/peppol-rounding.xml b/tests/Integration/peppol-rounding.xml new file mode 100644 index 0000000..c6e5db4 --- /dev/null +++ b/tests/Integration/peppol-rounding.xml @@ -0,0 +1,100 @@ + + + + urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + SampleForDecimals + 2022-11-03 + 2022-11-11 + 380 + EUR + + + admin@example.com + + 12345678 + + + Yellow Brick Road + Kuki + 400001 + RO-CJ + + RO + + + + 12345678 + + + + Test S.r.o + J12/1234/2016 + + + + + + + Strada Zebreiou 432 + Bacau + 57433 + RO-BC + + RO + + + + RO17364910 + + + + POP Alexandra SRL + RO17364910 + + + + + 31 + + + 1279.45 + + 6733.95 + 1279.45 + + S + 19 + + VAT + + + + + + 6733.95 + 6733.95 + 8013.4 + 8013.4 + + + 101 + 26935.78 + 6733.95 + + Test + + S + 19 + + VAT + + + + + 0.25 + + + diff --git a/tests/Models/InvoiceTotalsTest.php b/tests/Models/InvoiceTotalsTest.php index 7f6b551..db5564b 100644 --- a/tests/Models/InvoiceTotalsTest.php +++ b/tests/Models/InvoiceTotalsTest.php @@ -12,7 +12,7 @@ final class InvoiceTotalsTest extends TestCase { private $invoice; protected function setUp(): void { - $this->invoice = new Invoice(); + $this->invoice = (new Invoice)->setRoundingMatrix(['' => 3]); } public function testClassConstructors(): void { @@ -29,6 +29,19 @@ public function testClassConstructors(): void { $this->assertEquals(100, $totalsB->payableAmount); } + public function testRoundingOfTotals(): void { + $line = (new InvoiceLine()) + ->setPrice(0.25) + ->setQuantity(26935.78) + ->setVatRate(19); + $this->invoice->addLine($line); + + $totals = $this->invoice->getTotals(); + $this->assertEquals(6733.945, $totals->taxExclusiveAmount); + $this->assertEquals(1279.45, $totals->vatAmount); + $this->assertEquals(8013.395, $totals->taxInclusiveAmount); + } + public function testVatExemptionReasons(): void { $firstLine = (new InvoiceLine()) ->setName('Line #1')