1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Tests for ro einvoice

This commit is contained in:
David Bomba 2024-05-27 17:11:35 +10:00
parent 4ffe50fcee
commit db0b98d375
2 changed files with 155 additions and 4 deletions

8
composer.lock generated
View File

@ -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",

View File

@ -0,0 +1,151 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Integration\Einvoice;
use Tests\TestCase;
use App\Models\Client;
use App\Models\Invoice;
use Tests\MockAccountData;
use App\Models\ClientContact;
use App\DataMapper\ClientSettings;
use App\DataMapper\InvoiceItem;
use CleverIt\UBL\Invoice\Party;
use Contact;
use Illuminate\Support\Facades\Cache;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Invoiceninja\Einvoice\Models\FACT1\AddressType\PostalAddress;
use Invoiceninja\Einvoice\Models\FACT1\ContactType\Contact;
use Invoiceninja\Einvoice\Models\FACT1\CountryType\Country;
use Invoiceninja\Einvoice\Models\FACT1\CustomerPartyType\AccountingCustomerParty;
use Invoiceninja\Einvoice\Models\FACT1\PartyIdentificationType\PartyIdentification;
use Invoiceninja\Einvoice\Models\FACT1\PartyLegalEntityType\PartyLegalEntity;
use Invoiceninja\Einvoice\Models\FACT1\PartyTaxSchemeType\PartyTaxScheme;
use Invoiceninja\Einvoice\Models\FACT1\PartyType\Party;
use Invoiceninja\Einvoice\Models\FACT1\SupplierPartyType\AccountingSupplierParty;
use Invoiceninja\Einvoice\Models\FACT1\TaxSchemeType\TaxScheme;
/**
* @test
*/
class Fact1Test extends TestCase
{
use MockAccountData;
use DatabaseTransactions;
protected function setUp(): void
{
parent::setUp();
$this->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
}
}