diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 89013ae05028..c96b9dc54ac1 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -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', diff --git a/app/Jobs/Invoice/CreateXInvoice.php b/app/Jobs/Invoice/CreateXInvoice.php index 18ca57899d00..4ce8ff344cca 100644 --- a/app/Jobs/Invoice/CreateXInvoice.php +++ b/app/Jobs/Invoice/CreateXInvoice.php @@ -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); diff --git a/app/Models/Company.php b/app/Models/Company.php index e036fe8b1c40..5b6c849a3bf4 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -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', diff --git a/database/migrations/2023_04_20_215159_drop_e_invoice_type_column.php b/database/migrations/2023_04_20_215159_drop_e_invoice_type_column.php new file mode 100644 index 000000000000..ad2adcfd18ea --- /dev/null +++ b/database/migrations/2023_04_20_215159_drop_e_invoice_type_column.php @@ -0,0 +1,31 @@ +dropColumn('e_invoice_type'); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +};