From e967373f8581079232503dc6761df2e29ffb4071 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 28 May 2024 12:52:38 +1000 Subject: [PATCH] FatturaPA tests --- app/Services/EDocument/Standards/FatturaPANew.php | 9 ++++++++- tests/Feature/EInvoice/FatturaPATest.php | 13 +++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/Services/EDocument/Standards/FatturaPANew.php b/app/Services/EDocument/Standards/FatturaPANew.php index 19ceb0c26a87..870021d08ddd 100644 --- a/app/Services/EDocument/Standards/FatturaPANew.php +++ b/app/Services/EDocument/Standards/FatturaPANew.php @@ -132,6 +132,12 @@ class FatturaPANew extends AbstractService $anagrafica->Denominazione = $this->invoice->client->present()->name(); $datiAnagrafici->Anagrafica = $anagrafica; + $idFiscale = new IdFiscaleIVA; + $idFiscale->IdCodice= $this->invoice->client->vat_number; + $idFiscale->IdPaese = $this->invoice->client->country->iso_3166_2; + + $datiAnagrafici->IdFiscaleIVA = $idFiscale; + $sede = new Sede; $sede->Indirizzo = $this->invoice->client->address1; $sede->CAP = (int)$this->invoice->client->postal_code; @@ -205,6 +211,8 @@ class FatturaPANew extends AbstractService private function setLineItems(): self { + $calc = $this->invoice->calc(); + $datiBeniServizi = new DatiBeniServizi(); $tax_rate_level = 0; //line items @@ -233,7 +241,6 @@ class FatturaPANew extends AbstractService $tax_rate_level = sprintf('%0.2f', $this->invoice->tax_rate1); } - $calc = $this->invoice->calc(); $subtotal = sprintf('%0.2f', $calc->getSubTotal()); $taxes = sprintf('%0.2f', $calc->getTotalTaxes()); diff --git a/tests/Feature/EInvoice/FatturaPATest.php b/tests/Feature/EInvoice/FatturaPATest.php index 7c9c57dbc0b4..c47aee98d65b 100644 --- a/tests/Feature/EInvoice/FatturaPATest.php +++ b/tests/Feature/EInvoice/FatturaPATest.php @@ -76,7 +76,6 @@ $settings->state = 'PA'; 'name' => 'Italian Client Name', 'address1' => 'Via Antonio da Legnago 68', 'city' => 'Monasterace', - 'state' => 'CR', // 'state' => 'Reggio Calabria', 'postal_code' => '89040', @@ -90,7 +89,9 @@ $settings->state = 'PA'; $item->notes = "Product Description"; $item->cost = 10; $item->quantity = 10; - + $item->tax_rate1 = 22; + $item->tax_name1 = 'IVA'; + $invoice = Invoice::factory()->create([ 'company_id' => $company->id, 'user_id' => $this->user->id, @@ -98,8 +99,12 @@ $settings->state = 'PA'; 'discount' => 0, 'uses_inclusive_taxes' => false, 'status_id' => 1, - 'tax_rate1' => 19, - 'tax_name1' => 'IVA', + 'tax_rate1' => 0, + 'tax_name1' => '', + 'tax_rate2' => 0, + 'tax_rate3' => 0, + 'tax_name2' => '', + 'tax_name3' => '', 'line_items' => [$item], 'number' => 'ITA-'.rand(1000,100000) ]);