From 8c83df558c6f6bebadcdd151ff53210df55c1eba Mon Sep 17 00:00:00 2001 From: Timo Date: Sat, 20 Apr 2024 23:08:32 +0200 Subject: [PATCH] Add Company VAT-ID and Tax-ID (#54) * add company vat_id & tax_id field * add tax & vat id field in company settings * fix vat & tax id validation * add german vat & tax id translation * add translations for pdf * add vat_id and tax_id field before timestamps * make fields nullable and fix code style --- app/Http/Requests/CompaniesRequest.php | 2 + app/Http/Requests/CompanyRequest.php | 8 ++++ app/Http/Resources/CompanyResource.php | 2 + ..._04_12_162703_add_tax_ids_to_companies.php | 32 ++++++++++++++++ lang/de.json | 6 ++- lang/en.json | 6 ++- .../views/installation/Step7CompanyInfo.vue | 27 ++++++++++++-- .../views/settings/CompanyInfoSettings.vue | 37 ++++++++----------- 8 files changed, 94 insertions(+), 26 deletions(-) create mode 100644 database/migrations/2024_04_12_162703_add_tax_ids_to_companies.php diff --git a/app/Http/Requests/CompaniesRequest.php b/app/Http/Requests/CompaniesRequest.php index 60e2e0ca..c774ea5c 100644 --- a/app/Http/Requests/CompaniesRequest.php +++ b/app/Http/Requests/CompaniesRequest.php @@ -69,6 +69,8 @@ class CompaniesRequest extends FormRequest return collect($this->validated()) ->only([ 'name', + 'vat_id', + 'tax_id', ]) ->merge([ 'owner_id' => $this->user()->id, diff --git a/app/Http/Requests/CompanyRequest.php b/app/Http/Requests/CompanyRequest.php index 730fe7b9..8dc5001a 100644 --- a/app/Http/Requests/CompanyRequest.php +++ b/app/Http/Requests/CompanyRequest.php @@ -29,6 +29,12 @@ class CompanyRequest extends FormRequest 'required', Rule::unique('companies')->ignore($this->header('company'), 'id'), ], + 'vat_id' => [ + 'nullable', + ], + 'tax_id' => [ + 'nullable', + ], 'slug' => [ 'nullable', ], @@ -44,6 +50,8 @@ class CompanyRequest extends FormRequest ->only([ 'name', 'slug', + 'vat_id', + 'tax_id', ]) ->toArray(); } diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index 9a81682c..7ca384df 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -17,6 +17,8 @@ class CompanyResource extends JsonResource return [ 'id' => $this->id, 'name' => $this->name, + 'vat_id' => $this->vat_id, + 'tax_id' => $this->tax_id, 'logo' => $this->logo, 'logo_path' => $this->logo_path, 'unique_hash' => $this->unique_hash, diff --git a/database/migrations/2024_04_12_162703_add_tax_ids_to_companies.php b/database/migrations/2024_04_12_162703_add_tax_ids_to_companies.php new file mode 100644 index 00000000..90d620e7 --- /dev/null +++ b/database/migrations/2024_04_12_162703_add_tax_ids_to_companies.php @@ -0,0 +1,32 @@ +after('unique_hash', function (Blueprint $table) { + $table->string('vat_id')->nullable(); + $table->string('tax_id')->nullable(); + }); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('companies', function (Blueprint $table) { + $table->dropColumn('vat_id'); + $table->dropColumn('tax_id'); + }); + } +}; diff --git a/lang/de.json b/lang/de.json index d5105593..985fc411 100644 --- a/lang/de.json +++ b/lang/de.json @@ -863,6 +863,8 @@ "company_info": { "company_info": "Firmeninfo", "company_name": "Name des Unternehmens", + "vat_id": "Umsatzsteuer-Identifikationsnummer", + "tax_id": "Steuernummer", "company_logo": "Firmenlogo", "section_description": "Informationen zu Ihrem Unternehmen, die auf Rechnungen, Angeboten und anderen von InvoiceShelf erstellten Dokumenten angezeigt werden.", "phone": "Telefon", @@ -1528,5 +1530,7 @@ "pdf_bill_to": "Rechnungsanschrift", "pdf_ship_to": "Lieferanschrift", "pdf_received_from": "Erhalten von:", - "pdf_tax_label": "Steuer" + "pdf_tax_label": "Steuer", + "pdf_tax_id": "Steuer-Nr.", + "pdf_vat_id": "USt.-ID" } diff --git a/lang/en.json b/lang/en.json index a1c372b9..9e042c29 100644 --- a/lang/en.json +++ b/lang/en.json @@ -863,6 +863,8 @@ "company_info": { "company_info": "Company info", "company_name": "Company Name", + "tax_id": "Tax Identification Number", + "vat_id": "VAT Identification Number", "company_logo": "Company Logo", "section_description": "Information about your company that will be displayed on invoices, estimates and other documents created by InvoiceShelf.", "phone": "Phone", @@ -1528,5 +1530,7 @@ "pdf_bill_to": "Bill to,", "pdf_ship_to": "Ship to,", "pdf_received_from": "Received from:", - "pdf_tax_label": "Tax" + "pdf_tax_label": "Tax", + "pdf_tax_id": "Tax-ID", + "pdf_vat_id": "VAT-ID" } diff --git a/resources/scripts/admin/views/installation/Step7CompanyInfo.vue b/resources/scripts/admin/views/installation/Step7CompanyInfo.vue index f5295171..73880722 100644 --- a/resources/scripts/admin/views/installation/Step7CompanyInfo.vue +++ b/resources/scripts/admin/views/installation/Step7CompanyInfo.vue @@ -131,6 +131,25 @@ /> + + + + + + + + @@ -162,6 +181,8 @@ let logoFileName = ref(null) const companyForm = reactive({ name: null, + tax_id: null, + vat_id: null, address: { address_street_1: '', address_street_2: '', @@ -200,13 +221,13 @@ const rules = { address_street_1: { maxLength: helpers.withMessage( t('validation.address_maxlength', { count: 255 }), - maxLength(255) + maxLength(255), ), }, address_street_2: { maxLength: helpers.withMessage( t('validation.address_maxlength', { count: 255 }), - maxLength(255) + maxLength(255), ), }, }, @@ -241,7 +262,7 @@ async function next() { JSON.stringify({ name: logoFileName.value, data: logoFileBlob.value, - }) + }), ) await companyStore.updateCompanyLogo(logoData) } diff --git a/resources/scripts/admin/views/settings/CompanyInfoSettings.vue b/resources/scripts/admin/views/settings/CompanyInfoSettings.vue index 2da507be..ade292a0 100644 --- a/resources/scripts/admin/views/settings/CompanyInfoSettings.vue +++ b/resources/scripts/admin/views/settings/CompanyInfoSettings.vue @@ -84,6 +84,16 @@ class="mt-2" /> + +
+ + + + + + + +