From db0b98d375af5961ddfad83f37496281bb4a14b8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 27 May 2024 17:11:35 +1000 Subject: [PATCH] Tests for ro einvoice --- composer.lock | 8 +- tests/Integration/Einvoice/Fact1Test.php | 151 +++++++++++++++++++++++ 2 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 tests/Integration/Einvoice/Fact1Test.php diff --git a/composer.lock b/composer.lock index d705c722885b..601c13ab6363 100644 --- a/composer.lock +++ b/composer.lock @@ -5076,12 +5076,12 @@ "source": { "type": "git", "url": "https://github.com/invoiceninja/einvoice.git", - "reference": "d0781c77b434a113845a1abd3234f7dd80f1c7fd" + "reference": "da30e1542726b36cab8d48095dedaaecea5a0116" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/invoiceninja/einvoice/zipball/d0781c77b434a113845a1abd3234f7dd80f1c7fd", - "reference": "d0781c77b434a113845a1abd3234f7dd80f1c7fd", + "url": "https://api.github.com/repos/invoiceninja/einvoice/zipball/da30e1542726b36cab8d48095dedaaecea5a0116", + "reference": "da30e1542726b36cab8d48095dedaaecea5a0116", "shasum": "" }, "require": { @@ -5120,7 +5120,7 @@ "source": "https://github.com/invoiceninja/einvoice/tree/main", "issues": "https://github.com/invoiceninja/einvoice/issues" }, - "time": "2024-05-27T04:10:37+00:00" + "time": "2024-05-27T06:05:25+00:00" }, { "name": "invoiceninja/inspector", diff --git a/tests/Integration/Einvoice/Fact1Test.php b/tests/Integration/Einvoice/Fact1Test.php new file mode 100644 index 000000000000..cc63cfb0d0d6 --- /dev/null +++ b/tests/Integration/Einvoice/Fact1Test.php @@ -0,0 +1,151 @@ +makeTestData(); + } + + public function testRoBuild() + { + $settings = ClientSettings::defaults(); + +//VAT +//19% + $client = Client::factory() + ->create([ + 'user_id' => $this->user->id, + 'company_id' => $this->company->id, + 'id_number' => '646546549', + 'address1' => '40D, Șoseaua București-Ploiești', + 'city' => 'SECTOR3', + 'state' => 'RO-B', + 'country_id' => 642, + 'vat_number' => 646546549, + 'name' => 'Client Company Name', + ]); + + ClientContact::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $this->company->id, + 'client_id' => $client->id, + 'first_name' => 'Bob', + 'last_name' => 'Jane', + 'email' => 'bob@gmail.com', + ]); + + $items = []; + + $item = new InvoiceItem; + $item->cost = 10; + $item->quantity = 10; + $item->tax_name1 = 'VAT'; + $item->tax_rate1 = '19'; + + $_invoice = Invoice::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $this->company->id, + 'client_id' => $client->id, + 'number' => 'INV-'.rand(1000,1000000), + 'line_items' => [$item], + 'due_date' => now()->addDays(20)->format('Y-m-d'), + ]); + + $invoice = new \InvoiceNinja\Einvoice\Models\FACT1\Invoice; + $invoice->UBLVersionID = '2.1'; + $invoice->CustomizationID = 'urn:cen.eu:en16931:2017#compliant#urn:efactura.mfinante.ro:CIUS-RO:1.0.1'; + $invoice->ID = $_invoice->number; + $invoice->InvoiceTypeCode = 380; + $invoice->IssueDate = $_invoice->date; + $invoice->DueDate = $_invoice->due_date; + $invoice->DocumentCurrencyCode = 'RON'; + $invoice->TaxCurrencyCode = 'RON'; + + $asp = new AccountingSupplierParty(); + $party = new Party(); + + $party_identification = new PartyIdentification(); + $party_identification->id = 'company_id_number'; + $party->PartyIdentification = $party_identification; + + $sp_address = new PostalAddress(); + $sp_address->StreetName = $this->company->settings->address1; + $sp_address->CityName = 'SECTOR2'; + $sp_address->CountrySubentity = 'RO-B'; + + $country = new Country(); + $country->IdentificationCode='RO'; + $sp_address->Country = $country; + + $party->PostalAddress = $sp_address; + + $pts = new PartyTaxScheme(); + $tax_scheme = new TaxScheme(); + $tax_scheme->ID = 'VAT'; + + $pts->CompanyID = 'RO234234234'; + $pts->TaxScheme = $tax_scheme; + + $party->PartyTaxScheme = $pts; + + $ple = new PartyLegalEntity(); + $ple->RegistrationName = $this->company->settings->name; + $ple->CompanyID = 'J40/2222/2009'; + + $party->PartyLegalEntity = $ple; + + $p_contact = new Contact(); + $p_contact->Name = $this->company->owner()->present()->name(); + $p_contact->Telephone = $this->company->settings->phone; + $p_contact->ElectronicMail = $this->company->owner()->present()->email(); + + $party->Contact = $p_contact; + + $acp = new AccountingCustomerParty(); + + $asp->Party = $party; + //set default standard props + } +}