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

Working on Peppol

This commit is contained in:
David Bomba 2024-08-08 14:16:35 +10:00
parent 5bd411b394
commit a8e313b5e9
3 changed files with 123 additions and 1 deletions

View File

@ -400,6 +400,7 @@ class BaseDriver extends AbstractPaymentDriver
return;
$invoices = Invoice::query()
->where('company_id', $this->company_gateway->company_id)
->whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))
->whereJsonContains('line_items', ['type_id' => '3'])
->withTrashed();
@ -407,6 +408,7 @@ class BaseDriver extends AbstractPaymentDriver
if($invoices->count() == 0){
$invoice = Invoice::query()
->where('company_id', $this->company_gateway->company_id)
->whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))
->orderBy('id','desc')
->withTrashed()

View File

@ -1087,7 +1087,13 @@ class Peppol extends AbstractService
return $this;
}
/**
* FR
* @Pending - clarification on codes needed
*
* @return self
*/
private function FR(): self
{

View File

@ -503,6 +503,120 @@ $x = '<?xml version="1.0" encoding="utf-8"?>
return $invoice;
}
private function createFRData()
{
$this->routing_id = 293338;
$settings = CompanySettings::defaults();
$settings->company_logo = 'https://pdf.invoicing.co/favicon-v2.png';
$settings->website = 'www.invoiceninja.de';
$settings->address1 = '10 Rue de la Paix';
$settings->address2 = 'Bâtiment A, Bureau 5';
$settings->city = 'Paris';
$settings->state = 'Île-de-France';
$settings->postal_code = '75002';
$settings->phone = '01 23456789';
$settings->email = $this->faker->unique()->safeEmail();
$settings->country_id = '250'; // France's ISO country code
$settings->vat_number = 'FR12345678901';
$settings->id_number = '12345678900010';
$settings->use_credits_payment = 'always';
$settings->timezone_id = '1'; // CET (Central European Time)
$settings->entity_send_time = 0;
$settings->e_invoice_type = 'PEPPOL';
$settings->currency_id = '3';
$company = Company::factory()->create([
'account_id' => $this->account->id,
'settings' => $settings,
]);
$this->user->companies()->attach($company->id, [
'account_id' => $this->account->id,
'is_owner' => true,
'is_admin' => 1,
'is_locked' => 0,
'permissions' => '',
'notifications' => CompanySettings::notificationAdminDefaults(),
'settings' => null,
]);
Client::unguard();
$c =
Client::create([
'company_id' => $company->id,
'user_id' => $this->user->id,
'name' => 'Beispiel Firma GmbH',
'website' => 'https://www.beispiel-firma.de',
'private_notes' => 'Dies sind private Notizen zum Testkunden.',
'balance' => 0,
'paid_to_date' => 0,
'vat_number' => 'DE654321987',
'id_number' => 'HRB 12345', // Typical format for German company registration numbers
'custom_value1' => '2024-07-22 10:00:00',
'custom_value2' => 'blau',
'custom_value3' => 'musterwort',
'custom_value4' => 'test@example.com',
'address1' => 'Musterstraße 123',
'address2' => '2. Etage, Büro 45',
'city' => 'München',
'state' => 'Bayern',
'postal_code' => '80331',
'country_id' => '276', // Germany
'shipping_address1' => 'Musterstraße 123',
'shipping_address2' => '2. Etage, Büro 45',
'shipping_city' => 'München',
'shipping_state' => 'Bayern',
'shipping_postal_code' => '80331',
'shipping_country_id' => '276', // Germany
'settings' => ClientSettings::Defaults(),
'client_hash' => \Illuminate\Support\Str::random(32),
'routing_id' => '',
]);
$item = new InvoiceItem();
$item->product_key = "Product Key";
$item->notes = "Product Description";
$item->cost = 10;
$item->quantity = 10;
$item->tax_rate1 = 19;
$item->tax_name1 = 'mwst';
$invoice = Invoice::factory()->create([
'company_id' => $company->id,
'user_id' => $this->user->id,
'client_id' => $c->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' => 'DE-'.rand(1000, 100000),
'date' => now()->format('Y-m-d'),
'due_date' => now()->addDays(14)->format('Y-m-d'),
]);
$invoice = $invoice->calc()->getInvoice();
$invoice->service()->markSent()->save();
return $invoice;
}
private function createDEData()