Move e_invoice_type to settings object

This commit is contained in:
David Bomba 2023-04-21 07:54:35 +10:00
parent 735e2bb40a
commit d06fa55f31
4 changed files with 38 additions and 2 deletions

View File

@ -475,7 +475,10 @@ class CompanySettings extends BaseSettings
public $sync_invoice_quote_columns = true;
public $e_invoice_type = 'EN16931';
public static $casts = [
'e_invoice_type' => 'string',
'mailgun_endpoint' => 'string',
'client_initiated_payments' => 'bool',
'client_initiated_payments_minimum' => 'float',

View File

@ -38,7 +38,7 @@ class CreateXInvoice implements ShouldQueue
$company = $invoice->company;
$client = $invoice->client;
$profile = "";
switch ($company->e_invoice_type) {
switch ($client->getSetting('e_invoice_type')) {
case "EN16931":
$profile = ZugferdProfiles::PROFILE_EN16931;
break;
@ -63,6 +63,9 @@ class CreateXInvoice implements ShouldQueue
case "XInvoice-Basic":
$profile = ZugferdProfiles::PROFILE_BASIC;
break;
default:
$profile = ZugferdProfiles::PROFILE_EN16931;
break;
}
$xrechnung = ZugferdDocumentBuilder::CreateNew($profile);

View File

@ -840,7 +840,6 @@ class Company extends BaseModel
'matomo_url',
'matomo_id',
'enable_e_invoice',
'e_invoice_type',
'client_can_register',
'enable_shop_api',
'invoice_task_timelog',

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('companies', function (Blueprint $table) {
$table->dropColumn('e_invoice_type');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};