makeTestData(); // $this->markTestSkipped('prevent running in CI'); $this->withoutMiddleware( ThrottleRequests::class ); } public function testInvoiceBoot() { $settings = CompanySettings::defaults(); $settings->address1 = 'Via Silvio Spaventa 108'; $settings->city = 'Calcinelli'; $settings->state = 'PA'; // $settings->state = 'Perugia'; $settings->postal_code = '61030'; $settings->country_id = '380'; $settings->currency_id = '3'; $settings->vat_number = '01234567890'; $settings->id_number = ''; $company = Company::factory()->create([ 'account_id' => $this->account->id, 'settings' => $settings, ]); $client_settings = ClientSettings::defaults(); $client_settings->currency_id = '3'; $client = Client::factory()->create([ 'company_id' => $company->id, 'user_id' => $this->user->id, 'name' => 'Italian Client Name', 'address1' => 'Via Antonio da Legnago 68', 'city' => 'Monasterace', 'state' => 'CR', // 'state' => 'Reggio Calabria', 'postal_code' => '89040', 'country_id' => 380, 'routing_id' => 'ABC1234', 'settings' => $client_settings, ]); $item = new InvoiceItem(); $item->product_key = "Product Key"; $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, 'client_id' => $client->id, 'discount' => 0, 'uses_inclusive_taxes' => false, 'status_id' => 1, 'tax_rate1' => 0, 'tax_name1' => '', 'tax_rate2' => 0, 'tax_rate3' => 0, 'tax_name2' => '', 'tax_name3' => '', 'line_items' => [$item], 'number' => 'ITA-'.rand(1000, 100000), 'date' => now()->format('Y-m-d') ]); $invoice->service()->markSent()->save(); $peppol = new Peppol($invoice); $peppol->run(); $fe = $peppol->getInvoice(); $this->assertNotNull($fe); $this->assertInstanceOf(\InvoiceNinja\EInvoice\Models\Peppol\Invoice::class, $fe); $e = new EInvoice(); $xml = $e->encode($fe, 'xml'); $this->assertNotNull($xml); nlog($xml); $json = $e->encode($fe, 'json'); $this->assertNotNull($json); nlog($json); $decode = $e->decode('Peppol', $json, 'json'); $this->assertInstanceOf(\InvoiceNinja\EInvoice\Models\Peppol\Invoice::class, $decode); $errors = $e->validate($fe); if(count($errors) > 0) { nlog($errors); } $this->assertCount(0, $errors); nlog(json_encode($fe, JSON_PRETTY_PRINT)); } }